aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src/ui
diff options
context:
space:
mode:
authorAlexis Kalabura2022-07-21 04:03:12 +0000
committerGitHub2022-07-21 04:03:12 +0000
commit8b2a14153b0d21391e06636d0df7e8cc1b8143c4 (patch)
tree1acd64f439523618eec4ccc8ad049d68fb748c90 /helix-term/src/ui
parent906259cc41cc251dbbe1802e3a5e54a566a7d8d2 (diff)
add statusline element to display file line endings (#3113)
* add statusline element to display file line endings * run cargo fmt --all * change the word *ending* from plural to singular * support for the unicode-lines feature flag
Diffstat (limited to 'helix-term/src/ui')
-rw-r--r--helix-term/src/ui/statusline.rs26
1 files changed, 26 insertions, 0 deletions
diff --git a/helix-term/src/ui/statusline.rs b/helix-term/src/ui/statusline.rs
index 895043cd..85992c60 100644
--- a/helix-term/src/ui/statusline.rs
+++ b/helix-term/src/ui/statusline.rs
@@ -138,6 +138,7 @@ where
helix_view::editor::StatusLineElement::Spinner => render_lsp_spinner,
helix_view::editor::StatusLineElement::FileName => render_file_name,
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,
helix_view::editor::StatusLineElement::Diagnostics => render_diagnostics,
helix_view::editor::StatusLineElement::Selections => render_selections,
@@ -280,6 +281,31 @@ where
}
}
+fn render_file_line_ending<F>(context: &mut RenderContext, write: F)
+where
+ F: Fn(&mut RenderContext, String, Option<Style>) + Copy,
+{
+ use helix_core::LineEnding::*;
+ let line_ending = match context.doc.line_ending {
+ Crlf => "CRLF",
+ LF => "LF",
+ #[cfg(feature = "unicode-lines")]
+ VT => "VT", // U+000B -- VerticalTab
+ #[cfg(feature = "unicode-lines")]
+ FF => "FF", // U+000C -- FormFeed
+ #[cfg(feature = "unicode-lines")]
+ CR => "CR", // U+000D -- CarriageReturn
+ #[cfg(feature = "unicode-lines")]
+ Nel => "NEL", // U+0085 -- NextLine
+ #[cfg(feature = "unicode-lines")]
+ LS => "LS", // U+2028 -- Line Separator
+ #[cfg(feature = "unicode-lines")]
+ PS => "PS", // U+2029 -- ParagraphSeparator
+ };
+
+ write(context, format!(" {} ", line_ending), None);
+}
+
fn render_file_type<F>(context: &mut RenderContext, write: F)
where
F: Fn(&mut RenderContext, String, Option<Style>) + Copy,