本文整理汇总了C#中IEditor.UnselectText方法的典型用法代码示例。如果您正苦于以下问题:C# IEditor.UnselectText方法的具体用法?C# IEditor.UnselectText怎么用?C# IEditor.UnselectText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEditor
的用法示例。
在下文中一共展示了IEditor.UnselectText方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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
//.........这里部分代码省略.........
示例2: 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
//.........这里部分代码省略.........