separate inner section of status line from outer

inner now is independent from current mode
- easier to read and set bold style
- less distraction from switching modes
any combination of colors can be set easily
- one for inner section
- other for outer section
style of inner section can be set using bold and others modifications
This commit is contained in:
Anton Simonov 2024-02-26 17:40:10 +03:00
parent d8abb3ed79
commit 5d8e677edc
3 changed files with 24 additions and 6 deletions

View file

@ -48,8 +48,11 @@ syntect_theme = ""
[status] [status]
separator_open = "" separator_open = ""
separator_close = "" separator_close = ""
# remove separator_style? probably in use on cand.rs:32
separator_style = { fg = "darkgray", bg = "darkgray" } separator_style = { fg = "darkgray", bg = "darkgray" }
inner_section = { fg = "black", bg = "darkgray", bold = true }
# Mode # Mode
mode_normal = { fg = "black", bg = "lightblue", bold = true } mode_normal = { fg = "black", bg = "lightblue", bold = true }
mode_select = { fg = "black", bg = "lightgreen", bold = true } mode_select = { fg = "black", bg = "lightgreen", bold = true }

View file

@ -49,6 +49,7 @@ struct Status {
pub separator_open: String, pub separator_open: String,
pub separator_close: String, pub separator_close: String,
pub separator_style: Style, pub separator_style: Style,
pub inner_section: Style,
// Mode // Mode
pub mode_normal: Style, pub mode_normal: Style,

View file

@ -31,10 +31,17 @@ function Status:size()
return ui.Line {} return ui.Line {}
end end
local style = self.style() -- style of inner section always uses inner_section style
-- independent of current mode
-- set inner separator and section style
local st_sec = THEME.status.inner_section
-- set color of separator to bg of inner section
local fg_sep = st_sec.bg
return ui.Line { return ui.Line {
ui.Span(" " .. ya.readable_size(h:size() or h.cha.length) .. " "):fg(style.bg):bg(THEME.status.separator_style.bg), ui.Span(" " .. ya.readable_size(h:size() or h.cha.length) .. " "):style(st_sec),
ui.Span(THEME.status.separator_close):fg(THEME.status.separator_style.fg), ui.Span(THEME.status.separator_close):fg(fg_sep),
} }
end end
@ -90,10 +97,17 @@ function Status:percentage()
percent = string.format(" %3d%% ", percent) percent = string.format(" %3d%% ", percent)
end end
local style = self.style() -- style of inner section always uses inner_section style
-- independent of current mode
-- set inner separator and section style
local st_sec = THEME.status.inner_section
-- set color of separator to bg of inner section
local fg_sep = st_sec.bg
return ui.Line { return ui.Line {
ui.Span(" " .. THEME.status.separator_open):fg(THEME.status.separator_style.fg), ui.Span(" " .. THEME.status.separator_open):fg(fg_sep),
ui.Span(percent):fg(style.bg):bg(THEME.status.separator_style.bg), ui.Span(percent):style(st_sec),
} }
end end