private void dgvMessages_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e) { if (e.RowIndex == -1) { return; } DialogueParser data = (DialogueParser)dgvMessages.Rows[e.RowIndex].Cells[0].Tag; List <TextMarker> marker = textEditor.Document.MarkerStrategy.GetMarkers(0, textEditor.Document.TextLength); if (marker.Count > 0) { textEditor.Document.MarkerStrategy.RemoveMarker(marker[0]); } LineSegment ls = textEditor.Document.GetLineSegment(data.codeNumLine); string codeline = TextUtilities.GetLineAsString(textEditor.Document, data.codeNumLine); int offset = codeline.IndexOf(data.shortcode); int len = data.shortcode.Length; if (offset > 0) { while (Char.IsLetter(textEditor.Document.GetCharAt(ls.Offset + (offset - 1)))) { offset--; len++; } } TextMarker tm = new TextMarker(ls.Offset + offset, len, TextMarkerType.Underlined, Color.DeepPink); textEditor.Document.MarkerStrategy.AddMarker(tm); textEditor.Refresh(); }
protected virtual void OnFormClosing(object sender, FormClosingEventArgs e) { _searchOptonsUpdate?.Invoke(this.SearchText, _isMatchCase, _isMatchWholeWord); if (_highlightGroups.ContainsKey(_editor)) { HighlightGroup group = _highlightGroups[_editor]; if (group.HasMarkers) { // Clear highlights group.ClearMarkers(); _editor.Refresh(); } } // Prevent dispose, as this form can be re-used if (e.CloseReason != CloseReason.FormOwnerClosing) { if (this.Owner != null) { this.Owner.Select(); // prevent another app from being activated instead } _panelIsHidden = true; e.Cancel = true; this.Hide(); // Discard search region _searchHandler.ClearScanRegion(); _editor.Refresh(); // must repaint manually } }
//------------------------------------------------------------------------ private void icsEditor_DocumentChanged(object sender, DocumentEventArgs e) { if (icsEditor.Document.UndoStack.UndoItemCount == 0) { SetModified(false, false); } else if (!modified) { SetModified(true, false); } if ((completer != null) && (e.Text != null)) { if ((fileType == ProjectFile.FileType.REPGEN) && (e.Text == ":")) { ICSharpCode.TextEditor.Gui.CompletionWindow.CodeCompletionWindow.ShowCompletionWindow(this, icsEditor, "filename", completer, e.Text[0]); icsEditor.Refresh(); return; } } if (folder != null) { //special key (backspace/delete/enter) if ((e.Text == null) && (e.Length == 1)) { UpdateFoldings(); return; } //Comments (can easily effect blocking) if ((fileType == ProjectFile.FileType.REPGEN) && (e.Text != null) && (e.Text.Length == 1)) { if ((e.Text == "[") || (e.Text == "]")) { UpdateFoldings(); return; } } //length > 1, probably a paste, we'll go ahead & update foldings if ((e.Text != null) && (e.Text.Length > 1)) { UpdateFoldings(); return; } //look for END or RETURN in current line string updatedLine = icsEditor.Document.GetText(icsEditor.Document.GetLineSegmentForOffset(e.Offset)).ToUpper(); if (updatedLine.Contains("END") || updatedLine.Contains("RETURN")) { UpdateFoldings(); return; } } icsEditor.Refresh(); }
void OnDebugStopped(object sender, EventArgs e) { foreach (Task task in TaskService.Tasks) { AddTask(task, false); } textEditor.Refresh(); }
private void RefreshSecretObject(SecretBundle s) { PropertyObject = new PropertyObjectSecret(s, SecretObject_PropertyChanged); uxPropertyGridSecret.SelectedObject = PropertyObject; uxTextBoxValue.SetHighlighting(PropertyObject.ContentType.ToSyntaxHighlightingMode()); uxTextBoxName.Text = PropertyObject.Name; ToggleCertificateMode(PropertyObject.ContentType.IsCertificate()); uxTextBoxValue.Text = PropertyObject.Value; uxTextBoxValue.Refresh(); }
void RefreshTextEditor() { if (TaskService.InUpdate) { requireTextEditorRefresh = true; } else { textEditor.Refresh(); } }
public void HandleWrite(string txt, bool refresh) { lock (this) { if (document != null) { document.ReadOnly = false; document.Insert(document.TextLength, txt); document.ReadOnly = true; if (refresh) { editor.Refresh(); } } } }
private int Replace(Regex regex, int startPos, string replaceWith) { if (txtEditCtl != null) { if (txtEditCtl.ActiveTextAreaControl.TextArea.SelectionManager.SelectedText.Length > 0) { int start = txtEditCtl.ActiveTextAreaControl.SelectionManager.SelectionCollection[0].Offset; int length = txtEditCtl.ActiveTextAreaControl.TextArea.SelectionManager.SelectedText.Length; txtEditCtl.Document.Replace(start, length, replaceWith); return(Find(regex, length + start)); } string context = txtEditCtl.Text.Substring(startPos); Match m = regex.Match(context); if (!m.Success) { MessageBox.Show("The specified text was not found.", "Search", MessageBoxButtons.OK, MessageBoxIcon.Information); return(0); } txtEditCtl.Document.Replace(m.Index + startPos, m.Length, replaceWith); txtEditCtl.Refresh(); TextUtils.SetPosition(txtEditCtl, m.Index + replaceWith.Length + startPos); return(m.Index + replaceWith.Length + startPos); } return(0); }
public override void Run() { string clipboardText = ClipboardWrapper.GetText(); if (string.IsNullOrEmpty(clipboardText)) { return; } //IViewContent viewContent = WorkbenchSingleton.Workbench.ActiveViewContent; ITextEditorControlProvider viewContent = WorkbenchSingleton.ActiveControl as ITextEditorControlProvider; if (viewContent == null || !(viewContent is ITextEditorControlProvider)) { return; } TextEditorControl textEditor = ((ITextEditorControlProvider)viewContent).TextEditorControl; if (textEditor == null) { return; } textEditor.BeginUpdate(); textEditor.Document.UndoStack.StartUndoGroup(); try { Run(textEditor, clipboardText); } finally { textEditor.Document.UndoStack.EndUndoGroup(); textEditor.EndUpdate(); } textEditor.Refresh(); }
private void BtnHighlightAll_Click(object sender, EventArgs e) { if (!_highlightGroups.ContainsKey(_editor)) { _highlightGroups[_editor] = new HighlightGroup(_editor); } var group = _highlightGroups[_editor]; if (string.IsNullOrEmpty(LookFor)) { // Clear highlights group.ClearMarkers(); } else { _search.LookFor = _tbSearchTerm.Text; _search.MatchCase = chkMatchCase.Checked; _search.MatchWholeWordOnly = chkMatchWholeWord.Checked; int offset = 0, count = 0; for (; ;) { bool looped; TextRange range = _search.FindNext(offset, false, out looped); if (range == null || looped) { break; } offset = range.Offset + range.Length; count++; var m = new TextMarker(range.Offset, range.Length, TextMarkerType.SolidBlock, Color.Yellow, Color.Black); group.AddMarker(m); } if (count == 0) { Dialog.ShowDialog(Application.ProductName, "Search text not found.", string.Empty); } else { _editor.Refresh(); } } }
public static void AppendTextAtEnd([NotNull] this TextEditorControl textEditorControl, string text) { if (textEditorControl == null) { throw new ArgumentNullException("textEditorControl"); } textEditorControl.Document.TextContent += text; textEditorControl.Refresh(); }
public void ClearMarkers() { foreach (TextMarker m in _markers) { _document.MarkerStrategy.RemoveMarker(m); } _markers.Clear(); _editor.Refresh(); }
private void FridaHookControl1_NativeScriptGenerateCompleted(object sender, NativeConfigEventArgs e) { int counter = 0; string res = ""; foreach (NativeConfig cr in e.Config.ConfigList) { foreach (Dictionary <string, NativeParaItem> chk in cr.ParamConfig) { List <Object> checkedItems = chk.Values.ToList <Object>(); string script = CodeUtil.GenNativeCode(cr.ModelName, cr.Address, checkedItems, counter++); res += "\r\n" + script; } } outputBox.Text = res; outputBox.Refresh(); ScriptGenerateCompleted?.Invoke(this, e); }
public void Edit(SourceLocation loc) { if (loc.Exception != null) { LineSegment ls = editor.Document.GetLineSegment(loc.Line - 1); TextMarker marker = new TextMarker(ls.Offset, ls.Length, TextMarkerType.SolidBlock, Color.Yellow); marker.ToolTip = loc.Exception.Message; editor.Document.MarkerStrategy.AddMarker(marker); } else { editor.Focus(); TextAreaControl ctl = editor.ActiveTextAreaControl; if (ctl != null) { ctl.Caret.Position = new Point(loc.Column - 1, loc.Line - 1); } } editor.Refresh(); }
public DocumentWriter(IDocument Document, TextEditorControl Editor, Control Parent) { document = Document; this.Parent = Parent; editor = Editor; document.ReadOnly = false; document.Insert(0, ew.buf.ToString()); document.ReadOnly = true; ew.Listeners.Add(this); editor.Refresh(); }
public static void ShowCodeCoverage(TextEditorControl textEditor, string fileName) { foreach (CodeCoverageResults results in CodeCoverageService.Results) { List <CodeCoverageSequencePoint> sequencePoints = results.GetSequencePoints(fileName); if (sequencePoints.Count > 0) { codeCoverageHighlighter.AddMarkers(textEditor.Document.MarkerStrategy, sequencePoints); textEditor.Refresh(); } } }
void HighlightText(int offset, int length) { int endOffset = offset + length; TextArea.Caret.Position = TextArea.Document.OffsetToPosition(endOffset); TextArea.SelectionManager.ClearSelection(); IDocument document = TextArea.Document; DefaultSelection selection = new DefaultSelection(document, document.OffsetToPosition(offset), document.OffsetToPosition(endOffset)); TextArea.SelectionManager.SetSelection(selection); textEditor.Refresh(); }
protected virtual void ReloadSettings() { textEditorControl.TextEditorProperties.TabIndent = Properties.Settings.Default.TabSize; textEditorControl.TextEditorProperties.ShowMatchingBracket = Properties.Settings.Default.HighlightMatchingBrackets; textEditorControl.TextEditorProperties.LineViewerStyle = Properties.Settings.Default.HighlightCurrentRow ? LineViewerStyle.FullRow : LineViewerStyle.None; textEditorControl.TextEditorProperties.ShowLineNumbers = Properties.Settings.Default.ShowLineNumbers; textEditorControl.TextEditorProperties.ShowSpaces = Properties.Settings.Default.ShowSpaces; textEditorControl.TextEditorProperties.ShowEOLMarker = Properties.Settings.Default.ShowNewlines; textEditorControl.TextEditorProperties.Font = Properties.Settings.Default.Font; textEditorControl.Refresh(); }
public static void SelectText(TextEditorControl textArea, int offset, int endOffset) { int textLength = textArea.ActiveTextAreaControl.Document.TextLength; if (textLength < endOffset) { endOffset = textLength - 1; } textArea.ActiveTextAreaControl.Caret.Position = textArea.Document.OffsetToPosition(endOffset); textArea.ActiveTextAreaControl.TextArea.SelectionManager.ClearSelection(); textArea.ActiveTextAreaControl.TextArea.SelectionManager.SetSelection(new DefaultSelection(textArea.Document, textArea.Document.OffsetToPosition(offset), textArea.Document.OffsetToPosition(endOffset))); textArea.Refresh(); }
private void highlightLine(int newLineNumber) { // this code highlights the current line // I KNOW IT WORKS DONT F**K WITH IT TextEditorControl editorBox = GlobalClass.activeChild.editorBox; TextArea textArea = editorBox.ActiveTextAreaControl.TextArea; editorBox.ActiveTextAreaControl.ScrollTo(newLineNumber - 1); editorBox.ActiveTextAreaControl.Caret.Line = newLineNumber - 1; int start = textArea.Caret.Offset == editorBox.Text.Length ? textArea.Caret.Offset - 1 : textArea.Caret.Offset; int length = editorBox.Document.TextContent.Split('\n')[textArea.Caret.Line].Length; if (textArea.Document.TextContent[start] == '\n') { start--; } while (start > 0 && textArea.Document.TextContent[start] != '\n') { start--; } start++; while (start < textArea.Document.TextContent.Length && (textArea.Document.TextContent[start] == ' ' || textArea.Document.TextContent[start] == '\t')) { start++; length--; } if (length >= editorBox.Text.Length) { length += (editorBox.Text.Length - 1) - length; } if (editorBox.Text.IndexOf(';', start, length) != -1) { length = editorBox.Text.IndexOf(';', start, length) - start - 1; } if (editorBox.Text.Length <= start + length) { length--; } while (editorBox.Text[start + length] == ' ' || editorBox.Text[start + length] == '\t') { length--; } length++; this.highlight = new TextMarker(start, length, TextMarkerType.SolidBlock, Color.Yellow, Color.Black) { Tag = editorBox.FileName }; editorBox.Document.MarkerStrategy.AddMarker(this.highlight); editorBox.Refresh(); }
private void FindAndReplaceForm_FormClosing(object sender, FormClosingEventArgs e) { // Prevent dispose, as this form can be re-used if (e.CloseReason != CloseReason.FormOwnerClosing) { Owner?.Select(); // prevent another app from being activated instead e.Cancel = true; Hide(); // Discard search region _search.ClearScanRegion(); _editor.Refresh(); // must repaint manually } }
public void ClearMarkers() { foreach (TextMarker m in _markers) { _document.MarkerStrategy.RemoveMarker(m); } _markers.Clear(); try { _editor.Refresh(); } catch (System.Exception) { ; } }
public void SetEditorActive() { TabPage page = tabControl.Parent as TabPage; if (page != null) { TabControl main = page.Parent as TabControl; if (main != null) { main.SelectedTab = page; } } tabControl.SelectedTab = tabPage; editor.Focus(); editor.Refresh(); }
//------------------------------------------------------------------------ private void btnReplaceAll_Click(object sender, EventArgs e) { TextEditorControl ics = Util.MainForm.ActiveSource.icsEditor; prevFind.Assign(cmbFind.Text, chkCase.Checked, chkRegex.Checked, cmbReplace.Text); prevFind.restart = true; ics.Document.UndoStack.StartUndoGroup(); while (FindNext()) { DoReplace(); } ics.Document.UndoStack.EndUndoGroup(); ics.Refresh(); }
void ChangeSyntax(object sender, EventArgs e) { if (control != null) { MenuCheckBox item = (MenuCheckBox)sender; foreach (MenuCheckBox i in menuCommands) { i.Checked = false; } item.Checked = true; try { control.SetHighlighting(item.Text); } catch (HighlightingDefinitionInvalidException ex) { MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } control.Refresh(); } }
public void HighlightForText(TextEditorControl editor, string txtLookFor) { Editor = editor; _search.ClearScanRegion(); if (!_highlightGroups.ContainsKey(_editor)) { _highlightGroups[_editor] = new HighlightGroup(_editor); } HighlightGroup group = _highlightGroups[_editor]; group.ClearMarkers(); Editor.Refresh(); if (string.IsNullOrEmpty(txtLookFor)) { // Clear highlights group.ClearMarkers(); } else { _search.LookFor = txtLookFor; _search.MatchCase = false; _search.MatchWholeWordOnly = false; bool looped = false; int offset = 0, count = 0; for (; ;) { TextRange range = _search.FindNext(offset, false, out looped); if (range == null || looped) { break; } offset = range.Offset + range.Length; count++; var m = new TextMarker(range.Offset, range.Length, TextMarkerType.SolidBlock, Color.Yellow, Color.Black); group.AddMarker(m); } } }
public void Write(string text, Color backgroundColour, Color foregroundColor) { if (textEditorControl.InvokeRequired) { WriteInvoker invoker = new WriteInvoker(Write); textEditorControl.Invoke(invoker, new object[] { text, backgroundColour, foregroundColor }); } else { int offset = textEditorControl.Document.PositionToOffset(new TextLocation(Column, Line)); textEditorControl.ActiveTextAreaControl.TextArea.InsertString(text); if (!backgroundColour.IsEmpty) { TextMarker marker = new TextMarker(offset, text.Length, TextMarkerType.SolidBlock, backgroundColour, foregroundColor); textEditorControl.Document.MarkerStrategy.AddMarker(marker); textEditorControl.Refresh(); } } }
//public TextRange FindNext(string searchText, bool throwOnInvalidRegex = false) //{ // try // { // _ulStatus.Text = "Ready."; // _ulStatus.ForeColor = Color.Green; // RemoveHighlighting(); // if (string.IsNullOrEmpty(searchText)) // { // _ulStatus.ForeColor = Color.Red; // _ulStatus.Text = "Nothing specified to find."; // return null; // } // _searcher.SearchTerm = searchText; // // Make sure that the editor we're searching for is focused // //if (!_editor.Visible) // //{ // // _editor.Focus(); // // Focus(); // //} // var caret = _textEditor.ActiveTextAreaControl.Caret; // var startFrom = caret.Offset; // if (_searcher.SearchDirection == _searcher.PreviousSearchDirection && _searcher.SearchDirection == SearchDirection.Down) // { // startFrom = caret.Offset; // } // else if (_searcher.SearchDirection == _searcher.PreviousSearchDirection && _searcher.SearchDirection == SearchDirection.Up) // { // startFrom = caret.Offset - 1; // } // else if (_searcher.SearchDirection == SearchDirection.Down && _searcher.PreviousSearchDirection == SearchDirection.Up) // { // startFrom = caret.Offset; // } // else if (_searcher.SearchDirection == SearchDirection.Up && _searcher.PreviousSearchDirection == SearchDirection.Down) // { // startFrom = caret.Offset - 1; // } // TextRange range; // try // { // range = _searcher.FindNext(startFrom, out _lastSearchLoopedAround); // } // catch (InvalidRegexException ex) // { // _ulStatus.ForeColor = Color.Red; // _ulStatus.Text = "Invalid regular expression: " + ex.Message; // if (throwOnInvalidRegex) // { // throw; // } // return null; // } // if (range != null) // { // SelectResult(range); // if (_lastSearchLoopedAround) // { // _ulStatus.Text = "Match was found at the " + (_searcher.SearchDirection == SearchDirection.Down ? "beginning" : "end" ) + " of the document."; // _ulStatus.ForeColor = Color.Green; // } // } // else // { // _ulStatus.ForeColor = Color.Red; // _ulStatus.Text = "Nothing found."; // } // // Add find term to the combo box results // if (!_searchTerms.Contains(searchText)) // { // _searchTerms.Insert(0, searchText); // } // return range; // } // catch (Exception ex) // { // _log.Error(ex.Message, ex); // Dialog.ShowErrorDialog(Application.ProductName, "Error occurred.", ex.Message, ex.StackTrace); // } // return null; //} //private void SelectResult(TextRange range) //{ // var p1 = _textEditor.Document.OffsetToPosition(range.Offset); // var p2 = _textEditor.Document.OffsetToPosition(range.Offset + range.Length); // _textEditor.ActiveTextAreaControl.SelectionManager.SetSelection(p1, p2); // _textEditor.ActiveTextAreaControl.ScrollTo(p1.Line, p1.Column); // // Also move the caret to the end of the selection, because when the user // // presses F3, the caret is where we start searching next time. // _textEditor.ActiveTextAreaControl.Caret.Position = // _textEditor.Document.OffsetToPosition(range.Offset + range.Length); //} //private void BtnHighlightAll_Click(object sender, EventArgs e) //{ // if (!_highlightGroups.ContainsKey(_textEditor)) // _highlightGroups[_textEditor] = new HighlightGroup(_textEditor); // var group = _highlightGroups[_textEditor]; // if (string.IsNullOrEmpty(LookFor)) // // Clear highlights // group.ClearMarkers(); // else // { // _searcher.SearchTerm = _ucFind.Text; // _searcher.MatchCase = _cbMatchCase.Checked; // _searcher.MatchWholeWordOnly = _cbMatchWholeWord.Checked; // int offset = 0, count = 0; // for (; ; ) // { // bool looped; // TextRange range = _searcher.FindNext(offset, out looped); // if (range == null || looped) // break; // offset = range.Offset + range.Length; // count++; // var m = new TextMarker(range.Offset, range.Length, // TextMarkerType.SolidBlock, Color.Yellow, Color.Black); // group.AddMarker(m); // } // if (count == 0) // { // Dialog.ShowDialog(Application.ProductName, "Search text not found.", string.Empty); // } // else // { // _textEditor.Refresh(); // } // } //} //private void RemoveHighlighting() //{ // if (!_highlightGroups.ContainsKey(_textEditor)) // _highlightGroups[_textEditor] = new HighlightGroup(_textEditor); // HighlightGroup group = _highlightGroups[_textEditor]; // group.ClearMarkers(); //} private void FindAndReplaceForm_FormClosing(object sender, FormClosingEventArgs e) { // Prevent dispose, as this form can be re-used if (e.CloseReason != CloseReason.FormOwnerClosing) { if (this.Owner != null) { this.Owner.Select(); // prevent another app from being activated instead } e.Cancel = true; Hide(); // Discard search region if (_textEditor != null) { _textEditor.Refresh(); // must repaint manually } } else { SaveSettings(); } }
private void treeDocPart_AfterSelect(object sender, TreeViewEventArgs e) { if (e.Node.Tag is ZipEntryData) { ZipEntryData data = (ZipEntryData)e.Node.Tag; if (data.Type == ZipEntryType.File) { TextEditorControl editor = e.Node.TreeView.Tag as TextEditorControl; UTF8Encoding utf8 = new UTF8Encoding(false); byte[] test = Encoding.UTF8.GetBytes(data.Content); string xml; //remove utf8 string BOM flags if (test[0] == 0xef && test[1] == 0xbb && test[2] == 0xbf) { xml = utf8.GetString(test, 3, test.Length - 3); } else { xml = data.Content; } xmlDoc.LoadXml(xml); using (MemoryStream ms = new MemoryStream()) { using (XmlTextWriter xmlWriter = new XmlTextWriter(ms, utf8)) { xmlWriter.Indentation = 4; xmlWriter.Formatting = System.Xml.Formatting.Indented; xmlDoc.WriteContentTo(xmlWriter); xmlWriter.Close(); } string result = Encoding.UTF8.GetString(ms.ToArray()); editor.Text = result; editor.Refresh(); } } } }
void ChangeSyntax(object sender, EventArgs e) { if (control != null) { MenuCheckBox item = (MenuCheckBox)sender; foreach (MenuCheckBox i in menuCommands) { i.Checked = false; } item.Checked = true; IHighlightingStrategy strat = HighlightingStrategyFactory.CreateHighlightingStrategy(item.Text); if (strat == null) { throw new Exception("Strategy can't be null"); } control.Document.HighlightingStrategy = strat; if (control is SharpDevelopTextAreaControl) { ((SharpDevelopTextAreaControl)control).InitializeAdvancedHighlighter(); } control.Refresh(); } }