-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathLineWriter.cs
More file actions
48 lines (42 loc) · 1.08 KB
/
LineWriter.cs
File metadata and controls
48 lines (42 loc) · 1.08 KB
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
using System.Collections.Generic;
using System.IO;
using System.Text;
namespace GLGUI.GLControlExample
{
public class LineWriter : TextWriter
{
public List<string> Lines;
public bool Changed = false;
private StringBuilder currentLine;
public LineWriter()
{
this.Lines = new List<string>(1024);
this.currentLine = new StringBuilder(256);
}
public override void Write(char value)
{
if (value == '\n')
Flush();
else
currentLine.Append(value);
}
public override void Flush()
{
Lines.Add(currentLine.ToString());
if (Lines.Count > 1024)
Lines.RemoveAt(0);
currentLine.Clear();
Changed = true;
}
public override Encoding Encoding
{
get { return System.Text.Encoding.UTF8; }
}
public void Clear()
{
Lines.Clear();
currentLine.Clear();
Changed = true;
}
}
}