From 8f994008dda06b83f8d1f8ffd666303b0c3237a8 Mon Sep 17 00:00:00 2001 From: ChrHorn Date: Mon, 3 Oct 2022 16:44:45 +0200 Subject: [PATCH] Add `ui.gutter.selected` option for themes (#3303) * add `ui.gutter.selected` * add `ui.gutter`, `ui.gutter.selected` to docs --- book/src/themes.md | 2 ++ helix-term/src/ui/editor.rs | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/book/src/themes.md b/book/src/themes.md index 9908456fca38f..b92b6d7b1da35 100644 --- a/book/src/themes.md +++ b/book/src/themes.md @@ -219,6 +219,8 @@ These scopes are used for theming the editor interface. | `ui.cursor.select` | | | `ui.cursor.match` | Matching bracket etc. | | `ui.cursor.primary` | Cursor with primary selection | +| `ui.gutter` | Gutter | +| `ui.gutter.selected` | Gutter for the line the cursor is on | | `ui.linenr` | Line numbers | | `ui.linenr.selected` | Line number for the line the cursor is on | | `ui.statusline` | Statusline | diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs index c6e5ed759cca7..e3094ead36c57 100644 --- a/helix-term/src/ui/editor.rs +++ b/helix-term/src/ui/editor.rs @@ -745,6 +745,7 @@ impl EditorView { let mut offset = 0; let gutter_style = theme.get("ui.gutter"); + let gutter_selected_style = theme.get("ui.gutter.selected"); // avoid lots of small allocations by reusing a text buffer for each line let mut text = String::with_capacity(8); @@ -757,6 +758,12 @@ impl EditorView { let x = viewport.x + offset; let y = viewport.y + i as u16; + let gutter_style = if selected { + gutter_selected_style + } else { + gutter_style + }; + if let Some(style) = gutter(line, selected, &mut text) { surface.set_stringn(x, y, &text, *width, gutter_style.patch(style)); } else {