From e60895eb0f950f0e16fedb9d326f0ceddce4fae4 Mon Sep 17 00:00:00 2001 From: Adam Driscoll Date: Fri, 24 Jul 2026 11:07:46 -0500 Subject: [PATCH] Add edit commands and keyboard shortcuts help --- EditorTextView.cs | 10 +++++++++- ShowEditorCommand.cs | 30 +++++++++++++++++++++++++++--- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/EditorTextView.cs b/EditorTextView.cs index 7415155..6d62749 100644 --- a/EditorTextView.cs +++ b/EditorTextView.cs @@ -78,6 +78,14 @@ public void Format() { Text = editorContext.Format(Text.ToString()); } + public void Undo() + { + InvokeKeybindings(new KeyEvent(Key.CtrlMask | Key.Z, new KeyModifiers { Ctrl = true })); + } + public void Redo() + { + InvokeKeybindings(new KeyEvent(Key.CtrlMask | Key.R, new KeyModifiers { Ctrl = true })); + } public string Run(string path, bool exit = false) { var output = String.Empty; @@ -305,4 +313,4 @@ void GetEncodedRegionBounds(out long start, out long end) return (w, h); } } -} \ No newline at end of file +} diff --git a/ShowEditorCommand.cs b/ShowEditorCommand.cs index c4a6925..65d5fd2 100644 --- a/ShowEditorCommand.cs +++ b/ShowEditorCommand.cs @@ -132,10 +132,18 @@ private void SetMenuBar(Toplevel top) new MenuItem ("_Quit", "", Quit, shortcut: Key.CtrlMask | Key.Q) })); menuItems.Add(new MenuBarItem("_Edit", new MenuItem[] { - new MenuItem ("_Find", "", () => Find(), shortcut: Key.CtrlMask | Key.F), - new MenuItem ("_Replace", "", () => Replace(), shortcut: Key.CtrlMask | Key.H), + new MenuItem ("_Undo", "", () => textEditor.Undo(), shortcut: Key.CtrlMask | Key.Z), + new MenuItem ("_Redo", "", () => textEditor.Redo(), shortcut: Key.CtrlMask | Key.R), + null, + new MenuItem ("Cu_t", "", () => textEditor.Cut(), shortcut: Key.CtrlMask | Key.X), + new MenuItem ("_Copy", "", () => textEditor.Copy(), shortcut: Key.CtrlMask | Key.C), + new MenuItem ("_Paste", "", () => textEditor.Paste(), shortcut: Key.CtrlMask | Key.Y), null, new MenuItem ("_Select All", "", () => SelectAll(), shortcut: Key.CtrlMask | Key.T), + new MenuItem ("_Delete All", "", () => textEditor.DeleteAll(), shortcut: Key.CtrlMask | Key.G), + null, + new MenuItem ("_Find", "", () => Find(), shortcut: Key.CtrlMask | Key.F), + new MenuItem ("_Replace", "", () => Replace(), shortcut: Key.CtrlMask | Key.H), //new MenuItem("Autocomplete", "", Autocomplete, shortcut: Key.CtrlMask | Key.Space), })); @@ -171,6 +179,8 @@ private void SetMenuBar(Toplevel top) } menuItems.Add(new MenuBarItem("_Help", new[] { + new MenuItem("_Keyboard Shortcuts", "", ShowKeyboardShortcuts), + null, new MenuItem("_About", "", () => MessageBox.Query("About", $"PowerShell Pro Tools Terminal Editor\nVersion: {base.MyInvocation.MyCommand.Module.Version.ToString()}\n", "Ok")), new MenuItem("_GitHub", "", () => { try { @@ -193,6 +203,20 @@ private void SetMenuBar(Toplevel top) } + private void ShowKeyboardShortcuts() + { + MessageBox.Query("Keyboard Shortcuts", + "File: Open Ctrl+O, Save Ctrl+S, Quit Ctrl+Q\n" + + "Edit: Undo Ctrl+Z, Redo Ctrl+R\n" + + " Cut Ctrl+X, Copy Ctrl+C, Paste Ctrl+Y\n" + + " Select All Ctrl+T, Delete All Ctrl+G\n" + + " Find Ctrl+F, Replace Ctrl+H\n" + + "Format: Format Ctrl+Shift+R\n" + + "Run: Run F5, Execute Selection F8\n" + + " Exit and Run Ctrl+Shift+F5", + "Ok"); + } + protected override void ProcessRecord() { textEditor = new EditorTextView(_runspace); @@ -960,4 +984,4 @@ private void UpdatePosition() } } -} \ No newline at end of file +}