riffle icon indicating copy to clipboard operation
riffle copied to clipboard

Design goals

Open sharkdp opened this issue 5 years ago • 1 comments

Advantages of a "pager" as a library:

  • Make everything easily configurable: custom header and footer messages, keybindings
  • Bidirectional communication: send events like "terminal resize" or key presses back to the application to trigger a redraw or other actions.

A few advantages if we would use a builtin pager in bat:

  • Have one consistent pager experience across all operating systems. No need to call external programs that might not be available. No special handling / bug fixing for different versions of less. Consistent "quit if one screen" handling (#860, #1000, #717, #710, #681, #520, #415, #312, #271, #519, #376, #887, #943, #838, …)
  • Handling of terminal resize events (#294, #322, #921, #1009)
  • Open editor with a key press (#358, #464, #528, #697)
  • Possibility to always draw the header at the top of the screen, even when scrolling down (#908)
  • Builtin --follow support (#457, #808)
  • Special handling for multiple files? (press 'n' to go to the next file)
  • Error handling: we could print errors/warnings in the footer of the pager, instead of in the background (#946)
  • Better 'tab' handling (#980, #894)
  • Handling of ANSI hyperlinks (#961)
  • Disable style components via keypress. For example: switch off the side bar with a keypress - for easy copy&paste.

sharkdp avatar May 28 '20 10:05 sharkdp

Links added; feel free to use my text and remove the comment

Let's use this ticket to discuss some ideas and possible upsides/downsides of writing our own custom pager library that we could use instead of calling an external $PAGER process (or, essentially, less).

A few advantages if we would use a builtin pager in bat:

General advantages of a "pager" as a library (not just for bat):

  • Make everything easily configurable: custom header and footer messages, keybindings
  • Bidirectional communication: send events like "terminal resize" or key presses back to the main application to trigger a redraw or other actions.

The obvious downsides are:

  • this will be a lot of work 😄
  • I'm sure there will be TONS of bug reports regarding obscure terminal emulators and operating systems where things are not working as expected - which results in even more work. less comes with 36 years(!!) of experience.

One way to circumvent the second point would be to make this an opt-in feature, at least in the beginning.

I have actually started to implement a really simple cross-platform pager-as-a-library like this in a private repository. The first results look promising 😄 out

I'd be happy to hear about your thoughts and ideas!

stdedos avatar Feb 06 '22 21:02 stdedos