forked from DebugST/STTextBox
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTextHistory.cs
More file actions
49 lines (43 loc) · 1.22 KB
/
TextHistory.cs
File metadata and controls
49 lines (43 loc) · 1.22 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
49
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ST.Library.UI.STTextBox
{
public class TextHistory : ITextHistory
{
private int m_nIndex;
private int m_nCount;
private int m_nMax;
private TextHistoryRecord[][] m_arr;
public TextHistory(int nCount) {
m_nMax = nCount;
m_arr = new TextHistoryRecord[nCount][];
}
public void SetHistory(TextHistoryRecord[] histories) {
if (m_nIndex == m_nMax) {
for (int i = 1; i < m_arr.Length; i++) {
m_arr[i - 1] = m_arr[i];
}
m_nIndex--;
}
m_arr[m_nIndex++] = histories;
m_nCount = m_nIndex;
}
public TextHistoryRecord[] GetUndo() {
if (m_nIndex == 0) { //not have history
return null;
}
return m_arr[--m_nIndex];
}
public TextHistoryRecord[] GetRedo() {
if (m_nIndex == m_nCount) {
return null;
}
return m_arr[m_nIndex++];
}
public void Clear() {
m_nIndex = m_nCount = 0;
}
}
}