bool DoCaseCompletion(SharpDevelopTextAreaControl editor) { ICSharpCode.TextEditor.Caret caret = editor.ActiveTextAreaControl.Caret; NRefactoryResolver r = new NRefactoryResolver(LanguageProperties.CSharp); if (r.Initialize(ParserService.GetParseInformation(editor.FileName), caret.Line + 1, caret.Column + 1)) { AST.INode currentMember = r.ParseCurrentMember(editor.Text); if (currentMember != null) { CaseCompletionSwitchFinder ccsf = new CaseCompletionSwitchFinder(caret.Line + 1, caret.Column + 1); currentMember.AcceptVisitor(ccsf, null); if (ccsf.bestStatement != null) { r.RunLookupTableVisitor(currentMember); ResolveResult rr = r.ResolveInternal(ccsf.bestStatement.SwitchExpression, ExpressionContext.Default); if (rr != null && rr.ResolvedType != null) { return(ProvideContextCompletion(editor, rr.ResolvedType, ' ')); } } } } return(false); }
public void ReplaceChar(char ch) { bool isInUpdate = this.motherTextEditorControl.IsInUpdate; if (!isInUpdate) { this.BeginUpdate(); } if (this.Document.TextEditorProperties.DocumentSelectionMode == DocumentSelectionMode.Normal && this.SelectionManager.SelectionCollection.Count > 0) { this.Caret.Position = this.SelectionManager.SelectionCollection[0].StartPosition; this.SelectionManager.RemoveSelectedText(); } int line = this.Caret.Line; LineSegment lineSegment = this.Document.GetLineSegment(line); int offset = this.Document.PositionToOffset(this.Caret.Position); if (offset >= lineSegment.Offset + lineSegment.Length) { this.Document.Insert(offset, ch.ToString()); } else { this.Document.Replace(offset, 1, ch.ToString()); } if (!isInUpdate) { this.EndUpdate(); this.UpdateLineToEnd(line, this.Caret.Column); } ICSharpCode.TextEditor.Caret caret = this.Caret; caret.Column = caret.Column + 1; }
public TextArea(TextEditorControl motherTextEditorControl, TextAreaControl motherTextAreaControl) { this.motherTextAreaControl = motherTextAreaControl; this.motherTextEditorControl = motherTextEditorControl; this.caret = new ICSharpCode.TextEditor.Caret(this); this.selectionManager = new ICSharpCode.TextEditor.Document.SelectionManager(this.Document, this); this.textAreaClipboardHandler = new TextAreaClipboardHandler(this); base.ResizeRedraw = true; base.SetStyle(ControlStyles.OptimizedDoubleBuffer, true); base.SetStyle(ControlStyles.Opaque, false); base.SetStyle(ControlStyles.ResizeRedraw, true); base.SetStyle(ControlStyles.Selectable, true); this.textView = new ICSharpCode.TextEditor.TextView(this); this.gutterMargin = new ICSharpCode.TextEditor.GutterMargin(this); this.foldMargin = new ICSharpCode.TextEditor.FoldMargin(this); this.iconBarMargin = new ICSharpCode.TextEditor.IconBarMargin(this); List <AbstractMargin> abstractMargins = this.leftMargins; AbstractMargin[] abstractMarginArray = new AbstractMargin[] { this.iconBarMargin, this.gutterMargin, this.foldMargin }; abstractMargins.AddRange(abstractMarginArray); this.OptionsChanged(); (new TextAreaMouseHandler(this)).Attach(); (new TextAreaDragDropHandler()).Attach(this); this.bracketshemes.Add(new BracketHighlightingSheme('{', '}')); this.bracketshemes.Add(new BracketHighlightingSheme('(', ')')); this.bracketshemes.Add(new BracketHighlightingSheme('[', ']')); this.caret.PositionChanged += new EventHandler(this.SearchMatchingBracket); this.Document.TextContentChanged += new EventHandler(this.TextContentChanged); this.Document.FoldingManager.FoldingsChanged += new EventHandler(this.DocumentFoldingsChanged); }
public override QUT.Gppg.LexLocation GetCursorPosition() { ICodeFileDocument doc = (_wb as IWorkbenchDocumentService).CurrentCodeFileDocument; List <ICSharpCode.TextEditor.Document.ISelection> sel = doc.TextEditor.ActiveTextAreaControl.SelectionManager.SelectionCollection; if (sel.Count > 0) { return(new QUT.Gppg.LexLocation(sel[0].StartPosition.Line + 1, sel[0].StartPosition.Column + 1, sel[0].EndPosition.Line + 1, sel[0].EndPosition.Column + 1)); } ICSharpCode.TextEditor.Caret caret = doc.TextEditor.ActiveTextAreaControl.Caret; return(new QUT.Gppg.LexLocation(caret.Line + 1, caret.Column, caret.Line + 1, caret.Column)); }
public void SetCaretToDesiredColumn() { FoldMarker foldMarker; ICSharpCode.TextEditor.Caret caret = this.Caret; ICSharpCode.TextEditor.TextView textView = this.textView; int line = this.Caret.Line; int desiredColumn = this.Caret.DesiredColumn; Point virtualTop = this.VirtualTop; caret.Position = textView.GetLogicalColumn(line, desiredColumn + virtualTop.X, out foldMarker); }
protected IMember GetCurrentMember(SharpDevelopTextAreaControl editor) { ICSharpCode.TextEditor.Caret caret = editor.ActiveTextAreaControl.Caret; NRefactoryResolver r = new NRefactoryResolver(ParserService.CurrentProjectContent, languageProperties); if (r.Initialize(editor.FileName, caret.Line + 1, caret.Column + 1)) { return(r.CallingMember); } else { return(null); } }
public void findINodeAtCaretLocation(ICSharpCode.TextEditor.Caret caret) { if (AstData_MethodStream != null) { var iNode = AstData_MethodStream.iNode(MethodStreamFile, caret); if (iNode != null) { //CodeViewer.editor().selectTextWithColor(iNode); if (iNode is TypeReference) { iNode = iNode.Parent; } CurrentINode = iNode; CurrentINodeLabel.set_Text("current iNode:{0}".format(iNode.typeName())); //"current iNode:{0} : {1}".debug(iNode.typeName(), iNode); //createAndShowCodeStream(iNode); } } }
public void InsertChar(char ch) { bool isInUpdate = this.motherTextEditorControl.IsInUpdate; if (!isInUpdate) { this.BeginUpdate(); } if (char.IsWhiteSpace(ch) && ch != '\t' && ch != '\n') { ch = ' '; } this.Document.UndoStack.StartUndoGroup(); if (this.Document.TextEditorProperties.DocumentSelectionMode == DocumentSelectionMode.Normal && this.SelectionManager.SelectionCollection.Count > 0) { this.Caret.Position = this.SelectionManager.SelectionCollection[0].StartPosition; this.SelectionManager.RemoveSelectedText(); } LineSegment lineSegment = this.Document.GetLineSegment(this.Caret.Line); int offset = this.Caret.Offset; int column = this.Caret.Column; if (lineSegment.Length >= column || ch == '\n') { this.Document.Insert(offset, ch.ToString()); } else { this.Document.Insert(offset, string.Concat(this.GenerateWhitespaceString(column - lineSegment.Length), ch)); } this.Document.UndoStack.EndUndoGroup(); ICSharpCode.TextEditor.Caret caret = this.Caret; caret.Column = caret.Column + 1; if (!isInUpdate) { this.EndUpdate(); this.UpdateLineToEnd(this.Caret.Line, this.Caret.Column); } }
internal void NavigationLocationChanged() { ICSharpCode.TextEditor.Caret c = CurrentSyntaxEditor.TextEditor.ActiveTextAreaControl.Caret; NavigationManager.LocationChanged(c.Line + 1, c.Column + 1, CurrentSourceFileName); }