本文整理汇总了C#中TextSource.NeedRecalc方法的典型用法代码示例。如果您正苦于以下问题:C# TextSource.NeedRecalc方法的具体用法?C# TextSource.NeedRecalc怎么用?C# TextSource.NeedRecalc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TextSource
的用法示例。
在下文中一共展示了TextSource.NeedRecalc方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ClearSelected
internal static void ClearSelected(TextSource ts)
{
var tb = ts.CurrentTB;
Place start = tb.Selection.Start;
Place end = tb.Selection.End;
int fromLine = Math.Min(end.iLine, start.iLine);
int toLine = Math.Max(end.iLine, start.iLine);
int fromChar = tb.Selection.FromX;
int toChar = tb.Selection.ToX;
if (fromLine < 0) return;
//
if (fromLine == toLine)
ts[fromLine].RemoveRange(fromChar, toChar - fromChar);
else
{
ts[fromLine].RemoveRange(fromChar, ts[fromLine].Count - fromChar);
ts[toLine].RemoveRange(0, toChar);
ts.RemoveLine(fromLine + 1, toLine - fromLine - 1);
InsertCharCommand.MergeLines(fromLine, ts);
}
//
tb.Selection.Start = new Place(fromChar, fromLine);
//
ts.NeedRecalc(new TextSource.TextChangedEventArgs(fromLine, toLine));
}
示例2: InsertText
internal static void InsertText(string insertedText, TextSource ts, bool normalizeEOL=false)
{
var tb = ts.CurrentTB;
try
{
tb.Selection.BeginUpdate();
char cc = '\x0';
if (ts.Count == 0)
{
InsertCharCommand.InsertLine(ts);
tb.Selection.Start = Place.Empty;
}
tb.ExpandBlock(tb.Selection.Start.iLine);
if (normalizeEOL)
{
// The EOL characters in insertedText have to be converted to the EOL characters in the TextSource.
switch (tb.DefaultEolFormat)
{
case EolFormat.LF:
// \r\n -> \n
// \r -> \n
insertedText = insertedText.Replace("\r\n", "\n").Replace("\r", "\n");
break;
case EolFormat.CRLF:
// \r[^\n] (a \r not followed by a \n)
// [^\r]\n (a \n not preceeded by a \r)
// yikes, I don't want to use a Regex for this. Let's normalize to \n and then to \r\n
insertedText = insertedText.Replace("\r\n", "\n").Replace("\r", "\n").Replace("\n", "\r\n");
break;
case EolFormat.CR:
// \r\n -> \r
// \n -> \r
insertedText = insertedText.Replace("\r\n", "\r").Replace("\n", "\r");
break;
case EolFormat.None:
default:
// The entire text is replaced, keep the EOL characters the way they are.
// Make sure to call FastColoredTextbox.TryDeriveEolFormat(...)
break;
}
}
foreach (char c in insertedText)
{
InsertCharCommand.InsertChar(c, ref cc, ts);
}
ts.NeedRecalc(new TextSource.TextSourceTextChangedEventArgs(0, 1));
}
finally
{
tb.Selection.EndUpdate();
}
}
示例3: InsertText
internal static void InsertText(string insertedText, TextSource ts)
{
var tb = ts.CurrentTB;
try
{
tb.Selection.BeginUpdate();
char cc = '\x0';
if (ts.Count == 0)
InsertCharCommand.InsertLine(ts);
tb.ExpandBlock(tb.Selection.Start.iLine);
foreach (char c in insertedText)
InsertCharCommand.InsertChar(c, ref cc, ts);
ts.NeedRecalc(new TextSource.TextChangedEventArgs(0, 1));
}
finally {
tb.Selection.EndUpdate();
}
}
示例4: MergeLines
/// <summary>
/// Merge lines i and i+1
/// </summary>
internal static void MergeLines(int i, TextSource ts)
{
var tb = ts.CurrentTB;
if (i + 1 >= ts.Count)
return;
tb.ExpandBlock(i);
tb.ExpandBlock(i + 1);
int pos = ts[i].Count;
//
if(ts[i].Count == 0)
ts.RemoveLine(i);
else
if (ts[i + 1].Count == 0)
ts.RemoveLine(i + 1);
else
{
ts[i].AddRange(ts[i + 1]);
ts.RemoveLine(i + 1);
}
tb.Selection.Start = new Place(pos, i);
ts.NeedRecalc(new TextSource.TextChangedEventArgs(0, 1));
}
示例5: InsertLine
internal static void InsertLine(TextSource ts)
{
var tb = ts.CurrentTB;
if (!tb.Multiline && tb.LinesCount > 0)
return;
if (ts.Count == 0)
ts.InsertLine(0, ts.CreateLine());
else
BreakLines(tb.Selection.Start.iLine, tb.Selection.Start.iChar, ts);
tb.Selection.Start = new Place(0, tb.Selection.Start.iLine + 1);
ts.NeedRecalc(new TextSource.TextChangedEventArgs(0, 1));
}
示例6: InsertText
internal static void InsertText(string insertedText, TextSource ts)
{
var tb = ts.CurrentTB;
try
{
tb.Selection.BeginUpdate();
char cc = '\x0';
if (ts.Count == 0)
{
InsertCharCommand.InsertLine(ts);
tb.Selection.Start = Place.Empty;
}
tb.ExpandBlock(tb.Selection.Start.iLine);
var len = insertedText.Length;
for (int i = 0; i < len; i++)
{
var c = insertedText[i];
if(c == '\r' && (i >= len - 1 || insertedText[i + 1] != '\n'))
InsertCharCommand.InsertChar('\n', ref cc, ts);
else
InsertCharCommand.InsertChar(c, ref cc, ts);
}
ts.NeedRecalc(new TextSource.TextChangedEventArgs(0, 1));
}
finally {
tb.Selection.EndUpdate();
}
}
示例7: MergeLines
/// <summary>
/// Merge lines i and i+1
/// </summary>
internal static void MergeLines(int i, TextSource ts)
{
var tb = ts.CurrentTB;
if (i + 1 >= ts.Count)
return;
tb.ExpandBlock(i);
tb.ExpandBlock(i + 1);
int pos = ts[i].Count;
// save the next lines EolFormat, because this one is the one that is saved
EolFormat format = ts[i + 1].EolFormat;
//
/*
if(ts[i].Count == 0)
ts.RemoveLine(i);
else*/
if (ts[i + 1].Count == 0)
{
ts.RemoveLine(i + 1);
}
else
{
ts[i].AddRange(ts[i + 1]);
ts.RemoveLine(i + 1);
}
// set the EolFormat to the next lines EolFormat.
ts[i].EolFormat = format;
tb.Selection.Start = new Place(pos, i);
ts.NeedRecalc(new TextSource.TextSourceTextChangedEventArgs(0, 1));
}