Skip to content

Commit

Permalink
Add visual feedback for select_register command
Browse files Browse the repository at this point in the history
Resolves issue #1585 by adding a new statusline component which indicates
the currently selected register.
  • Loading branch information
spectre256 committed Jun 8, 2023
1 parent d511122 commit e3d2fe3
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
1 change: 1 addition & 0 deletions book/src/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ The following statusline elements can be configured:
| `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 |
| `register` | The current selected register |

### `[editor.lsp]` Section

Expand Down
10 changes: 10 additions & 0 deletions helix-term/src/ui/statusline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ where
helix_view::editor::StatusLineElement::Separator => render_separator,
helix_view::editor::StatusLineElement::Spacer => render_spacer,
helix_view::editor::StatusLineElement::VersionControl => render_version_control,
helix_view::editor::StatusLineElement::Register => render_register,
}
}

Expand Down Expand Up @@ -489,3 +490,12 @@ where

write(context, head, None);
}

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)
}
}
11 changes: 10 additions & 1 deletion helix-view/src/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,13 @@ impl Default for StatusLineConfig {
E::FileModificationIndicator,
],
center: vec![],
right: vec![E::Diagnostics, E::Selections, E::Position, E::FileEncoding],
right: vec![
E::Diagnostics,
E::Selections,
E::Register,
E::Position,
E::FileEncoding,
],
separator: String::from("│"),
mode: ModeConfig::default(),
}
Expand Down Expand Up @@ -484,6 +490,9 @@ pub enum StatusLineElement {

/// Current version control information
VersionControl,

/// Indicator for selected register
Register,
}

// Cursor shape is read and used on every rendered frame and so needs
Expand Down

0 comments on commit e3d2fe3

Please sign in to comment.