|
|
|
@ -11,7 +11,10 @@ use helix_core::{
|
|
|
|
|
syntax::{self, HighlightEvent},
|
|
|
|
|
Position, Range,
|
|
|
|
|
};
|
|
|
|
|
use helix_view::{document::Mode, Document, Editor, Theme, View};
|
|
|
|
|
use helix_view::{
|
|
|
|
|
document::{IndentStyle, Mode},
|
|
|
|
|
Document, Editor, Theme, View,
|
|
|
|
|
};
|
|
|
|
|
use std::borrow::Cow;
|
|
|
|
|
|
|
|
|
|
use crossterm::{
|
|
|
|
@ -455,6 +458,10 @@ impl EditorView {
|
|
|
|
|
theme: &Theme,
|
|
|
|
|
is_focused: bool,
|
|
|
|
|
) {
|
|
|
|
|
//-------------------------------
|
|
|
|
|
// Left side of the status line.
|
|
|
|
|
//-------------------------------
|
|
|
|
|
|
|
|
|
|
let mode = match doc.mode() {
|
|
|
|
|
Mode::Insert => "INS",
|
|
|
|
|
Mode::Select => "SEL",
|
|
|
|
@ -487,24 +494,41 @@ impl EditorView {
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
surface.set_stringn(
|
|
|
|
|
viewport.x + viewport.width.saturating_sub(15),
|
|
|
|
|
viewport.y,
|
|
|
|
|
format!("{}", doc.diagnostics().len()),
|
|
|
|
|
4,
|
|
|
|
|
text_color,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// render line:col
|
|
|
|
|
//-------------------------------
|
|
|
|
|
// Right side of the status line.
|
|
|
|
|
//-------------------------------
|
|
|
|
|
|
|
|
|
|
// Compute the individual info strings.
|
|
|
|
|
let diag_count = format!("{}", doc.diagnostics().len());
|
|
|
|
|
let indent_info = match doc.indent_style {
|
|
|
|
|
IndentStyle::Tabs => "tab",
|
|
|
|
|
IndentStyle::Spaces(1) => "spaces:1",
|
|
|
|
|
IndentStyle::Spaces(2) => "spaces:2",
|
|
|
|
|
IndentStyle::Spaces(3) => "spaces:3",
|
|
|
|
|
IndentStyle::Spaces(4) => "spaces:4",
|
|
|
|
|
IndentStyle::Spaces(5) => "spaces:5",
|
|
|
|
|
IndentStyle::Spaces(6) => "spaces:6",
|
|
|
|
|
IndentStyle::Spaces(7) => "spaces:7",
|
|
|
|
|
IndentStyle::Spaces(8) => "spaces:8",
|
|
|
|
|
_ => "indent:ERROR",
|
|
|
|
|
};
|
|
|
|
|
let position_info = {
|
|
|
|
|
let pos = coords_at_pos(doc.text().slice(..), doc.selection(view.id).cursor());
|
|
|
|
|
format!("{}:{}", pos.row + 1, pos.col + 1) // convert to 1-indexing
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
let text = format!("{}:{}", pos.row + 1, pos.col + 1); // convert to 1-indexing
|
|
|
|
|
let len = text.len();
|
|
|
|
|
|
|
|
|
|
// Render them to the status line together.
|
|
|
|
|
let right_side_text = format!(
|
|
|
|
|
"{} {} {} ",
|
|
|
|
|
&diag_count[..diag_count.len().min(4)],
|
|
|
|
|
indent_info,
|
|
|
|
|
position_info
|
|
|
|
|
);
|
|
|
|
|
let text_len = right_side_text.len() as u16;
|
|
|
|
|
surface.set_string(
|
|
|
|
|
viewport.x + viewport.width.saturating_sub(len as u16 + 1),
|
|
|
|
|
viewport.x + viewport.width.saturating_sub(text_len),
|
|
|
|
|
viewport.y,
|
|
|
|
|
text,
|
|
|
|
|
right_side_text,
|
|
|
|
|
text_color,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|