public JsonSearchContext(string selectedWord, IScintillaGateway gateway, int initialLineIndex, int indexOfSelectedWord) { _gateway = gateway; _selectedWord = selectedWord; _totalLinesCount = _gateway.GetLineCount(); _selectedProperty = TryInitSelectedProperty(initialLineIndex, indexOfSelectedWord); }
/// <summary>Trennt die Punkte aus dem angegebenen Text</summary> /// <param name="settings"></param> /// <param name="editor"></param> public void getPointsFromEditor(Settings settings, IScintillaGateway editor) { punkte.Clear(); if (editor != null) { Int32 countLines = editor.GetLineCount(); for (Int32 lc = 0; lc < countLines; lc++) { String cuLine = editor.GetLine(lc); // Auch Excel Splitbar machen ;-) cuLine = cuLine.Replace('\t', ' '); // Tab durch Leerzeichen ersetzten cuLine = cuLine.Replace(',', settings.Decimalseperator[0]); // , durch . ersetzten String[] split = ClassStringTools.GetFieldsManyDelimiters(cuLine, ' ', true); if (split != null) { if (split.Length >= 4) // mind PNR R H E { ClassCADdyPunkt newPoint = new ClassCADdyPunkt(); { newPoint.Punktnummer = ClassStringTools.trimToEmpty(split[settings.PointName_Column - 1]); if (settings.PointName_ToUpper) { newPoint.Punktnummer = newPoint.Punktnummer.ToUpper(); } if (!ClassStringTools.IsNullOrWhiteSpace(newPoint.Punktnummer)) { Double temp = Double.NaN; if (ClassConverters.StringToDouble(split[settings.Koord_RW_E_Column - 1], out temp)) { newPoint.Rechtswert = temp; if (ClassConverters.StringToDouble(split[settings.Koord_HW_N_Column - 1], out temp)) { newPoint.Hochwert = temp; if (ClassConverters.StringToDouble(split[settings.Koord_Elev_Column - 1], out temp)) { newPoint.Hoehe = temp; newPoint.LineNumber = lc; if (split.Length >= 5) { // code newPoint.Code = ClassStringTools.trimToEmpty(split[settings.Koord_Code_Column - 1]); if (split.Length >= 6) { // code newPoint.Bemerkung = ClassStringTools.trimToEmpty(split[settings.Koord_Descript_Column - 1]); } } punkte.Add(newPoint); } } } } } } } } } hasPunkte = punkte.Count > 0; }
private void HighlightVisibleText() { TryCleanCurrentFileHighlighting(); if (_expectedWords.Count == 0) { return; } _lastHighlightTime = DateUtils.CurrentUts(); var lastHighlightTime = _lastHighlightTime; var linesOnScreen = _gateway.LinesOnScreen(); var totalLinesCount = _gateway.GetLineCount(); int lineIndex = _startLineIndex - 1; while (linesOnScreen-- > 0) { // прерываем текущий процесс подсветки, потому что запустился новый if (IsNeedToBreak(lastHighlightTime)) { return; } lineIndex++; if (lineIndex >= totalLinesCount) { return; } if (!_gateway.GetLineVisible(lineIndex)) { // перепрыгиваем hidden/collapsed lines int invisibleNoDocLine = _gateway.VisibleFromDocLine(lineIndex); lineIndex = _gateway.DocLineFromVisible(invisibleNoDocLine); } var isEscape = false; StringBuilder currentWord = null; var lineText = _gateway.GetLineText(lineIndex); for (int i = 0; i < lineText.Length; i++) { var ch = lineText[i]; if (!isEscape && ch == '"') { if (currentWord == null) { currentWord = new StringBuilder(); } else { string word = currentWord.ToString(); var wordLength = word.Length; if (IsNeedToBreak(lastHighlightTime)) { return; } if (IsNeedToHighlightWord(word, lineIndex, i - wordLength, lastHighlightTime)) { // TODO может помочь победить баг с кириллицей // int position = _gateway.LineToPosition(lineIndex) + i; // int startPosition = _gateway.WordStartPosition(position, true); // int endPosition = _gateway.WordEndPosition(position, true); // HighlightWord(startPosition, endPosition - startPosition); // в доке эта штука была описана как то, что мне нужно ( // int position = _gateway.IndexPositionFromLine(lineIndex, i - wordLength); int position = _gateway.LineToPosition(lineIndex) + i - wordLength; HighlightWord(position, wordLength); } currentWord = null; } } else if (currentWord != null) { if (ch.IsPartOfWord()) { currentWord.Append(ch); } else { currentWord = null; } } isEscape = !isEscape && ch == '\\'; } } }
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(); } } }