Skip to content

Commit 998c81b

Browse files
committed
feat: implement "Select All" menu
1 parent 2a46155 commit 998c81b

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

MacHelix/MacHelixApp.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ struct HelixApp: App {
4747

4848
Button("Paste") { viewStore.send(.helix(.pasteMenuSelected)) }
4949
.keyboardShortcut("v", modifiers: [.command])
50+
51+
Button("Select All") { viewStore.send(.helix(.selectAllMenuSelected)) }
52+
.keyboardShortcut("a", modifiers: [.command])
5053
}
5154
CommandGroup(after: .sidebar) {
5255
Toggle("Mouse reporting enabled",

Modules/Feature/HelixFeature/HelixFeature.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public struct HelixFeature: Reducer, Sendable {
3939
case cutMenuSelected
4040
case copyMenuSelected
4141
case pasteMenuSelected
42+
case selectAllMenuSelected
4243
}
4344

4445
public var body: some Reducer<State, Action> {
@@ -107,6 +108,9 @@ public struct HelixFeature: Reducer, Sendable {
107108

108109
case .pasteMenuSelected:
109110
return .run { send in await ipcManager.sendMessage(":clipboard-paste-before") }
111+
112+
case .selectAllMenuSelected:
113+
return .run { send in await ipcManager.sendMessage("static_command:select_all") }
110114
}
111115
}
112116
}

helix/helix-term/src/application.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ use tui::backend::CrosstermBackend;
5454

5555
#[cfg(feature = "integration")]
5656
use tui::backend::TestBackend;
57+
use crate::keymap::KeyTrie::MappableCommand;
5758
use crate::ui::PromptEvent;
5859

5960
#[cfg(not(feature = "integration"))]
@@ -497,6 +498,9 @@ impl Application<'_> {
497498
"" => {
498499
self.execute_typed_command(&*rest.join(" "))
499500
}
501+
"static_command" => {
502+
self.execute_static_command(&*rest.join(" "))
503+
}
500504
"force_theme_update" => {
501505
self.editor.ipc_notify_theme_changed();
502506
}
@@ -517,6 +521,26 @@ impl Application<'_> {
517521
execute_typed_command(&mut cx, input, PromptEvent::Validate);
518522
}
519523

524+
fn execute_static_command(&mut self, input: &str) {
525+
debug!("execute_static_command {}", input);
526+
let mut cx = crate::commands::Context {
527+
editor: &mut self.editor,
528+
count: None,
529+
register: None,
530+
callback: None,
531+
on_next_key_callback: None,
532+
jobs: &mut self.jobs,
533+
};
534+
535+
use std::str::FromStr;
536+
use crate::commands::MappableCommand;
537+
let result = MappableCommand::from_str(&input);
538+
match result {
539+
Ok(cmd) => { cmd.execute(&mut cx); }
540+
Err(_) => { self.editor.set_error(format!("unknown command {}", input)); }
541+
}
542+
}
543+
520544
#[cfg(windows)]
521545
// no signal handling available on windows
522546
pub async fn handle_signals(&mut self, _signal: ()) -> bool {

0 commit comments

Comments
 (0)