internal CommandPlayer(TextEditorControl control, ITextEditorCore core) { textEditorControl = control; textEditorCore = core; textEditorCore.SetCommandRecorder(null); textEditorCore.EnableRegularCommands = false; }
/// <summary> /// This method is a static call made via reflection from the Caller of the Extensions. /// It instantiates all the IDE extensions and passes the list back to the caller, where /// different methods can be called for different visual behaviours from the controls. /// </summary> /// <param name="textEditorControl"> Main TextEditorControl object </param> /// <param name="textCore"> TextCore singleton </param> /// <returns></returns> public static List<EditorExtension> EnumerateExtensions(TextEditorControl textEditorControl, ITextEditorCore textCore) { ExtensionFactory.textEditorCore = textCore; List<EditorExtension> extensions = new List<EditorExtension>(); // Instantiate all popups FunctionSignatureExtension functionSignatureExt = new FunctionSignatureExtension(); AutoCompleteExtension autoCompleteExt = new AutoCompleteExtension(); NumericSliderExtension numericSliderExt = new NumericSliderExtension(); InspectionToolTipExtension inspectionToolTipExt = new InspectionToolTipExtension(); // Instantiate Core functionSignatureExt.SetEditorCore(textEditorControl, textCore); autoCompleteExt.SetEditorCore(textEditorControl, textCore); numericSliderExt.SetEditorCore(textEditorControl, textCore); inspectionToolTipExt.SetEditorCore(textEditorControl, textCore); // Add to main list extensions.Add(functionSignatureExt); extensions.Add(autoCompleteExt); extensions.Add(numericSliderExt); extensions.Add(inspectionToolTipExt); return extensions; }
public void ShowFor(TextEditorControl editor, bool replaceMode) { Editor = editor; _search.ClearScanRegion(); var sm = editor.ActiveTextAreaControl.SelectionManager; if (sm.HasSomethingSelected && sm.SelectionCollection.Count == 1) { var sel = sm.SelectionCollection[0]; if (sel.StartPosition.Line == sel.EndPosition.Line) txtLookFor.Text = sm.SelectedText; else _search.SetScanRegion(sel); } else { // Get the current word that the caret is on Caret caret = editor.ActiveTextAreaControl.Caret; int start = TextUtilities.FindWordStart(editor.Document, caret.Offset); int endAt = TextUtilities.FindWordEnd(editor.Document, caret.Offset); txtLookFor.Text = editor.Document.GetText(start, endAt - start); } ReplaceMode = replaceMode; Owner = (Form)editor.TopLevelControl; Show(); txtLookFor.SelectAll(); txtLookFor.Focus(); }
CodeCompletionWindow(ICompletionDataProvider completionDataProvider, ICompletionData[] completionData, Form parentForm, TextEditorControl control, bool showDeclarationWindow, bool fixedListViewWidth) : base(parentForm, control) { this.dataProvider = completionDataProvider; this.completionData = completionData; this.document = control.Document; this.showDeclarationWindow = showDeclarationWindow; this.fixedListViewWidth = fixedListViewWidth; workingScreen = Screen.GetWorkingArea(Location); startOffset = control.ActiveTextAreaControl.Caret.Offset + 1; endOffset = startOffset; if (completionDataProvider.PreSelection != null) { startOffset -= completionDataProvider.PreSelection.Length + 1; endOffset--; } codeCompletionListView = new CodeCompletionListView(completionData); codeCompletionListView.Font = new System.Drawing.Font(FontFamily.GenericMonospace, codeCompletionListView.Font.Size); codeCompletionListView.ImageList = completionDataProvider.ImageList; codeCompletionListView.Dock = DockStyle.Fill; codeCompletionListView.SelectedItemChanged += new EventHandler(CodeCompletionListViewSelectedItemChanged); codeCompletionListView.DoubleClick += new EventHandler(CodeCompletionListViewDoubleClick); codeCompletionListView.Click += new EventHandler(CodeCompletionListViewClick); Controls.Add(codeCompletionListView); if (completionData.Length > MaxListLength) { vScrollBar.Dock = DockStyle.Right; vScrollBar.Minimum = 0; vScrollBar.Maximum = completionData.Length - 1; vScrollBar.SmallChange = 1; vScrollBar.LargeChange = MaxListLength; codeCompletionListView.FirstItemChanged += new EventHandler(CodeCompletionListViewFirstItemChanged); Controls.Add(vScrollBar); } this.drawingSize = GetListViewSize(); SetLocation(); if (declarationViewWindow == null) { declarationViewWindow = new DeclarationViewWindow(parentForm); } SetDeclarationViewLocation(); declarationViewWindow.ShowDeclarationViewWindow(); declarationViewWindow.MouseMove += ControlMouseMove; control.Focus(); CodeCompletionListViewSelectedItemChanged(this, EventArgs.Empty); if (completionDataProvider.DefaultIndex >= 0) { codeCompletionListView.SelectIndex(completionDataProvider.DefaultIndex); } if (completionDataProvider.PreSelection != null) { CaretOffsetChanged(this, EventArgs.Empty); } vScrollBar.ValueChanged += VScrollBarValueChanged; document.DocumentAboutToBeChanged += DocumentAboutToBeChanged; }
/// <summary> /// Shows the completion window. /// </summary> /// <param name="parent">The parent.</param> /// <param name="control">The text editor control.</param> /// <param name="fileName">Name of the file.</param> /// <param name="completionDataProvider">The completion data provider.</param> /// <param name="firstChar">The first char.</param> /// <param name="showDeclarationWindow"><see langword="true"/> to show declaration window; otherwise <see langword="false"/>.</param> /// <param name="fixedListViewWidth"><see langword="true"/> to use a fixed width in the list view.</param> /// <param name="closeAutomatically"><see langword="true"/> to close the completion window automatically.</param> /// <returns>The code completion window.</returns> public static CompletionWindow ShowCompletionWindow(Form parent, TextEditorControl control, string fileName, ICompletionDataProvider completionDataProvider, char firstChar, bool showDeclarationWindow, bool fixedListViewWidth, bool closeAutomatically) { ICompletionData[] completionData = completionDataProvider.GenerateCompletionData(fileName, control.ActiveTextAreaControl.TextArea, firstChar); if (completionData == null || completionData.Length == 0) return null; CompletionWindow codeCompletionWindow = new CompletionWindow(completionDataProvider, completionData, parent, control, showDeclarationWindow, fixedListViewWidth, closeAutomatically); codeCompletionWindow.ShowCompletionWindow(); return codeCompletionWindow; }
public static CodeCompletionWindow ShowCompletionWindow(Form parent, TextEditorControl control, string fileName, ICompletionDataProvider completionDataProvider, char firstChar) { ICompletionData[] completionData = completionDataProvider.GenerateCompletionData(fileName, control.ActiveTextAreaControl.TextArea, firstChar); if (completionData == null || completionData.Length == 0) { return null; } CodeCompletionWindow codeCompletionWindow = new CodeCompletionWindow(completionDataProvider, completionData, parent, control); codeCompletionWindow.ShowCompletionWindow(); return codeCompletionWindow; }
public static PABCNETCodeCompletionWindow ShowCompletionWindow(Form parent, TextEditorControl control, string fileName, ICompletionDataProvider completionDataProvider, char firstChar, bool visibleKeyPressed, bool is_by_dot,PascalABCCompiler.Parsers.KeywordKind keyw) { ICompletionData[] completionData = (completionDataProvider as VisualPascalABC.CodeCompletionProvider).GenerateCompletionDataWithKeyword(fileName, control.ActiveTextAreaControl.TextArea, firstChar, keyw); if (completionData == null || completionData.Length == 0) { return null; } PABCNETCodeCompletionWindow codeCompletionWindow = new PABCNETCodeCompletionWindow(completionDataProvider, completionData, parent, control, visibleKeyPressed, is_by_dot); codeCompletionWindow.ShowCompletionWindow(); return codeCompletionWindow; }
public static PABCNETCodeCompletionWindow ShowOverridableMethodsCompletionWindows(Form parent, TextEditorControl control, string fileName, ICompletionDataProvider completionDataProvider) { ICompletionData[] completionData = (completionDataProvider as VisualPascalABC.CodeCompletionProvider).GenerateCompletionDataForOverridableMethods(fileName, control.ActiveTextAreaControl.TextArea); if (completionData == null || completionData.Length == 0) { return null; } PABCNETCodeCompletionWindow codeCompletionWindow = new PABCNETCodeCompletionWindow(completionDataProvider, completionData, parent, control, false, false); codeCompletionWindow.is_overrided_meths = true; codeCompletionWindow.ShowCompletionWindow(); return codeCompletionWindow; }
public static PABCNETCodeCompletionWindow ShowCompletionWindowWithFirstChar(Form parent, TextEditorControl control, string fileName, ICompletionDataProvider completionDataProvider, char firstChar, PascalABCCompiler.Parsers.KeywordKind keyw) { ICompletionData[] completionData = (completionDataProvider as VisualPascalABC.CodeCompletionProvider).GenerateCompletionDataByFirstChar(fileName, control.ActiveTextAreaControl.TextArea, firstChar, keyw); if (completionData == null || completionData.Length == 0) { return null; } (completionDataProvider as VisualPascalABC.CodeCompletionProvider).preSelection = firstChar.ToString(); PABCNETCodeCompletionWindow codeCompletionWindow = new PABCNETCodeCompletionWindow(completionDataProvider, completionData, parent, control, true, false); codeCompletionWindow.ShowCompletionWindow(); return codeCompletionWindow; }
public static CodeCompletionWindow ShowCompletionWindow(Form parent, TextEditorControl control, string fileName, ICompletionDataProvider completionDataProvider, char firstChar, bool showDeclarationWindow, bool fixedListViewWidth) { ICompletionData[] completionData = completionDataProvider.GenerateCompletionData(fileName, control.ActiveTextAreaControl.TextArea, firstChar); if (completionData == null || completionData.Length == 0) { return null; } CodeCompletionWindow codeCompletionWindow = new CodeCompletionWindow(completionDataProvider, completionData, parent, control, showDeclarationWindow, fixedListViewWidth); codeCompletionWindow.CloseWhenCaretAtBeginning = firstChar == '\0'; codeCompletionWindow.ShowCompletionWindow(); return codeCompletionWindow; }
protected AbstractCompletionWindow(Form parentForm, TextEditorControl control) { mWorkingScreen = Screen.GetWorkingArea(parentForm); // SetStyle(ControlStyles.Selectable, false); this.mParentForm = parentForm; this.mEditorControl = control; SetLocation(); StartPosition = FormStartPosition.Manual; FormBorderStyle = FormBorderStyle.None; ShowInTaskbar = false; MinimumSize = new Size(1, 1); Size = new Size(1, 1); }
/// <summary> /// Initializes a new instance of the <see cref="AbstractCompletionWindow"/> class. /// </summary> /// <param name="parentForm">The parent form.</param> /// <param name="control">The text editor control.</param> protected AbstractCompletionWindow(Form parentForm, TextEditorControl control) { _workingScreen = Screen.GetWorkingArea(parentForm); _parentForm = parentForm; _textEditorControl = control; SetLocation(); StartPosition = FormStartPosition.Manual; FormBorderStyle = FormBorderStyle.None; ShowInTaskbar = false; MinimumSize = new Size(1, 1); Size = new Size(1, 1); }
public override bool SaveContent(string saveHint, TextEditorControl textEditor) { if (ScriptData == null) { Utils.ShowWarning("Not enough information exists to save the shared script to the database.\r\nYou will be asked to save the script as file.", MessageBoxButtons.OK); return(SaveContentAs(saveHint, textEditor)); } ScriptData.Script = textEditor.Text; _facade.UpdateItem(ScriptData); _contentName = ScriptData.Name; _hint = ScriptData.Name; return(true); }
public bool IsValid(object caller, Condition condition) { string textcontent = condition.Properties["textcontent"]; if (caller is TextEditorControl) { TextEditorControl ctrl = (TextEditorControl)caller; if (ctrl.Document != null && ctrl.Document.HighlightingStrategy != null) { return(string.Equals(textcontent, ctrl.Document.HighlightingStrategy.Name, StringComparison.OrdinalIgnoreCase)); } } return(false); }
public void SetUpFixture() { using (TextEditorControl textEditorControl = new TextEditorControl()) { textEditorControl.Text = ">>> __builtins__"; TextEditor textEditor = new TextEditor(textEditorControl); memberProvider = new MockMemberProvider(); memberProvider.SetMemberNames(new string[] { "a", "b", "c" }); expectedCompletionItems = CreateCompletionItems(memberProvider.GetMemberNames("__builtins__")); provider = new PythonConsoleCompletionDataProvider(memberProvider); completionItems = provider.GenerateCompletionData(String.Empty, textEditorControl.ActiveTextAreaControl.TextArea, '.'); } }
public static CodeCompletionKeyHandler Attach(TextEditorControl editor) { CodeCompletionKeyHandler h = new CodeCompletionKeyHandler(editor); ht[editor] = h; editor.ActiveTextAreaControl.TextArea.KeyEventHandler += h.TextAreaKeyEventHandler; editor.ActiveTextAreaControl.TextArea.Caret.PositionChanged += h.CaretPositionChangedEventHandler; //editor.ActiveTextAreaControl.TextArea.KeyDown += new System.Windows.Forms.KeyEventHandler(TextArea_KeyDown); //editor.ActiveTextAreaControl.KeyDown += h.TextControlEventHandler; // When the editor is disposed, close the code completion window editor.Disposed += h.CloseCodeCompletionWindow; return(h); }
private void miSetFont_Click(object sender, EventArgs e) { TextEditorControl editor = ActiveEditor; if (editor != null) { fontDialog.Font = editor.Font; if (fontDialog.ShowDialog(this) == DialogResult.OK) { editor.Font = fontDialog.Font; OnSettingsChanged(); } } }
public static CodeCompletionWindow ShowCompletionWindow(Form parent, TextEditorControl control, string fileName, ICompletionDataProvider completionDataProvider, char firstChar, bool showDeclarationWindow, bool fixedListViewWidth) { var completionData = completionDataProvider.GenerateCompletionData(fileName, control.ActiveTextAreaControl.TextArea, firstChar); if (completionData == null || completionData.Length == 0) { return(null); } var codeCompletionWindow = new CodeCompletionWindow(completionDataProvider, completionData, parent, control, showDeclarationWindow, fixedListViewWidth); codeCompletionWindow.CloseWhenCaretAtBeginning = firstChar == '\0'; codeCompletionWindow.ShowCompletionWindow(); return(codeCompletionWindow); }
public objattoo() { this.InitializeComponent(); this.textcode = this.textBox1; this.tabitmes[0] = this.TabItem0; this.tabitmes[1] = this.TabItem1; this.tabitmes[2] = this.TabItem2; this.tabitmes[3] = this.TabItem3; this.tabitmes[4] = this.TabItem4; this.tabitmes[5] = this.TabItem5; this.tabitmes[6] = this.TabItem6; this.tabitmes[7] = this.TabItem7; this.Close(); }
void TextEditor_TextChanged(object sender, EventArgs e) { TextEditorControl txt = (TextEditorControl)sender; TabPage page = (TabPage)txt.Parent; if (txt.Text.Length > 100) { page.ToolTipText = txt.Text.Substring(1, 100); } else { page.ToolTipText = txt.Text; } }
string GetSourceFileLanguage() { TextEditorControl textEditor = GetTextEditorControl(); if (textEditor != null) { string fileExtension = Path.GetExtension(textEditor.ActiveTextAreaControl.TextArea.MotherTextEditorControl.FileName); if (fileExtension.Equals(".vb", StringComparison.OrdinalIgnoreCase)) { return("VB"); } } return("C#"); }
public static CodeCompletionWindow ShowCompletionWindow(Form parent, TextEditorControl control, string fileName, ICompletionDataProvider completionDataProvider, char firstChar, bool showDeclarationWindow, bool fixedListViewWidth) { if (busy) // DC to prevent multiple calls { "CodeCompletionWindow.ShowCompletionWindow was busy, skipping ShowCompletionWindow calculation".info(); return null; } busy = true; return (CodeCompletionWindow)parent.invokeOnThread( () => { try { var tempCompletionData = new ICompletionData[] { }; CodeCompletionWindow codeCompletionWindow = new CodeCompletionWindow(completionDataProvider, tempCompletionData, parent, control, showDeclarationWindow, fixedListViewWidth); codeCompletionWindow.CloseWhenCaretAtBeginning = firstChar == '\0'; codeCompletionWindow.ShowCompletionWindow(); O2Thread.mtaThread( // run in on a separate thread for performance reasons () => { try { ICompletionData[] completionData = completionDataProvider.GenerateCompletionData(fileName, control.ActiveTextAreaControl.TextArea, firstChar); if (completionData == null || completionData.Length == 0) { //return null; } else codeCompletionWindow.setCodeCompletionData(completionData); busy = false; } catch (Exception ex) { ex.log("in CodeCompletionWindow.ShowCompletionWindow "); } }); return codeCompletionWindow; } catch (Exception ex) { busy = false; return null; } }); }
CodeCompletionWindow(ICompletionDataProvider completionDataProvider, ICompletionData[] completionData, Form parentForm, TextEditorControl control, bool showDeclarationWindow, bool fixedListViewWidth) : base(parentForm, control) { this.dataProvider = completionDataProvider; this.completionData = completionData; this.document = control.Document; this.showDeclarationWindow = showDeclarationWindow; this.fixedListViewWidth = fixedListViewWidth; this.guiLoaded = false; startOffset = control.ActiveTextAreaControl.Caret.Offset +1; endOffset = startOffset; //startOffset = -1; //endOffset = -1; }
public int Find(TextEditorControl editor, string text, int offset) { Regex regex = new Regex(text, RegexOptions.None); if (regex.IsMatch(editor.Document.TextContent, offset)) { Match m = regex.Match(editor.Document.TextContent, offset); Select(editor, m.Index, m.Length); return(m.Index); } return(0); }
/// <summary> /// Returns the first ISelection object from the currently active text editor /// </summary> static ISelection GetCurrentTextSelection() { TextEditorControl textArea = SearchReplaceUtilities.GetActiveTextEditor(); if (textArea != null) { SelectionManager selectionManager = textArea.ActiveTextAreaControl.SelectionManager; if (selectionManager.HasSomethingSelected) { return(selectionManager.SelectionCollection[0]); } } return(null); }
private void TSB_RunScript_Click(object sender, EventArgs e) { TB_Output.Text = ""; ScriptEngine scriptEngine = Python.CreateEngine(); ScriptScope pyScope = scriptEngine.CreateScope(); MemoryStream ms = new MemoryStream(); EventRaisingStreamWriter outputWr = new EventRaisingStreamWriter(ms); outputWr.StringWritten += new EventHandler <MyEvtArgs <string> >(sWr_StringWritten); scriptEngine.Runtime.IO.SetOutput(ms, outputWr); //Set path string path = Assembly.GetExecutingAssembly().Location; string rootDir = Directory.GetParent(path).FullName; List <string> paths = new List <string>(); paths.Add(rootDir); paths.Add(Path.Combine(rootDir, "Lib")); scriptEngine.SetSearchPaths(paths.ToArray()); pyScope.SetVariable("mipy", frmMain.CurrentWin); TextEditorControl editor = ActiveEditor; if (editor != null) { string code = editor.Text; if (code.Trim() == "") { this.Cursor = Cursors.Default; return; } this.Cursor = Cursors.WaitCursor; ScriptSource source = scriptEngine.CreateScriptSourceFromString(code, SourceCodeKind.Statements); try { source.Execute(pyScope); } catch (Exception exception) { //MessageBox.Show(scriptEngine.GetService<ExceptionOperations>().FormatException(exception), "Error",MessageBoxButtons.OK); TB_Output.Text += scriptEngine.GetService <ExceptionOperations>().FormatException(exception); } } this.Cursor = Cursors.Default; }
void ShowLineNumberItem(string text) { int num; if (int.TryParse(text, out num)) { TextEditorControl editor = GetEditor(); if (editor != null) { num = Math.Min(editor.Document.TotalNumberOfLines, Math.Max(1, num)); AddItem(StringParser.Parse("${res:Dialog.Goto.GotoLine} ") + num, ClassBrowserIconService.GotoArrowIndex, num, 0, int.MaxValue); } } }
public static CodeCompletionWindow ShowCompletionWindow(Form parent, TextEditorControl control, string fileName, ICompletionDataProvider completionDataProvider, char firstChar, bool showDeclarationWindow, bool fixedListViewWidth) { if (busy) // DC to prevent multiple calls { "CodeCompletionWindow.ShowCompletionWindow was busy, skipping ShowCompletionWindow calculation".info(); return(null); } busy = true; return((CodeCompletionWindow)parent.invokeOnThread( () => { try { var tempCompletionData = new ICompletionData[] { }; CodeCompletionWindow codeCompletionWindow = new CodeCompletionWindow(completionDataProvider, tempCompletionData, parent, control, showDeclarationWindow, fixedListViewWidth); codeCompletionWindow.CloseWhenCaretAtBeginning = firstChar == '\0'; codeCompletionWindow.ShowCompletionWindow(); O2Thread.mtaThread( // run in on a separate thread for performance reasons () => { try { ICompletionData[] completionData = completionDataProvider.GenerateCompletionData(fileName, control.ActiveTextAreaControl.TextArea, firstChar); if (completionData == null || completionData.Length == 0) { //return null; } else { codeCompletionWindow.setCodeCompletionData(completionData); } busy = false; } catch (Exception ex) { ex.log("in CodeCompletionWindow.ShowCompletionWindow "); } }); return codeCompletionWindow; } catch (Exception ex) { busy = false; return null; } })); }
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(); }
public override void Run() { //IViewContent viewContent = WorkbenchSingleton.Workbench.ActiveViewContent; ITextEditorControlProvider viewContent = WorkbenchSingleton.ActiveControl as ITextEditorControlProvider; if (viewContent == null || !(viewContent is ITextEditorControlProvider)) { return; } TextEditorControl textarea = ((ITextEditorControlProvider)viewContent).TextEditorControl; new ICSharpCode.TextEditor.Actions.ToggleComment().Execute(textarea.ActiveTextAreaControl.TextArea); }
protected AbstractCompletionWindow(Form parentForm, TextEditorControl control) { workingScreen = Screen.GetWorkingArea(parentForm); // SetStyle(ControlStyles.Selectable, false); this.parentForm = parentForm; this.control = control; SetLocation(); StartPosition = FormStartPosition.Manual; FormBorderStyle = FormBorderStyle.None; ShowInTaskbar = false; MinimumSize = new Size(1, 1); Size = new Size(1, 1); }
public static void SetSearchPattern() { // Get Highlighted value and set it to FindDialog.searchPattern TextEditorControl textArea = SearchReplaceUtilities.GetActiveTextEditor(); if (textArea != null) { string selectedText = textArea.ActiveTextAreaControl.TextArea.SelectionManager.SelectedText; if (selectedText != null && selectedText.Length > 0 && !IsMultipleLines(selectedText)) { SearchOptions.CurrentFindPattern = selectedText; } } }
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(); }
void OKButtonClick(object sender, EventArgs e) { try { if (listView.SelectedItems.Count == 0) { return; } object tag = listView.SelectedItems[0].Tag; if (tag is int) { TextEditorControl editor = GetEditor(); if (editor != null) { int i = Math.Min(editor.Document.TotalNumberOfLines, Math.Max(1, (int)tag)); editor.ActiveTextAreaControl.JumpTo(i - 1, int.MaxValue); } } else if (tag is IClass) { IClass c = tag as IClass; CodeCompletionDataUsageCache.IncrementUsage(c.DotNetName); GotoRegion(c.Region, c.CompilationUnit.FileName); } else if (tag is IMember) { IMember m = tag as IMember; CodeCompletionDataUsageCache.IncrementUsage(m.DotNetName); GotoRegion(m.Region, m.DeclaringType.CompilationUnit.FileName); } else if (tag is FileLineReference) { FileLineReference flref = (FileLineReference)tag; if (flref.Line <= 0) { FileService.OpenFile(flref.FileName); } else { FileService.JumpToFilePosition(flref.FileName, flref.Line - 1, flref.Column); } } else { throw new NotImplementedException("Unknown tag: " + tag); } } finally { Close(); } }
public static bool FindNext() { SetSearchOptions(); if (find == null || SearchOptions.FindPattern == null || SearchOptions.FindPattern.Length == 0) { return(false); } if (!find.SearchStrategy.CompilePattern()) { find.Reset(); lastResult = null; return(false); } TextEditorControl textArea = null; while (textArea == null) { var result = find.FindNext(); if (result == null) { find.Reset(); lastResult = null; return(false); } else { textArea = OpenTextArea(result.FileName); if (textArea != null) { if (lastResult != null && lastResult.FileName == result.FileName && textArea.ActiveTextAreaControl.Caret.Offset != lastResult.Offset + lastResult.Length) { find.Reset(); } int startPos = Math.Min(textArea.Document.TextLength, Math.Max(0, result.Offset)); int endPos = Math.Min(textArea.Document.TextLength, startPos + result.Length); SearchReplaceUtilities.SelectText(textArea, startPos, endPos); lastResult = result; return(true); } } } return(false); }
public override void Run() { IViewContent viewContent = WorkbenchSingleton.Workbench.ActiveViewContent; if (viewContent == null || !(viewContent is ITextEditorControlProvider)) { return; } TextEditorControl textEditorControl = ((ITextEditorControlProvider)viewContent).TextEditorControl; if (textEditorControl != null) { textEditorControl.Split(); } }
private void ExecuteFind(bool replaceMode) { if (this.findForm == null) { this.findForm = new FindAndReplaceForm(); this.findForm.Owner = this.ParentForm; } TextEditorControl editor = ActiveEditor; if (editor == null) { return; } findForm.ShowFor(editor, replaceMode); }
/// <summary> /// Creates a GotoLineForm that will be assigned to a specific Owner control. /// </summary> /// <param name="Owner">The SyntaxBox that will use the GotoLineForm</param> public GotoLineForm(TextEditorControl Owner) { // // Required for Windows Form Designer support // InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call // int RowCount = Owner.Document.TotalNumberOfLines; lblLines.Text = Resources.Line_number + " (1-" + (RowCount).ToString() + "):"; mOwner = Owner; }
public override void Run() { IWorkbenchWindow window = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow; if (window == null || !(window.ViewContent is ITextEditorControlProvider)) { return; } TextEditorControl textEditorControl = ((ITextEditorControlProvider)window.ViewContent).TextEditorControl; if (textEditorControl != null) { textEditorControl.Split(); } }
private void SetModifiedFlag(TextEditorControl editor, bool flag) { if (IsModified(editor) != flag) { var p = editor.Parent; if (IsModified(editor)) { p.Text = p.Text.Substring(0, p.Text.Length - 1); } else { p.Text += "*"; } } }
private void SetSyntaxMode(object sender, string mode) { TextEditorControl te = sender as TextEditorControl; ComboBox cmb = sender as ComboBox; if (te != null) { base.CurrentSytaxMode = mode; te.Document.HighlightingStrategy = ICSharpCode.TextEditor.Document.HighlightingStrategyFactory.CreateHighlightingStrategy(mode); } else if (cmb != null) { cmb.SelectedIndex = cmb.FindStringExact(mode); } }
private void UpdateEditorReferences() { foreach (var file in _references) { TextEditorControl editor = _editors[file.First().File]; foreach (var reference in file) { int offset = editor.Document.GetOffsetForLineNumber(reference.Line) + reference.Col; int len = reference.ReferenceString.Length; editor.Document.Replace(offset, len, nameBox.Text); editor.Document.MarkerStrategy.AddMarker(new TextMarker(offset, nameBox.Text.Length, TextMarkerType.SolidBlock, Color.LightGreen)); editor.Document.BookmarkManager.AddMark(new Bookmark(editor.Document, new TextLocation(0, reference.Line))); } } }
public static TextEditorControl showAstValueInSourceCode(this TextEditorControl textEditorControl, AstValue <object> astValue) { return((TextEditorControl)textEditorControl.invokeOnThread(() => { PublicDI.log.error("{0} {1} - {2}", astValue.Text, astValue.StartLocation, astValue.EndLocation); var start = new TextLocation(astValue.StartLocation.X - 1, astValue.StartLocation.Y - 1); var end = new TextLocation(astValue.EndLocation.X - 1, astValue.EndLocation.Y - 1); var selection = new DefaultSelection(textEditorControl.Document, start, end); textEditorControl.ActiveTextAreaControl.SelectionManager.SetSelection(selection); setCaretToCurrentSelection(textEditorControl); return textEditorControl; })); }
/// <summary> /// Checks that when the user presses the return key after the Operator line that the /// expected code is generated. /// </summary> void RunFormatLineTest(string code, string expectedCode) { string foo = "As Foo"; int cursorOffset = code.IndexOf(foo) + foo.Length; int line = 2; using (TextEditorControl editor = new TextEditorControl()) { editor.Document.TextContent = code; editor.ActiveTextAreaControl.Caret.Position = editor.Document.OffsetToPosition(cursorOffset); VBFormattingStrategy formattingStrategy = new VBFormattingStrategy(); formattingStrategy.FormatLine(editor.ActiveTextAreaControl.TextArea, line, cursorOffset, '\n'); Assert.AreEqual(expectedCode, editor.Document.TextContent); } }
public static CodeCompletionWindow ShowCompletionWindow(Form parent, TextEditorControl control, string fileName, ICompletionDataProvider completionDataProvider, char firstChar, bool showDeclarationWindow, bool fixedListViewWidth) { if (busy) // DC to prevent multiple calls { "CodeCompletionWindow.ShowCompletionWindow was busy, skipping ShowCompletionWindow calculation".info(); return null; } busy = true; //return (CodeCompletionWindow)parent.invokeOnThread( return (CodeCompletionWindow)control.invokeOnThread( ()=>{ return ShowCompletionWindow_Thread(parent, control, fileName,completionDataProvider, firstChar, showDeclarationWindow, fixedListViewWidth); }); }
public Generator(string[] arguments, ITextEditorCore textCore, TextEditorControl textEditorControl) { textEditorCore = textCore; this.textEditorControl = textEditorControl; if (arguments.Length > 2 && arguments[1] == "/path") { filePath = arguments[2]; MadTypistBeingMad(); } else { currentFilePath = filePath; Start(); random = new Random((int)DateTime.Now.Ticks); } }
public static CodeCompletionWindow ShowCompletionWindow_Thread(Form parent,TextEditorControl control, string fileName, ICompletionDataProvider completionDataProvider, char firstChar, bool showDeclarationWindow, bool fixedListViewWidth) { try { var tempCompletionData = new ICompletionData[] { }; CodeCompletionWindow codeCompletionWindow = new CodeCompletionWindow(completionDataProvider, tempCompletionData, parent, control, showDeclarationWindow, fixedListViewWidth); codeCompletionWindow.CloseWhenCaretAtBeginning = firstChar == '\0'; codeCompletionWindow.ShowCompletionWindow(); codeCompletionWindow.AfterWindowOpen.invoke(); O2Thread.mtaThread( // run in on a separate thread for performance reasons () => { try { ICompletionData[] completionData = completionDataProvider.GenerateCompletionData(fileName, control.ActiveTextAreaControl.TextArea, firstChar); if (completionData == null || completionData.Length == 0) { //"There was no CompleteData".error(); //return null; } else codeCompletionWindow.setCodeCompletionData(completionData); } catch (Exception ex) { ex.log("in CodeCompletionWindow.ShowCompletionWindow "); } busy = false; }); return codeCompletionWindow; } catch// (Exception ex) { busy = false; return null; } }
public TextMarkerService(TextEditorControl textView, ITextEditorUIContextImpl uiContext, ITextLineObjectManager textLineObjectManager) { this.textEditorControl = textView; this.uiContext = uiContext; this.textLineObjectManager = textLineObjectManager; uiContext.NewTextContent += TextEditorUIContext_NewTextContent; TextView.DocumentChanged += TextView_DocumentChanged; textLineObjectManager.OnListModified += TextLineObjectManager_OnListModified; OnDocumentChanged(); }
public TextEditorElementProvider(TextEditorControl control) : base(control) { }
/// <summary> /// Initializes a new instance of the <see cref="CompletionWindow"/> class. /// </summary> /// <param name="completionDataProvider">The completion data provider.</param> /// <param name="completionData">The completion data.</param> /// <param name="parentForm">The parent form.</param> /// <param name="control">The text editor control.</param> /// <param name="showDeclarationWindow"><see langword="true"/> to show declaration window; otherwise <see langword="false"/>.</param> /// <param name="fixedListViewWidth"><see langword="true"/> to use a fixed width in the list view.</param> /// <param name="closeAutomatically"><see langword="true"/> to close the completion window automatically.</param> CompletionWindow(ICompletionDataProvider completionDataProvider, ICompletionData[] completionData, Form parentForm, TextEditorControl control, bool showDeclarationWindow, bool fixedListViewWidth, bool closeAutomatically) : base(parentForm, control) { _dataProvider = completionDataProvider; _completionData = completionData; _document = control.Document; _showDeclarationWindow = showDeclarationWindow; _fixedListViewWidth = fixedListViewWidth; _closeAutomatically = closeAutomatically; int caretOffset = control.ActiveTextAreaControl.Caret.Offset; _startOffset = caretOffset; _endOffset = caretOffset; // Move start offset if something is pre-selected. if (!String.IsNullOrEmpty(completionDataProvider.PreSelection)) _startOffset -= completionDataProvider.PreSelection.Length; _completionListView = new CompletionListView(completionData); _completionListView.Dock = DockStyle.Fill; _completionListView.FilterList = true; _completionListView.ImageList = completionDataProvider.ImageList; _completionListView.Click += CompletionListViewClick; _completionListView.DoubleClick += CompletionListViewDoubleClick; _completionListView.FirstItemChanged += CompletionListViewFirstItemChanged; _completionListView.ItemCountChanged += CompletionListViewItemCountChanged; _completionListView.SelectedItemChanged += CompletionListViewSelectedItemChanged; Controls.Add(_completionListView); _vScrollBar = new VScrollBar(); _vScrollBar.SmallChange = 1; _vScrollBar.LargeChange = _maxListLength; _vScrollBar.Dock = DockStyle.Right; Controls.Add(_vScrollBar); UpdateScrollBar(); _workingScreen = Screen.GetWorkingArea(Location); DrawingSize = GetListViewSize(); _textLocation = TextEditorControl.ActiveTextAreaControl.TextArea.Caret.Position; SetLocation(_textLocation); if (_declarationViewWindow == null) _declarationViewWindow = new DeclarationViewWindow(parentForm); SetDeclarationViewLocation(); _declarationViewWindow.Show(); _declarationViewWindow.MouseMove += ControlMouseMove; control.Focus(); CompletionListViewSelectedItemChanged(this, EventArgs.Empty); if (!String.IsNullOrEmpty(completionDataProvider.PreSelection)) { // Select item based on pre-selection. CaretOffsetChanged(this, EventArgs.Empty); } else if (completionDataProvider.DefaultIndex >= 0) { // Select default item _completionListView.SelectItem(completionDataProvider.DefaultIndex); } _vScrollBar.ValueChanged += VScrollBarValueChanged; _document.DocumentAboutToBeChanged += DocumentAboutToBeChanged; }
/// <summary> /// Initializes a new instance of the <see cref="InsightWindow"/> class. /// </summary> /// <param name="parentForm">The parent form.</param> /// <param name="control">The text editor.</param> public InsightWindow(Form parentForm, TextEditorControl control) : base(parentForm, control) { SetStyle(ControlStyles.UserPaint, true); SetStyle(ControlStyles.OptimizedDoubleBuffer, true); }
public void Initialize(IMenuManager menuManager, TextEditorControl textEditorControl) { this.textEditorControl = textEditorControl; this.wpfCommandManager.Add(CommandConstants.GUID_TEXTEDITOR_UICONTEXT, textEditorControl); this.wpfCommandManager.Add(CommandConstants.GUID_TEXTEDITOR_UICONTEXT_TEXTEDITOR, textEditorControl.TextEditor); this.wpfCommandManager.Add(CommandConstants.GUID_TEXTEDITOR_UICONTEXT_TEXTAREA, textEditorControl.TextEditor.TextArea); menuManager.InitializeContextMenu(this.textEditorControl, MenuConstants.GUIDOBJ_TEXTEDITORCONTROL_GUID, new GuidObjectsCreator(this), new ContextMenuInitializer(textEditorControl, textEditorControl.TextEditor)); }
/// <summary> /// Executes the action on the active <see cref="TextArea"/> of a /// <see cref="TextEditorControl"/>. /// </summary> /// <param name="textEditor"> /// The text editor control on which the to execute the action. /// </param> public void Execute(TextEditorControl textEditor) { Execute(textEditor.ActiveTextAreaControl.TextArea); }
public static CodeCompletionWindow ShowCompletionWindow(Form parent, TextEditorControl control, string fileName, ICompletionDataProvider completionDataProvider, char firstChar) { return ShowCompletionWindow(parent, control, fileName, completionDataProvider, firstChar, true, true); }
public HighlightGroup(TextEditorControl editor) { _editor = editor; _document = editor.Document; }
/// <summary> /// Shows the template completion window. /// </summary> /// <param name="textEditorControl">The text editor control.</param> /// <param name="snippets">The snippets (text template).</param> /// <param name="imageList">The image list to use in the completion window.</param> /// <param name="snippetImageIndex">Index of the snippet image in the <paramref name="imageList"/>.</param> /// <param name="ch">The character that is going to be inserted. <c>'\0'</c> if no character.</param> public static void ShowTemplateCompletionWindow(TextEditorControl textEditorControl, IEnumerable<Snippet> snippets, ImageList imageList, int snippetImageIndex, char ch) { SnippetCompletionDataProvider snippetCompletionDataProvider = new SnippetCompletionDataProvider(snippets, imageList, snippetImageIndex); textEditorControl.ShowCompletionWindow(snippetCompletionDataProvider, ch, false); }
public TextRangeProvider(TextEditorControl control, ISelection selection) { _control = control; _selection = selection; }
PABCNETCodeCompletionWindow(ICompletionDataProvider completionDataProvider, ICompletionData[] completionData, Form parentForm, TextEditorControl control,bool visibleKeyPressed, bool is_by_dot) : base(parentForm, control) { this.dataProvider = completionDataProvider; this.completionData = completionData; this.document = control.Document; workingScreen = Screen.GetWorkingArea(Location); lastCursorScreenPosition = control.ActiveTextAreaControl.Caret.ScreenPosition; startOffset = control.ActiveTextAreaControl.Caret.Offset + (visibleKeyPressed ? 1 : 0); endOffset = startOffset; if (completionDataProvider.PreSelection != null) { startOffset -= completionDataProvider.PreSelection.Length; //+ 1; if (visibleKeyPressed) endOffset--; //endOffset--; (completionDataProvider as VisualPascalABC.CodeCompletionProvider).preSelection = null; } codeCompletionListView = new PABCNETCodeCompletionListView(completionData, is_by_dot); codeCompletionListView.ImageList = completionDataProvider.ImageList; codeCompletionListView.Dock = DockStyle.Fill; codeCompletionListView.SelectedItemChanged += new EventHandler(CodeCompletionListViewSelectedItemChanged); codeCompletionListView.DoubleClick += new EventHandler(CodeCompletionListViewDoubleClick); codeCompletionListView.Click += new EventHandler(CodeCompletionListViewClick); codeCompletionListView.Font = new Font(VisualPascalABC.Constants.CompletionWindowCodeCompletionListViewFontName,codeCompletionListView.Font.Size); Controls.Add(codeCompletionListView); int MaxListLength = VisualPascalABC.Constants.CompletionWindowMaxListLength; if (completionData.Length > MaxListLength) { vScrollBar.Dock = DockStyle.Right; vScrollBar.Minimum = 0; vScrollBar.Maximum = completionData.Length - 1; vScrollBar.SmallChange = 1; vScrollBar.LargeChange = MaxListLength; codeCompletionListView.FirstItemChanged += new EventHandler(CodeCompletionListViewFirstItemChanged); Controls.Add(vScrollBar); } this.drawingSize = new Size(//codeCompletionListView.ItemHeight * 10, VisualPascalABC.Constants.CompletionWindowWidth, codeCompletionListView.ItemHeight * Math.Min(MaxListLength, completionData.Length) + 2); SetLocation(); if (declarationViewWindow == null) { declarationViewWindow = new DeclarationWindow(parentForm); declarationViewWindow.in_completion_list = true; declarationViewWindow.Font = new Font(VisualPascalABC.Constants.CompletionWindowDeclarationViewWindowFontName, declarationViewWindow.Font.Size); } SetDeclarationViewLocation(); //DS закоментил, это желтый квадрат при старте //declarationViewWindow.ShowDeclarationViewWindow(); declarationViewWindow.MouseMove += ControlMouseMove; control.Focus(); CodeCompletionListViewSelectedItemChanged(this, EventArgs.Empty); if ((completionDataProvider as VisualPascalABC.CodeCompletionProvider).DefaultCompletionElement != null) { if ((completionDataProvider as VisualPascalABC.CodeCompletionProvider).ByFirstChar) codeCompletionListView.FirstInsert = true; codeCompletionListView.SelectIndexByCompletionData((completionDataProvider as VisualPascalABC.CodeCompletionProvider).DefaultCompletionElement); } if (completionDataProvider.PreSelection != null) { CaretOffsetChanged(this, EventArgs.Empty); } vScrollBar.ValueChanged += VScrollBarValueChanged; document.DocumentAboutToBeChanged += DocumentAboutToBeChanged; }
//-------------------------------------------------------------- /// <summary> /// Inserts the snippet into the text editor at the current caret position. /// </summary> /// <param name="textEditorControl">The text editor control.</param> public void Insert(TextEditorControl textEditorControl) { TextArea textArea = textEditorControl.ActiveTextAreaControl.TextArea; Insert(textArea); }
public AutoCompleteMessageHandler(TextEditorControl textEditorControl) { this.textEditorControl = textEditorControl; outputMessages = new List<ProtoCore.OutputMessage>(); }