diff options
author | Blaž Hrastnik | 2021-04-09 08:56:31 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2021-04-09 09:57:46 +0000 |
commit | d692390d10cdbf7ac98128688de2f7fa0ba9bc06 (patch) | |
tree | ae003ef55ca588aedce0d12da9021328feffc573 /helix-term/src | |
parent | 865429643bf924e7b2b7fbbc7f239c469bbd22ca (diff) |
Render current line:col.
Diffstat (limited to 'helix-term/src')
-rw-r--r-- | helix-term/src/ui/editor.rs | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs index 556462b0..5426e014 100644 --- a/helix-term/src/ui/editor.rs +++ b/helix-term/src/ui/editor.rs @@ -7,6 +7,7 @@ use crate::{ }; use helix_core::{ + coords_at_pos, syntax::{self, HighlightEvent}, Position, Range, }; @@ -87,7 +88,7 @@ impl EditorView { view.area.width, 1, ); - self.render_statusline(doc, area, surface, theme, is_focused); + self.render_statusline(doc, view, area, surface, theme, is_focused); // render status if let Some(status_msg) = &self.status_msg { @@ -411,6 +412,7 @@ impl EditorView { pub fn render_statusline( &self, doc: &Document, + view: &View, viewport: Rect, surface: &mut Surface, theme: &Theme, @@ -449,10 +451,24 @@ impl EditorView { ); } - surface.set_string( - viewport.x + viewport.width.saturating_sub(10), + surface.set_stringn( + viewport.x + viewport.width.saturating_sub(15), viewport.y, format!("{}", doc.diagnostics.len()), + 4, + text_color, + ); + + // render line:col + let pos = coords_at_pos(doc.text().slice(..), doc.selection(view.id).cursor()); + + let text = format!("{}:{}", pos.row + 1, pos.col + 1); // convert to 1-indexing + let len = text.len(); + + surface.set_string( + viewport.x + viewport.width.saturating_sub(len as u16 + 1), + viewport.y, + text, text_color, ); } |