scroll(1) – pager #44

Open
opened 2024-02-03 20:42:03 +00:00 by emma · 8 comments
Owner

What should our pager program look like?

What should our pager program look like?
emma added the
enhancement
question
labels 2024-02-03 20:42:03 +00:00
Owner

I have a particularly bad one in my source tree. It was less useful once I'd figured out I could scroll my xterms but nowadays I just use less(1).

"Good pager" is a very subjective judgement. I like both Plan 9's p(1) and [I forgot]'s bat(1) though they're both polar opposites. Maybe we should have one that's nearly featureless and one with the kitchen sink, or some sort of way to choose baroque or barren depending on mood.

I have [a particularly bad one in my source tree](https://git.sr.ht/~trinity/src/tree/main/item/p). It was less useful once I'd figured out I could scroll my xterms but nowadays I just use less(1). "Good pager" is a very subjective judgement. I like both Plan 9's p(1) and [I forgot]'s bat(1) though they're both polar opposites. Maybe we should have one that's nearly featureless and one with the kitchen sink, or some sort of way to choose baroque or barren depending on mood.
Author
Owner

What do you think of scroll(1) as a name?

What do you think of `scroll(1)` as a name?
emma changed title from pager to `scroll(1)` – pager 2024-02-17 00:05:15 +00:00
Owner

What features should scroll(1) have?

  • scrolling back to previous lines? (more(1) doesn't have this, less(1) does)
  • syntax highlighting? (bat(1) has this)
  • search? (more(1) has this)
  • should it be in cooked mode or raw mode? Plan 9's p(1) uses cooked mode (the default line-editing mode available on all terminal devices), more(1) uses raw mode (where keypresses are handled only by the running program and not the terminal).
  • scrolling different numbers of lines depending on what key is pressed (e.g. jk for single-line scrolling, PgUp/PgDn for paging)?
What features should scroll(1) have? - scrolling back to previous lines? (more(1) doesn't have this, less(1) does) - syntax highlighting? (bat(1) has this) - search? (more(1) has this) - should it be in cooked mode or raw mode? Plan 9's p(1) uses cooked mode (the default line-editing mode available on all terminal devices), more(1) uses raw mode (where keypresses are handled only by the running program and not the terminal). - scrolling different numbers of lines depending on what key is pressed (e.g. `jk` for single-line scrolling, PgUp/PgDn for paging)?
Author
Owner

What features should scroll(1) have?

  • scrolling back to previous lines? (more(1) doesn't have this, less(1) does)

Definitely.

  • syntax highlighting? (bat(1) has this)

I don’t think this is in scope for the tool.

  • search? (more(1) has this)

I think it should have this.

  • should it be in cooked mode or raw mode? Plan 9's p(1) uses cooked mode (the default line-editing mode available on all terminal devices), more(1) uses raw mode (where keypresses are handled only by the running program and not the terminal).
  • scrolling different numbers of lines depending on what key is pressed (e.g. jk for single-line scrolling, PgUp/PgDn for paging)?

I will think more on these two.

> What features should scroll(1) have? > - scrolling back to previous lines? (more(1) doesn't have this, less(1) does) Definitely. > - syntax highlighting? (bat(1) has this) I don’t think this is in scope for the tool. > - search? (more(1) has this) I think it should have this. > - should it be in cooked mode or raw mode? Plan 9's p(1) uses cooked mode (the default line-editing mode available on all terminal devices), more(1) uses raw mode (where keypresses are handled only by the running program and not the terminal). > - scrolling different numbers of lines depending on what key is pressed (e.g. `jk` for single-line scrolling, PgUp/PgDn for paging)? I will think more on these two.
Owner

Scrollback would be cumbersome in cooked mode.

I don't think search should be part of the pager. I think we should make a searching utility and make the pager pipe through that tool instead. This can also be how we implement syntax highlighting.

Scrollback would be cumbersome in cooked mode. I don't think search should be part of the pager. I think we should make a searching utility and make the pager pipe through that tool instead. This can also be how we implement syntax highlighting.
Author
Owner

What if we had a pager/text editor combo? that way we wouldn’t be implementing redundant features

What if we had a pager/text editor combo? that way we wouldn’t be implementing redundant features
Author
Owner

You both read from and write to scrolls.

You both read from and write to scrolls.
Owner

I think a very light pager would be useful in addition to a (necessarily) slightly heavier editor. We could have two editors - pg(1) (operating in cooked mode using stdio.h) and scroll(1) (operating in raw mode, possibly using curses.h).

My p(1) implementation is a bare minimum pager operating in cooked mode based on Plan 9's utility of the same name. It operates in a loop, printing some lines from /dev/stdin and watching for a newline from /dev/tty before continuing. This would be the core functionality accomplished by pg(1).

The user could enter a newline to page the default amount of lines (22 - this is from Plan 9 and in my experience seems to be a nice default, leaving room to see the current and previous prompts for /dev/tty input on even a very small 24-row terminal window - or whatever the user specifies with the -d option) or enter an integer value to see only a certain amount of lines past what's been shown.

A reverse paging buffer would be very welcome for terminal emulators that don't support scrolling (like many kernel framebuffers) but not necessarily welcome on extremely low-memory systems on which large documents are being paged, so reverse paging can be optional (-r) and limited if necessary (with -b specifying a number of bytes on extremely constrained systems and -l specifying a number of lines on systems only somewhat constrained). Then at the /dev/tty read the user could specify a negative integer value to page backwards.

Then at the prompt the user could also change options relating to the running pg(1) instance. I think this is important because on especially constrained systems it might be pertinent to adjust - even coarsely - how much memory is used by the pager, and it's a hassle to restart a pager halfway through paging a very large file. So typing set default_scroll 47 would do just that. This isn't a feature I'd expect from a minimal pager and one I'm not suggesting without considering code complexity - I think it's important and implementation wouldn't be hard or too ineligant.

So for pg(1) I'm imagining Usage: pg (-r (-b [bytes])|(-l [lines])) (-d [lines]). -r enables a reverse-scrolling buffer, with the optional -b or -l indicating a maximum size for the buffer in bytes or lines respectively. -d changes the default amount of lines scrolled.

I think a very light pager would be useful in addition to a (necessarily) slightly heavier editor. We could have two editors - pg(1) (operating in cooked mode using stdio.h) and scroll(1) (operating in raw mode, possibly using curses.h). [My p(1) implementation](https://git.tebibyte.media/trinity/src/src/branch/main/p/p.c) is a bare minimum pager operating in cooked mode based on Plan 9's utility of the same name. It operates in a loop, printing some lines from /dev/stdin and watching for a newline from /dev/tty before continuing. This would be the core functionality accomplished by pg(1). The user could enter a newline to page the default amount of lines (22 - this is from Plan 9 and in my experience seems to be a nice default, leaving room to see the current and previous prompts for /dev/tty input on even a very small 24-row terminal window - or whatever the user specifies with the `-d` option) or enter an integer value to see only a certain amount of lines past what's been shown. A reverse paging buffer would be very welcome for terminal emulators that don't support scrolling (like many kernel framebuffers) but not necessarily welcome on extremely low-memory systems on which large documents are being paged, so reverse paging can be optional (`-r`) and limited if necessary (with `-b` specifying a number of bytes on extremely constrained systems and `-l` specifying a number of lines on systems only somewhat constrained). Then at the /dev/tty read the user could specify a negative integer value to page backwards. Then at the prompt the user could also change options relating to the running pg(1) instance. I think this is important because on especially constrained systems it might be pertinent to adjust - even coarsely - how much memory is used by the pager, and it's a hassle to restart a pager halfway through paging a very large file. So typing `set default_scroll 47` would do just that. This isn't a feature I'd expect from a minimal pager and one I'm not suggesting without considering code complexity - I think it's important and implementation wouldn't be hard or too ineligant. So for pg(1) I'm imagining `Usage: pg (-r (-b [bytes])|(-l [lines])) (-d [lines])`. `-r` enables a reverse-scrolling buffer, with the optional `-b` or `-l` indicating a maximum size for the buffer in bytes or lines respectively. `-d` changes the default amount of lines scrolled.
Sign in to join this conversation.
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: bonsai/coreutils#44
No description provided.