on master help sign in
Add ability to theme cursor
ac1e98dwojciechkepka
helix-term/src/ui/editor.rs+17−6
@@ -281,9 +281,17 @@ impl EditorView {
281 let end = text.line_to_char(last_line + 1);
281 let end = text.line_to_char(last_line + 1);
282 Range::new(start, end)
282 Range::new(start, end)
283 };
283 };
284− let cursor_style = Style::default()
284+ let scope = match doc.mode() {
285− // .bg(Color::Rgb(255, 255, 255))
285+ Mode::Insert => "ui.cursor.insert",
286+ Mode::Select => "ui.cursor.select",
287+ Mode::Normal => "ui.cursor",
288+ };
289+ let cursor_style = theme.try_get(scope).unwrap_or_else(|| {
290+ theme
291+ //if cursor.insert or cursor.select was not present try to default to cursor
292+ .try_get("ui.cursor")
286− .add_modifier(Modifier::REVERSED);
293+ .unwrap_or_else(|| Style::default().add_modifier(Modifier::REVERSED))
294+ });
287
295
288 let selection_style = theme.get("ui.selection");
296 let selection_style = theme.get("ui.selection");
289
297
@@ -388,9 +396,12 @@ impl EditorView {
388 if (pos.col as u16) < viewport.width + view.first_col as u16
396 if (pos.col as u16) < viewport.width + view.first_col as u16
389 && pos.col >= view.first_col
397 && pos.col >= view.first_col
390 {
398 {
399+ let style =
400+ theme.try_get("ui.cursor.match").unwrap_or_else(|| {
391− let style = Style::default()
401+ Style::default()
392− .add_modifier(Modifier::REVERSED)
402+ .add_modifier(Modifier::REVERSED)
393− .add_modifier(Modifier::DIM);
403+ .add_modifier(Modifier::DIM)
404+ });
394
405
395 surface
406 surface
396 .get_mut(
407 .get_mut(