aboutsummaryrefslogtreecommitdiff
path: root/helix-term
diff options
context:
space:
mode:
authorMathspy2022-06-30 09:26:00 +0000
committerGitHub2022-06-30 09:26:00 +0000
commitd06800f1dd47315f5738c529d40d1e0952ee2115 (patch)
tree7359e27191a12f132fc882f40c0981fb5dc30939 /helix-term
parented89f8897eab84bf7614a718d5d1e3ec5c57086c (diff)
Add mode specific styles (#2676)
* Add mode specific styles In similar vein to neovim's lualine and similar statusline packages this allows helix users to style their mode based on which mode it is thus making each mode more visually distinct at a glance * Add an example based on rosepine * Add editor.colors-mode config * Document statusline mode styles
Diffstat (limited to 'helix-term')
-rw-r--r--helix-term/src/ui/editor.rs21
1 files changed, 14 insertions, 7 deletions
diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs
index 948803eb..a7c67a21 100644
--- a/helix-term/src/ui/editor.rs
+++ b/helix-term/src/ui/editor.rs
@@ -161,7 +161,7 @@ impl EditorView {
.area
.clip_top(view.area.height.saturating_sub(1))
.clip_bottom(1); // -1 from bottom to remove commandline
- self.render_statusline(doc, view, statusline_area, surface, theme, is_focused);
+ self.render_statusline(editor, doc, view, statusline_area, surface, is_focused);
}
pub fn render_rulers(
@@ -732,11 +732,11 @@ impl EditorView {
pub fn render_statusline(
&self,
+ editor: &Editor,
doc: &Document,
view: &View,
viewport: Rect,
surface: &mut Surface,
- theme: &Theme,
is_focused: bool,
) {
use tui::text::{Span, Spans};
@@ -745,10 +745,11 @@ impl EditorView {
// Left side of the status line.
//-------------------------------
- let mode = match doc.mode() {
- Mode::Insert => "INS",
- Mode::Select => "SEL",
- Mode::Normal => "NOR",
+ let theme = &editor.theme;
+ let (mode, mode_style) = match doc.mode() {
+ Mode::Insert => (" INS ", theme.get("ui.statusline.insert")),
+ Mode::Select => (" SEL ", theme.get("ui.statusline.select")),
+ Mode::Normal => (" NOR ", theme.get("ui.statusline.normal")),
};
let progress = doc
.language_server()
@@ -767,7 +768,13 @@ impl EditorView {
// statusline
surface.set_style(viewport.with_height(1), base_style);
if is_focused {
- surface.set_string(viewport.x + 1, viewport.y, mode, base_style);
+ let color_modes = editor.config().color_modes;
+ surface.set_string(
+ viewport.x,
+ viewport.y,
+ mode,
+ if color_modes { mode_style } else { base_style },
+ );
}
surface.set_string(viewport.x + 5, viewport.y, progress, base_style);