public void ExecuteSourceLocationAction(PascalABCCompiler.SourceLocation SourceLocation, VisualPascalABCPlugins.SourceLocationAction Action) { if (Action != SourceLocationAction.NavigationGoto) { NavigationLocationChanged(); } if (SourceLocation.FileName != null) { WorkbenchServiceFactory.FileService.OpenFile(SourceLocation.FileName, null, true); } CodeFileDocumentTextEditorControl editor = CurrentSyntaxEditor.TextEditor; editor.ActiveTextAreaControl.SelectionManager.ClearSelection(); //Point Beg = new Point(SourceLocation.BeginPosition.Column - 1, SourceLocation.BeginPosition.Line - 1); //Point End = new Point(SourceLocation.EndPosition.Column, SourceLocation.EndPosition.Line - 1); ICSharpCode.TextEditor.TextLocation Beg = new ICSharpCode.TextEditor.TextLocation(SourceLocation.BeginPosition.Column - 1, SourceLocation.BeginPosition.Line - 1); ICSharpCode.TextEditor.TextLocation End = new ICSharpCode.TextEditor.TextLocation(SourceLocation.EndPosition.Column, SourceLocation.EndPosition.Line - 1); switch (Action) { case SourceLocationAction.SelectAndGotoBeg: case SourceLocationAction.SelectAndGotoEnd: case SourceLocationAction.FindSelection: if (Action == SourceLocationAction.SelectAndGotoBeg) { editor.ActiveTextAreaControl.Caret.Position = Beg; } else { editor.ActiveTextAreaControl.Caret.Position = End; } editor.ActiveTextAreaControl.SelectionManager.SetSelection(Beg, End); if (Action != SourceLocationAction.FindSelection) { SetFocusToEditor(); } break; case SourceLocationAction.NavigationGoto: case SourceLocationAction.GotoBeg: case SourceLocationAction.GotoEnd: if (Action == SourceLocationAction.GotoBeg || Action == SourceLocationAction.NavigationGoto) { editor.ActiveTextAreaControl.Caret.Position = Beg; } else { editor.ActiveTextAreaControl.Caret.Position = End; } SetFocusToEditor(); break; } if (Action != SourceLocationAction.NavigationGoto) { NavigationLocationChanged(); CurrentSyntaxEditor.CenterView(); } }
public void setCaretToCurrentSelection(ICSharpCode.TextEditor.TextEditorControl textEditorControl) { var finalCaretPosition = textEditorControl.ActiveTextAreaControl.TextArea.SelectionManager.SelectionCollection[0].StartPosition; var tempCaretPosition = new ICSharpCode.TextEditor.TextLocation { X = finalCaretPosition.X, Y = finalCaretPosition.Y + 10 }; textEditorControl.ActiveTextAreaControl.Caret.Position = tempCaretPosition; textEditorControl.ActiveTextAreaControl.TextArea.ScrollToCaret(); textEditorControl.ActiveTextAreaControl.Caret.Position = finalCaretPosition; textEditorControl.ActiveTextAreaControl.TextArea.ScrollToCaret(); }
bool checkForDotNetItem() { ICSharpCode.TextEditor.TextLocation cp = CurrentSyntaxEditor.TextEditor.ActiveTextAreaControl.Caret.Position; ICSharpCode.TextEditor.Document.TextWord tw = CurrentSyntaxEditor.TextEditor.ActiveTextAreaControl.TextArea.Document.GetLineSegment(cp.Line).GetWord(cp.Column); if (tw != null) { Position pos = default(Position); if (isDotNetItem(tw.Word, ref pos)) { return(true); } } return(false); }
void __showhelpf1(object state) { ICSharpCode.TextEditor.TextLocation cp = CurrentSyntaxEditor.TextEditor.ActiveTextAreaControl.Caret.Position; ICSharpCode.TextEditor.Document.TextWord tw = CurrentSyntaxEditor.TextEditor.ActiveTextAreaControl.TextArea.Document.GetLineSegment(cp.Line).GetWord(cp.Column); if (tw != null) { MetadataType metadata_type = MetadataType.Class; /*if (isDotNetItem(tw.Word, ref metadata_type)) * { * //Help.ShowHelp(this, DotNetHelpFileName, HelpNavigator.KeywordIndex); * //Help.ShowHelp(this, DotNetHelpFileName, HelpNavigator.KeywordIndex, tw.Word); * //Help.ShowHelp(this, DotNetHelpFileName); * //Help.ShowHelp(this, DotNetHelpFileName, HelpNavigator.KeywordIndex); * //Help.ShowHelpIndex(this, DotNetHelpFileName); * //Help.ShowHelp(this, DotNetHelpFileName,HelpNavigator.KeywordIndex, tw.Word); * AddTabWithUrl(MainDockPanel, tw.Word, getMSDNUrlByName(tw.Word)); * Help.ShowHelp(this, DotNetHelpFileName, HelpNavigator.TableOfContents); * * switch (metadata_type) * { * case MetadataType.Class: Help.ShowHelp(this, DotNetHelpFileName, HelpNavigator.KeywordIndex, tw.Word + " êëàññ"); break; * case MetadataType.Constructor: Help.ShowHelp(this, DotNetHelpFileName, HelpNavigator.KeywordIndex, tw.Word + "." + tw.Word + " êîíñòðóêòîðû"); break; * case MetadataType.Delegate: Help.ShowHelp(this, DotNetHelpFileName, HelpNavigator.KeywordIndex, tw.Word + " äåëåãàò"); break; * case MetadataType.Enumeration: Help.ShowHelp(this, DotNetHelpFileName, HelpNavigator.KeywordIndex, tw.Word + " ïåðå÷èñëåíèå"); break; * case MetadataType.EnumerationMember: Help.ShowHelp(this, DotNetHelpFileName, HelpNavigator.KeywordIndex, tw.Word + " ýëåìåíò ïåðå÷èñëåíèÿ"); break; * case MetadataType.Event: Help.ShowHelp(this, DotNetHelpFileName, HelpNavigator.KeywordIndex, tw.Word + " ñîáûòèå"); break; * case MetadataType.Field: Help.ShowHelp(this, DotNetHelpFileName, HelpNavigator.KeywordIndex, tw.Word + " ïîëå"); break; * case MetadataType.Interface: Help.ShowHelp(this, DotNetHelpFileName, HelpNavigator.KeywordIndex, tw.Word + " èíòåðôåéñ"); break; * case MetadataType.Method: Help.ShowHelp(this, DotNetHelpFileName, HelpNavigator.KeywordIndex, tw.Word + " ìåòîä"); break; * case MetadataType.Property: Help.ShowHelp(this, DotNetHelpFileName, HelpNavigator.KeywordIndex, tw.Word + " ñâîéñòâî"); break; * case MetadataType.Struct: Help.ShowHelp(this, DotNetHelpFileName, HelpNavigator.KeywordIndex, tw.Word + " çàïèñü"); break; * } * * } * else*/ { Help.ShowHelp(this, HelpFileName, HelpNavigator.TableOfContents); Help.ShowHelp(this, HelpFileName, HelpNavigator.KeywordIndex, tw.Word); } } else { Help.ShowHelp(this, HelpFileName, HelpNavigator.KeywordIndex, "PascalABC"); // ôèêòèâíûé âûçîâ. Íóæåí ÷òîáû îêíî ñïðàâêè íå ïîêàçûâàëîñü Always on Top Help.ShowHelp(this, HelpFileName); } }
void __showDotNetHelp() { ICSharpCode.TextEditor.TextLocation cp = CurrentSyntaxEditor.TextEditor.ActiveTextAreaControl.Caret.Position; ICSharpCode.TextEditor.Document.TextWord tw = CurrentSyntaxEditor.TextEditor.ActiveTextAreaControl.TextArea.Document.GetLineSegment(cp.Line).GetWord(cp.Column); if (tw != null) { Position pos = default(Position); if (isDotNetItem(tw.Word, ref pos)) { if (pos.full_metadata_title != null) { AddTabWithUrl(MainDockPanel, pos.full_metadata_title, getMSDNUrlByName(tw.Word, pos)); } } } }
//NOTE: these two methods need to be moved to the ascx_SourceCodeEditor control public void showInSourceCode(Object sender, TreeViewEventArgs e) { var treeNoteTag = e.Node.Tag; // temp Hack to handle the fact that AstValue<obTject> is current using AstValue<object> var endLocation = (ICSharpCode.NRefactory.Location)O2.Kernel.PublicDI.reflection.getProperty("EndLocation", treeNoteTag); var startLocation = (ICSharpCode.NRefactory.Location)O2.Kernel.PublicDI.reflection.getProperty("StartLocation", treeNoteTag); var originalObject = O2.Kernel.PublicDI.reflection.getProperty("OriginalObject", treeNoteTag); var text = (string)O2.Kernel.PublicDI.reflection.getProperty("Text", treeNoteTag); var astValue = new AstValue <object>(text, originalObject, startLocation, endLocation); //if (treeNoteTag is AstValue<object>) //{ //var astValue = (AstValue<object>)treeNoteTag; var textEditorControl = sourceCodeEditor.getObject_TextEditorControl(); var start = new ICSharpCode.TextEditor.TextLocation(astValue.StartLocation.X - 1, astValue.StartLocation.Y - 1); var end = new ICSharpCode.TextEditor.TextLocation(astValue.EndLocation.X - 1, astValue.EndLocation.Y - 1); var selection = new ICSharpCode.TextEditor.Document.DefaultSelection(textEditorControl.Document, start, end); textEditorControl.ActiveTextAreaControl.SelectionManager.SetSelection(selection); setCaretToCurrentSelection(textEditorControl); //} }
public void ExecuteSourceLocationAction(PascalABCCompiler.SourceLocation SourceLocation, VisualPascalABCPlugins.SourceLocationAction Action) { if (Action != SourceLocationAction.NavigationGoto) NavigationLocationChanged(); if (SourceLocation.FileName != null) WorkbenchServiceFactory.FileService.OpenFile(SourceLocation.FileName, null, true); CodeFileDocumentTextEditorControl editor = CurrentSyntaxEditor.TextEditor; editor.ActiveTextAreaControl.SelectionManager.ClearSelection(); //Point Beg = new Point(SourceLocation.BeginPosition.Column - 1, SourceLocation.BeginPosition.Line - 1); //Point End = new Point(SourceLocation.EndPosition.Column, SourceLocation.EndPosition.Line - 1); ICSharpCode.TextEditor.TextLocation Beg = new ICSharpCode.TextEditor.TextLocation(SourceLocation.BeginPosition.Column - 1, SourceLocation.BeginPosition.Line - 1); ICSharpCode.TextEditor.TextLocation End = new ICSharpCode.TextEditor.TextLocation(SourceLocation.EndPosition.Column, SourceLocation.EndPosition.Line - 1); switch (Action) { case SourceLocationAction.SelectAndGotoBeg: case SourceLocationAction.SelectAndGotoEnd: case SourceLocationAction.FindSelection: if (Action == SourceLocationAction.SelectAndGotoBeg) editor.ActiveTextAreaControl.Caret.Position = Beg; else editor.ActiveTextAreaControl.Caret.Position = End; editor.ActiveTextAreaControl.SelectionManager.SetSelection(Beg, End); if (Action != SourceLocationAction.FindSelection) SetFocusToEditor(); break; case SourceLocationAction.NavigationGoto: case SourceLocationAction.GotoBeg: case SourceLocationAction.GotoEnd: if (Action == SourceLocationAction.GotoBeg || Action == SourceLocationAction.NavigationGoto) editor.ActiveTextAreaControl.Caret.Position = Beg; else editor.ActiveTextAreaControl.Caret.Position = End; SetFocusToEditor(); break; } if (Action != SourceLocationAction.NavigationGoto) { NavigationLocationChanged(); CurrentSyntaxEditor.CenterView(); } }
public void setCaretToCurrentSelection(ICSharpCode.TextEditor.TextEditorControl textEditorControl) { var finalCaretPosition = textEditorControl.ActiveTextAreaControl.TextArea.SelectionManager.SelectionCollection[0].StartPosition; var tempCaretPosition = new ICSharpCode.TextEditor.TextLocation { X = finalCaretPosition.X, Y = finalCaretPosition.Y + 10 }; textEditorControl.ActiveTextAreaControl.Caret.Position = tempCaretPosition; textEditorControl.ActiveTextAreaControl.TextArea.ScrollToCaret(); textEditorControl.ActiveTextAreaControl.Caret.Position = finalCaretPosition; textEditorControl.ActiveTextAreaControl.TextArea.ScrollToCaret(); }
//NOTE: these two methods need to be moved to the ascx_SourceCodeEditor control public void showInSourceCode(Object sender, TreeViewEventArgs e) { var treeNoteTag = e.Node.Tag; // temp Hack to handle the fact that AstValue<obTject> is current using AstValue<object> var endLocation = (ICSharpCode.NRefactory.Location)O2.Kernel.PublicDI.reflection.getProperty("EndLocation",treeNoteTag); var startLocation = (ICSharpCode.NRefactory.Location)O2.Kernel.PublicDI.reflection.getProperty("StartLocation", treeNoteTag); var originalObject = O2.Kernel.PublicDI.reflection.getProperty("OriginalObject", treeNoteTag); var text = (string)O2.Kernel.PublicDI.reflection.getProperty("Text", treeNoteTag); var astValue = new AstValue<object>(text,originalObject,startLocation,endLocation); //if (treeNoteTag is AstValue<object>) //{ //var astValue = (AstValue<object>)treeNoteTag; var textEditorControl = sourceCodeEditor.getObject_TextEditorControl(); var start = new ICSharpCode.TextEditor.TextLocation(astValue.StartLocation.X - 1, astValue.StartLocation.Y - 1); var end = new ICSharpCode.TextEditor.TextLocation(astValue.EndLocation.X - 1, astValue.EndLocation.Y - 1); var selection = new ICSharpCode.TextEditor.Document.DefaultSelection(textEditorControl.Document, start, end); textEditorControl.ActiveTextAreaControl.SelectionManager.SetSelection(selection); setCaretToCurrentSelection(textEditorControl); //} }
public bool FindNext(bool exec_goto_action = true) { Form1 = (Form1)this.Owner; UpdateLastWordsList(this.tbTextToFind); if (exec_goto_action) { startOffset = Form1.CurrentSyntaxEditor.TextEditor.ActiveTextAreaControl.TextArea.Caret.Offset; } if (cbSearchUp.Checked && resLength >= 0) { startOffset -= resLength; } resOffset = -1; //resLength = -1; System.Text.RegularExpressions.RegexOptions options = System.Text.RegularExpressions.RegexOptions.None; if (!cbMathCase.Checked) { options = options | System.Text.RegularExpressions.RegexOptions.IgnoreCase; } if (cbSearchUp.Checked) { options = options | System.Text.RegularExpressions.RegexOptions.RightToLeft; } string pattern = this.tbTextToFind.Text; if (pattern == "") { findSuccess = false; return(findSuccess); } if (!cbUseRegex.Checked) { pattern = System.Text.RegularExpressions.Regex.Escape(pattern); } if (cbMathWord.Checked) { pattern = @"\b" + pattern + @"\b"; } System.Text.RegularExpressions.Regex Regex; try { Regex = new System.Text.RegularExpressions.Regex(pattern, options); } catch (Exception e) { MessageBox.Show(string.Format(PascalABCCompiler.StringResources.Get("VP_REPLACEFORM_REGEXPERR{0}"), e.Message), PascalABCCompiler.StringResources.Get("!ERROR"), MessageBoxButtons.OK, MessageBoxIcon.Warning); findSuccess = false; return(findSuccess); } if (cbSearchUp.Checked) { Match = Regex.Match(Form1.CurrentSyntaxEditor.TextEditor.Document.TextContent, 0, startOffset); } else { Match = Regex.Match(Form1.CurrentSyntaxEditor.TextEditor.Document.TextContent, startOffset); } if (findSuccess = Match.Success) { resOffset = Match.Index; resLength = Match.Length; //Point p = Form1.CurrentSyntaxEditor.TextEditor.Document.OffsetToPosition(resOffset); if (exec_goto_action) { ICSharpCode.TextEditor.TextLocation p = Form1.CurrentSyntaxEditor.TextEditor.Document.OffsetToPosition(resOffset); Form1.ExecuteSourceLocationAction(new PascalABCCompiler.SourceLocation(null, p.Y + 1, p.X + 1, p.Y + 1, p.X + resLength), VisualPascalABCPlugins.SourceLocationAction.FindSelection); } else { startOffset = resOffset + resLength; } } return(findSuccess); }
public int PositionToOffset(ICSharpCode.TextEditor.TextLocation p) { throw new NotImplementedException(); }
public BreakPoint(ICSharpCode.TextEditor.Document.IDocument document, ICSharpCode.TextEditor.TextLocation location) : base(document, location) { }
public HighlightBookmark(IDocument document, ICSharpCode.TextEditor.TextLocation location) : base(document, location) { }