diff options
author | wojciechkepka | 2021-06-20 19:47:35 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2021-06-23 12:55:02 +0000 |
commit | ac1e98d088dcb05bfb72d39bc33394163b8303ba (patch) | |
tree | 9bedd184b8d0590444fe478a71d459e33628532e /helix-term/src/ui | |
parent | f09ccbc89112fb2df57f4c6817ee11acfd70591e (diff) |
Add ability to theme cursor
Diffstat (limited to 'helix-term/src/ui')
-rw-r--r-- | helix-term/src/ui/editor.rs | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs index 550ff181..43f1069d 100644 --- a/helix-term/src/ui/editor.rs +++ b/helix-term/src/ui/editor.rs @@ -281,9 +281,17 @@ impl EditorView { let end = text.line_to_char(last_line + 1); Range::new(start, end) }; - let cursor_style = Style::default() - // .bg(Color::Rgb(255, 255, 255)) - .add_modifier(Modifier::REVERSED); + let scope = match doc.mode() { + Mode::Insert => "ui.cursor.insert", + Mode::Select => "ui.cursor.select", + Mode::Normal => "ui.cursor", + }; + let cursor_style = theme.try_get(scope).unwrap_or_else(|| { + theme + //if cursor.insert or cursor.select was not present try to default to cursor + .try_get("ui.cursor") + .unwrap_or_else(|| Style::default().add_modifier(Modifier::REVERSED)) + }); let selection_style = theme.get("ui.selection"); @@ -388,9 +396,12 @@ impl EditorView { if (pos.col as u16) < viewport.width + view.first_col as u16 && pos.col >= view.first_col { - let style = Style::default() - .add_modifier(Modifier::REVERSED) - .add_modifier(Modifier::DIM); + let style = + theme.try_get("ui.cursor.match").unwrap_or_else(|| { + Style::default() + .add_modifier(Modifier::REVERSED) + .add_modifier(Modifier::DIM) + }); surface .get_mut( |