Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tweaks for less compatibility #14

Closed
wants to merge 5 commits into from

Conversation

quark-zju
Copy link
Contributor

Some tweaks to make sp more familiar to less users.

@markbt
Copy link
Owner

markbt commented Jan 6, 2020

I really don't like less's behaviour that prevents you from scrolling past the end of the file. It's still possible to scroll past the end anyway (e.g. by searching), and I often find it useful to do so (e.g. to line things up on my terminal). I'd prefer not to adopt that.

The other stuff is fine. I wasn't aiming for less/vim compatibility, but I understand some people have muscle memory for these things.

@quark-zju
Copy link
Contributor Author

quark-zju commented Jan 6, 2020

I think it depends on whether the alternate screen is used. When it's not used it seems cleaner not having the "~" left on screen at exit. I'm used to the less -F -X behavior. I'll make it an option then.

Emulates `less -F -X`. Stream the output immediately to the terminal before
entering the full screen mode. Error and progress are rendered after output
so it looks visually similar to the full screen UI.

The streaming rendering mode (`InterfaceMode::Hybrid`) can be used standalone
without entering full screen (`InterfaceMode::Cat`) to emulate buck-build-style
output.

The 2-second delay "all or nothing" rendering is preserved as
`InterfaceMode::Delayed`.
Add flags `--delayed (-D)`, `--no-alternate (-X)` for the new InterfaceMode
config. The old flag `--force` was removed. It can be expressed by `-D 0`.

`sp -X` matches `less -X -F`.
`sp -D 9999` roughly matches `less -F`.
`sp -D 0` matches `less` without `-X` or `-F`.

`sp` without arguments works like `sp -D 2`, preserving the old behavior.
This makes the code shorter.
Add key bindings that are defined consistently in both vim and less.
Including:

- j, k: move down or up, by a line
- Ctrl+D, Ctrl+U: move down or up, by half a screen
- Ctrl+F, Ctrl+B: move down or up, by a screen
- g, G: move to the beginning or the end.
- N: move to the previous match (line match in sp).

I didn't find a good editor for `help.txt` so it is left unchanged for now.
By default, allow scrolling past EOF.

If `SP_SCROLL_PAST_EOF` is set to `0`, disallow scrolling past EOF, which
matches vim or less' user expectation.
@quark-zju
Copy link
Contributor Author

quark-zju commented Jan 8, 2020

I made it a config option that can be set via SP_SCROLL_PAST_EOF. It defaults to true, preserving the existing behavior.

(This is now based on #13, so I don't need to rebase back and forth)

@markbt
Copy link
Owner

markbt commented Jan 11, 2020

Looks good. I'll merge after #13 for simplicity.

markbt added a commit that referenced this pull request Jan 12, 2020
@markbt markbt closed this in 3b74a36 Jan 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants