|
|
@ -1,4 +1,4 @@
|
|
|
|
use helix_core::{coords_at_pos, encoding};
|
|
|
|
use helix_core::{coords_at_pos, encoding, Position};
|
|
|
|
use helix_view::{
|
|
|
|
use helix_view::{
|
|
|
|
document::{Mode, SCRATCH_BUFFER_NAME},
|
|
|
|
document::{Mode, SCRATCH_BUFFER_NAME},
|
|
|
|
graphics::Rect,
|
|
|
|
graphics::Rect,
|
|
|
@ -143,6 +143,7 @@ where
|
|
|
|
helix_view::editor::StatusLineElement::Diagnostics => render_diagnostics,
|
|
|
|
helix_view::editor::StatusLineElement::Diagnostics => render_diagnostics,
|
|
|
|
helix_view::editor::StatusLineElement::Selections => render_selections,
|
|
|
|
helix_view::editor::StatusLineElement::Selections => render_selections,
|
|
|
|
helix_view::editor::StatusLineElement::Position => render_position,
|
|
|
|
helix_view::editor::StatusLineElement::Position => render_position,
|
|
|
|
|
|
|
|
helix_view::editor::StatusLineElement::PositionPercentage => render_position_percentage,
|
|
|
|
helix_view::editor::StatusLineElement::Spacer => render_spacer,
|
|
|
|
helix_view::editor::StatusLineElement::Spacer => render_spacer,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -251,19 +252,22 @@ where
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn render_position<F>(context: &mut RenderContext, write: F)
|
|
|
|
fn get_position(context: &RenderContext) -> Position {
|
|
|
|
where
|
|
|
|
coords_at_pos(
|
|
|
|
F: Fn(&mut RenderContext, String, Option<Style>) + Copy,
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
let position = coords_at_pos(
|
|
|
|
|
|
|
|
context.doc.text().slice(..),
|
|
|
|
context.doc.text().slice(..),
|
|
|
|
context
|
|
|
|
context
|
|
|
|
.doc
|
|
|
|
.doc
|
|
|
|
.selection(context.view.id)
|
|
|
|
.selection(context.view.id)
|
|
|
|
.primary()
|
|
|
|
.primary()
|
|
|
|
.cursor(context.doc.text().slice(..)),
|
|
|
|
.cursor(context.doc.text().slice(..)),
|
|
|
|
);
|
|
|
|
)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn render_position<F>(context: &mut RenderContext, write: F)
|
|
|
|
|
|
|
|
where
|
|
|
|
|
|
|
|
F: Fn(&mut RenderContext, String, Option<Style>) + Copy,
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
let position = get_position(context);
|
|
|
|
write(
|
|
|
|
write(
|
|
|
|
context,
|
|
|
|
context,
|
|
|
|
format!(" {}:{} ", position.row + 1, position.col + 1),
|
|
|
|
format!(" {}:{} ", position.row + 1, position.col + 1),
|
|
|
@ -271,6 +275,19 @@ where
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn render_position_percentage<F>(context: &mut RenderContext, write: F)
|
|
|
|
|
|
|
|
where
|
|
|
|
|
|
|
|
F: Fn(&mut RenderContext, String, Option<Style>) + Copy,
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
let position = get_position(context);
|
|
|
|
|
|
|
|
let maxrows = context.doc.text().len_lines();
|
|
|
|
|
|
|
|
write(
|
|
|
|
|
|
|
|
context,
|
|
|
|
|
|
|
|
format!("{}%", (position.row + 1) * 100 / maxrows),
|
|
|
|
|
|
|
|
None,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn render_file_encoding<F>(context: &mut RenderContext, write: F)
|
|
|
|
fn render_file_encoding<F>(context: &mut RenderContext, write: F)
|
|
|
|
where
|
|
|
|
where
|
|
|
|
F: Fn(&mut RenderContext, String, Option<Style>) + Copy,
|
|
|
|
F: Fn(&mut RenderContext, String, Option<Style>) + Copy,
|
|
|
|