-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add register statusline element #7222
Add register statusline element #7222
Conversation
helix-term/src/ui/editor.rs
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer to see a new statusline element StatusLineElement::Register
which could be rendered like so:
// ... helix-term/src/ui/statusline.rs ...
fn render_register<F>(context: &mut RenderContext, write: F)
where
F: Fn(&mut RenderContext, String, Option<Style>) + Copy,
{
if let Some(reg) = context.editor.selected_register {
write(context, format!(" reg={} ", reg), None)
}
}
and included in the default statusline config:
helix/helix-view/src/editor.rs
Lines 394 to 411 in 2f9b639
impl Default for StatusLineConfig { | |
fn default() -> Self { | |
use StatusLineElement as E; | |
Self { | |
left: vec![ | |
E::Mode, | |
E::Spinner, | |
E::FileName, | |
E::FileModificationIndicator, | |
], | |
center: vec![], | |
right: vec![E::Diagnostics, E::Selections, E::Position, E::FileEncoding], | |
separator: String::from("│"), | |
mode: ModeConfig::default(), | |
} | |
} | |
} |
probably between Selections and Position. I think that's a better fit for this kind of display. (The macro recording symbol is sort of special like the tracker of typed keys.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done! Would it be helpful to add a similar component for when a macro is being recorded? Seems like it would be more consistent that way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like the consitency of it being a statusline element too but I think it's ok where it is now. It only shows up rarely (depending on how often you use macros) and it's somewhat related to the pseudo-pending text indicator next to it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, well let me know if you change your mind; I'd be happy to help with that :)
70ebaa8
to
da261ac
Compare
@@ -484,6 +490,9 @@ pub enum StatusLineElement { | |||
|
|||
/// Current version control information | |||
VersionControl, | |||
|
|||
/// Indicator for selected register | |||
Register, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add this to the docs?
helix/book/src/configuration.md
Lines 98 to 119 in e2a1678
The following statusline elements can be configured: | |
| Key | Description | | |
| ------ | ----------- | | |
| `mode` | The current editor mode (`mode.normal`/`mode.insert`/`mode.select`) | | |
| `spinner` | A progress spinner indicating LSP activity | | |
| `file-name` | The path/name of the opened file | | |
| `file-base-name` | The basename of the opened file | | |
| `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) | | |
| `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 | | |
| `workspace-diagnostics` | The number of warnings and/or errors on workspace | | |
| `selections` | The number of active selections | | |
| `primary-selection-length` | The number of characters currently in primary selection | | |
| `position` | The cursor position | | |
| `position-percentage` | The cursor position as a percentage of the total number of lines | | |
| `separator` | The string defined in `editor.statusline.separator` (defaults to `"│"`) | | |
| `spacer` | Inserts a space between elements (multiple/contiguous spacers may be specified) | | |
| `version-control` | The current branch name or detached commit hash of the opened workspace | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done! Anything else I need to do for the documentation? I tried running cargo xtask docgen
but nothing seemed to change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, just that part of the book needed updating. cargo xtask docgen
generates the files under book/src/generated/
which is currently just the list of typable commands and the language support table
Resolves issue helix-editor#1585 by adding a new statusline component which indicates the currently selected register.
da261ac
to
e3d2fe3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thanks!
Resolves issue #1585 by adding a status message when a register is selected with the
select_register
command, similar to the message produced when starting to record a macro. Additionally, an indicator appears on the right with the selected register.