Add current working directory status

pull/10998/head
mfirhas 5 months ago
parent 9b7dffbd61
commit d8a69233f9

@ -92,6 +92,7 @@ The following statusline elements can be configured:
| `file-name` | The path/name of the opened file |
| `file-absolute-path` | The absolute path/name of the opened file |
| `file-base-name` | The basename of the opened file |
| `current-working-directory` | The current working directory |
| `file-modification-indicator` | The indicator to show whether the file is modified (a `[+]` appears when there are unsaved changes) |
| `file-encoding` | The encoding of the opened file if it differs from UTF-8 |
| `file-line-ending` | The file line endings (CRLF or LF) |

@ -163,6 +163,7 @@ where
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::CurrentWorkingDirectory => render_cwd,
}
}
@ -531,3 +532,17 @@ where
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 = helix_stdx::env::current_working_dir()
.file_name()
.unwrap_or_default()
.to_str()
.unwrap_or_default()
.into();
write(context, cwd, None)
}

@ -575,6 +575,8 @@ pub enum StatusLineElement {
/// Indicator for selected register
Register,
CurrentWorkingDirectory,
}
// Cursor shape is read and used on every rendered frame and so needs

Loading…
Cancel
Save