void ResetEditorState(TextEditorData data) { if (data == null) { return; } data.ClearSelection(); //Editor can be null during GUI-less tests // Commenting this fixes bug: Bug 622618 - Inline search fails in vi mode // if (Editor != null) // Editor.HighlightSearchPattern = false; if (CaretMode.Block != data.Caret.Mode) { data.Caret.Mode = CaretMode.Block; if (data.Caret.Column > DocumentLocation.MinColumn) { data.Caret.Column--; } } ViActions.RetreatFromLineEnd(data); }
void ResetEditorState(TextEditorData data) { if (data == null) { return; } data.ClearSelection(); //Editor can be null during GUI-less tests if (Editor != null) { Editor.HighlightSearchPattern = false; } if (CaretMode.Block != data.Caret.Mode) { data.Caret.Mode = CaretMode.Block; if (data.Caret.Column > 0) { data.Caret.Column--; } } ViActions.RetreatFromLineEnd(data); }
void ResetEditorState (TextEditorData data) { if (data == null) return; data.ClearSelection (); //Editor can be null during GUI-less tests if (Editor != null) Editor.HighlightSearchPattern = false; if (CaretMode.Block != data.Caret.Mode) { data.Caret.Mode = CaretMode.Block; if (data.Caret.Column > DocumentLocation.MinColumn) data.Caret.Column--; } ViActions.RetreatFromLineEnd (data); }
public override void Run(RefactoringOptions options) { IResolver resolver = options.GetResolver(); INRefactoryASTProvider provider = options.GetASTProvider(); TextEditorData data = options.GetTextEditorData(); IType type = options.ResolveResult.CallingType; if (invoke.TargetObject is IdentifierExpression) { fileName = options.Document.FileName; newMethodName = ((IdentifierExpression)invoke.TargetObject).Identifier; indent = options.GetIndent(options.ResolveResult.CallingMember); if (options.ResolveResult.CallingMember.IsStatic) { modifiers |= ICSharpCode.NRefactory.Ast.Modifiers.Static; } } else { newMethodName = ((MemberReferenceExpression)invoke.TargetObject).MemberName; string callingObject = provider.OutputNode(options.Dom, ((MemberReferenceExpression)invoke.TargetObject).TargetObject); ResolveResult resolveResult = resolver.Resolve(new ExpressionResult(callingObject), resolvePosition); type = options.Dom.GetType(resolveResult.ResolvedType); fileName = type.CompilationUnit.FileName; if (resolveResult.StaticResolve) { modifiers |= ICSharpCode.NRefactory.Ast.Modifiers.Static; } if (fileName == options.Document.FileName) { indent = options.GetIndent(options.ResolveResult.CallingMember); // insertNewMethod.Offset = options.Document.TextEditor.GetPositionFromLineColumn (options.ResolveResult.CallingMember.BodyRegion.End.Line, options.ResolveResult.CallingMember.BodyRegion.End.Column); } else { var openDocument = IdeApp.Workbench.OpenDocument(fileName); data = openDocument.TextEditorData; if (data == null) { return; } modifiers |= ICSharpCode.NRefactory.Ast.Modifiers.Public; bool isInInterface = type.ClassType == MonoDevelop.Projects.Dom.ClassType.Interface; if (isInInterface) { modifiers = ICSharpCode.NRefactory.Ast.Modifiers.None; } if (data == null) { throw new InvalidOperationException("Can't open file:" + modifiers); } try { indent = data.Document.GetLine(type.Location.Line - 1).GetIndentation(data.Document) ?? ""; } catch (Exception) { indent = ""; } indent += "\t"; // insertNewMethod.Offset = otherFile.Document.LocationToOffset (type.BodyRegion.End.Line - 1, 0); } } InsertionCursorEditMode mode = new InsertionCursorEditMode(data.Parent, HelperMethods.GetInsertionPoints(data.Document, type)); if (fileName == options.Document.FileName) { for (int i = 0; i < mode.InsertionPoints.Count; i++) { var point = mode.InsertionPoints[i]; if (point.Location < data.Caret.Location) { mode.CurIndex = i; } else { break; } } } ModeHelpWindow helpWindow = new ModeHelpWindow(); helpWindow.TransientFor = IdeApp.Workbench.RootWindow; helpWindow.TitleText = GettextCatalog.GetString("<b>Create Method -- Targeting</b>"); helpWindow.Items.Add(new KeyValuePair <string, string> (GettextCatalog.GetString("<b>Key</b>"), GettextCatalog.GetString("<b>Behavior</b>"))); helpWindow.Items.Add(new KeyValuePair <string, string> (GettextCatalog.GetString("<b>Up</b>"), GettextCatalog.GetString("Move to <b>previous</b> target point."))); helpWindow.Items.Add(new KeyValuePair <string, string> (GettextCatalog.GetString("<b>Down</b>"), GettextCatalog.GetString("Move to <b>next</b> target point."))); helpWindow.Items.Add(new KeyValuePair <string, string> (GettextCatalog.GetString("<b>Enter</b>"), GettextCatalog.GetString("<b>Declare new method</b> at target point."))); helpWindow.Items.Add(new KeyValuePair <string, string> (GettextCatalog.GetString("<b>Esc</b>"), GettextCatalog.GetString("<b>Cancel</b> this refactoring."))); mode.HelpWindow = helpWindow; mode.StartMode(); mode.Exited += delegate(object s, InsertionCursorEventArgs args) { if (args.Success) { insertionPoint = args.InsertionPoint; insertionOffset = data.Document.LocationToOffset(args.InsertionPoint.Location); base.Run(options); if (string.IsNullOrEmpty(fileName)) { return; } MonoDevelop.Ide.Gui.Document document = IdeApp.Workbench.OpenDocument(fileName); TextEditorData docData = document.TextEditorData; if (docData != null) { docData.ClearSelection(); docData.Caret.Offset = selectionEnd; docData.SetSelection(selectionStart, selectionEnd); } } }; }
void ResetEditorState (TextEditorData data) { if (data == null) return; data.ClearSelection (); Editor.HighlightSearchPattern = false; if (CaretMode.Block != data.Caret.Mode) { data.Caret.Mode = CaretMode.Block; if (data.Caret.Column > 0) data.Caret.Column--; } ViActions.RetreatFromLineEnd (data); }
void ResetEditorState (TextEditorData data) { if (data == null) return; data.ClearSelection (); //Editor can be null during GUI-less tests // Commenting this fixes bug: Bug 622618 - Inline search fails in vi mode // if (Editor != null) // Editor.HighlightSearchPattern = false; if (CaretMode.Block != data.Caret.Mode) { data.Caret.Mode = CaretMode.Block; if (data.Caret.Column > DocumentLocation.MinColumn) data.Caret.Column--; } ViActions.RetreatFromLineEnd (data); }
public override void Run(RefactoringOptions options) { TextEditorData data = options.GetTextEditorData(); fileName = declaringType.CompilationUnit.FileName; var openDocument = IdeApp.Workbench.OpenDocument(fileName); if (openDocument == null) { MessageService.ShowError(string.Format(GettextCatalog.GetString("Can't open file {0}."), fileName)); return; } data = openDocument.Editor; if (data == null) { return; } if (data == null) { throw new InvalidOperationException("Can't open file:" + modifiers); } try { indent = data.Document.GetLine(declaringType.Location.Line).GetIndentation(data.Document) ?? ""; } catch (Exception) { indent = ""; } indent += "\t"; InsertionCursorEditMode mode = new InsertionCursorEditMode(data.Parent, CodeGenerationService.GetInsertionPoints(options.Document, declaringType)); if (fileName == options.Document.FileName) { for (int i = 0; i < mode.InsertionPoints.Count; i++) { var point = mode.InsertionPoints [i]; if (point.Location < data.Caret.Location) { mode.CurIndex = i; } else { break; } } } ModeHelpWindow helpWindow = new ModeHelpWindow(); helpWindow.TransientFor = IdeApp.Workbench.RootWindow; helpWindow.TitleText = GettextCatalog.GetString("<b>Create Method -- Targeting</b>"); helpWindow.Items.Add(new KeyValuePair <string, string> (GettextCatalog.GetString("<b>Key</b>"), GettextCatalog.GetString("<b>Behavior</b>"))); helpWindow.Items.Add(new KeyValuePair <string, string> (GettextCatalog.GetString("<b>Up</b>"), GettextCatalog.GetString("Move to <b>previous</b> target point."))); helpWindow.Items.Add(new KeyValuePair <string, string> (GettextCatalog.GetString("<b>Down</b>"), GettextCatalog.GetString("Move to <b>next</b> target point."))); helpWindow.Items.Add(new KeyValuePair <string, string> (GettextCatalog.GetString("<b>Enter</b>"), GettextCatalog.GetString("<b>Declare new method</b> at target point."))); helpWindow.Items.Add(new KeyValuePair <string, string> (GettextCatalog.GetString("<b>Esc</b>"), GettextCatalog.GetString("<b>Cancel</b> this refactoring."))); mode.HelpWindow = helpWindow; mode.StartMode(); mode.Exited += delegate(object s, InsertionCursorEventArgs args) { if (args.Success) { SetInsertionPoint(args.InsertionPoint); BaseRun(options); if (string.IsNullOrEmpty(fileName)) { return; } MonoDevelop.Ide.Gui.Document document = IdeApp.Workbench.OpenDocument(fileName); TextEditorData docData = document.Editor; if (docData != null) { docData.ClearSelection(); docData.Caret.Offset = selectionEnd; docData.SetSelection(selectionStart, selectionEnd); } } }; }