Add ability to theme cursor

pull/353/head
wojciechkepka 3 years ago committed by Blaž Hrastnik
parent f09ccbc891
commit ac1e98d088

@ -281,9 +281,17 @@ impl EditorView {
let end = text.line_to_char(last_line + 1); let end = text.line_to_char(last_line + 1);
Range::new(start, end) Range::new(start, end)
}; };
let cursor_style = Style::default() let scope = match doc.mode() {
// .bg(Color::Rgb(255, 255, 255)) Mode::Insert => "ui.cursor.insert",
.add_modifier(Modifier::REVERSED); 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"); 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 if (pos.col as u16) < viewport.width + view.first_col as u16
&& pos.col >= view.first_col && pos.col >= view.first_col
{ {
let style = Style::default() let style =
.add_modifier(Modifier::REVERSED) theme.try_get("ui.cursor.match").unwrap_or_else(|| {
.add_modifier(Modifier::DIM); Style::default()
.add_modifier(Modifier::REVERSED)
.add_modifier(Modifier::DIM)
});
surface surface
.get_mut( .get_mut(

Loading…
Cancel
Save