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

[Feature] Sticky headers #35

Open
quark-zju opened this issue Jan 20, 2021 · 3 comments
Open

[Feature] Sticky headers #35

quark-zju opened this issue Jan 20, 2021 · 3 comments
Labels
enhancement New feature or request

Comments

@quark-zju
Copy link
Contributor

quark-zju commented Jan 20, 2021

Just log the idea while I encounter it (again). When running git log -p I sometimes find the change I want and wanted to get back to the commit hash. It would be nice to have some sort of "sticky header" so it looks like:

commit deadbeef (sticky header level 1)
diff --git a/filename... (sticky header level 2)
(scroll-able text)

I don't know how to express it exactly. Potentially we can use some kind of ANSI sequences to define "header 1", "header 2" etc that are otherwise no-ops? I'm no expert on ANSI sequences. But if we define it here, I'm interested in implementing it except others beat me on it.

EDIT: Probably should try the new "discussions" GitHub feature for this.

@quark-zju quark-zju changed the title [Feature] Pinned headers [Feature] Sticky headers Jan 20, 2021
@markbt
Copy link
Owner

markbt commented Jan 24, 2021

This is a great idea. I already had a similar idea where a static banner could be added to the file which gets shown at the top. I was anticipating using that for showing titles, which would be particularly useful for controlled mode.

This is subtly different: my proposed banners would be entirely static, whereas (I assume) these sticky header lines would scroll left and right with the content. You could also use it, e.g. for showing large tables of SQL output, where you can make the first 3 lines sticky and only the data scrolls.

I'm not sure custom ANSI sequences would work so well, as I'm not sure what they'd mean anywhere but at the top. Instead I propose the following (defining some terms while I'm at it):

  • The header is an initial number of file lines that are always shown at the top of the file-view portion of the screen. They scroll left and right with the rest of the content when wrapping is disabled, but do not scroll up and down.

    • The header can be controlled by keyboard shortcuts, increasing or decreasing the number of lines.

    • The header's initial size can be set by command line flags (on a per-stream basis). For example: git log -p | sp --header-lines=3

    • The header's initial size can also be set using parameters to the Pager when using streampager as a library.

  • The banner is a set of lines that is always shown at the top of the screen above the file content. It can only be set when using streampager as a library.

@markbt
Copy link
Owner

markbt commented Jan 24, 2021

If you think an escape sequence might be useful (e.g. because you want a template to print it out to get the right line), then perhaps we could use an OSC sequence. Something like:

ESC ] streampager ; set-end-of-header BEL

This should be ignored by terminals, I believe.

In termwiz it gets parsed as OperatingSystemCommand::Unspecified(["streampager", "set-end-of-header"]) which should make it easy enough to parse out in line.rs.

@markbt markbt added the enhancement New feature or request label Mar 11, 2021
@martinvonz
Copy link

Once this feature is in, it would be nice to also have keyboard shortcuts to scroll between the headers. I often review a series of patches by running hg log -pvr <some revset>. It would be nice to be able to press some key(s) to get the next/previous changeset/file header at the top of the screen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants