override protected void DoCreate() { list = new SwitchList <string>(); tabBar = new TabBar <string>(list, TabBar <string> .DefaultStringOf); tabBar.Text = "Info"; tabBar.CloseClick += OnCloseClick; Controls.Add(tabBar); KeyMap frameKeyMap = new KeyMap(); frameKeyMap.AddItem(new KeyItem(Keys.Escape, null, new KeyAction("&View\\Close info", DoClose, null, false))); frameKeyMap.AddItem(new KeyItem(Keys.Enter, null, new KeyAction("&View\\Close info", DoClose, null, false))); textBox = new MulticaretTextBox(); textBox.KeyMap.AddAfter(KeyMap); textBox.KeyMap.AddAfter(frameKeyMap, 1); textBox.KeyMap.AddAfter(DoNothingKeyMap, -1); textBox.FocusedChange += OnTextBoxFocusedChange; textBox.Controller.isReadonly = true; textBox.ViShortcut += OnViShortcut; SetTextBoxParameters(); Controls.Add(textBox); tabBar.MouseDown += OnTabBarMouseDown; InitResizing(tabBar, null); Height = MinSize.Height; }
override protected void DoCreate() { tabBar = new TabBar <string>(new SwitchList <string>(), TabBar <string> .DefaultStringOf); tabBar.Text = Name; tabBar.CloseClick += OnCloseClick; Controls.Add(tabBar); KeyMap frameKeyMap = new KeyMap(); KeyItem escape = new KeyItem(Keys.Escape, null, new KeyAction("&View\\File tree\\Cancel renaming", DoCancel, null, false)); frameKeyMap.AddItem(escape); frameKeyMap.AddItem(new KeyItem(Keys.Enter, null, new KeyAction("&View\\File tree\\Complete renaming", DoComplete, null, false))); KeyMap beforeKeyMap = new KeyMap(); beforeKeyMap.AddItem(escape); textBox = new MulticaretTextBox(); textBox.KeyMap.AddBefore(beforeKeyMap); textBox.KeyMap.AddAfter(KeyMap); textBox.KeyMap.AddAfter(frameKeyMap, 1); textBox.KeyMap.AddAfter(DoNothingKeyMap, -1); textBox.FocusedChange += OnTextBoxFocusedChange; Controls.Add(textBox); tabBar.MouseDown += OnTabBarMouseDown; InitResizing(tabBar, null); }
public TabList(Buffer buffer, MainForm mainForm) : base(null, "Tab list", SettingsMode.TabList) { this.buffer = buffer; this.mainForm = mainForm; expanded = new Dictionary <int, bool>(); showEncoding = false; Controller.isReadonly = true; onSelected = OnBufferSelected; additionKeyMap = new KeyMap(); { KeyAction action = new KeyAction("&View\\Tab list\\Close tab list", DoCloseBuffer, null, false); additionKeyMap.AddItem(new KeyItem(Keys.Escape, null, action)); additionKeyMap.AddItem(new KeyItem(Keys.Control | Keys.OemOpenBrackets, null, action)); } { KeyAction action = new KeyAction("&View\\Tab list\\Select tab", DoOpenTab, null, false); additionKeyMap.AddItem(new KeyItem(Keys.Enter, null, action)); } additionBeforeKeyMap = new KeyMap(); { KeyAction action = new KeyAction("&View\\Tab list\\Remove tab", DoRemoveTab, null, false); additionBeforeKeyMap.AddItem(new KeyItem(Keys.Delete, null, action)); } }
override protected void DoCreate() { SwitchList <NamedAction> list = new SwitchList <NamedAction>(); KeyMap frameKeyMap = new KeyMap(); frameKeyMap.AddItem(new KeyItem(Keys.Escape, null, new KeyAction("F&ind\\Cancel find", DoCancel, null, false))); frameKeyMap.AddItem(new KeyItem(Keys.Enter, null, new KeyAction("F&ind\\Find next", DoFindNext, null, false))); if (data.history != null) { KeyAction prevAction = new KeyAction("F&ind\\Previous pattern", DoPrevPattern, null, false); KeyAction nextAction = new KeyAction("F&ind\\Next pattern", DoNextPattern, null, false); frameKeyMap.AddItem(new KeyItem(Keys.Up, null, prevAction)); frameKeyMap.AddItem(new KeyItem(Keys.Down, null, nextAction)); frameKeyMap.AddItem(new KeyItem(Keys.Control | Keys.P, null, prevAction)); frameKeyMap.AddItem(new KeyItem(Keys.Control | Keys.N, null, nextAction)); } frameKeyMap.AddItem(new KeyItem(Keys.None, null, new KeyAction("F&ind\\-", null, null, false))); frameKeyMap.AddItem(new KeyItem(Keys.Control | Keys.F, null, new KeyAction("&View\\Vi normal mode", DoNormalMode, null, false))); frameKeyMap.AddItem(new KeyItem(Keys.Control | Keys.Shift | Keys.R, null, new KeyAction("F&ind\\Switch regex", DoSwitchRegex, null, false) .SetGetText(GetFindRegex))); frameKeyMap.AddItem(new KeyItem(Keys.Control | Keys.Shift | Keys.I, null, new KeyAction("F&ind\\Switch ignore case", DoSwitchIgnoreCase, null, false) .SetGetText(GetFindIgnoreCase))); KeyMap beforeKeyMap = new KeyMap(); textBox = new MulticaretTextBox(true); textBox.KeyMap.AddBefore(beforeKeyMap); textBox.KeyMap.AddAfter(KeyMap); textBox.KeyMap.AddAfter(frameKeyMap, 1); textBox.KeyMap.AddAfter(DoNothingKeyMap, -1); textBox.FocusedChange += OnTextBoxFocusedChange; textBox.TextChange += OnTextChange; Controls.Add(textBox); tabBar = new TabBar <NamedAction>(list, TabBar <NamedAction> .DefaultStringOf, NamedAction.HintOf); tabBar.Text = (isBackward ? "?" : "/") + Name; tabBar.ButtonMode = true; tabBar.RightHint = findParams != null?findParams.GetIndicationHint() : null; tabBar.TabClick += OnTabClick; tabBar.CloseClick += OnCloseClick; tabBar.MouseDown += OnTabBarMouseDown; Controls.Add(tabBar); InitResizing(tabBar, null); Height = MinSize.Height; UpdateFindParams(); }
override protected void DoCreate() { if (Nest.buffers == null) { throw new Exception("buffers == null"); } this.buffers = Nest.buffers; buffers.frame = this; buffers.list.SelectedChange += OnTabSelected; tabBar = new TabBar <Buffer>(buffers.list, Buffer.StringOf); tabBar.CloseClick += OnCloseClick; tabBar.TabDoubleClick += OnTabDoubleClick; tabBar.NewTabDoubleClick += OnNewTabDoubleClick; Controls.Add(tabBar); splitLine = new SplitLine(); Controls.Add(splitLine); KeyMap frameKeyMap = new KeyMap(); frameKeyMap.AddItem(new KeyItem(Keys.Tab, Keys.Control, new KeyAction("&View\\Switch tab", DoTabDown, DoTabModeChange, false))); { KeyAction action = new KeyAction("&View\\Close tab", DoCloseTab, null, false); frameKeyMap.AddItem(new KeyItem(Keys.Control | Keys.W, null, action)); frameKeyMap.AddItem(new KeyItem(Keys.Control | Keys.F4, null, action)); } frameKeyMap.AddItem(new KeyItem(Keys.Tab, null, new KeyAction("&Edit\\Snippets\\Apply snippet", Snippets_DoApply, null, false))); frameKeyMap.AddItem(new KeyItem(Keys.Control | Keys.Shift | Keys.Tab, null, new KeyAction("&Edit\\Snippets\\Autocomplete snippet", Snippets_DoAutocomplete, null, false))); textBox = new MulticaretTextBox(); textBox.ViShortcut += OnViShortcut; textBox.KeyMap.AddAfter(KeyMap); textBox.KeyMap.AddAfter(frameKeyMap); textBox.KeyMap.AddAfter(DoNothingKeyMap, -1); textBox.FocusedChange += OnTextBoxFocusedChange; textBox.Controller = GetEmptyController(); Controls.Add(textBox); InitResizing(tabBar, splitLine); tabBar.MouseDown += OnTabBarMouseDown; OnTabSelected(); }
override protected void DoCreate() { SwitchList <NamedAction> list = new SwitchList <NamedAction>(); KeyMap frameKeyMap = new KeyMap(); frameKeyMap.AddItem(new KeyItem(Keys.Escape, null, new KeyAction("&View\\Cancel command", DoCancel, null, false))); frameKeyMap.AddItem(new KeyItem(Keys.Enter, null, new KeyAction("&View\\Run command", DoRunCommand, null, false))); { KeyAction prevAction = new KeyAction("&View\\Previous command", DoPrevCommand, null, false); KeyAction nextAction = new KeyAction("&View\\Next command", DoNextCommand, null, false); frameKeyMap.AddItem(new KeyItem(Keys.Up, null, prevAction)); frameKeyMap.AddItem(new KeyItem(Keys.Down, null, nextAction)); frameKeyMap.AddItem(new KeyItem(Keys.Control | Keys.P, null, prevAction)); frameKeyMap.AddItem(new KeyItem(Keys.Control | Keys.N, null, nextAction)); } { KeyAction action = new KeyAction("&View\\Autocomplete", DoAutocomplete, null, false); frameKeyMap.AddItem(new KeyItem(Keys.Control | Keys.Space, null, action)); frameKeyMap.AddItem(new KeyItem(Keys.Tab, null, action)); } frameKeyMap.AddItem(new KeyItem(Keys.Control | Keys.F, null, new KeyAction("&View\\Vi normal mode", DoNormalMode, null, false))); textBox = new MulticaretTextBox(true); textBox.KeyMap.AddAfter(KeyMap); textBox.KeyMap.AddAfter(frameKeyMap, 1); textBox.KeyMap.AddAfter(DoNothingKeyMap, -1); textBox.FocusedChange += OnTextBoxFocusedChange; textBox.TextChange += OnTextChange; Controls.Add(textBox); tabBar = new TabBar <NamedAction>(list, TabBar <NamedAction> .DefaultStringOf, NamedAction.HintOf); tabBar.Text = Name; tabBar.ButtonMode = true; tabBar.TabClick += OnTabClick; tabBar.CloseClick += OnCloseClick; tabBar.MouseDown += OnTabBarMouseDown; Controls.Add(tabBar); InitResizing(tabBar, null); Height = MinSize.Height; }
public SnippetMode(MulticaretTextBox textBox, Controller controller, Snippet snippet, int position, Setter onClose) { this.textBox = textBox; this.snippet = snippet; this.controller = controller; this.position = position; this.onClose = onClose; keyMap = new KeyMap(); { KeyAction action = new KeyAction("&Edit\\Snippets\\Exit", DoExit, null, false); keyMap.AddItem(new KeyItem(Keys.Up, null, action)); keyMap.AddItem(new KeyItem(Keys.Down, null, action)); keyMap.AddItem(new KeyItem(Keys.PageUp, null, action)); keyMap.AddItem(new KeyItem(Keys.PageDown, null, action)); keyMap.AddItem(new KeyItem(Keys.Control | Keys.Home, null, action)); keyMap.AddItem(new KeyItem(Keys.Control | Keys.End, null, action)); } { KeyAction action = new KeyAction("&Edit\\Snippets\\Exit", DoExitWithConsume, null, false); keyMap.AddItem(new KeyItem(Keys.Escape, null, action)); } }
override protected void DoCreate() { tabBar = new TabBar <string>(null, TabBar <string> .DefaultStringOf); tabBar.CloseClick += OnCloseClick; tabBar.Text = Name; Controls.Add(tabBar); KeyMap frameKeyMap = new KeyMap(); frameKeyMap.AddItem(new KeyItem(Keys.Escape, null, new KeyAction("&View\\File tree\\Cancel path", DoCancel, null, false))); frameKeyMap.AddItem(new KeyItem(Keys.Enter, null, new KeyAction("&View\\File tree\\Run path", DoInput, null, false))); if (data.history != null) { frameKeyMap.AddItem(new KeyItem(Keys.Up, null, new KeyAction("&View\\File tree\\Previous path", DoPrevPath, null, false))); frameKeyMap.AddItem(new KeyItem(Keys.Down, null, new KeyAction("&View\\File tree\\Next path", DoNextPath, null, false))); } { KeyAction action = new KeyAction("&View\\File tree\\Autocomplete", DoAutocomplete, null, false); frameKeyMap.AddItem(new KeyItem(Keys.Control | Keys.Space, null, action)); frameKeyMap.AddItem(new KeyItem(Keys.Tab, null, action)); } textBox = new MulticaretTextBox(); textBox.KeyMap.AddAfter(KeyMap); textBox.KeyMap.AddAfter(frameKeyMap, 1); textBox.KeyMap.AddAfter(DoNothingKeyMap, -1); textBox.FocusedChange += OnTextBoxFocusedChange; Controls.Add(textBox); tabBar.MouseDown += OnTabBarMouseDown; InitResizing(tabBar, null); Height = MinSize.Height; }
public DialogManager(MainForm mainForm, TempSettings tempSettings) { this.mainForm = mainForm; this.tempSettings = tempSettings; frames = mainForm.frames; closeMethods = new List <Getter <bool, bool> >(); KeyMap keyMap = mainForm.KeyMap; keyMap.AddItem(new KeyItem(Keys.Control | Keys.OemSemicolon, null, new KeyAction("&View\\Open/close command dialog", DoInputCommand, null, false))); keyMap.AddItem(new KeyItem(Keys.Control | Keys.Shift | Keys.OemSemicolon, null, new KeyAction("&View\\Open/close command dialog (no history)", DoInputCommandNoHistory, null, false))); keyMap.AddItem(new KeyItem(Keys.Control | Keys.OemMinus, null, new KeyAction("&View\\Set syntax…", DoSetSyntax, null, false))); keyMap.AddItem(new KeyItem(Keys.Control | Keys.Shift | Keys.OemMinus, null, new KeyAction("&View\\Reset syntax", DoResetSyntax, null, false))); keyMap.AddItem(new KeyItem(Keys.Control | Keys.Oemplus, null, new KeyAction("&View\\Set save encoding…", DoSetSaveEncoding, null, false))); keyMap.AddItem(new KeyItem(Keys.Control | Keys.OemPipe, null, new KeyAction("&View\\Reload with encoding…", DoReloadWithEncoding, null, false))); keyMap.AddItem(new KeyItem(Keys.Control | Keys.Shift | Keys.C, null, new KeyAction("&View\\Preview color scheme…", DoSchemeIncrementalSearch, null, false))); keyMap.AddItem(new KeyItem(Keys.Control | Keys.F, null, new KeyAction("F&ind\\Find…", DoFind, null, false))); keyMap.AddItem(new KeyItem(Keys.Control | Keys.Shift | Keys.F, null, new KeyAction("F&ind\\Find in files…", DoFindInFiles, null, false))); keyMap.AddItem(new KeyItem(Keys.Control | Keys.H, null, new KeyAction("F&ind\\Replace…", DoReplace, null, false))); keyMap.AddItem(new KeyItem(Keys.Control | Keys.G, null, new KeyAction("F&ind\\Go to line…", DoGoToLine, null, false))); keyMap.AddItem(new KeyItem(Keys.None, null, new KeyAction("F&ind\\-", null, null, false))); keyMap.AddItem(new KeyItem(Keys.Control | Keys.P, null, new KeyAction("F&ind\\File incremental search…", DoFileIncrementalSearch, null, false))); keyMap.AddItem(new KeyItem(Keys.Control | Keys.Shift | Keys.O, null, new KeyAction("F&ind\\Recently incremental search…", DoRecentlyIncrementalSearch, null, false))); keyMap.AddItem(new KeyItem(Keys.Control | Keys.Shift | Keys.G, null, new KeyAction("F&ind\\Recently dirs incremental search…", DoRecentlyDirsIncrementalSearch, null, false))); keyMap.AddItem(new KeyItem(Keys.Control | Keys.Shift | Keys.P, null, new KeyAction("F&ind\\Menu item incremental search…", DoMenuItemIncrementalSearch, null, false))); KeyAction escape = new KeyAction("F&ind\\Close dialogs", DoCloseDialogs, null, false); keyMap.AddItem(new KeyItem(Keys.Escape, null, escape)); keyMap.AddItem(new KeyItem(Keys.Control | Keys.OemOpenBrackets, null, escape)); info = new DialogOwner <InfoDialog>(this); fileIncrementalSearch = new DialogOwner <FileIncrementalSearch>(this); recentlyIncrementalSearch = new DialogOwner <RecentlyIncrementalSearch>(this); recentlyDirsIncrementalSearch = new DialogOwner <RecentlyDirsIncrementalSearch>(this); menuItemIncrementalSearch = new DialogOwner <MenuItemIncrementalSearch>(this); syntaxIncrementalSearch = new DialogOwner <SyntaxIncrementalSearch>(this); snippetIncrementalSearch = new DialogOwner <SnippetIncrementalSearch>(this); saveEncodingIncrementalSearch = new DialogOwner <EncodingIncrementalSearch>(this); loadEncodingIncrementalSearch = new DialogOwner <EncodingIncrementalSearch>(this); schemeIncrementalSearch = new DialogOwner <SchemeIncrementalSearch>(this); command = new DialogOwner <CommandDialog>(this); find = new DialogOwner <FindDialog>(this); viFind = new DialogOwner <ViFindDialog>(this); findData = new FindDialog.Data(tempSettings.FindHistory); findInFiles = new DialogOwner <FindInFilesDialog>(this); findInFilesData = new FindInFilesDialog.Data(tempSettings.FindInFilesHistory, tempSettings.FindInFilesTempFilter, tempSettings.FindInFilesTempCurrentFilter); replace = new DialogOwner <ReplaceDialog>(this); replaceData = new ReplaceDialog.Data(tempSettings.ReplacePatternHistory, tempSettings.ReplaceHistory); goToLine = new DialogOwner <FindDialog>(this); goToLineData = new FindDialog.Data(tempSettings.GoToLineHistory); input = new DialogOwner <FindDialog>(this); inputData = new FindDialog.Data(null); rename = new DialogOwner <RenameDialog>(this); moveData = new MoveDialog.Data(tempSettings.MoveHistory); move = new DialogOwner <MoveDialog>(this); }
override protected void DoCreate() { { KeyMap frameKeyMap = new KeyMap(); frameKeyMap.AddItem(new KeyItem(Keys.Escape, null, new KeyAction("F&ind\\Cancel find", DoCancel, null, false))); frameKeyMap.AddItem(new KeyItem(Keys.Enter, null, new KeyAction("F&ind\\Find text", DoFindText, null, false))); frameKeyMap.AddItem(new KeyItem(Keys.Control | Keys.E, null, new KeyAction("F&ind\\Switch to input field", DoSwitchToInputField, null, false))); if (data.filterHistory != null) { KeyAction prevAction = new KeyAction("F&ind\\Previous filter", DoFilterPrevPattern, null, false); KeyAction nextAction = new KeyAction("F&ind\\Next filter", DoFilterNextPattern, null, false); frameKeyMap.AddItem(new KeyItem(Keys.Up, null, prevAction)); frameKeyMap.AddItem(new KeyItem(Keys.Down, null, nextAction)); frameKeyMap.AddItem(new KeyItem(Keys.Control | Keys.P, null, prevAction)); frameKeyMap.AddItem(new KeyItem(Keys.Control | Keys.N, null, nextAction)); } frameKeyMap.AddItem(new KeyItem(Keys.Control | Keys.F, null, new KeyAction("F&ind\\Vi normal mode", DoNormalMode, null, true))); filterTextBox = new MulticaretTextBox(true); filterTextBox.FontFamily = FontFamily.GenericMonospace; filterTextBox.SetFontSize(10.25f, 0); filterTextBox.ShowLineNumbers = false; filterTextBox.HighlightCurrentLine = false; filterTextBox.KeyMap.AddAfter(KeyMap); filterTextBox.KeyMap.AddAfter(frameKeyMap, 1); filterTextBox.KeyMap.AddAfter(DoNothingKeyMap, -1); filterTextBox.FocusedChange += OnTextBoxFocusedChange; filterTextBox.Visible = false; filterTextBox.Text = data.currentFilter.value; filterTextBox.TextChange += OnFilterTextChange; Controls.Add(filterTextBox); } tabBar = new TabBar <string>(new SwitchList <string>(), TabBar <string> .DefaultStringOf); tabBar.CloseClick += OnCloseClick; Controls.Add(tabBar); { KeyMap frameKeyMap = new KeyMap(); frameKeyMap.AddItem(new KeyItem(Keys.Escape, null, new KeyAction("F&ind\\Cancel find", DoCancel, null, false))); frameKeyMap.AddItem(new KeyItem(Keys.Enter, null, new KeyAction("F&ind\\Find text", DoFindText, null, false))); frameKeyMap.AddItem(new KeyItem(Keys.Control | Keys.E, null, new KeyAction("F&ind\\Temp filter", DoSwitchToTempFilter, null, false))); frameKeyMap.AddItem(new KeyItem(Keys.Control | Keys.F, null, new KeyAction("&View\\Vi normal mode", DoNormalMode, null, false))); if (data.history != null) { KeyAction prevAction = new KeyAction("F&ind\\Previous pattern", DoPrevPattern, null, false); KeyAction nextAction = new KeyAction("F&ind\\Next pattern", DoNextPattern, null, false); frameKeyMap.AddItem(new KeyItem(Keys.Up, null, prevAction)); frameKeyMap.AddItem(new KeyItem(Keys.Down, null, nextAction)); frameKeyMap.AddItem(new KeyItem(Keys.Control | Keys.P, null, prevAction)); frameKeyMap.AddItem(new KeyItem(Keys.Control | Keys.N, null, nextAction)); } textBox = new MulticaretTextBox(true); textBox.KeyMap.AddAfter(KeyMap); textBox.KeyMap.AddAfter(frameKeyMap, 1); textBox.KeyMap.AddAfter(DoNothingKeyMap, -1); textBox.FocusedChange += OnFiltersTextBoxFocusedChange; Controls.Add(textBox); } tabBar.RightHint = "Ctrl+E(enter/exit custom filter)" + (findParams != null ? "/" + findParams.GetIndicationHint() : ""); tabBar.MouseDown += OnTabBarMouseDown; InitResizing(tabBar, null); Height = MinSize.Height; UpdateFindParams(); }
public AutocompleteMode(MulticaretTextBox textBox, Mode mode) { this.textBox = textBox; this.mode = mode; keyMap = new KeyMap(); { KeyAction action = new KeyAction("&View\\Autocomplete\\MoveUp", DoMoveUp, null, false); keyMap.AddItem(new KeyItem(Keys.Up, null, action)); keyMap.AddItem(new KeyItem(Keys.Control | Keys.P, null, action)); keyMap.AddItem(new KeyItem(Keys.Control | Keys.K, null, action)); } { KeyAction action = new KeyAction("&View\\Autocomplete\\MoveDown", DoMoveDown, null, false); keyMap.AddItem(new KeyItem(Keys.Control | Keys.N, null, action)); keyMap.AddItem(new KeyItem(Keys.Down, null, action)); keyMap.AddItem(new KeyItem(Keys.Control | Keys.J, null, action)); if (mode == Mode.Raw) { keyMap.AddItem(new KeyItem(Keys.Tab, null, action)); } } { KeyAction action = new KeyAction("&View\\Autocomplete\\MovePageUp", DoMovePageUp, null, false); keyMap.AddItem(new KeyItem(Keys.PageUp, null, action)); keyMap.AddItem(new KeyItem(Keys.Control | Keys.B, null, action)); } { KeyAction action = new KeyAction("&View\\Autocomplete\\MovePageDown", DoMovePageDown, null, false); keyMap.AddItem(new KeyItem(Keys.PageDown, null, action)); keyMap.AddItem(new KeyItem(Keys.Control | Keys.F, null, action)); } keyMap.AddItem(new KeyItem(Keys.Control | Keys.Home, null, new KeyAction("&View\\Autocomplete\\MoveToFirst", DoMoveToFirst, null, false))); keyMap.AddItem(new KeyItem(Keys.Control | Keys.End, null, new KeyAction("&View\\Autocomplete\\MoveToLast", DoMoveToLast, null, false))); { KeyAction action = new KeyAction("&View\\Autocomplete\\Close", DoClose, null, false); keyMap.AddItem(new KeyItem(Keys.Escape, null, action)); } keyMap.AddItem(new KeyItem(Keys.Enter, null, new KeyAction("&View\\Autocomplete\\Complete", DoComplete, null, false))); }
override protected void DoCreate() { list = new SwitchList <string>(); tabBar = new TabBar <string>(list, TabBar <string> .DefaultStringOf); tabBar.Text = name; tabBar.CloseClick += OnCloseClick; Controls.Add(tabBar); KeyMap textKeyMap = new KeyMap(); KeyMap variantsKeyMap = new KeyMap(); KeyMap beforeKeyMap = new KeyMap(); { KeyAction action = new KeyAction("F&ind\\" + submenu + "\\Close", DoClose, null, false); textKeyMap.AddItem(new KeyItem(Keys.Escape, null, action)); variantsKeyMap.AddItem(new KeyItem(Keys.Escape, null, action)); } { KeyAction actionUp = new KeyAction("F&ind\\" + submenu + "\\Select up", DoUp, null, false); KeyAction actionDown = new KeyAction("F&ind\\" + submenu + "\\Select down", DoDown, null, false); textKeyMap.AddItem(new KeyItem(Keys.Up, null, actionUp)); textKeyMap.AddItem(new KeyItem(Keys.Down, null, actionDown)); textKeyMap.AddItem(new KeyItem(Keys.Control | Keys.K, null, actionUp)); textKeyMap.AddItem(new KeyItem(Keys.Control | Keys.J, null, actionDown)); textKeyMap.AddItem(new KeyItem(Keys.Control | Keys.F, null, new KeyAction("&View\\Vi normal mode", DoNormalMode, null, false))); if (findInFilesData != null) { textKeyMap.AddItem(new KeyItem(Keys.Control | Keys.E, null, new KeyAction("F&ind\\Temp filter", DoSwitchToTempFilter, null, false))); } } { beforeKeyMap.AddItem(new KeyItem(Keys.Control | Keys.Home, null, new KeyAction("F&ind\\" + submenu + "\\Select document start", DoDocumentStart, null, false))); beforeKeyMap.AddItem(new KeyItem(Keys.Control | Keys.End, null, new KeyAction("F&ind\\" + submenu + "\\Select document end", DoDocumentEnd, null, false))); beforeKeyMap.AddItem(new KeyItem(Keys.PageUp, null, new KeyAction("F&ind\\" + submenu + "\\Select page up", DoPageUp, null, false))); beforeKeyMap.AddItem(new KeyItem(Keys.PageDown, null, new KeyAction("F&ind\\" + submenu + "\\Select page down", DoPageDown, null, false))); } { KeyAction action = new KeyAction("F&ind\\" + submenu + "\\Next field", DoNextField, null, false); textKeyMap.AddItem(new KeyItem(Keys.Tab, null, action)); variantsKeyMap.AddItem(new KeyItem(Keys.Tab, null, action)); } { KeyAction action = new KeyAction("F&ind\\" + submenu + "\\Open", DoExecute, null, false); textKeyMap.AddItem(new KeyItem(Keys.Enter, null, action)); textKeyMap.AddItem(new KeyItem(Keys.None, null, action).SetDoubleClick(true)); variantsKeyMap.AddItem(new KeyItem(Keys.Enter, null, action)); variantsKeyMap.AddItem(new KeyItem(Keys.None, null, action).SetDoubleClick(true)); } variantsTextBox = new MulticaretTextBox(); variantsTextBox.KeyMap.AddAfter(KeyMap); variantsTextBox.KeyMap.AddAfter(variantsKeyMap, 1); variantsTextBox.KeyMap.AddAfter(DoNothingKeyMap, -1); variantsTextBox.FocusedChange += OnTextBoxFocusedChange; variantsTextBox.Controller.isReadonly = true; variantsTextBox.AfterClick += OnVariantsTextBoxClick; variantsTextBox.AfterKeyPress += OnVariantsTextBoxClick; Controls.Add(variantsTextBox); textBox = new MulticaretTextBox(true); textBox.KeyMap.AddBefore(beforeKeyMap); textBox.KeyMap.AddAfter(KeyMap); textBox.KeyMap.AddAfter(textKeyMap, 1); textBox.KeyMap.AddAfter(DoNothingKeyMap, -1); textBox.FocusedChange += OnTextBoxFocusedChange; textBox.TextChange += OnTextBoxTextChange; Controls.Add(textBox); SetTextBoxParameters(); tabBar.RightHint = tempSettings.FindParams != null? tempSettings.FindParams.GetIgnoreCaseIndicationHint() : ""; tabBar.MouseDown += OnTabBarMouseDown; if (findInFilesData != null) { KeyMap filterKeyMap = new KeyMap(); { KeyAction action = new KeyAction("F&ind\\Switch to input field", DoSwitchToInputField, null, false); filterKeyMap.AddItem(new KeyItem(Keys.Control | Keys.E, null, action)); filterKeyMap.AddItem(new KeyItem(Keys.Enter, null, action)); } filterKeyMap.AddItem(new KeyItem(Keys.Control | Keys.F, null, new KeyAction("&View\\Vi normal mode", DoNormalMode, null, false))); if (findInFilesData.filterHistory != null) { KeyAction prevAction = new KeyAction("F&ind\\Previous filter", DoFilterPrevPattern, null, false); KeyAction nextAction = new KeyAction("F&ind\\Next filter", DoFilterNextPattern, null, false); filterKeyMap.AddItem(new KeyItem(Keys.Up, null, prevAction)); filterKeyMap.AddItem(new KeyItem(Keys.Down, null, nextAction)); filterKeyMap.AddItem(new KeyItem(Keys.Control | Keys.P, null, prevAction)); filterKeyMap.AddItem(new KeyItem(Keys.Control | Keys.N, null, nextAction)); } filterTextBox = new MulticaretTextBox(true); filterTextBox.FontFamily = FontFamily.GenericMonospace; filterTextBox.SetFontSize(10.25f, 0); filterTextBox.ShowLineNumbers = false; filterTextBox.HighlightCurrentLine = false; filterTextBox.KeyMap.AddAfter(KeyMap); filterTextBox.KeyMap.AddAfter(filterKeyMap, 1); filterTextBox.KeyMap.AddAfter(DoNothingKeyMap, -1); filterTextBox.FocusedChange += OnTextBoxFocusedChange; filterTextBox.Visible = false; filterTextBox.Text = findInFilesData.currentFilter.value; filterTextBox.TextChange += OnFilterTextChange; tabBar.Controls.Add(filterTextBox); } InitResizing(tabBar, null); Height = MinSize.Height; Name = GetSubname(); if (findInFilesData != null) { lastFilter = GetFilterText(); } if (!Prebuild()) { preventOpen = true; return; } UpdateVariantsText(); UpdateFindParams(); }
public void Build(Properties.CommandInfo commandInfo, Encoding encoding, out string error, out string shellError) { TextNodeParser buildinParser = null; string command = commandInfo.command; int index = command.IndexOf(':'); if (index != -1) { customSyntax = command.Substring(index + 1).Trim(); command = command.Substring(0, index).Trim(); } foreach (TextNodeParser parser in buildinParsers) { if (parser.name == command) { buildinParser = parser; break; } } error = null; shellError = null; Node node = null; if (buildinParser != null) { node = buildinParser.Parse(buffer.Controller.Lines); } else { Process p = new Process(); p.StartInfo.RedirectStandardOutput = true; p.StartInfo.RedirectStandardError = true; p.StartInfo.RedirectStandardInput = true; p.StartInfo.StandardOutputEncoding = encoding; p.StartInfo.StandardErrorEncoding = encoding; p.StartInfo.UseShellExecute = false; p.StartInfo.FileName = "cmd.exe"; p.StartInfo.Arguments = "/C " + command; p.Start(); p.StandardInput.Write(buffer.Controller.Lines); p.StandardInput.Close(); string output = p.StandardOutput.ReadToEnd(); string errors = p.StandardError.ReadToEnd(); p.WaitForExit(); if (!string.IsNullOrEmpty(errors)) { shellError = errors; } else { try { node = new Parser().Load(output); } catch (System.Exception e) { error = "Parsing error: " + e.Message + "\nSee \"" + settings.getTextNodes.name + "\" for more info"; } } } if (node == null) { if (error == null) { error = "Empty output\nSee \"" + settings.getTextNodes.name + "\" for more info"; } return; } tabSize = settings.tabSize.GetValue(null); lines = Controller.Lines; lines.ClearAllUnsafely(); places = new List <Place>(); AddLine(buffer.Name, new Place(-1, -1), true); AppendNodeOrNodesList(node); if (lines.LinesCount == 0) { lines.AddLineUnsafely(new Line(32)); } else { lines.CutLastLineBreakUnsafely(); } Place target = buffer.Controller.Lines.SoftNormalizedPlaceOf(buffer.Controller.LastSelection.caret); for (int i = places.Count; i-- > 0;) { if (places[i].iLine <= target.iLine) { Place place = new Place(0, i); if (place.iLine < 0) { place.iLine = 0; } else if (place.iLine >= buffer.Controller.Lines.LinesCount) { place.iLine = buffer.Controller.Lines.LinesCount; } Controller.PutCursor(place, false); break; } } showEncoding = false; Controller.isReadonly = true; additionKeyMap = new KeyMap(); { KeyAction action = new KeyAction("&View\\Nodes list\\Close nodes list", DoCloseBuffer, null, false); additionKeyMap.AddItem(new KeyItem(Keys.Escape, null, action)); additionKeyMap.AddItem(new KeyItem(Keys.Control | Keys.OemOpenBrackets, null, action)); } { KeyAction action = new KeyAction("&View\\Nodes list\\Jump to node", DoJumpTo, null, false); additionKeyMap.AddItem(new KeyItem(Keys.Enter, null, action)); } }
public Repl(string rawCommand, MainForm mainForm) : base(RemoveParameters(rawCommand), "REPL: " + GetShortName(rawCommand), SettingsMode.EditableNotFile) { tags = BufferTag.NeedCorrectRemoving; onAdd = OnAdd; onRemove = OnRemove; additionKeyMap = new KeyMap(); additionKeyMap.AddItem(new KeyItem(Keys.Enter, null, new KeyAction("&Edit\\REPL\\Enter command", OnEnter, null, false))); additionKeyMap.AddItem(new KeyItem(Keys.Back, null, new KeyAction("&Edit\\REPL\\Backspace", OnBackspace, null, false))); additionBeforeKeyMap = new KeyMap(); additionBeforeKeyMap.AddItem(new KeyItem(Keys.Home, null, new KeyAction("&Edit\\REPL\\Home", OnHome, null, false))); additionBeforeKeyMap.AddItem(new KeyItem(Keys.Shift | Keys.Home, null, new KeyAction("&Edit\\REPL\\Home with selection", OnHomeWithSelection, null, false))); { KeyAction action = new KeyAction("&Edit\\REPL\\Prev command", DoMoveUp, null, false); additionKeyMap.AddItem(new KeyItem(Keys.Up, null, action)); additionKeyMap.AddItem(new KeyItem(Keys.Control | Keys.P, null, action)); additionKeyMap.AddItem(new KeyItem(Keys.Control | Keys.K, null, action)); } { KeyAction action = new KeyAction("&Edit\\REPL\\Next command", DoMoveDown, null, false); additionKeyMap.AddItem(new KeyItem(Keys.Control | Keys.N, null, action)); additionKeyMap.AddItem(new KeyItem(Keys.Down, null, action)); additionKeyMap.AddItem(new KeyItem(Keys.Control | Keys.J, null, action)); } { KeyAction action = new KeyAction("&Edit\\REPL\\Autocomplete path", DoAutocomplete, null, false); additionKeyMap.AddItem(new KeyItem(Keys.Control | Keys.Space, null, action)); additionKeyMap.AddItem(new KeyItem(Keys.Tab, null, action)); } string parameters = RunShellCommand.CutParametersFromLeft(ref rawCommand); int index = -1; for (int i = 0; i < rawCommand.Length; ++i) { if (rawCommand[i] == '"') { for (++i; i < rawCommand.Length; ++i) { if (rawCommand[i] == '"') { break; } } } else if (rawCommand[i] == ' ') { index = i; break; } } arguments = index != -1 ? rawCommand.Substring(index + 1) : ""; command = index != -1 ? rawCommand.Substring(0, index) : rawCommand; Encoding encoding = RunShellCommand.GetEncoding(mainForm, parameters); encodingPair = new EncodingPair(encoding, false); customSyntax = RunShellCommand.TryGetSyntax(parameters); string invitation = RunShellCommand.TryGetParameter(parameters, 'i'); if (invitation == null) { invitation = "$"; } if (invitation != "") { invitation += " "; } this.invitation = invitation; Controller.onBeforePaint = OnBeforePaint; }