-
Notifications
You must be signed in to change notification settings - Fork 0
/
uSpan.h
129 lines (112 loc) · 3.42 KB
/
uSpan.h
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
//---------------------------------------------------------------------------
#ifndef uSpanH
#define uSpanH
#include "uParser.h"
#include "uStack.h"
#include <wchar.h>
#include <list>
namespace SHEdit
{
class Mark;
class Iter;
//---------------------------------------------------------------------------
/*!
* Span
* ----
* Span represents some text span placed somewhere in buffer. More info can be found in the Buffer class.
* */
struct Span
{
Span(Span * prev, Span * next, wchar_t* string, short length);
Span(Iter * After);
Span(Span * afterword);
Span();
~Span();
Span* prev;
Span* next;
wchar_t* string;
short length;
Stack<Mark> marks;
};
//---------------------------------------------------------------------------
/*!
* NSpan
* -----
* NSpan represents some new line, and creates a linked list of new lines, while taking part in the linked list created of Spans as well. More info can be found in the Buffer class.
*
* Each NSpan holds cached state of parser from beginning of that line.
* */
struct NSpan : Span
{
NSpan(Span* afterword, NSpan* afterline);
NSpan(Iter * After);
NSpan();
~NSpan();
NSpan * nextline;
NSpan * prevline;
/*
std::list<Iter*> ItrList;
void Register(Iter* itr);
void Unregister(Iter* itr);
void Invalidate(Span * from);
void ItersSplit(Span * from, Span * toFirst, Span * toSec, int byPos, bool custoff = false, int tooffset = 0);
void ItersTranslate(Span * from, Span * to, int byPos, int inc = 1);
void ItersTransmitAll(NSpan * to);
void ItersTransmit(Span * from, NSpan * to);
void ItersMove(Span * from, NSpan * to, Span * toword, int offset); */
Parser::ParserState parserState;
//int GetPos();
//whatever
};
//---------------------------------------------------------------------------
/*!
* Range
* ----
* Range represents some range of Spans and NSpans. In fact it holds part of buffer by its ends. More info can be found in the Buffer class.
* */
struct Range
{
Range(Span * first, Span * last, bool empty, NSpan * firstLine, NSpan * lastLine, bool lineempty, int linecount);
~Range();
void Free(); //destructor shall not destroy data it holds, but free shoul
Span* first;
Span* last;
NSpan* firstLine;
NSpan* lastLine;
bool empty;
bool lineempty;
int linecount;
};
//---------------------------------------------------------------------------
/*!
* Action
* ------
* Action holds relative (numeric) description of an edition that was made on buffer. It serves for updating iterators back to their initial state when the edit is being undone. More info can be found in the Buffer class.
* */
struct Action
{
enum ActionType{deletion, insertion};
Action(int fromlinenum, int tolinenum, int frompos, int topos, ActionType type);
~Action();
ActionType type;
int fromlinenum;
int tolinenum;
int frompos;
int topos;
};
//---------------------------------------------------------------------------
/*!
* UndoTask
* --------
* Serves for undo/redo. More info can be found in the Buffer class.
* */
struct UndoTask
{
UndoTask(Action * action, Range * range);
~UndoTask();
Action * action;
Range * range;
};
};
//---------------------------------------------------------------------------
#endif