📄 textinput.cs
字号:
using System;
using System.Collections.Generic;
using System.Text;
namespace QiHe.CodeLib.Csv
{
public class TextInput : ParserInput<char>
{
string InputText;
List<int> LineBreaks;
public TextInput(string text)
{
InputText = text;
LineBreaks = new List<int>();
LineBreaks.Add(0);
for (int index = 0; index < InputText.Length; index++)
{
if (InputText[index] == '\n')
{
LineBreaks.Add(index);
}
}
}
#region ParserInput<char> Members
public bool HasInput(int pos)
{
return pos < InputText.Length;
}
public char GetInputSymbol(int pos)
{
return InputText[pos];
}
public string GetSubString(int start, int length)
{
return InputText.Substring(start, length);
}
public string LocateError(int position, string message)
{
int line;
int col = 1;
for (line = 1; line < LineBreaks.Count; line++)
{
if (LineBreaks[line] > position)
{
col = position - LineBreaks[line - 1];
break;
}
}
string ch = HasInput(position) ? " '" + GetInputSymbol(position) + "'" : null;
return String.Format("Line {0}, Col {1}: {2}{3}", line, col, message, ch);
}
#endregion
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -