-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path16mark.c
119 lines (90 loc) · 2.79 KB
/
16mark.c
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
#include "common.h"
ViWin*% ViWin*::initialize(ViWin*% self, int y, int x, int width, int height, Vi* vi) version 16
{
auto result = inherit(self, y, x, width, height, vi);
result.mark = new map<wchar_t, tuple3<int,int, int>*%>.initialize();
return result;
}
void ViWin*::markAtCurrentPoint(ViWin* self, wchar_t c)
{
auto point = new tuple3<int, int, int>;
point.v1 = self.scroll;
point.v2 = self.cursorY;
point.v3 = self.cursorX;
self.mark.insert(c, point);
}
void ViWin*::returnAtMarkedPoint(ViWin* self, wchar_t c)
{
auto point = self.mark.at(c, null);
if(point != null) {
self.saveReturnPoint();
self.scroll = point.v1;
self.cursorY = point.v2;
self.cursorX = point.v3;
self.modifyUnderCursorYValue();
self.modifyOverCursorYValue();
self.modifyOverCursorXValue();
}
}
void ViWin*::returnBack(ViWin* self)
{
auto point = self.returnPoint;
if(point != null) {
int cursor_y = self.cursorY;
int cursor_x = self.cursorX;
int scroll = self.scroll;
self.cursorY = point.v1;
self.cursorX = point.v2;
self.scroll = point.v3;
self.modifyUnderCursorYValue();
self.modifyOverCursorYValue();
self.modifyOverCursorXValue();
auto return_point = new tuple3<int,int,int>;
return_point.v1 = cursor_y;
return_point.v2 = cursor_x;
return_point.v3 = scroll;
self.returnPoint = return_point;
}
}
void ViWin*::returnBackOfStack(ViWin* self)
{
auto point = self.returnPointStack.item(-1, null);
if(point != null) {
self.cursorY = point.v1;
self.cursorX = point.v2;
self.scroll = point.v3;
self.modifyUnderCursorYValue();
self.modifyOverCursorYValue();
self.modifyOverCursorXValue();
self.returnPointStack.delete(-1, -1);
}
}
Vi*% Vi*::initialize(Vi*% self) version 16
{
auto result = inherit(self);
result.events.replace('.', void lambda(Vi* self, int key)
{
self.activeWin.autoInput = true;
self.activeWin.pressedDot = true;
});
result.events.replace('m', void lambda(Vi* self, int key)
{
auto key2 = self.activeWin.getKey(false);
self.activeWin.markAtCurrentPoint(key2);
});
result.events.replace('O'-'A'+1, void lambda(Vi* self, int key)
{
self.activeWin.returnBackOfStack();
});
result.events.replace('`', void lambda(Vi* self, int key)
{
auto key2 = self.activeWin.getKey(false);
if(key2 == '`') {
self.activeWin.returnBack();
}
else {
self.activeWin.returnAtMarkedPoint(key2);
}
});
return result;
}