Skip to content

Commit

Permalink
#60 Create format menu, with Allow Tabs entry, disable TAB by default
Browse files Browse the repository at this point in the history
  • Loading branch information
halvarsson committed May 10, 2024
1 parent 8af4fca commit 780a2fe
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
1 change: 1 addition & 0 deletions EditorTextView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public class EditorTextView : TextView
public LanguageEnum _language = LanguageEnum.Powershell;
public EditorTextView(Runspace runspace)
{
AllowsTab = false;
_runspace = runspace;
SetLanguage(LanguageEnum.Powershell);
}
Expand Down
23 changes: 21 additions & 2 deletions ShowEditorCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,21 @@ protected override void BeginProcessing()
_allowedFileTypes.Add(".txt");
}

private MenuItem CreateAllowsTabChecked()
{
var item = new MenuItem
{
Title = "Allows Tab"
};
item.CheckType |= MenuItemCheckStyle.Checked;
item.Checked = textEditor.AllowsTab;
item.Action += () =>
{
textEditor.AllowsTab = item.Checked = !item.Checked;
};

return item;
}
protected override void ProcessRecord()
{
textEditor = new EditorTextView(_runspace);
Expand Down Expand Up @@ -118,10 +133,14 @@ protected override void ProcessRecord()
new MenuItem ("_Replace", "", () => Replace(), shortcut: Key.CtrlMask | Key.H),
null,
new MenuItem ("_Select All", "", () => SelectAll(), shortcut: Key.CtrlMask | Key.T),
null,
new MenuItem("Format", "", Format, shortcut: Key.CtrlMask | Key.ShiftMask | Key.R),
//new MenuItem("Autocomplete", "", Autocomplete, shortcut: Key.CtrlMask | Key.Space),
}),
new MenuBarItem("_Format", new []
{
CreateAllowsTabChecked(),
null,
new MenuItem("Format", "", Format, shortcut: Key.CtrlMask | Key.ShiftMask | Key.R)
}),
new MenuBarItem("_View", new []
{
new MenuItem("Errors", "", () => { if (textEditor._language == LanguageEnum.Powershell) ErrorDialog.Show(_runspace); }),
Expand Down

0 comments on commit 780a2fe

Please sign in to comment.