Unnamed repository; edit this file 'description' to name the repository.
Make ruler char configurable, default to `┊`
| -rw-r--r-- | book/src/editor.md | 1 | ||||
| -rw-r--r-- | helix-term/src/ui/editor.rs | 16 | ||||
| -rw-r--r-- | helix-view/src/editor.rs | 3 |
3 files changed, 15 insertions, 5 deletions
diff --git a/book/src/editor.md b/book/src/editor.md index a9ea219b..f807f6a3 100644 --- a/book/src/editor.md +++ b/book/src/editor.md @@ -48,6 +48,7 @@ | `true-color` | Set to `true` to override automatic detection of terminal truecolor support in the event of a false negative | `false` | | `undercurl` | Set to `true` to override automatic detection of terminal undercurl support in the event of a false negative | `false` | | `rulers` | List of column positions at which to display the rulers. Can be overridden by language specific `rulers` in `languages.toml` file | `[]` | +| `ruler-char` | Character used to draw rulers | `┊` | | `bufferline` | Renders a line at the top of the editor displaying open buffers. Can be `always`, `never` or `multiple` (only shown if more than one buffer is in use) | `never` | | `color-modes` | Whether to color the mode indicator with different colors depending on the mode itself | `false` | | `text-width` | Maximum line length. Used for the `:reflow` command and soft-wrapping if `soft-wrap.wrap-at-text-width` is set | `80` | diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs index b25af107..a20fc9dd 100644 --- a/helix-term/src/ui/editor.rs +++ b/helix-term/src/ui/editor.rs @@ -245,10 +245,11 @@ impl EditorView { surface: &mut Surface, theme: &Theme, ) { - let editor_rulers = &editor.config().rulers; + let config = editor.config(); + let editor_rulers = &config.rulers; let ruler_theme = theme .try_get("ui.virtual.ruler") - .unwrap_or_else(|| Style::default().bg(Color::Red)); + .unwrap_or_else(|| Style::default().fg(Color::Red)); let rulers = doc .language_config() @@ -257,14 +258,19 @@ impl EditorView { let view_offset = doc.view_offset(view.id); - rulers + let ruler_cols = rulers .iter() // View might be horizontally scrolled, convert from absolute distance // from the 1st column to relative distance from left of viewport .filter_map(|ruler| ruler.checked_sub(1 + view_offset.horizontal_offset as u16)) .filter(|ruler| ruler < &viewport.width) - .map(|ruler| viewport.clip_left(ruler).with_width(1)) - .for_each(|area| surface.set_style(area, ruler_theme)) + .map(|ruler| viewport.x + ruler); + + for col in ruler_cols { + for y in viewport.y..viewport.height { + surface.set_string(col, y, &config.ruler_char, ruler_theme); + } + } } fn viewport_byte_range( diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs index 162d2b1f..3e7ccaa2 100644 --- a/helix-view/src/editor.rs +++ b/helix-view/src/editor.rs @@ -333,6 +333,8 @@ pub struct Config { pub terminal: Option<TerminalConfig>, /// Column numbers at which to draw the rulers. Defaults to `[]`, meaning no rulers. pub rulers: Vec<u16>, + /// Character used to draw rulers. Defaults to `┊`. + pub ruler_char: String, #[serde(default)] pub whitespace: WhitespaceConfig, /// Persistently display open buffers along the top @@ -1046,6 +1048,7 @@ impl Default for Config { lsp: LspConfig::default(), terminal: get_terminal_provider(), rulers: Vec::new(), + ruler_char: "┊".to_owned(), whitespace: WhitespaceConfig::default(), bufferline: BufferLine::default(), indent_guides: IndentGuidesConfig::default(), |