private void HandleCodeCompletionSelection_Ex() { try { ActiveTextArea.BeginUpdate(); string userSelection = String.Empty; if (_codeCompWindowEx.Selector.HasMultipleSelection) { userSelection = _codeCompWindowEx.SelectedItemsAsCommaSeparatedString; } else { userSelection = _codeCompWindowEx.SelectedItem; } if (_codeCompWindowEx.Selector.HasMultipleSelection) { ActiveTextArea.InsertString(userSelection); } else { DeleteWordBeforeCaret(); ActiveTextArea.InsertString(userSelection); } FireAfterCodeCompletionShowed(CodeCompletionType.UserDefinedList, userSelection, true); } finally { ActiveTextArea.EndUpdate(); } _codeCompWindowEx.DismissSelector(); _textEditor.Focus(); }
private void lv_DoubleClick(object sender, EventArgs e) { if (lv.SelectedItems.Count == 0) { return; } ListViewItem selItem = lv.SelectedItems[0]; string selText = selItem.SubItems[2].Text; if (String.IsNullOrEmpty(selText)) { return; } int lineNo = Convert.ToInt32(selText); if (lineNo > ActiveTextArea.Document.TotalNumberOfLines) { return; } ActiveTextArea.Caret.Column = 0; ActiveTextArea.Caret.Line = lineNo - 1; ActiveTextArea.Select(); Point startPoint = ActiveTextArea.Caret.Position; Point endPoint = ActiveTextArea.Caret.Position; endPoint.X = endPoint.X + ActiveTextArea.Document.GetLineSegment(lineNo - 1).Length; ActiveTextArea.SelectionManager.SetSelection(startPoint, endPoint); }
private int MatchNext(string matchText) { if (String.IsNullOrEmpty(matchText)) { return(-1); } int indexOf = -1; try { ActiveTextArea.BeginUpdate(); int lineNo = ActiveTextArea.Caret.Line; int colNo = ActiveTextArea.Caret.Column; int totalNumOfLines = ActiveDocument.TotalNumberOfLines; string LineText = SharpDevelopTextEditorUtilities.GetLineAsString(ActiveDocument, lineNo); LineText = ActiveDocument.GetText(ActiveTextArea.Caret.Offset, LineText.Length - colNo); indexOf = LineText.IndexOf(matchText, StringComparison.InvariantCultureIgnoreCase); int offset = colNo; if (indexOf < 0) { offset = 0; do { int tmpLineNo = ActiveDocument.GetNextVisibleLineAbove(lineNo, 1); if (tmpLineNo == lineNo) { break; } lineNo = tmpLineNo; LineText = SharpDevelopTextEditorUtilities.GetLineAsString(ActiveDocument, lineNo); indexOf = LineText.IndexOf(matchText, StringComparison.InvariantCultureIgnoreCase); }while (indexOf < 0 && lineNo < totalNumOfLines); } if (indexOf >= 0) { ActiveTextArea.Caret.Column = 0; ActiveTextArea.Caret.Line = lineNo; Point startPoint = ActiveTextArea.Caret.Position; startPoint.X = indexOf + offset; Point endPoint = startPoint; endPoint.X = endPoint.X + matchText.Length; ActiveTextArea.SelectionManager.SetSelection(startPoint, endPoint); ActiveTextArea.Caret.Column = endPoint.X; } else if (lineNo == totalNumOfLines - 1) { MessageBox.Show("Reached end of document", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information); } } finally { ActiveTextArea.EndUpdate(); } return(indexOf); }
private int MatchPrev(string matchText) { if (String.IsNullOrEmpty(matchText)) { return(-1); } int indexOf = -1; try { ActiveTextArea.BeginUpdate(); int lineNo = ActiveTextArea.Caret.Line; int colNo = ActiveTextArea.Caret.Column; string LineText = SharpDevelopTextEditorUtilities.GetLineAsString(ActiveDocument, lineNo); LineText = LineText.Substring(0, ActiveTextArea.Caret.Column); indexOf = LineText.LastIndexOf(matchText, StringComparison.InvariantCultureIgnoreCase); if (indexOf < 0) { do { int tmpLineNo = ActiveDocument.GetNextVisibleLineBelow(lineNo, 1); if (tmpLineNo == lineNo) { break; } lineNo = tmpLineNo; LineText = SharpDevelopTextEditorUtilities.GetLineAsString(ActiveDocument, lineNo); indexOf = LineText.LastIndexOf(matchText, StringComparison.InvariantCultureIgnoreCase); }while (indexOf < 0 && lineNo >= 0); } if (indexOf > 0) { ActiveTextArea.Caret.Column = 0; ActiveTextArea.Caret.Line = lineNo; Point startPoint = ActiveTextArea.Caret.Position; startPoint.X = indexOf; Point endPoint = startPoint; endPoint.X = endPoint.X + matchText.Length; ActiveTextArea.SelectionManager.SetSelection(startPoint, endPoint); ActiveTextArea.Caret.Column = startPoint.X; } else if (lineNo == 0) { MessageBox.Show("Reached start of document", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information); } } finally { ActiveTextArea.EndUpdate(); } return(indexOf); }
public void ClearResults() { _bs.DataSource = null; _dataTbl.Clear(); ActiveDocument.TextContent = String.Empty; ActiveTextArea.Invalidate(); ActiveTextArea.Update(); }
public void ConvertTokensTo(TokenConversionType conversionType) { try { ActiveTextArea.BeginUpdate(); StringBuilder sb = null; HighlightRuleSet rules = ActiveDocument.HighlightingStrategy.GetRuleSet(null); IList <LineSegment> lines = ActiveDocument.LineSegmentCollection; for (int k = 0; k < lines.Count; k++) { LineSegment segment = lines[k]; for (int i = 0; i < segment.Words.Count; i++) { TextWord word = segment.Words[i]; if (word.Type != TextWordType.Word) { continue; } if (rules.KeyWords[ActiveDocument, segment, word.Offset, word.Length] != null) { string newVal = word.Word; switch (conversionType) { case TokenConversionType.Lower: newVal = word.Word.ToLowerInvariant(); break; case TokenConversionType.Upper: newVal = word.Word.ToUpperInvariant(); break; case TokenConversionType.Capitalize: newVal = word.Word; char[] chars = newVal.ToCharArray(); chars[0] = Char.ToUpperInvariant(newVal[0]); sb = new StringBuilder(); sb.Append(chars); newVal = sb.ToString(); break; default: break; } ActiveDocument.Replace(segment.Offset + word.Offset, word.Length, newVal); } } } } finally { ActiveTextArea.EndUpdate(); } }
public void AppendContent(string content) { try { ActiveTextArea.BeginUpdate(); ActiveTextArea.Text += content; } finally { ActiveTextArea.EndUpdate(); ActiveTextArea.Invalidate(); } }
private void OnGoToLine(object sender, int lineNo) { if (lineNo <= 0 || lineNo > ActiveDocument.TotalNumberOfLines) { MessageBox.Show("Can not locate line in script!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } ActiveTextArea.Caret.Line = lineNo - 1; ActiveTextArea.Caret.Column = 0; ActiveTextArea.Focus(); _frmGoToLine.Hide(); }
private void HandleCodeCompletionSelection() { if (_codeCompWindow.Selector.HasMultipleSelection) { ActiveTextArea.InsertString(_codeCompWindow.SelectedItemsAsCommaSeparatedString); } else { DeleteWordBeforeCaret(); ActiveTextArea.InsertString(_codeCompWindow.SelectedItem); } _codeCompWindow.DismissSelector(); }
public void RemoveContent(CaretPosition startPos, CaretPosition endPos) { try { ActiveTextArea.BeginUpdate(); ActiveTextArea.SelectionManager.SetSelection(startPos.ToPoint(), endPos.ToPoint()); ActiveTextArea.SelectionManager.RemoveSelectedText(); } finally { ActiveTextArea.EndUpdate(); ActiveTextArea.Invalidate(); } }
private void OnAction_ToggleFoldings_Execute(object sender, EventArgs e) { try { ActiveTextArea.BeginUpdate(); foreach (FoldMarker marker in ActiveDocument.FoldingManager.FoldMarker) { marker.IsFolded = !marker.IsFolded; } } finally { ActiveTextArea.EndUpdate(); ActiveTextArea.Invalidate(); } }
private void _bs_CurrentChanged(object sender, EventArgs e) { DataRowView row = _bs.Current as DataRowView; if (row == null) { ActiveDocument.TextContent = String.Empty; ActiveTextArea.Invalidate(); ActiveTextArea.Update(); return; } ActiveDocument.TextContent = row["ObjectScript"] as string; kryptonHeader1.Text = String.Format("Script of '{0}'",row["ObjectName"]); ActiveTextArea.Invalidate(); ActiveTextArea.Update(); _textEditor.BringToFront(); }
public string GetContent(CaretPosition startPos, CaretPosition endPos) { string result = String.Empty; try { ActiveTextArea.BeginUpdate(); ActiveTextArea.SelectionManager.SetSelection(startPos.ToPoint(), endPos.ToPoint()); result = ActiveTextArea.SelectionManager.SelectedText; ActiveTextArea.SelectionManager.ClearSelection(); return(result); } finally { ActiveTextArea.EndUpdate(); ActiveTextArea.Invalidate(); } }
private void HandleCodeCompletionKeyPress_Ex(char c) { switch (c) { case (char)27: //ESC _codeCompWindowEx.DismissSelector(); _textEditor.Focus(); return; default: if (Char.IsControl(c)) { return; } ActiveTextArea.InsertChar(c); _codeCompWindowEx.JumpTo(GetPreviousNonWSLineParts); break; } }
private void HandleCodeCompletionKeyPress_Ex(char c) { switch (c) { case (char)27: //ESC _codeCompWindowEx.DismissSelector(); _textEditor.Focus(); FireAfterCodeCompletionShowed(CodeCompletionType.UserDefinedList, String.Empty, false); return; default: if (Char.IsControl(c)) { return; } ActiveTextArea.InsertChar(c); _codeCompWindowEx.JumpTo(GetPreviousNonWSLineParts); break; } }
public void ChangeScriptCase(TokenConversionType conversionType) { try { ActiveTextArea.BeginUpdate(); HighlightRuleSet rules = ActiveDocument.HighlightingStrategy.GetRuleSet(null); IList <LineSegment> lines = ActiveDocument.LineSegmentCollection; for (int k = 0; k < lines.Count; k++) { LineSegment segment = lines[k]; for (int i = 0; i < segment.Words.Count; i++) { TextWord word = segment.Words[i]; if (word.Type != TextWordType.Word) { continue; } string newVal = word.Word; switch (conversionType) { case TokenConversionType.Lower: newVal = word.Word.ToLowerInvariant(); break; case TokenConversionType.Upper: newVal = word.Word.ToUpperInvariant(); break; default: break; } ActiveDocument.Replace(segment.Offset + word.Offset, word.Length, newVal); } } } finally { ActiveTextArea.EndUpdate(); } }
private void HandleCodeCompletionKeyPress(char c) { switch (c) { case (char)27: //ESC _codeCompWindow.DismissSelector(); return; /* * case '\b': * return; * case '\n': * return; */ default: if (Char.IsControl(c)) { return; } ActiveTextArea.InsertChar(c); _codeCompWindow.JumpTo(PreviousNonWSLineParts); break; } }
public void InsertContent(CaretPosition startPos, string content) { PositionCaretTo(startPos); ActiveTextArea.InsertString(content); }
public void InsertContent(string content) { ActiveTextArea.InsertString(content); }