public static void Up(TextEditorData data) { using (var undo = data.OpenUndoGroup()) { int desiredColumn = data.Caret.DesiredColumn; //on Mac, when deselecting and moving up/down a line, column is always the column of the selection's start if (Platform.IsMac && data.IsSomethingSelected && !data.Caret.PreserveSelection) { int col = data.MainSelection.Anchor > data.MainSelection.Lead ? data.MainSelection.Lead.Column : data.MainSelection.Anchor.Column; int line = data.MainSelection.MinLine - 1; data.ClearSelection(); data.Caret.Location = (line >= DocumentLocation.MinLine) ? new DocumentLocation(line, col) : new DocumentLocation(DocumentLocation.MinLine, DocumentLocation.MinColumn); data.Caret.SetToDesiredColumn(desiredColumn); return; } if (data.Caret.Line > DocumentLocation.MinLine) { int visualLine = data.LogicalToVisualLine(data.Caret.Line); int line = data.VisualToLogicalLine(visualLine - 1); int offset = MoveCaretOutOfFolding(data, data.Document.LocationToOffset(line, data.Caret.Column), false); data.Caret.SetToOffsetWithDesiredColumn(offset); } else { ToDocumentStart(data); } } }
public static void Down(TextEditorData data) { using (var undo = data.OpenUndoGroup()) { //on Mac, when deselecting and moving up/down a line, column is always the column of the selection's start if (Platform.IsMac && data.IsSomethingSelected && !data.Caret.PreserveSelection) { int col = data.MainSelection.Anchor > data.MainSelection.Lead ? data.MainSelection.Lead.Column : data.MainSelection.Anchor.Column; int line = data.MainSelection.MaxLine + 1; data.ClearSelection(); if (line <= data.Document.LineCount) { int offset = data.Document.LocationToOffset(line, col); data.Caret.SetToOffsetWithDesiredColumn(MoveCaretOutOfFolding(data, offset)); } else { data.Caret.Offset = data.Document.TextLength; } return; } if (data.Caret.Line < data.Document.LineCount) { int nextLine = data.LogicalToVisualLine(data.Caret.Line) + 1; int line = data.VisualToLogicalLine(nextLine); int offset = MoveCaretOutOfFolding(data, data.LocationToOffset(line, data.Caret.Column), true); data.Caret.SetToOffsetWithDesiredColumn(offset); } else { ToDocumentEnd(data); } } }
public static void PageDown(TextEditorData data) { using (var undo = data.OpenUndoGroup()) { int pageLines = (int)((data.VAdjustment.PageSize + ((int)data.VAdjustment.Value % data.LineHeight)) / data.LineHeight); int visualLine = data.LogicalToVisualLine(data.Caret.Line); visualLine += pageLines; int line = System.Math.Min(data.VisualToLogicalLine(visualLine), data.Document.LineCount); int offset = data.Document.LocationToOffset(line, data.Caret.Column); ScrollActions.PageDown(data); data.Caret.Offset = MoveCaretOutOfFolding(data, offset); } }
public static void PageUp(TextEditorData data) { int pageLines = (int)((data.VAdjustment.PageSize + ((int)data.VAdjustment.Value % data.LineHeight)) / data.LineHeight); int visualLine = data.LogicalToVisualLine(data.Caret.Line); visualLine -= pageLines; int line = System.Math.Max(data.VisualToLogicalLine(visualLine), DocumentLocation.MinLine); int offset = data.LocationToOffset(line, data.Caret.Column); ScrollActions.PageUp(data); data.Caret.Offset = MoveCaretOutOfFolding(data, offset); }
public static void Down(TextEditorData editor) { if (!Platform.IsMac) CaretMoveActions.Down(editor); else { using (var undo = editor.OpenUndoGroup()) { if (editor.Caret.Line < editor.Document.LineCount) { int nextLine = editor.LogicalToVisualLine(editor.Caret.Line); int line = editor.VisualToLogicalLine(nextLine + 1); editor.Caret.Line = line; } } } }
public static void Up(TextEditorData editor) { if (!Platform.IsMac) CaretMoveActions.Up(editor); else { using (var undo = editor.OpenUndoGroup()) { if (editor.Caret.Line > DocumentLocation.MinLine) { int visualLine = editor.LogicalToVisualLine(editor.Caret.Line); int line = editor.VisualToLogicalLine(visualLine - 1); editor.Caret.Line = line; } } } }
public static void PageDown (TextEditorData data) { int pageLines = (int)((data.VAdjustment.PageSize + ((int)data.VAdjustment.Value % data.LineHeight)) / data.LineHeight); int visualLine = data.LogicalToVisualLine (data.Caret.Line); visualLine += pageLines; int line = System.Math.Min (data.VisualToLogicalLine (visualLine), data.Document.LineCount); int offset = data.Document.LocationToOffset (line, data.Caret.Column); ScrollActions.PageDown (data); data.Caret.Offset = MoveCaretOutOfFolding (data, offset); }
public static void Down (TextEditorData data) { //on Mac, when deselecting and moving up/down a line, column is always the column of the selection's start if (Platform.IsMac && data.IsSomethingSelected && !data.Caret.PreserveSelection) { int col = data.MainSelection.Anchor > data.MainSelection.Lead ? data.MainSelection.Lead.Column : data.MainSelection.Anchor.Column; int line = data.MainSelection.MaxLine + 1; data.ClearSelection (); if (line <= data.Document.LineCount) { int offset = data.Document.LocationToOffset (line, col); data.Caret.SetToOffsetWithDesiredColumn (MoveCaretOutOfFolding (data, offset)); } else { data.Caret.Offset = data.Document.TextLength; } return; } if (data.Caret.Line < data.Document.LineCount) { int nextLine = data.LogicalToVisualLine (data.Caret.Line) + 1; int line = data.VisualToLogicalLine (nextLine); int offset = MoveCaretOutOfFolding (data, data.LocationToOffset (line, data.Caret.Column), true); data.Caret.SetToOffsetWithDesiredColumn (offset); } else { ToDocumentEnd (data); } }
public static void Up (TextEditorData data) { int desiredColumn = data.Caret.DesiredColumn; //on Mac, when deselecting and moving up/down a line, column is always the column of the selection's start if (Platform.IsMac && data.IsSomethingSelected && !data.Caret.PreserveSelection) { int col = data.MainSelection.Anchor > data.MainSelection.Lead ? data.MainSelection.Lead.Column : data.MainSelection.Anchor.Column; int line = data.MainSelection.MinLine - 1; data.ClearSelection (); data.Caret.Location = (line >= DocumentLocation.MinLine) ? new DocumentLocation (line, col) : new DocumentLocation (DocumentLocation.MinLine, DocumentLocation.MinColumn); data.Caret.SetToDesiredColumn (desiredColumn); return; } if (data.Caret.Line > DocumentLocation.MinLine) { int visualLine = data.LogicalToVisualLine (data.Caret.Line); int line = data.VisualToLogicalLine (visualLine - 1); int offset = MoveCaretOutOfFolding (data, data.Document.LocationToOffset (line, data.Caret.Column), false); data.Caret.SetToOffsetWithDesiredColumn (offset); } else { ToDocumentStart (data); } }
public static void PageUp (TextEditorData data) { using (var undo = data.OpenUndoGroup ()) { int pageLines = (int)((data.VAdjustment.PageSize + ((int)data.VAdjustment.Value % data.LineHeight)) / data.LineHeight); int visualLine = data.LogicalToVisualLine (data.Caret.Line); visualLine -= pageLines; int line = System.Math.Max (data.VisualToLogicalLine (visualLine), DocumentLocation.MinLine); int offset = data.LocationToOffset (line, data.Caret.Column); ScrollActions.PageUp (data); data.Caret.Offset = MoveCaretOutOfFolding (data, offset); } }