mirror of
https://github.com/helix-editor/helix.git
synced 2024-11-25 02:46:17 +04:00
Added CWD option for editor.statusline
This commit is contained in:
parent
84e24b33dc
commit
97968debe8
@ -162,6 +162,7 @@ fn get_render_function<F>(element_id: StatusLineElementID) -> impl Fn(&mut Rende
|
||||
helix_view::editor::StatusLineElement::Spacer => render_spacer,
|
||||
helix_view::editor::StatusLineElement::VersionControl => render_version_control,
|
||||
helix_view::editor::StatusLineElement::Register => render_register,
|
||||
helix_view::editor::StatusLineElement::WorkingDirectory => render_cwd,
|
||||
}
|
||||
}
|
||||
|
||||
@ -514,3 +515,23 @@ fn render_register<F>(context: &mut RenderContext, write: F)
|
||||
write(context, format!(" reg={} ", reg), None)
|
||||
}
|
||||
}
|
||||
|
||||
fn render_cwd<F>(context: &mut RenderContext, write: F)
|
||||
where
|
||||
F: Fn(&mut RenderContext, String, Option<Style>) + Copy,
|
||||
{
|
||||
let cwd = std::env::current_dir();
|
||||
let title: String = match cwd {
|
||||
// Errors converting resolve to String::Default
|
||||
Ok(path) => path
|
||||
.iter()
|
||||
.last()
|
||||
.unwrap_or_default()
|
||||
.to_owned()
|
||||
.into_string()
|
||||
.unwrap_or_default(),
|
||||
Err(_) => "".into(),
|
||||
};
|
||||
|
||||
write(context, title, None);
|
||||
}
|
||||
|
@ -524,6 +524,9 @@ pub enum StatusLineElement {
|
||||
|
||||
/// Indicator for selected register
|
||||
Register,
|
||||
|
||||
/// Current Working Directory
|
||||
WorkingDirectory,
|
||||
}
|
||||
|
||||
// Cursor shape is read and used on every rendered frame and so needs
|
||||
|
Loading…
Reference in New Issue
Block a user