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

feat: Use custom character to draw editor rulers #11798

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

codingjerk
Copy link

This PR allows selecting custom character to draw editor rulers and it contains fixes and improvements on PR #9256

Differences from previous PR

  1. No unnecessary formatting changes
  2. No unnecessary string allocation for every character drawn
  3. Separate theme key (ui.virtual.ruler.char) if editor.ruler-char is set to allow using different styles for "background ruler" and "character ruler"
  4. Ruler character is drawn under the text

Screenshot

Default theme with config

[editor]
  rulers = [ 40, 60 ]
  ruler-char = "¦"

image

@codingjerk
Copy link
Author

codingjerk commented Sep 30, 2024

I believe I also need to add theme key ui.virtual.ruler.char to every theme in helix.

I believe reasonable value for it is the same as ui.virtual.indent-guide. Using bg from ui.virtual.ruler as fg doesn't work well — in some themes it's pretty hard to see "character rulers" since they're thinner.

I'll wait for reviewers to approve this approach, before adding new key to every theme.

@baldwindavid
Copy link

baldwindavid commented Sep 30, 2024

@codingjerk Thanks for this; a real big win here is fixing the issue of the disappearing cursor over a ruler.

I read about some of the constraints and complications in #9256 and see that it's not completely straightforward how to approach.

Not a reviewer at all, but I do wonder if an option might be to introduce a couple settings:

Settings

| `ruler-style` | `bg` displays the ruler as a background color, while `char` displays the configured `ruler-char` | `bg` |
| `ruler-char`  | Specifies the character used to display the rulers when `ruler-style` is `char` | `|` |

The default style would be background so as not to break current settings. The default ruler character is set to |, but will only display if the ruler-style is set to char.

Theme Changes

Perhaps an additional theme key is then not necessary. Instead, the bg dictates the bg ruler-style just as it does now and fg dictates the char ruler-style.

"ui.virtual.ruler" = { bg = "cursorline", fg = "cursorline" }

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.

2 participants