本文整理汇总了C#中Cursor.Newline方法的典型用法代码示例。如果您正苦于以下问题:C# Cursor.Newline方法的具体用法?C# Cursor.Newline怎么用?C# Cursor.Newline使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cursor
的用法示例。
在下文中一共展示了Cursor.Newline方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IncrementTests
public void IncrementTests()
{
Cursor c = new Cursor();
Assert.AreEqual(0, c.Offset);
Assert.AreEqual(0, c.Line);
Assert.AreEqual(0, c.LinePos);
c++;
Assert.AreEqual(1, c.Offset);
Assert.AreEqual(0, c.Line);
Assert.AreEqual(1, c.LinePos);
c++;
Assert.AreEqual(2, c.Offset);
Assert.AreEqual(0, c.Line);
Assert.AreEqual(2, c.LinePos);
c = c.Newline();
Assert.AreEqual(3, c.Offset);
Assert.AreEqual(1, c.Line);
Assert.AreEqual(0, c.LinePos);
c++;
Assert.AreEqual(4, c.Offset);
Assert.AreEqual(1, c.Line);
Assert.AreEqual(1, c.LinePos);
c = c + 2;
Assert.AreEqual(6, c.Offset);
Assert.AreEqual(1, c.Line);
Assert.AreEqual(3, c.LinePos);
}
示例2: ExpectSkipLineTerminator
/// <summary>
/// Validates that a newline occurs at cursor and advances cursor.
/// </summary>
/// <param name="input">input characters.</param>
/// <param name="cursor">Reference to the cursor.</param>
public static void ExpectSkipLineTerminator(char[] input, ref Cursor cursor)
{
char ch = PeekExpectChar(input, cursor, LineTerminatorChars);
// If we got carriage return, see if there is a linefeed...
if ((ch == '\r')
&& input.Length > (cursor + 1)
&& (input[cursor + 1] == '\n'))
{ // ... there is, skip it too...
cursor = cursor.Newline(2);
}
else
cursor = cursor.Newline();
}