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

Show percentage through the file in the statusline/modeline #246

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

oldaccountdeadname
Copy link
Contributor

Not quite sure if there's a proper name for this; here's a screenshot of the new behavior (see the "61%" in the modeline):

screenshot-of-changes

I personally like this, but I don't know if everyone does. Tell me if you'd prefer this to be an option in the config rather than hard-coded!

@jmacdonald
Copy link
Owner

I like it! I have a couple of questions/suggestions:

  • The percentage seems based on the cursor position, but it might be better to use the last visible line of the window. That would prevent the number from changing when the cursor is moved within the window, which feels distracting. I also tend to think of these indicators as answering "how far down in the document am I looking?", which aligns with the window. Any idea what other editors have landed on for this?
  • Does the percentage still display if all of the buffer content fits on-screen? This relates to my earlier point: if it's meant to be an indicator of the how far down the window is looking into the buffer, we should hide it if the answer to that question is obvious.
  • I kinda feel like it might be a better fit at the end of the line, since it's not critical information, unlike the name or editor mode. What do you think?

@oldaccountdeadname
Copy link
Contributor Author

oldaccountdeadname commented Jan 23, 2022 via email

This will make following changes (adding a position indicator)
moderately simpler.
A modeline may look like, for instance:

	NORMAL  [17%] src/presenters/mod.rs

as opposed to the previous:

	NORMAL  src/presenters/mod.rs

This is a small & slightly opinionated change.
The previous logic to display the statusline did so by right aligning
only the last element. This isn't sufficient if more than one element is
to appear on the right (e.g., a cursor position indicator). So, this
commit replaces the logic to first render the right elements as
compactly as possible, then render the first left elements as compactly
as possible, but expand out the last left element to fill the remaining
space.

Behavior is identical; this is purely an API change.
This only applies to normal mode, and is a straightforward extension of
ff0dc68's modifications.
This modifies the display function in normal mode without changing the
logic to gather the percentage, and should make the statusline a bit
cleaner on small files.
@oldaccountdeadname
Copy link
Contributor Author

I rebased the commits to fix up the merge conflict. The hashes mentioned above are now out-of-date, but hopefully the log is clear enough - thanks!

The percentage indicator previously used the default colors, which was
in contrast to the rest of the statusline, which used focused.
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