public override void Execute(TextBoxControl editor) { int iLine = editor.LineCount; Paragraph pg = editor.GetParagraph(iLine); TextLocation endPos = new TextLocation(pg.Length, iLine); if (editor.Caret.Position != endPos) { editor.Caret.Position = endPos; if (editor.VerticalScroll.Visible) { editor.VerticalScroll.Value = editor.VerticalScroll.Maximum; } if (editor.HorizontalScroll.Visible) { int lineWidth = editor.GetLineWidth(iLine); if (lineWidth > editor.DrawRectangle.Width && editor.HorizontalScroll.Visible) { editor.HorizontalScroll.Value = Math.Min(editor.HorizontalScroll.Maximum, editor.HorizontalScroll.Value + lineWidth - editor.DrawRectangle.Width); } editor.PerformLayout(); } } }
/// <remarks> /// Executes this edit action /// </remarks> /// <param name="editor">The <see cref="Ieditor"/> which is used for callback purposes</param> public override void Execute(TextBoxControl editor) { int curLineNr = editor.Caret.Line; int iPageLines = editor.ClientSize.Height / editor.FontHeight; int requestedLineNumber = Math.Max((curLineNr - iPageLines), 1); if (curLineNr != requestedLineNumber) { int lineWidth = editor.GetLineWidth(requestedLineNumber); if (editor.CalColumnLocation(editor.Caret.Position.Y, editor.Caret.Position.X) > lineWidth) { if (editor.Caret.Position.Y > 1) { editor.Caret.Position = new TextLocation(editor.CalColumnNumber(requestedLineNumber, lineWidth), requestedLineNumber); editor.Caret.UpdateCaretPosition(); } } else { int oldLocation = editor.CalColumnLocation(editor.Caret.Position.Y, editor.Caret.Position.X); int location = oldLocation > 0 ? oldLocation : 0; editor.Caret.Position = new TextLocation(editor.CalColumnNumber(requestedLineNumber, location), requestedLineNumber); editor.Caret.UpdateCaretPosition(); } if (editor.VerticalScroll.Visible) { editor.VerticalScroll.Value = Math.Max(0, editor.VerticalScroll.Value - iPageLines * editor.FontHeight); editor.PerformLayout(); } } }
public override void Execute(TextBoxControl editor) { int lineWidth = editor.GetLineWidth(editor.Caret.Position.Y); if (lineWidth <= editor.CalColumnLocation(editor.Caret.Position.Y, editor.Caret.Position.X) && editor.Caret.Position.Y != editor.LineCount) { if (editor.HorizontalScroll.Value != 0 && editor.HorizontalScroll.Visible) { editor.HorizontalScroll.Value = 0; } if ((editor.Caret.Position.Y + 1) * editor.FontHeight > editor.DrawRectangle.Height && editor.VerticalScroll.Visible) { editor.VerticalScroll.Value = Math.Min(editor.VerticalScroll.Maximum, editor.VerticalScroll.Value + editor.FontHeight); } editor.PerformLayout(); editor.Caret.Position = new TextLocation(0, editor.Caret.Position.Y + 1); editor.Caret.UpdateCaretPosition(); } else { int location = editor.GetMovePositionByKey(false); if (location > editor.DrawRectangle.Width && location > editor.HorizontalScroll.Value + editor.DrawRectangle.Width && editor.HorizontalScroll.Visible) { editor.HorizontalScroll.Value = Math.Min(editor.VerticalScroll.Maximum, editor.HorizontalScroll.Value + editor.DrawRectangle.Width); } editor.PerformLayout(); editor.Caret.Position = new TextLocation(editor.CalColumnNumber(editor.Caret.Position.Y, location), editor.Caret.Position.Y); editor.Caret.UpdateCaretPosition(); } }
public override void Execute(TextBoxControl editor) { if (editor.Caret.Position.X == 0) { if (editor.Caret.Position.Y > 1) { int lineWidth = editor.GetLineWidth(editor.Caret.Position.Y - 1); if (lineWidth > editor.DrawRectangle.Width && editor.HorizontalScroll.Visible) { editor.HorizontalScroll.Value = Math.Min(editor.HorizontalScroll.Maximum, editor.HorizontalScroll.Value + lineWidth - editor.DrawRectangle.Width); } // 由于光标的起点为光标顶端点,在计算相对于垂直滚动条位置时需减2 if ((editor.Caret.Position.Y - 2) * editor.FontHeight < editor.VerticalScroll.Value && editor.VerticalScroll.Visible) { editor.VerticalScroll.Value = Math.Max(editor.VerticalScroll.Minimum, editor.VerticalScroll.Value - editor.FontHeight); } editor.PerformLayout(); editor.Caret.Position = new TextLocation(editor.CalColumnNumber(editor.Caret.Position.Y - 1, lineWidth), editor.Caret.Position.Y - 1); editor.Caret.UpdateCaretPosition(); } } else { int location = editor.GetMovePositionByKey(true); int hScroll2 = editor.HorizontalScroll.Value - editor.DrawRectangle.Width; if (location < editor.HorizontalScroll.Value && editor.HorizontalScroll.Visible) { editor.HorizontalScroll.Value = Math.Max(editor.VerticalScroll.Minimum, hScroll2 > 0 ? hScroll2 : 0); } editor.PerformLayout(); editor.Caret.Position = new TextLocation(editor.CalColumnNumber(editor.Caret.Position.Y, location), editor.Caret.Position.Y); editor.Caret.UpdateCaretPosition(); } }
public override void Execute(TextBoxControl editor) { if (editor.Caret.Position.Y == editor.LineCount) { return; } int lineWidth = editor.GetLineWidth(editor.Caret.Position.Y + 1); if (editor.CalColumnLocation(editor.Caret.Position.Y, editor.Caret.Position.X) > lineWidth) { editor.Caret.Position = new TextLocation(editor.CalColumnNumber(editor.Caret.Position.Y + 1, lineWidth), editor.Caret.Position.Y + 1); editor.Caret.UpdateCaretPosition(); } else { int oldLocation = editor.CalColumnLocation(editor.Caret.Position.Y, editor.Caret.Position.X); int location = oldLocation > 0 ? oldLocation : 0; editor.Caret.Position = new TextLocation(editor.CalColumnNumber(editor.Caret.Position.Y + 1, location), editor.Caret.Position.Y + 1); editor.Caret.UpdateCaretPosition(); } if (editor.VerticalScroll.Visible && editor.VerticalScroll.Value + editor.DrawRectangle.Height < (editor.Caret.Line - 1) * editor.FontHeight) { editor.VerticalScroll.Value = Math.Min(editor.VerticalScroll.Maximum, editor.VerticalScroll.Value + editor.FontHeight); editor.PerformLayout(); } }
public override void Execute(TextBoxControl editor) { int lineWidth = editor.GetLineWidth(editor.Caret.Line); int colNum = editor.CalColumnNumber(editor.Caret.Line, lineWidth); editor.Caret.Position = new TextLocation(colNum, editor.Caret.Line); editor.Caret.UpdateCaretPosition(); if (lineWidth > editor.DrawRectangle.Width && editor.HorizontalScroll.Visible) { editor.HorizontalScroll.Value = Math.Min(editor.HorizontalScroll.Maximum, editor.HorizontalScroll.Value + lineWidth - editor.DrawRectangle.Width); editor.PerformLayout(); } }