public void OnNotification(ScNotification notification) { if (isPanelVisible) { if (notification.Header.Code == (uint)SciMsg.SCN_UPDATEUI) { if (syncViewWithCaretPosition && lastCaretPosition != scintillaGateway.GetCurrentPos().Value) { lastCaretPosition = scintillaGateway.GetCurrentPos().Value; ScrollToElementAtLineNo(scintillaGateway.GetCurrentLineNumber()); } } else if (notification.Header.Code == (uint)NppMsg.NPPN_BUFFERACTIVATED) { RenderMarkdown(); } else if (notification.Header.Code == (uint)SciMsg.SCN_MODIFIED) { bool isInsert = (notification.ModificationType & (uint)SciMsg.SC_MOD_INSERTTEXT) != 0; bool isDelete = (notification.ModificationType & (uint)SciMsg.SC_MOD_DELETETEXT) != 0; // Any modifications made ? if (isInsert || isDelete) { lastTickCount = Environment.TickCount; RenderMarkdown(); } } } }
public void OnNotification(ScNotification notification) { if (isPanelVisible) { if (notification.Header.Code == (uint)SciMsg.SCN_UPDATEUI) { if (!(ValidateMkdnExtension() || ValidateHtmlExtension())) { return; } var firstVisible = scintillaGateway.GetFirstVisibleLine(); var buffer = scintillaGateway.LinesOnScreen() / 2; var lastLine = scintillaGateway.GetLineCount(); if (syncViewWithCaretPosition && lastCaretPosition != scintillaGateway.GetCurrentPos().Value) { lastCaretPosition = scintillaGateway.GetCurrentPos().Value; if ((scintillaGateway.GetCurrentLineNumber() - buffer) < 0) { ScrollToElementAtLineNo(0); } else { ScrollToElementAtLineNo(scintillaGateway.GetCurrentLineNumber() - buffer); } } else if (syncViewWithScrollPosition && lastCaretPosition != scintillaGateway.GetFirstVisibleLine()) { lastCaretPosition = scintillaGateway.GetFirstVisibleLine(); var middleLine = lastCaretPosition + buffer; if (scintillaGateway.GetFirstVisibleLine() == 0) { ScrollToElementAtLineNo(0); } else if ((lastCaretPosition + scintillaGateway.LinesOnScreen()) >= lastLine) { ScrollToElementAtLineNo(lastLine); } else { ScrollToElementAtLineNo(middleLine - buffer); } } } else if (notification.Header.Code == (uint)NppMsg.NPPN_BUFFERACTIVATED) { UpdateEditorInformation(); RenderMarkdown(); } else if (notification.Header.Code == (uint)SciMsg.SCN_MODIFIED) { // bool isInsert = (notification.ModificationType & (uint)SciMsg.SC_MOD_INSERTTEXT) != 0; // bool isDelete = (notification.ModificationType & (uint)SciMsg.SC_MOD_DELETETEXT) != 0; // // Any modifications made ? // if (isInsert || isDelete) // { if (ValidateMkdnExtension() || ValidateHtmlExtension()) { lastTickCount = Environment.TickCount; RenderMarkdown(); } // } } else if (notification.Header.Code == (uint)NppMsg.NPPN_FILESAVED) { RenderMarkdown(); } } }