feat: statusline elements theme support

pull/13666/head
Erasin 2025-06-01 22:33:20 +08:00
parent 2773bb0fa7
commit 738bdb429d
2 changed files with 10 additions and 10 deletions

View File

@ -285,7 +285,7 @@ These scopes are used for theming the editor interface:
| `ui.gutter.selected` | Gutter for the line the cursor is on |
| `ui.linenr` | Line numbers |
| `ui.linenr.selected` | Line number for the line the cursor is on |
| `ui.statusline` | Statusline |
| `ui.statusline` | Statusline (support element style e.g. `ui.statusline.file-name`) |
| `ui.statusline.inactive` | Statusline (unfocused document) |
| `ui.statusline.normal` | Statusline mode during normal mode ([only if `editor.color-modes` is enabled][editor-section]) |
| `ui.statusline.insert` | Statusline mode during insert mode ([only if `editor.color-modes` is enabled][editor-section]) |

View File

@ -165,11 +165,15 @@ where
}
fn statusline_style(context: &RenderContext, scope: &str) -> Style {
let scope = format!("ui.statusline.{scope}");
let visible = context.focused;
let scope = if context.focused {
format!("ui.statusline.{scope}")
} else {
format!("ui.statusline.inactive.{scope}")
};
let config = context.editor.config();
if visible && config.color_modes {
if config.color_modes {
context.editor.theme.get(&scope)
} else {
Style::default()
@ -411,7 +415,7 @@ where
let maxrows = context.doc.text().len_lines();
write(
context,
format!("{}%", (position.row + 1) * 100 / maxrows).into(),
format!(" {}% ", (position.row + 1) * 100 / maxrows).into(),
);
}
@ -496,11 +500,7 @@ fn render_file_modification_indicator<'a, F>(context: &mut RenderContext<'a>, wr
where
F: Fn(&mut RenderContext<'a>, Span<'a>) + Copy,
{
let title = if context.doc.is_modified() {
"[+]"
} else {
" "
};
let title = if context.doc.is_modified() { "[+]" } else { "" };
write(context, title.into());
}