This repository has been archived by the owner on Jun 8, 2019. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 19
/
normal_mode.js
56 lines (47 loc) · 1.56 KB
/
normal_mode.js
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
(function () {
var U = Vimulator.Utils;
Vimulator.NormalMode = function (vim) {
this.name = "normal";
this.vim = vim;
this.buildOperation();
};
Vimulator.NormalMode.prototype.enter = function () {
};
Vimulator.NormalMode.prototype.buildOperation = function () {
this.currentOperation = new Vimulator.Operation(this.commandList());
};
Vimulator.NormalMode.prototype.cancelOperation = function () {
this.currentOperation.cancel();
this.buildOperation();
};
Vimulator.NormalMode.prototype.commandList = function () {
this.commands = this.commands || new Vimulator.CommandList(
Vimulator.NormalMode.Motions,
Vimulator.NormalMode.Insertion,
Vimulator.NormalMode.Edits,
Vimulator.NormalMode.LineSearch,
Vimulator.NormalMode.Operators,
Vimulator.NormalMode.Repeat,
Vimulator.NormalMode.Marks,
Vimulator.NormalMode.MarkMotions,
Vimulator.NormalMode.Search,
Vimulator.NormalMode.Yank
);
return this.commands;
};
Vimulator.NormalMode.prototype.keyPress = function (key) {
var op = this.currentOperation;
if (key === U.Keys.ESC) {
this.cancelOperation();
} else {
op.keyPress(key);
if (op.complete()) {
op.execute(this.vim);
}
if (op.complete() || op.cancelled) {
this.buildOperation();
}
}
return op;
};
}());