-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBuffer.cs
68 lines (56 loc) · 1.5 KB
/
Buffer.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
using System.Collections.Generic;
using System.IO;
namespace TextEditor
{
public class Buffer
{
string Filename;
List<Line> LineList;
List<Position> PositionList;
public Buffer(string filename = "")
{
Filename = filename;
LineList = new List<Line>();
PositionList = new List<Position>();
LineList.Add(new Line());
PositionList.Add(new Position());
}
public Line GetLineAt(int index)
{
if ((index > 0) && (index < LineList.Count()))
{
return LineList[index];
}
else
{
return LineList.Last();
}
}
// public Line[] GetLines(int start = 0, int end = 1)
// {
// Line[] lines = {new Line()};
// end = Math.Min(end, LineList.Count());
// start = Math.Max(start, 0);
// start = Math.Min(start, end);
// for (int i = start; i < end; i++)
// {
// lines[i] = GetLineAt(i);
// }
// return lines;
// }
public Position GetActivePosition()
{
return PositionList.First();
}
public int GetLineCount()
{
return LineList.Count();
}
public Line AddLine(string text)
{
Line l = new Line(text);
LineList.Add(l);
return l;
}
}
}