aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src/ui
diff options
context:
space:
mode:
authorConnortsui202023-08-08 12:51:34 +0000
committerGitHub2023-08-08 12:51:34 +0000
commitfcbac485f885d90f6341d7acaf75157a01d81892 (patch)
tree21184e39c95cd2b3d4e4a706608bf6584c6b9045 /helix-term/src/ui
parenta7a145ad3d78dc0b9f7c2ea289e07d60d9b51d30 (diff)
Show whether file readonly in statusline (#7740)
Diffstat (limited to 'helix-term/src/ui')
-rw-r--r--helix-term/src/ui/statusline.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/helix-term/src/ui/statusline.rs b/helix-term/src/ui/statusline.rs
index 61fca609..52dd49f9 100644
--- a/helix-term/src/ui/statusline.rs
+++ b/helix-term/src/ui/statusline.rs
@@ -145,6 +145,7 @@ where
helix_view::editor::StatusLineElement::FileModificationIndicator => {
render_file_modification_indicator
}
+ helix_view::editor::StatusLineElement::ReadOnlyIndicator => render_read_only_indicator,
helix_view::editor::StatusLineElement::FileEncoding => render_file_encoding,
helix_view::editor::StatusLineElement::FileLineEnding => render_file_line_ending,
helix_view::editor::StatusLineElement::FileType => render_file_type,
@@ -442,6 +443,19 @@ where
write(context, title, None);
}
+fn render_read_only_indicator<F>(context: &mut RenderContext, write: F)
+where
+ F: Fn(&mut RenderContext, String, Option<Style>) + Copy,
+{
+ let title = if context.doc.readonly {
+ " [readonly] "
+ } else {
+ ""
+ }
+ .to_string();
+ write(context, title, None);
+}
+
fn render_file_base_name<F>(context: &mut RenderContext, write: F)
where
F: Fn(&mut RenderContext, String, Option<Style>) + Copy,