public override HostResult LoadFileIntoNewWindow(string filePath) { try { var textDocument = TextDocumentFactoryService.CreateAndLoadTextDocument(filePath, TextBufferFactoryService.TextContentType); var wpfTextView = MainWindow.CreateTextView(textDocument.TextBuffer); MainWindow.AddNewTab(System.IO.Path.GetFileName(filePath), wpfTextView); return(HostResult.Success); } catch (Exception ex) { return(HostResult.NewError(ex.Message)); } }
private bool TryLoadPathAsFile(string filePath, out IWpfTextView textView) { try { var textDocument = TextDocumentFactoryService.CreateAndLoadTextDocument(filePath, TextBufferFactoryService.TextContentType); textView = MainWindow.CreateTextView(textDocument.TextBuffer); return(true); } catch (Exception) { textView = null; return(false); } }
public override bool LoadFileIntoNewWindow(string filePath) { try { var textDocument = TextDocumentFactoryService.CreateAndLoadTextDocument(filePath, TextBufferFactoryService.TextContentType); var wpfTextView = MainWindow.CreateTextView(textDocument.TextBuffer); MainWindow.AddNewTab(System.IO.Path.GetFileName(filePath), wpfTextView); return(true); } catch (Exception ex) { _vim.ActiveStatusUtil.OnError(ex.Message); return(false); } }
// TODO: The ITextView parameter isn't necessary. This command should always load into // the active window, not existing public override HostResult LoadFileIntoExistingWindow(string filePath, ITextView textView) { var vimWindow = MainWindow.ActiveVimWindowOpt; if (vimWindow == null) { return(HostResult.NewError("No active vim window")); } try { var textDocument = TextDocumentFactoryService.CreateAndLoadTextDocument(filePath, TextBufferFactoryService.TextContentType); var wpfTextViewHost = MainWindow.CreateTextViewHost(MainWindow.CreateTextView(textDocument.TextBuffer)); vimWindow.Clear(); vimWindow.AddVimViewInfo(wpfTextViewHost); return(HostResult.Success); } catch (Exception ex) { return(HostResult.NewError(ex.Message)); } }
public override bool LoadFileIntoNewWindow(string filePath, FSharpOption <int> line, FSharpOption <int> column) { try { var textDocument = TextDocumentFactoryService.CreateAndLoadTextDocument(filePath, TextBufferFactoryService.TextContentType); var wpfTextView = MainWindow.CreateTextView(textDocument.TextBuffer); MainWindow.AddNewTab(System.IO.Path.GetFileName(filePath), wpfTextView); if (line.IsSome()) { // Move the caret to its initial position. if (column.IsSome()) { wpfTextView.MoveCaretToLine(line.Value, column.Value); } else { // Default column implies moving to the first non-blank. wpfTextView.MoveCaretToLine(line.Value); var editorOperations = EditorOperationsFactoryService.GetEditorOperations(wpfTextView); editorOperations.MoveToStartOfLineAfterWhiteSpace(false); } } // Give the focus to the new buffer. var point = wpfTextView.Caret.Position.VirtualBufferPosition; NavigateTo(point); return(true); } catch (Exception ex) { _vim.ActiveStatusUtil.OnError(ex.Message); return(false); } }