on master help sign in
Primary cursor colors by mode (#5130)
deae13fgibbz00
book/src/themes.md+4
@@ -252,10 +252,14 @@ These scopes are used for theming the editor interface.
252| `ui.background` | |
252| `ui.background` | |
253| `ui.background.separator` | Picker separator below input line |
253| `ui.background.separator` | Picker separator below input line |
254| `ui.cursor` | |
254| `ui.cursor` | |
255+| `ui.cursor.normal` | |
255| `ui.cursor.insert` | |
256| `ui.cursor.insert` | |
256| `ui.cursor.select` | |
257| `ui.cursor.select` | |
257| `ui.cursor.match` | Matching bracket etc. |
258| `ui.cursor.match` | Matching bracket etc. |
258| `ui.cursor.primary` | Cursor with primary selection |
259| `ui.cursor.primary` | Cursor with primary selection |
260+| `ui.cursor.primary.normal` | |
261+| `ui.cursor.primary.insert` | |
262+| `ui.cursor.primary.select` | |
259| `ui.gutter` | Gutter |
263| `ui.gutter` | Gutter |
260| `ui.gutter.selected` | Gutter for the line the cursor is on |
264| `ui.gutter.selected` | Gutter for the line the cursor is on |
261| `ui.linenr` | Line numbers |
265| `ui.linenr` | Line numbers |
helix-term/src/ui/editor.rs+13−7
@@ -342,23 +342,29 @@ impl EditorView {
342 let selection_scope = theme
342 let selection_scope = theme
343 .find_scope_index("ui.selection")
343 .find_scope_index("ui.selection")
344 .expect("could not find `ui.selection` scope in the theme!");
344 .expect("could not find `ui.selection` scope in the theme!");
345+ let primary_selection_scope = theme
346+ .find_scope_index("ui.selection.primary")
347+ .unwrap_or(selection_scope);
345 let base_cursor_scope = theme
348 let base_cursor_scope = theme
346 .find_scope_index("ui.cursor")
349 .find_scope_index("ui.cursor")
347 .unwrap_or(selection_scope);
350 .unwrap_or(selection_scope);
351+ let base_primary_cursor_scope = theme
352+ .find_scope_index("ui.cursor.primary")
353+ .unwrap_or(base_cursor_scope);
348
354
349 let cursor_scope = match mode {
355 let cursor_scope = match mode {
350 Mode::Insert => theme.find_scope_index("ui.cursor.insert"),
356 Mode::Insert => theme.find_scope_index("ui.cursor.insert"),
351 Mode::Select => theme.find_scope_index("ui.cursor.select"),
357 Mode::Select => theme.find_scope_index("ui.cursor.select"),
352− Mode::Normal => Some(base_cursor_scope),
358+ Mode::Normal => theme.find_scope_index("ui.cursor.normal"),
353 }
359 }
354 .unwrap_or(base_cursor_scope);
360 .unwrap_or(base_cursor_scope);
355
361
356− let primary_cursor_scope = theme
362+ let primary_cursor_scope = match mode {
357− .find_scope_index("ui.cursor.primary")
363+ Mode::Insert => theme.find_scope_index("ui.cursor.primary.insert"),
358− .unwrap_or(cursor_scope);
364+ Mode::Select => theme.find_scope_index("ui.cursor.primary.select"),
359− let primary_selection_scope = theme
360− .find_scope_index("ui.selection.primary")
365+ Mode::Normal => theme.find_scope_index("ui.cursor.primary.normal"),
361− .unwrap_or(selection_scope);
366+ }
367+ .unwrap_or(base_primary_cursor_scope);
362
368
363 let mut spans: Vec<(usize, std::ops::Range<usize>)> = Vec::new();
369 let mut spans: Vec<(usize, std::ops::Range<usize>)> = Vec::new();
364 for (i, range) in selection.iter().enumerate() {
370 for (i, range) in selection.iter().enumerate() {