Skip to content

Commit

Permalink
Add ui.gutter.selected option for themes (helix-editor#3303)
Browse files Browse the repository at this point in the history
* add `ui.gutter.selected`

* add `ui.gutter`, `ui.gutter.selected` to docs
  • Loading branch information
ChrHorn authored and pathwave committed Nov 4, 2022
1 parent 24ea1f7 commit 8f99400
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions book/src/themes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down
7 changes: 7 additions & 0 deletions helix-term/src/ui/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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 {
Expand Down

0 comments on commit 8f99400

Please sign in to comment.