internal static void OnDWellEnd(SCNotification notify) { if (Manager != null) { Manager.OnDWellEnd(notify.position); } }
internal static void SciNotification_Modified(SCNotification notify) { if (Manager != null) { Manager.OnModified(notify); } }
internal static void OnFileSaved(SCNotification notify) { Trace.TraceEvent(TraceEventType.Verbose, 0, "Saving bufferID " + notify.nmhdr.idFrom); savingQueueBufferIds.Add(notify.nmhdr.idFrom); savingQueueWaitHandle.Set(); // kills all waiting threads... Thread.Sleep(5); // wtf?! really? savingQueueWaitHandle.Reset(); /* * //MessageBox.Show("Saving " + notify.nmhdr.idFrom); * Main.Trace.TraceEvent(TraceEventType.Verbose, 0, "Saving " + notify.nmhdr.idFrom); * * int id = (int)Win32.SendMessage(PluginBase.nppData._nppHandle, NppMsg.NPPM_GETCURRENTBUFFERID, 0, 0); * Main.Trace.TraceEvent(TraceEventType.Verbose, 0, "Cur " + id); * * StringBuilder sb = new StringBuilder(NppPluginNET.Win32.MAX_PATH); * int successful = (int)Win32.SendMessage(PluginBase.nppData._nppHandle, NppMsg.NPPM_GETFULLPATHFROMBUFFERID, id, sb); * * MessageBox.Show("Saving cur " + id + ";" + successful + ";" + sb.ToString()); */ //UpdateSFInfo(true); Dispatcher dispatcher = Dispatcher.CurrentDispatcher; Thread t = new Thread(WaitAfterSaved); t.Start(dispatcher); }
internal static void OnCharAdded(SCNotification notify) { if (Manager != null) { Manager.OnCharAdded(notify.ch); } }
internal static void OnReady(SCNotification notify) { //MessageBox.Show("READY!"); isReady = true; UpdateSFInfo(false); }
private void ToggleDBManager() { if (_frmDBExplorer == null) { _frmDBExplorer = new FrmDatabaseExplore(); _frmDBExplorer.AddNotifyHandler( //toogle menu item and toolbar button when docking dialog's close button click (ref Message msg) => { SCNotification nc = (SCNotification)Marshal.PtrToStructure(msg.LParam, typeof(SCNotification)); if (nc.nmhdr.code != (uint)DockMgrMsg.DMN_CLOSE) { return; } Win32.SendMessage(nppData._nppHandle, NppMsg.NPPM_SETMENUITEMCHECK, _funcItems.Items[_cmdFrmDBExplorerIdx]._cmdID, 0); }); using (Bitmap newBmp = new Bitmap(16, 16)) { Graphics g = Graphics.FromImage(newBmp); ColorMap[] colorMap = new ColorMap[1]; colorMap[0] = new ColorMap(); colorMap[0].OldColor = Color.Fuchsia; colorMap[0].NewColor = Color.FromKnownColor(KnownColor.ButtonFace); ImageAttributes attr = new ImageAttributes(); attr.SetRemapTable(colorMap); g.DrawImage(_imgMan, new Rectangle(0, 0, 16, 16), 0, 0, 16, 16, GraphicsUnit.Pixel, attr); tbIcon = Icon.FromHandle(newBmp.GetHicon()); } NppTbData nppTbData = new NppTbData(); nppTbData.hClient = _frmDBExplorer.Handle; nppTbData.pszName = _funcItems.Items[_cmdFrmDBExplorerIdx]._itemName; nppTbData.dlgID = _cmdFrmDBExplorerIdx; //default docking nppTbData.uMask = NppTbMsg.DWS_DF_CONT_RIGHT | NppTbMsg.DWS_ICONTAB | NppTbMsg.DWS_ICONBAR; nppTbData.hIconTab = (uint)tbIcon.Handle; nppTbData.pszModuleName = PluginName; IntPtr ptrNppTbData = Marshal.AllocHGlobal(Marshal.SizeOf(nppTbData)); Marshal.StructureToPtr(nppTbData, ptrNppTbData, false); Win32.SendMessage(nppData._nppHandle, NppMsg.NPPM_DMMREGASDCKDLG, 0, ptrNppTbData); //toogle both menu item and toolbar button Win32.SendMessage(nppData._nppHandle, NppMsg.NPPM_SETMENUITEMCHECK, _funcItems.Items[_cmdFrmDBExplorerIdx]._cmdID, 1); } else { var nppMsg = NppMsg.NPPM_DMMSHOW; var toggleStatus = 1; if (_frmDBExplorer.Visible) { nppMsg = NppMsg.NPPM_DMMHIDE; toggleStatus = 0; } Win32.SendMessage(nppData._nppHandle, nppMsg, 0, _frmDBExplorer.Handle); Win32.SendMessage(nppData._nppHandle, NppMsg.NPPM_SETMENUITEMCHECK, _funcItems.Items[_cmdFrmDBExplorerIdx]._cmdID, toggleStatus); } }
/// <summary> /// Called when the text in scintilla is modified (added/deleted) by the user (called after UI update) /// </summary> public static void OnTextModified(SCNotification nc, bool insertedText, bool deletedText, bool singleCharModification, bool undo, bool redo) { ParserHandler.ParseDocumentAsap(); if (!singleCharModification) { ClosePopups(); } }
public static void HandleTrigger(SCNotification Notification) { Thread gothread; string path = GetCurrentFileName(); OpenMember member; switch (Notification.nmhdr.code) { case (uint)NppMsg.NPPN_READY: break; case (uint)SciMsg.SCN_MODIFIED: break; case (uint)NppMsg.NPPN_FILEBEFOREOPEN: break; case (uint)NppMsg.NPPN_FILEOPENED: break; case (uint)NppMsg.NPPN_FILESAVED: member = OpenMembers.GetMember(path); if (member != null) { gothread = new Thread((ThreadStart) delegate { if (member.IsEditable()) { if (member.GetSystemName() == IBMi.GetConfig("system")) { bool UploadResult = IBMiUtilities.UploadMember(member.GetLocalFile(), member.GetLibrary(), member.GetObject(), member.GetMember()); if (UploadResult == false) { System.Windows.Forms.MessageBox.Show("Failed to upload to " + member.GetMember() + " on " + member.GetSystemName() + "."); } } else { System.Windows.Forms.MessageBox.Show("Unable to upload to " + member.GetMember() + ". You must be connected to " + member.GetSystemName() + " in order to save this file."); } if (Main.CommandWindow != null) { Main.CommandWindow.loadNewOutput(); } } }); gothread.Start(); } break; case (uint)NppMsg.NPPN_FILEBEFORECLOSE: if (OpenMembers.Contains(path)) { OpenMembers.RemoveMember(path); File.Delete(path); } break; } }
//sends a message to get the current buffer, since we only need to do this once it's a static handler private static void updateCurrentBuffer(SCNotification scn) { currentBuffer = (int)Win32.SendMessage(PluginBase.nppData._nppHandle, NppMsg.NPPM_GETCURRENTBUFFERID, 0, 0); if (IODoc.bufferChanged != null) { bufferChanged(scn); } }
internal static void OnFileSwitch(SCNotification notify) { if (!isReady) { return; } UpdateSFInfo(false); UpdateSettingsInFile(); }
static void beNotified(IntPtr notifyCode) { SCNotification nc = (SCNotification)Marshal.PtrToStructure(notifyCode, typeof(SCNotification)); OnBeNotified(nc); if (nc.nmhdr.code == (uint)NppMsg.NPPN_SHUTDOWN) { Marshal.FreeHGlobal(_ptrPluginName); } }
private void onCharAdded(SCNotification sn) { if (stdIn != null) { if (this.bufferId == (int)Win32.SendMessage(PluginBase.nppData._nppHandle, NppMsg.NPPM_GETCURRENTBUFFERID, 0, 0)) { stdIn.Write(sn.ch); } } }
public void __beNotified(SCNotification notifyCode) { if (notifyCode.nmhdr.code == (uint)NppMsg.NPPN_SHUTDOWN) { PluginCleanUp(); } else if (notifyCode.nmhdr.code == (uint)NppMsg.NPPN_TBMODIFICATION) { SetToolBarIcon(); } }
public static void OnNotification(SCNotification data) { foreach (ScriptInfo info in configuredScripts.Values) { if (info.Script != null && !(info.Script is NppScriptStub)) { try { info.Script.OnNotification(data); } catch { } //does not matter what but we should not interrupt the SCNotification handling } } }
static void beNotified(IntPtr notifyCode) { Debug.WriteLine("-------------------------------"); SCNotification nc = (SCNotification)Marshal.PtrToStructure(notifyCode, typeof(SCNotification)); //Debug.WriteLine("<<<<< ncnc.nmhdr.code={0}, {1}", nc.nmhdr.code, (int)nc.nmhdr.code); if (Plugin.Enabled && nc.nmhdr.code == (uint)NppMsg.NPPN_TBMODIFICATION) { Plugin.FuncItems.RefreshItems(); } else if (Plugin.Enabled && nc.nmhdr.code == (uint)SciMsg.SCN_SAVEPOINTREACHED) { Plugin.OnSavedOrUndo(); } else if (Plugin.Enabled && nc.nmhdr.code == (uint)SciMsg.SCN_CHARADDED) { Plugin.OnCharTyped((char)nc.ch); } else if (nc.nmhdr.code == (uint)SciMsg.SCN_DWELLSTART) { Debug.WriteLine("Tooltip started..."); } else if (nc.nmhdr.code == (uint)SciMsg.SCN_DWELLEND) { Debug.WriteLine("Tooltip started..."); } else if (Plugin.Enabled && nc.nmhdr.code == (uint)NppMsg.NPPN_BUFFERACTIVATED) { Plugin.OnCurrentFileChanegd(); } else if (Plugin.Enabled && nc.nmhdr.code == (uint)NppMsg.NPPN_READY) { Plugin.OnNppReady(); } else if (Plugin.Enabled && nc.nmhdr.code == (uint)NppMsg.NPPN_FILESAVED) { Plugin.OnBeforeDocumentSaved(); } else if (Plugin.Enabled && nc.nmhdr.code == (uint)NppMsg.NPPN_FILEOPENED) { Plugin.OnCurrentFileChanegd(); } else if (nc.nmhdr.code == (uint)NppMsg.NPPN_SHUTDOWN) { if (_ptrPluginName != IntPtr.Zero) { Marshal.FreeHGlobal(_ptrPluginName); } } }
/// <summary> /// When the user click on the margin /// </summary> public static void OnSciMarginClick(SCNotification nc) { // click on the error margin if (nc.margin == FilesInfo.ErrorMarginNumber) { // if it's an error symbol that has been clicked, the error on the line will be cleared if (!FilesInfo.ClearLineErrors(Npp.LineFromPosition(nc.position))) { // if nothing has been cleared, we go to the next error position FilesInfo.GoToNextError(Npp.LineFromPosition(nc.position)); } } }
static void beNotified(IntPtr notifyCode) { SCNotification nc = (SCNotification)Marshal.PtrToStructure(notifyCode, typeof(SCNotification)); if (nc.nmhdr.code == (uint)NppMsg.NPPN_TBMODIFICATION) { PluginBase._funcItems.RefreshItems(); } else if (nc.nmhdr.code == (uint)NppMsg.NPPN_SHUTDOWN) { Main.PluginCleanUp(); Marshal.FreeHGlobal(_ptrPluginName); } }
public static void OnSciUpdateUi(SCNotification nc) { if (nc.updated == (int)SciMsg.SC_UPDATE_V_SCROLL || nc.updated == (int)SciMsg.SC_UPDATE_H_SCROLL) { // user scrolled OnPageScrolled(); } else if (nc.updated == (int)SciMsg.SC_UPDATE_SELECTION) { // the user changed its selection OnUpdateSelection(); } }
public void __beNotified(SCNotification notifyCode) { if (notifyCode.nmhdr.code == (uint)NppMsg.NPPN_SHUTDOWN) { PluginCleanUp(); } else if (notifyCode.nmhdr.code == (uint)NppMsg.NPPN_TBMODIFICATION) { SetToolBarIcon(); } else if (notifyCode.nmhdr.code == (uint)SciMsg.SCN_CHARADDED) { CharAdded((char)notifyCode.ch); } }
//individual instance handler fired whenever the current buffer changes, to see if we need to spit out saved text. private void onBufferChanged(SCNotification scn) { //Main.debug.write("currB: " + currentBuffer.ToString()); //Main.debug.writeLine(" buffer: " + bufferId.ToString()); if (isVisible && toAppend.Length > 0) { lock (toAppend) { Win32.SendMessage(currScint, SciMsg.SCI_APPENDTEXT, toAppend.Length, toAppend.ToString()); toAppend.Clear(); } } }
static void beNotified(IntPtr notifyCode) { SCNotification nc = (SCNotification)Marshal.PtrToStructure(notifyCode, typeof(SCNotification)); switch (nc.nmhdr.code) { case (uint)NppMsg.NPPN_TBMODIFICATION: PluginBase._funcItems.RefreshItems(); Main.SetToolBarIcon(); break; case (uint)NppMsg.NPPN_SHUTDOWN: Main.PluginCleanUp(); Marshal.FreeHGlobal(_ptrPluginName); break; case (uint)NppMsg.NPPN_FILESAVED: case (uint)NppMsg.NPPN_FILEOPENED: case 4294967294: if (null == Main.frmMyDlg) { return; } Main.frmMyDlg.UpdateUserInterface(); break; case (uint)SciMsg.SCN_MODIFIED: if (null == Main.frmMyDlg || !new[] { 1048576, 2064, 16400 }.Contains(nc.modificationType)) { return; } // Mouse selection. // TODO: and if I use keyboard? if (nc.modificationType == 16400) { // Update selection. Main.frmMyDlg.SetNodeSelection(); return; } Main.frmMyDlg.UpdateUserInterface(); break; } }
static void beNotified(IntPtr notifyCode) { try { SCNotification nc = (SCNotification)Marshal.PtrToStructure(notifyCode, typeof(SCNotification)); //File.AppendAllLines(Path.Combine(Path.GetTempPath(), "npp_logevent.log"), new[] //{ // nc.nmhdr.code + ":" + nc.lParam + "," + nc.wParam //}); StringBuilder resultFileName = new StringBuilder(Win32.MAX_PATH); Win32.SendMessage(PluginBase.nppData._nppHandle, NppMsg.NPPM_GETFILENAME, Win32.MAX_PATH, resultFileName); if (nc.nmhdr.code == (uint)NppMsg.NPPN_TBMODIFICATION) { PluginBase._funcItems.RefreshItems(); PluginBase.SetToolBarIcon(); } else if (nc.nmhdr.code == (uint)SciMsg.SCN_CHARADDED) { //PluginBase.doInsertHtmlCloseTag((char)nc.ch); } else if (nc.nmhdr.code == (uint)NppMsg.NPPN_SHUTDOWN) { PluginBase.PluginCleanUp(); Marshal.FreeHGlobal(_ptrPluginName); } else if (nc.nmhdr.code == (uint)NppMsg.NPPN_FILESAVED) { PluginBase.OnFileSaved(); } else if (nc.nmhdr.code == (uint)NppMsg.NPPN_BUFFERACTIVATED) { PluginBase.OnFileChanged(); } } catch (Exception ex) { File.AppendAllLines(Path.Combine(Path.GetTempPath(), "npp_logevent.log"), new[] { "ERROR: " + ex.Message + " " + ex.StackTrace }); } }
/// <summary> /// When the user click on the margin /// </summary> public static void OnSciMarginClick(SCNotification nc) { if (!Npp.CurrentFileInfo.IsProgress) { return; } // click on the error margin if (nc.margin == OpenedFilesInfo.ErrorMarginNumber) { // if it's an error symbol that has been clicked, the error on the line will be cleared if (!OpenedFilesInfo.ClearLineErrors(Sci.LineFromPosition(nc.position.ToInt32()))) { // if nothing has been cleared, we go to the next error position OpenedFilesInfo.GoToNextError(Sci.LineFromPosition(nc.position.ToInt32())); } } }
static void beNotified(IntPtr notifyCode) { SCNotification nc = (SCNotification)Marshal.PtrToStructure(notifyCode, typeof(SCNotification)); if (nc.nmhdr.code == (uint)NppMsg.NPPN_TBMODIFICATION) { PluginBase._funcItems.RefreshItems(); //PluginBase.SetToolBarIcon(); } else if (nc.nmhdr.code == (uint)SciMsg.SCN_CHARADDED) { // PluginBase.doInsertHtmlCloseTag((char)nc.ch); } else if (nc.nmhdr.code == (uint)NppMsg.NPPN_SHUTDOWN) { PluginBase.PluginCleanUp(); Marshal.FreeHGlobal(_ptrPluginName); } }
public static void OnSciUpdateUi(SCNotification nc) { // we need to set the indentation when we received this notification, not before or it's overwritten while (ActionsAfterUpdateUi.Any()) { ActionsAfterUpdateUi.Dequeue()(); } if (nc.updated == (int)SciMsg.SC_UPDATE_V_SCROLL || nc.updated == (int)SciMsg.SC_UPDATE_H_SCROLL) { // user scrolled OnPageScrolled(); } else if (nc.updated == (int)SciMsg.SC_UPDATE_SELECTION) { // the user changed its selection OnUpdateSelection(); } }
/// <summary> /// When receiving a modification notification by scintilla /// </summary> public void OnScnModified(SCNotification scn, bool isInsertion) { _lastEncoding = Npp.Encoding; _oneByteCharEncoding = _lastEncoding.Equals(Encoding.Default); // bypass the hard work for simple encoding if (_oneByteCharEncoding) { return; } if (isInsertion) { OnInsertedText(scn); } else { OnDeletedText(scn); } }
public static void OnSciModified(SCNotification nc) { bool deletedText = (nc.modificationType & (int)SciMsg.SC_MOD_DELETETEXT) != 0; // if the text has changed if (deletedText || (nc.modificationType & (int)SciMsg.SC_MOD_INSERTTEXT) != 0) { // observe modifications to lines (MANDATORY) Npp.UpdateLinesInfo(nc, !deletedText); // parse ParserHandler.ParseCurrentDocument(); } // did the user supress 1 char? if (deletedText && nc.length == 1) { AutoComplete.UpdateAutocompletion(); } }
/// <summary> /// Updates the line info when inserting text /// </summary> /// <param name="scn"></param> private void OnInsertedText(SCNotification scn) { var startLine = SciLineFromPosition(scn.position); if (scn.linesAdded == 0) { var insCharLenght = GetCharCount(scn.position, scn.length); SetHoleInLine(startLine, insCharLenght); } else { var startCharPos = CharPositionFromLine(startLine); var lineByteStart = SciPositionFromLine(startLine); var lineByteLength = SciLineLength(startLine); var lineCharLenght = GetCharCount(lineByteStart, lineByteLength); var insCharLenght = lineCharLenght - LineCharLength(startLine); FillTheHole(); for (int i = 0; i < scn.linesAdded; i++) { startCharPos += lineCharLenght; var line = startLine + i + 1; lineByteStart += lineByteLength; lineByteLength = SciLineLength(line); lineCharLenght = GetCharCount(lineByteStart, lineByteLength); insCharLenght += lineCharLenght; _linesList.Insert(line, startCharPos); } SetHoleInLine(startLine + scn.linesAdded, insCharLenght); FillTheHole(); // We should not have a null lenght, but we actually can : // when a file is modified outside npp, npp suggests to reload it, a modified notification is sent // but is it sent BEFORE the text is actually put into scintilla! So what we do here doesn't work at all // so in that case, we need to refresh the info when the text is acutally inserted, that is after updateui if (TextLength == 0) { Plug.ActionsAfterUpdateUi.Enqueue(Reset); } } }
private static void beNotified(IntPtr notifyCode) { try { SCNotification nc = (SCNotification)Marshal.PtrToStructure(notifyCode, typeof(SCNotification)); var commandCode = nc.nmhdr.code; _plugin.ProcessCommand(commandCode); switch (commandCode) { case (uint)NppMsg.NPPN_SHUTDOWN: Marshal.FreeHGlobal(_ptrPluginName); break; } } catch (Exception ex) { File.AppendAllLines(Path.Combine(Path.GetTempPath(), "npp_js_map_parser_event.log"), new[] { "ERROR: " + ex.Message + " " + ex.StackTrace }); } }
static void beNotified(IntPtr notifyCode) { SCNotification nc = (SCNotification)Marshal.PtrToStructure(notifyCode, typeof(SCNotification)); switch (nc.nmhdr.code) { case (uint)NppMsg.NPPN_TBMODIFICATION: PluginBase._funcItems.RefreshItems(); Main.SetToolBarIcon(); break; case (uint)NppMsg.NPPN_SHUTDOWN: Main.PluginCleanUp(); Marshal.FreeHGlobal(_ptrPluginName); break; case (uint)NppMsg.NPPN_BUFFERACTIVATED: case (uint)NppMsg.NPPN_FILESAVED: Main.ReloadNavigatorTree(); break; } }