本文整理汇总了C#中IEditor.GoTo方法的典型用法代码示例。如果您正苦于以下问题:C# IEditor.GoTo方法的具体用法?C# IEditor.GoTo怎么用?C# IEditor.GoTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEditor
的用法示例。
在下文中一共展示了IEditor.GoTo方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SelectColumn
static void SelectColumn(IEditor editor, bool right, int line, int caretOld, int caretNew)
{
int x1, y1, x2, y2;
if (editor.SelectionExists)
{
if (editor.SelectionKind != PlaceKind.Column)
return;
// editor selection
var place = editor.SelectionPlace;
y1 = place.First.Y;
y2 = place.Last.Y;
// screen selection and carets
int select1 = editor.ConvertColumnEditorToScreen(y1, place.First.X);
int select2 = editor.ConvertColumnEditorToScreen(y2, place.Last.X);
int caret1 = editor.ConvertColumnEditorToScreen(line, caretOld);
int caret2 = editor.ConvertColumnEditorToScreen(line, caretNew);
if (right)
{
if (caret1 < select2 && caret2 > select2)
{
// invert selection
x1 = select2 + 1;
x2 = caret2 - 1;
}
else if (caret1 != select1)
{
// expand selection
x1 = select1;
x2 = caret2 - 1;
}
else
{
// reduce selection
x1 = caret2;
x2 = select2;
}
}
else
{
if (caret2 >= select1)
{
// reduce selection
x1 = select1;
x2 = caret2 - 1;
}
else if (caret1 > select1)
{
// invert selection
x1 = caret2;
x2 = select1 - 1;
}
else
{
// expand selection
x1 = caret2;
x2 = select2;
}
}
}
else
{
// start selection
y1 = y2 = line;
if (right)
{
x1 = editor.ConvertColumnEditorToScreen(y1, caretOld);
x2 = editor.ConvertColumnEditorToScreen(y1, caretNew - 1);
}
else
{
x1 = editor.ConvertColumnEditorToScreen(y1, caretNew);
x2 = editor.ConvertColumnEditorToScreen(y1, caretOld - 1);
}
}
// set/drop selection and set the caret
editor.GoTo(caretNew, line);
editor.SelectText(x1, y1, x2, y2, PlaceKind.Column);
editor.Redraw();
}
示例2: SelectStream
static void SelectStream(IEditor editor, ILine line, bool right, Point caretOld, Point caretNew)
{
Point first, last;
if (editor != null && editor.SelectionExists || line != null && line.SelectionSpan.Length > 0)
{
Place place;
if (line == null)
{
place = editor.SelectionPlace;
}
else
{
var span = line.SelectionSpan;
place = new Place(span.Start, 0, span.Start + span.Length - 1, 0);
}
if (right)
{
if (place.Last == new Point(caretNew.X - 1, caretNew.Y))
{
// vanish selection
first = last = new Point(-1, -1);
}
else if (caretOld != place.First)
{
// expand selection
first = place.First;
last = new Point(caretNew.X - 1, caretNew.Y);
}
else if (caretNew.Y > place.Last.Y || caretNew.Y == place.Last.Y && caretNew.X > place.Last.X)
{
// invert selection
first = new Point(place.Last.X + 1, place.Last.Y);
last = new Point(caretNew.X - 1, caretNew.Y);
}
else
{
// reduce selection
first = caretNew;
last = place.Last;
}
}
else
{
if (place.First == caretNew)
{
// vanish selection
first = last = new Point(-1, -1);
}
else if (place.Last != new Point(caretOld.X - 1, caretOld.Y))
{
// expand selection
first = caretNew;
last = place.Last;
}
else if (caretNew.Y < place.First.Y || caretNew.Y == place.First.Y && caretNew.X < place.First.X)
{
// invert selection
first = caretNew;
last = new Point(place.First.X - 1, place.First.Y);
}
else
{
// reduce selection
first = place.First;
last = new Point(caretNew.X - 1, caretNew.Y);
}
}
}
else
{
// start selection
if (right)
{
first = caretOld;
last = new Point(caretNew.X - 1, caretNew.Y);
}
else
{
first = caretNew;
last = new Point(caretOld.X - 1, caretOld.Y);
}
}
// set/drop selection and set the caret
if (line == null)
{
editor.GoTo(caretNew.X, caretNew.Y);
if (first.Y >= 0)
editor.SelectText(first.X, first.Y, last.X, last.Y);
else
editor.UnselectText();
editor.Redraw();
}
else
{
line.Caret = caretNew.X;
if (first.Y >= 0)
line.SelectText(first.X, last.X + 1);
else
//.........这里部分代码省略.........
示例3: Run
/// <summary>
/// Runs the specified operation.
/// </summary>
/// <param name="editor">The active editor or null.</param>
/// <param name="line">The active line or null.</param>
/// <param name="operation">The operation to run.</param>
/// <param name="right">True for right, false for left.</param>
/// <param name="alt">True for the alternative operation.</param>
static void Run(IEditor editor, ILine line, Operation operation, bool right, bool alt)
{
Point caret = line == null ? editor.Caret : new Point(line.Caret, 0);
int iColumn = caret.X;
int iLine = caret.Y;
for (; ; )
{
ILine currentLine = line ?? editor[iLine];
var text = currentLine.Text;
int newX = -1;
foreach (Match match in Regex.Matches(text))
{
if (right)
{
if (match.Index > iColumn)
{
newX = match.Index;
break;
}
}
else
{
if (match.Index >= iColumn)
break;
newX = match.Index;
}
}
// :: new position is not found in the line
if (newX < 0)
{
if (alt || line != null)
return;
if (right)
{
if (++iLine >= editor.Count)
return;
iColumn = -1;
}
else
{
if (--iLine < 0)
return;
iColumn = int.MaxValue;
}
continue;
}
if (operation == Operation.Step)
{
// :: step
if (line == null)
{
editor.GoTo(newX, iLine);
editor.UnselectText();
editor.Redraw();
}
else
{
//_100819_142053 Mantis#1464 Here was a kludge
line.UnselectText();
line.Caret = newX;
}
}
else if (operation == Operation.Select)
{
// :: select
if (alt)
SelectColumn(editor, right, iLine, caret.X, newX);
else
SelectStream(editor, line, right, caret, new Point(newX, iLine));
}
else
{
// :: delete
if (line == null)
{
if (!right && newX == 0 && caret.X > 0 && currentLine.Length == 0)
{
// "Cursor beyond end of line" and the line is empty
editor.UnselectText();
editor.GoToColumn(0);
}
else
//.........这里部分代码省略.........