mirror of
https://github.com/helix-editor/helix.git
synced 2024-11-25 02:46:17 +04:00
feat(statusline): add option to show total line numbers in file (#3960)
* feat(statusline): add option to show total line numbers in file * feat(line numbers): add config to doc book
This commit is contained in:
parent
519857d632
commit
c144cc0b04
@ -93,6 +93,7 @@ ### `[editor.statusline]` Section
|
||||
| `file-name` | The path/name of the opened file |
|
||||
| `file-encoding` | The encoding of the opened file if it differs from UTF-8 |
|
||||
| `file-line-ending` | The file line endings (CRLF or LF) |
|
||||
| `total-line-numbers` | The total line numbers of the opened file |
|
||||
| `file-type` | The type of the opened file |
|
||||
| `diagnostics` | The number of warnings and/or errors |
|
||||
| `selections` | The number of active selections |
|
||||
|
@ -144,6 +144,7 @@ fn get_render_function<F>(element_id: StatusLineElementID) -> impl Fn(&mut Rende
|
||||
helix_view::editor::StatusLineElement::Selections => render_selections,
|
||||
helix_view::editor::StatusLineElement::Position => render_position,
|
||||
helix_view::editor::StatusLineElement::PositionPercentage => render_position_percentage,
|
||||
helix_view::editor::StatusLineElement::TotalLineNumbers => render_total_line_numbers,
|
||||
helix_view::editor::StatusLineElement::Separator => render_separator,
|
||||
helix_view::editor::StatusLineElement::Spacer => render_spacer,
|
||||
}
|
||||
@ -276,6 +277,15 @@ fn render_position<F>(context: &mut RenderContext, write: F)
|
||||
);
|
||||
}
|
||||
|
||||
fn render_total_line_numbers<F>(context: &mut RenderContext, write: F)
|
||||
where
|
||||
F: Fn(&mut RenderContext, String, Option<Style>) + Copy,
|
||||
{
|
||||
let total_line_numbers = context.doc.text().len_lines();
|
||||
|
||||
write(context, format!(" {} ", total_line_numbers), None);
|
||||
}
|
||||
|
||||
fn render_position_percentage<F>(context: &mut RenderContext, write: F)
|
||||
where
|
||||
F: Fn(&mut RenderContext, String, Option<Style>) + Copy,
|
||||
|
@ -331,6 +331,9 @@ pub enum StatusLineElement {
|
||||
/// The cursor position as a percent of the total file
|
||||
PositionPercentage,
|
||||
|
||||
/// The total line numbers of the current file
|
||||
TotalLineNumbers,
|
||||
|
||||
/// A single space
|
||||
Spacer,
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user