/// <summary> /// When the user leaves his cursor inactive on npp /// </summary> public static void OnSciDwellStart() { if (WinApi.GetForegroundWindow() == Npp.Handle) { InfoToolTip.ShowToolTipFromDwell(); } }
/// <summary> /// When the user moves his cursor /// </summary> public static void OnSciDwellEnd() { if (!KeyboardMonitor.GetModifiers.IsCtrl) { InfoToolTip.Cloak(true); } }
/// <summary> /// Called on Npp shutdown /// </summary> internal static void DoNppShutDown() { try { if (OnShutDown != null) { OnShutDown(); } // clean up timers ReccurentAction.CleanAll(); DelayedAction.CleanAll(); // export modified conf FileTag.Export(); // save config (should be done but just in case) CodeExplorer.UpdateMenuItemChecked(); FileExplorer.UpdateMenuItemChecked(); Config.Save(); // remember the most used keywords Keywords.SaveRanking(); // close every form AutoComplete.ForceClose(); InfoToolTip.ForceClose(); Appli.ForceClose(); FileExplorer.ForceClose(); CodeExplorer.ForceClose(); UserCommunication.ForceClose(); AppliMenu.ForceCloseMenu(); } catch (Exception e) { ErrorHandler.ShowErrors(e, "Stop"); } }
/// <summary> /// Called on Npp shutdown /// </summary> internal static void DoNppShutDown() { try { if (OnShutDown != null) { OnShutDown(); } // clean up timers RecurentAction.CleanAll(); DelayedAction.CleanAll(); AsapButDelayableAction.CleanAll(); // Triggered when the resolution of an assembly fails, gives us the opportunity to feed the required assembly AppDomain.CurrentDomain.AssemblyResolve -= LibLoader.AssemblyResolver; // catch unhandled errors to log them AppDomain.CurrentDomain.UnhandledException -= ErrorHandler.UnhandledErrorHandler; Application.ThreadException -= ErrorHandler.ThreadErrorHandler; TaskScheduler.UnobservedTaskException -= ErrorHandler.UnobservedErrorHandler; // unsubscribe to static events ProEnvironment.OnEnvironmentChange -= FileExplorer.Instance.RebuildFileList; ProEnvironment.OnEnvironmentChange -= DataBase.Instance.UpdateDatabaseInfo; ProEnvironment.OnEnvironmentChange -= ParserHandler.ClearStaticData; Keywords.Instance.OnImport -= AutoCompletion.SetStaticItems; DataBase.Instance.OnDatabaseUpdate -= AutoCompletion.SetStaticItems; AutoCompletion.OnUpdateStaticItems -= ParserHandler.UpdateKnownStaticItems; ParserHandler.OnEndSendCompletionItems -= AutoCompletion.SetDynamicItems; ParserHandler.OnStart -= CodeExplorer.Instance.OnStart; ParserHandler.OnEndSendParserItems -= CodeExplorer.Instance.OnParseEndParserItems; ParserHandler.OnEndSendCodeExplorerItems -= CodeExplorer.Instance.OnParseEndCodeExplorerItems; ParserHandler.OnEnd -= CodeExplorer.Instance.OnParseEnd; ProExecutionHandleCompilation.OnEachCompilationOk -= FilesInfo.ProExecutionHandleCompilationOnEachCompilationOk; // export modified conf FileTag.Export(); // save config (should be done but just in case) Config.Save(); // remember the most used keywords Keywords.Instance.SaveRanking(); // close every form FileExplorer.Instance.ForceClose(); CodeExplorer.Instance.ForceClose(); AutoCompletion.ForceClose(); InfoToolTip.ForceClose(); Appli.ForceClose(); UserCommunication.ForceClose(); AppliMenu.ForceClose(); } catch (Exception e) { ErrorHandler.ShowErrors(e, "Stop"); } }
private void SigPatternTextBox_TextChanged(object sender, EventArgs e) { if (!(sender is TextBox textBox)) { return; } SigMaskTextBox.Enabled = textBox.Text.Contains(@"\x"); InfoToolTip.SetToolTip(label4, SigMaskTextBox.Enabled ? "" : "This signature format does not need a mask."); }
private void SigsTreeView_DoubleClick(object sender, EventArgs e) { if (!(sender is TreeView treeView)) { return; } try { Clipboard.SetText(treeView.SelectedNode.Text); InfoToolTip.Show("Copied to clipboard!", ActiveForm, PointToClient(MousePosition) - new Size(10, 40), 750); } catch (Exception exception) { Logger.ShowDebug(exception.ToString()); } }
public static bool MouseMessageHandler(WinApi.Messages message, Win32Api.MOUSEHOOKSTRUCT mouseStruct) { switch (message) { // middle click : go to definition case WinApi.Messages.WM_MBUTTONDOWN: if (Npp.CurrentFileInfo.IsProgress) { if (KeyboardMonitor.GetModifiers.IsCtrl) { Npp.GoBackFromDefinition(); } else { ProMisc.GoToDefinition(true); } } return(true); //break; // (CTRL + ) Right click : show main menu case WinApi.Messages.WM_RBUTTONUP: if (KeyboardMonitor.GetModifiers.IsCtrl) { // we need the cursor to be in scintilla but not on the application or the autocompletion! if ((!Appli.IsVisible || !Appli.IsMouseIn()) && (!InfoToolTip.IsVisible || !InfoToolTip.IsMouseIn()) && (!AutoCompletion.IsVisible || !AutoCompletion.IsMouseIn())) { AppliMenu.ShowMainMenu(true); return(true); } } break; } return(false); }
/// <summary> /// Call this method to close all popup/autocompletion form and alike /// </summary> public static void ClosePopups() { AutoCompletion.Cloak(); InfoToolTip.Cloak(); }
/// <summary> /// Called when the user presses a key /// </summary> // ReSharper disable once RedundantAssignment public static bool KeyDownHandler(KeyEventArgs e) { // if set to true, the keyinput is completly intercepted, otherwise npp sill does its stuff bool handled = false; MenuItem menuItem = null; try { // Since it's a keydown message, we can receive this a lot if the user let a button pressed var isSpamming = Utils.IsSpamming(e.KeyCode.ToString(), 100, true); // check if the user triggered a 3P function defined in the AppliMenu menuItem = TriggeredMenuItem(AppliMenu.Instance.ShortcutableItemList, isSpamming, e, ref handled); if (handled) { return(true); } // Autocompletion if (AutoCompletion.IsVisible) { handled = AutoCompletion.PerformKeyDown(e); } // next tooltip if (!handled && InfoToolTip.IsVisible && e.Control && (e.KeyCode == Keys.Up || e.KeyCode == Keys.Down)) { if (e.KeyCode == Keys.Up) { InfoToolTip.IndexToShow--; } else { InfoToolTip.IndexToShow++; } InfoToolTip.TryToShowIndex(); handled = true; } if (handled) { return(true); } // Ok so... when we open a form in notepad++, we can't use the overrides PreviewKeyDown / KeyDown // like we normally can, for some reasons, they don't react to certain keys (like enter!) // It only works "almost normally" if we ShowDialog() the form?! // So i gave up and handle things here! // Each control / form that should use a key not handled by Npp should implement a method // "PerformKeyDown" that will be triggered from here (see below) var curControl = Win32Api.GetFocusedControl(); if (curControl != null) { var invokeResponse = curControl.InvokeMethod("PerformKeyDown", new[] { (object)e }); if (invokeResponse != null && (bool)invokeResponse) { return(true); } } var curWindow = Control.FromHandle(WinApi.GetForegroundWindow()); if (curWindow != null) { var invokeResponse = curWindow.InvokeMethod("PerformKeyDown", new[] { (object)e }); if (invokeResponse != null && (bool)invokeResponse) { return(true); } } // Close interfacePopups if (e.KeyCode == Keys.PageDown || e.KeyCode == Keys.PageUp || e.KeyCode == Keys.Next || e.KeyCode == Keys.Prior) { ClosePopups(); } } catch (Exception ex) { ErrorHandler.ShowErrors(ex, "Occurred in : " + (menuItem == null ? new ShortcutKey(e.Control, e.Alt, e.Shift, e.KeyCode).ToString() : menuItem.ItemId)); } return(handled); }
public static bool MouseMessageHandler(WinApi.Messages message, Win32Api.MOUSEHOOKSTRUCT mouseStruct) { switch (message) { // middle click : go to definition case WinApi.Messages.WM_MBUTTONDOWN: if (Npp.CurrentFileInfo.IsProgress) { if (KeyboardMonitor.GetModifiers.IsCtrl) { Npp.GoBackFromDefinition(); } else { ProMisc.GoToDefinition(true); } } return(true); //break; // (CTRL + ) Right click : show main menu case WinApi.Messages.WM_RBUTTONUP: if (KeyboardMonitor.GetModifiers.IsCtrl) { // we need the cursor to be in scintilla but not on the application or the autocompletion! if ((!Appli.IsVisible || !Appli.IsMouseIn()) && (!InfoToolTip.IsVisible || !InfoToolTip.IsMouseIn()) && (!AutoCompletion.IsVisible || !AutoCompletion.IsMouseIn())) { AppliMenu.ShowMainMenu(true); return(true); } } break; } // HACK: The following is to handle the MOVE/RESIZE event of npp's window. // It would be cleaner to use a WndProc bypass but it costs too much... this is a cheaper solution switch (message) { case WinApi.Messages.WM_NCLBUTTONDOWN: if (!WinApi.GetWindowRect(Npp.CurrentSci.Handle).Contains(Cursor.Position)) { MouseMonitor.Instance.Add(WinApi.Messages.WM_MOUSEMOVE); } break; case WinApi.Messages.WM_LBUTTONUP: case WinApi.Messages.WM_NCLBUTTONUP: if (MouseMonitor.Instance.Remove(WinApi.Messages.WM_MOUSEMOVE)) { if (OnNppWindowsMove != null) { OnNppWindowsMove(); } } break; case WinApi.Messages.WM_MOUSEMOVE: if (OnNppWindowsMove != null) { OnNppWindowsMove(); } break; } return(false); }
/// <summary> /// Called when the user presses a key /// </summary> // ReSharper disable once RedundantAssignment private static bool KeyDownHandler(Keys key, KeyModifiers keyModifiers) { // if set to true, the keyinput is completly intercepted, otherwise npp sill does its stuff bool handled = false; MenuItem menuItem = null; try { // Since it's a keydown message, we can receive this a lot if the user let a button pressed var isSpamming = Utils.IsSpamming(key.ToString(), 100, true); //HACK: // Ok so... when we open a form in notepad++, we can't use the overrides PreviewKeyDown / KeyDown // like we normally can, for some reasons, they don't react to certain keys (like enter!) // It only works "almost normally" if we ShowDialog() the form?! Wtf right? // So i gave up and handle things here! if (Appli.IsFocused()) { handled = Appli.Form.HandleKeyPressed(key, keyModifiers); } else { // same shit for the YamuiMenu var curMenu = (Control.FromHandle(WinApi.GetForegroundWindow())); var menu = curMenu as YamuiMenu; if (menu != null) { menu.OnKeyDown(key); } } // check if the user triggered a 3P function defined in the AppliMenu menuItem = TriggeredMenuItem(AppliMenu.Instance.ShortcutableItemList, isSpamming, key, keyModifiers, ref handled); if (handled) { return(true); } // The following is specific to 3P so don't go further if we are not on a valid file if (!IsCurrentFileProgress) { return(false); } // Close interfacePopups if (key == Keys.PageDown || key == Keys.PageUp || key == Keys.Next || key == Keys.Prior) { ClosePopups(); } // Autocompletion if (AutoComplete.IsVisible) { if (key == Keys.Up || key == Keys.Down || key == Keys.Tab || key == Keys.Return || key == Keys.Escape) { handled = AutoComplete.OnKeyDown(key); } else { if ((key == Keys.Right || key == Keys.Left) && keyModifiers.IsAlt) { handled = AutoComplete.OnKeyDown(key); } } } else { // snippet ? if (key == Keys.Tab || key == Keys.Escape || key == Keys.Return) { if (!keyModifiers.IsCtrl && !keyModifiers.IsAlt && !keyModifiers.IsShift) { if (!Snippets.InsertionActive) { //no snippet insertion in progress if (key == Keys.Tab) { if (Snippets.TriggerCodeSnippetInsertion()) { handled = true; } } } else { //there is a snippet insertion in progress if (key == Keys.Tab) { if (Snippets.NavigateToNextParam()) { handled = true; } } else if (key == Keys.Escape || key == Keys.Return) { Snippets.FinalizeCurrent(); if (key == Keys.Return) { handled = true; } } } } } } // next tooltip if (keyModifiers.IsCtrl && InfoToolTip.IsVisible && (key == Keys.Up || key == Keys.Down)) { if (key == Keys.Up) { InfoToolTip.IndexToShow--; } else { InfoToolTip.IndexToShow++; } InfoToolTip.TryToShowIndex(); handled = true; } } catch (Exception e) { ErrorHandler.ShowErrors(e, "Occured in : " + (menuItem == null ? (new ShortcutKey(keyModifiers.IsCtrl, keyModifiers.IsAlt, keyModifiers.IsShift, key)).ToString() : menuItem.ItemId)); } return(handled); }
/// <summary> /// Call this method to close all popup/autocompletion form and alike /// </summary> public static void ClosePopups() { AutoComplete.Close(); InfoToolTip.Close(); }