@mak-98/dirvi-cli 0.3.2 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/application/action.d.ts +25 -18
- package/dist/application/dir-buffer-helpers.d.ts +5 -2
- package/dist/application/dir-buffer-helpers.js +17 -17
- package/dist/application/display-rows.d.ts +10 -3
- package/dist/application/display-rows.d.ts.map +1 -1
- package/dist/application/display-rows.js +54 -41
- package/dist/application/effect-to-action.d.ts +7 -4
- package/dist/application/effect-to-action.d.ts.map +1 -1
- package/dist/application/effect-to-action.js +84 -75
- package/dist/application/fold-helpers.d.ts +22 -6
- package/dist/application/fold-helpers.js +36 -32
- package/dist/application/intent-to-effect.d.ts +57 -37
- package/dist/application/intent-to-effect.d.ts.map +1 -1
- package/dist/application/intent-to-effect.js +116 -103
- package/dist/application/reducer-action.d.ts +22 -18
- package/dist/application/reducer.d.ts +1 -1
- package/dist/application/reducer.d.ts.map +1 -1
- package/dist/application/reducer.js +40 -28
- package/dist/application/user-input-to-intent.d.ts +38 -14
- package/dist/application/user-input-to-intent.d.ts.map +1 -1
- package/dist/application/user-input-to-intent.js +103 -49
- package/dist/domain/event-message.d.ts +14 -11
- package/dist/domain/print-message.d.ts +10 -8
- package/dist/index.d.ts +1 -1
- package/dist/index.js +35 -30
- package/dist/infrastructure/ink-input-to-user-input.d.ts +7 -0
- package/dist/infrastructure/ink-input-to-user-input.d.ts.map +1 -0
- package/dist/infrastructure/ink-input-to-user-input.js +45 -0
- package/dist/infrastructure/input.d.ts +7 -2
- package/dist/infrastructure/input.js +71 -71
- package/dist/infrastructure/load-initial-props.d.ts +1 -1
- package/dist/infrastructure/load-initial-props.d.ts.map +1 -1
- package/dist/infrastructure/load-initial-props.js +32 -25
- package/dist/infrastructure/user-input.d.ts +31 -16
- package/dist/infrastructure/user-input.d.ts.map +1 -1
- package/dist/infrastructure/user-input.js +42 -32
- package/dist/ui/App.d.ts +11 -6
- package/dist/ui/App.d.ts.map +1 -1
- package/dist/ui/App.js +127 -89
- package/dist/ui/App2.d.ts +11 -6
- package/dist/ui/App2.js +95 -84
- package/dist/ui/AppShell.d.ts +12 -7
- package/dist/ui/AppShell.js +11 -6
- package/dist/ui/components/DirEntries.d.ts +8 -5
- package/dist/ui/components/DirEntries.js +56 -31
- package/dist/ui/components/StatusBar.d.ts +10 -0
- package/dist/ui/components/StatusBar.d.ts.map +1 -0
- package/dist/ui/components/StatusBar.js +32 -0
- package/dist/ui/components/UnixEntry.d.ts +8 -5
- package/dist/ui/components/UnixEntry.js +17 -10
- package/dist/ui/components/UnixEntryComponent.d.ts +8 -5
- package/dist/ui/components/UnixEntryComponent.js +17 -10
- package/dist/ui/components/ViewRowComponent.d.ts +6 -4
- package/dist/ui/components/ViewRowComponent.js +30 -10
- package/dist/ui/hooks/useView.d.ts +6 -2
- package/dist/ui/hooks/useView.d.ts.map +1 -1
- package/dist/ui/hooks/useView.js +30 -22
- package/dist/ui/view.d.ts +15 -10
- package/dist/ui/view.d.ts.map +1 -1
- package/dist/ui/view.js +63 -59
- package/package.json +3 -2
|
@@ -1,118 +1,131 @@
|
|
|
1
1
|
import { Cursor, View } from 'dirvi-lib';
|
|
2
2
|
function dispatchAction(action) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
return {
|
|
4
|
+
effectType: 'dispatchEffectAsAction',
|
|
5
|
+
action,
|
|
6
|
+
};
|
|
7
7
|
}
|
|
8
8
|
function interactRightToEffect(state) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
return undefined;
|
|
16
|
-
}
|
|
17
|
-
if (currentEntry.kind === 'directory') {
|
|
18
|
-
if (currentEntry.entries === undefined) {
|
|
19
|
-
return {
|
|
20
|
-
effectType: 'loadDir',
|
|
21
|
-
path,
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
25
|
-
return dispatchAction({
|
|
26
|
-
kind: 'updateDir',
|
|
27
|
-
path,
|
|
28
|
-
entries: undefined,
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
if (currentEntry.kind === 'file') {
|
|
33
|
-
return {
|
|
34
|
-
effectType: 'printFile',
|
|
35
|
-
path,
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
// TODO Later: Peeking on folds
|
|
9
|
+
const currentEntry = View.getEntryAtCursor(state);
|
|
10
|
+
if (currentEntry === undefined) {
|
|
11
|
+
return undefined;
|
|
12
|
+
}
|
|
13
|
+
const path = Cursor.getPath(state.cursor);
|
|
14
|
+
if (path === undefined) {
|
|
39
15
|
return undefined;
|
|
16
|
+
}
|
|
17
|
+
if (currentEntry.kind === 'directory') {
|
|
18
|
+
if (currentEntry.entries === undefined) {
|
|
19
|
+
return {
|
|
20
|
+
effectType: 'loadDir',
|
|
21
|
+
path,
|
|
22
|
+
};
|
|
23
|
+
} else {
|
|
24
|
+
return dispatchAction({
|
|
25
|
+
kind: 'updateDir',
|
|
26
|
+
path,
|
|
27
|
+
entries: undefined,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
if (currentEntry.kind === 'file') {
|
|
32
|
+
return {
|
|
33
|
+
effectType: 'printFile',
|
|
34
|
+
path,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
// TODO Later: Peeking on folds
|
|
38
|
+
return undefined;
|
|
40
39
|
}
|
|
41
40
|
function interactLeftToEffect(state) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
41
|
+
if (state.cursor.parentPath.length === 0) {
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
44
|
+
return dispatchAction({
|
|
45
|
+
kind: 'outDir',
|
|
46
|
+
});
|
|
48
47
|
}
|
|
49
48
|
// Here if the updated command buffer reaches a recognized motion,
|
|
50
49
|
// sends the effect.
|
|
51
50
|
function commandBufferToEffectResult(updatedCommandBuffer) {
|
|
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
|
-
}
|
|
51
|
+
switch (updatedCommandBuffer) {
|
|
52
|
+
case 'q':
|
|
53
|
+
return {
|
|
54
|
+
effectType: 'exit',
|
|
55
|
+
exitMessage: '',
|
|
56
|
+
};
|
|
57
|
+
case 'z':
|
|
58
|
+
return {
|
|
59
|
+
effectType: 'changeInput',
|
|
60
|
+
inputMode: 'normal',
|
|
61
|
+
commandBuffer: updatedCommandBuffer,
|
|
62
|
+
commandLine: '',
|
|
63
|
+
};
|
|
64
|
+
case 'za':
|
|
65
|
+
return dispatchAction({
|
|
66
|
+
kind: 'toggleFold',
|
|
67
|
+
});
|
|
68
|
+
case 'zc':
|
|
69
|
+
return dispatchAction({
|
|
70
|
+
kind: 'fold',
|
|
71
|
+
});
|
|
72
|
+
case 'zo':
|
|
73
|
+
return dispatchAction({
|
|
74
|
+
kind: 'unfold',
|
|
75
|
+
});
|
|
76
|
+
default:
|
|
77
|
+
return {
|
|
78
|
+
effectType: 'changeInput',
|
|
79
|
+
inputMode: 'normal',
|
|
80
|
+
commandBuffer: '',
|
|
81
|
+
commandLine: '',
|
|
82
|
+
};
|
|
83
|
+
}
|
|
87
84
|
}
|
|
88
85
|
// Effect derived from Intent and the state.
|
|
89
86
|
export function intentToEffect(intent, state) {
|
|
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
|
-
|
|
87
|
+
switch (intent.intentType) {
|
|
88
|
+
case 'setNormalBuffer':
|
|
89
|
+
return commandBufferToEffectResult(intent.commandBuffer);
|
|
90
|
+
case 'interactRight':
|
|
91
|
+
return interactRightToEffect(state);
|
|
92
|
+
case 'interactLeft':
|
|
93
|
+
return interactLeftToEffect(state);
|
|
94
|
+
case 'interactDown':
|
|
95
|
+
return dispatchAction({
|
|
96
|
+
kind: 'nextEntry',
|
|
97
|
+
});
|
|
98
|
+
case 'interactUp':
|
|
99
|
+
return dispatchAction({
|
|
100
|
+
kind: 'prevEntry',
|
|
101
|
+
});
|
|
102
|
+
case 'enterCommandLineMode':
|
|
103
|
+
return {
|
|
104
|
+
effectType: 'changeInput',
|
|
105
|
+
inputMode: 'command',
|
|
106
|
+
commandBuffer: '',
|
|
107
|
+
commandLine: ':',
|
|
108
|
+
};
|
|
109
|
+
case 'setCommandLine':
|
|
110
|
+
return {
|
|
111
|
+
effectType: 'changeInput',
|
|
112
|
+
inputMode: 'command',
|
|
113
|
+
commandBuffer: '',
|
|
114
|
+
commandLine: intent.commandLine,
|
|
115
|
+
};
|
|
116
|
+
case 'exitCommandLineMode':
|
|
117
|
+
return {
|
|
118
|
+
effectType: 'changeInput',
|
|
119
|
+
inputMode: 'normal',
|
|
120
|
+
commandBuffer: '',
|
|
121
|
+
commandLine: '',
|
|
122
|
+
};
|
|
123
|
+
case 'executeCommandLine':
|
|
124
|
+
return {
|
|
125
|
+
effectType: 'changeInput',
|
|
126
|
+
inputMode: 'normal',
|
|
127
|
+
commandBuffer: '',
|
|
128
|
+
commandLine: '',
|
|
129
|
+
};
|
|
130
|
+
}
|
|
118
131
|
}
|
|
@@ -1,19 +1,23 @@
|
|
|
1
1
|
import { Cursor, UnixEntry, UnixEntryPath } from 'dirvi-lib';
|
|
2
|
-
export type ReducerAction =
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
2
|
+
export type ReducerAction =
|
|
3
|
+
| {
|
|
4
|
+
kind: 'changeCursor';
|
|
5
|
+
cursor: Cursor;
|
|
6
|
+
}
|
|
7
|
+
| {
|
|
8
|
+
kind: 'updateDir';
|
|
9
|
+
path: UnixEntryPath;
|
|
10
|
+
entries: UnixEntry[] | undefined;
|
|
11
|
+
}
|
|
12
|
+
| {
|
|
13
|
+
kind: 'fold';
|
|
14
|
+
parentPath: UnixEntryPath;
|
|
15
|
+
entry: UnixEntry;
|
|
16
|
+
cursor: Cursor;
|
|
17
|
+
}
|
|
18
|
+
| {
|
|
19
|
+
kind: 'unfold';
|
|
20
|
+
parentPath: UnixEntryPath;
|
|
21
|
+
cursor: Cursor;
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=reducer-action.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reducer.d.ts","sourceRoot":"","sources":["../../src/application/reducer.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"reducer.d.ts","sourceRoot":"","sources":["../../src/application/reducer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,KAAK,EAAY,MAAM,WAAW,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,wBAAgB,OAAO,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,aAAa,GAAG,KAAK,CA8ClE"}
|
|
@@ -1,31 +1,43 @@
|
|
|
1
|
-
import { UnixEntry, FoldNode
|
|
1
|
+
import { UnixEntry, FoldNode } from 'dirvi-lib';
|
|
2
2
|
export function reducer(state, action) {
|
|
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
|
-
}
|
|
3
|
+
switch (action.kind) {
|
|
4
|
+
case 'changeCursor':
|
|
5
|
+
return {
|
|
6
|
+
...state,
|
|
7
|
+
cursor: action.cursor,
|
|
8
|
+
};
|
|
9
|
+
case 'updateDir':
|
|
10
|
+
return {
|
|
11
|
+
...state,
|
|
12
|
+
buffer: UnixEntry.setEntriesAtPath(
|
|
13
|
+
state.buffer,
|
|
14
|
+
action.path,
|
|
15
|
+
action.entries,
|
|
16
|
+
),
|
|
17
|
+
};
|
|
18
|
+
case 'fold': {
|
|
19
|
+
const folds = FoldNode.addFoldedEntryAtPath(
|
|
20
|
+
state.folds,
|
|
21
|
+
action.parentPath,
|
|
22
|
+
action.entry,
|
|
23
|
+
);
|
|
24
|
+
return {
|
|
25
|
+
...state,
|
|
26
|
+
folds,
|
|
27
|
+
cursor: action.cursor,
|
|
28
|
+
};
|
|
30
29
|
}
|
|
30
|
+
case 'unfold': {
|
|
31
|
+
const folds = FoldNode.modifyAtPath(
|
|
32
|
+
state.folds,
|
|
33
|
+
action.parentPath,
|
|
34
|
+
(node) => FoldNode.clearFoldedEntries(node),
|
|
35
|
+
);
|
|
36
|
+
return {
|
|
37
|
+
...state,
|
|
38
|
+
folds,
|
|
39
|
+
cursor: action.cursor,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
}
|
|
31
43
|
}
|
|
@@ -1,15 +1,39 @@
|
|
|
1
1
|
import { UserInput } from '../infrastructure/user-input.js';
|
|
2
|
-
export type
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
2
|
+
export type InputMode = 'normal' | 'command';
|
|
3
|
+
export type Intent =
|
|
4
|
+
| {
|
|
5
|
+
intentType: 'interactRight';
|
|
6
|
+
}
|
|
7
|
+
| {
|
|
8
|
+
intentType: 'interactLeft';
|
|
9
|
+
}
|
|
10
|
+
| {
|
|
11
|
+
intentType: 'interactDown';
|
|
12
|
+
}
|
|
13
|
+
| {
|
|
14
|
+
intentType: 'interactUp';
|
|
15
|
+
}
|
|
16
|
+
| {
|
|
17
|
+
intentType: 'setNormalBuffer';
|
|
18
|
+
commandBuffer: string;
|
|
19
|
+
}
|
|
20
|
+
| {
|
|
21
|
+
intentType: 'enterCommandLineMode';
|
|
22
|
+
}
|
|
23
|
+
| {
|
|
24
|
+
intentType: 'setCommandLine';
|
|
25
|
+
commandLine: string;
|
|
26
|
+
}
|
|
27
|
+
| {
|
|
28
|
+
intentType: 'executeCommandLine';
|
|
29
|
+
}
|
|
30
|
+
| {
|
|
31
|
+
intentType: 'exitCommandLineMode';
|
|
32
|
+
};
|
|
33
|
+
export declare function userInputToIntent(
|
|
34
|
+
userInput: UserInput,
|
|
35
|
+
inputMode: InputMode,
|
|
36
|
+
normalBuffer: string,
|
|
37
|
+
commandLine: string,
|
|
38
|
+
): Intent | undefined;
|
|
39
|
+
//# sourceMappingURL=user-input-to-intent.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user-input-to-intent.d.ts","sourceRoot":"","sources":["../../src/application/user-input-to-intent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAE5D,MAAM,MAAM,MAAM,GACd;IACE,UAAU,EAAE,eAAe,CAAC;CAC7B,GACD;IACE,UAAU,EAAE,cAAc,CAAC;CAC5B,GACD;IACE,UAAU,EAAE,cAAc,CAAC;CAC5B,GACD;IACE,UAAU,EAAE,YAAY,CAAC;CAC1B,GACD;IACE,UAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"user-input-to-intent.d.ts","sourceRoot":"","sources":["../../src/application/user-input-to-intent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAE5D,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,SAAS,CAAC;AAE7C,MAAM,MAAM,MAAM,GACd;IACE,UAAU,EAAE,eAAe,CAAC;CAC7B,GACD;IACE,UAAU,EAAE,cAAc,CAAC;CAC5B,GACD;IACE,UAAU,EAAE,cAAc,CAAC;CAC5B,GACD;IACE,UAAU,EAAE,YAAY,CAAC;CAC1B,GACD;IACE,UAAU,EAAE,iBAAiB,CAAC;IAC9B,aAAa,EAAE,MAAM,CAAC;CACvB,GACD;IACE,UAAU,EAAE,sBAAsB,CAAC;CACpC,GACD;IACE,UAAU,EAAE,gBAAgB,CAAC;IAC7B,WAAW,EAAE,MAAM,CAAC;CACrB,GACD;IACE,UAAU,EAAE,oBAAoB,CAAC;CAClC,GACD;IACE,UAAU,EAAE,qBAAqB,CAAC;CACnC,CAAC;AAGN,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,SAAS,EACpB,SAAS,EAAE,SAAS,EACpB,YAAY,EAAE,MAAM,EACpB,WAAW,EAAE,MAAM,GAClB,MAAM,GAAG,SAAS,CAUpB"}
|
|
@@ -1,56 +1,110 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
intentType: 'interactUp',
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
}
|
|
1
|
+
// Derive the intent from the user input, the input mode, and the input buffers.
|
|
2
|
+
export function userInputToIntent(
|
|
3
|
+
userInput,
|
|
4
|
+
inputMode,
|
|
5
|
+
normalBuffer,
|
|
6
|
+
commandLine,
|
|
7
|
+
) {
|
|
8
|
+
if (inputMode === 'normal') {
|
|
9
|
+
normalUserInputToIntent(userInput, normalBuffer);
|
|
10
|
+
}
|
|
11
|
+
if (inputMode === 'command') {
|
|
12
|
+
commandUserInputToIntent(userInput, commandLine);
|
|
13
|
+
}
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
16
|
+
function normalUserInputToIntent(userInput, normalBuffer) {
|
|
17
|
+
if (userInput.userInputType === 'esc') {
|
|
22
18
|
return {
|
|
23
|
-
|
|
24
|
-
|
|
19
|
+
intentType: 'setNormalBuffer',
|
|
20
|
+
commandBuffer: '',
|
|
25
21
|
};
|
|
22
|
+
}
|
|
23
|
+
if (userInput.userInputType === 'character') {
|
|
24
|
+
return normalCharacterToIntent(userInput.string, normalBuffer);
|
|
25
|
+
}
|
|
26
|
+
switch (userInput.userInputType) {
|
|
27
|
+
case 'rightArrow':
|
|
28
|
+
return {
|
|
29
|
+
intentType: 'interactRight',
|
|
30
|
+
};
|
|
31
|
+
case 'leftArrow':
|
|
32
|
+
return {
|
|
33
|
+
intentType: 'interactLeft',
|
|
34
|
+
};
|
|
35
|
+
case 'downArrow':
|
|
36
|
+
return {
|
|
37
|
+
intentType: 'interactDown',
|
|
38
|
+
};
|
|
39
|
+
case 'upArrow':
|
|
40
|
+
return {
|
|
41
|
+
intentType: 'interactUp',
|
|
42
|
+
};
|
|
43
|
+
}
|
|
26
44
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
45
|
+
function normalCharacterToIntent(character, commandBuffer) {
|
|
46
|
+
if (commandBuffer === '') {
|
|
47
|
+
switch (character) {
|
|
48
|
+
case 'l':
|
|
30
49
|
return {
|
|
31
|
-
|
|
32
|
-
|
|
50
|
+
intentType: 'interactRight',
|
|
51
|
+
};
|
|
52
|
+
case 'h':
|
|
53
|
+
return {
|
|
54
|
+
intentType: 'interactLeft',
|
|
55
|
+
};
|
|
56
|
+
case 'j':
|
|
57
|
+
return {
|
|
58
|
+
intentType: 'interactDown',
|
|
59
|
+
};
|
|
60
|
+
case 'k':
|
|
61
|
+
return {
|
|
62
|
+
intentType: 'interactUp',
|
|
63
|
+
};
|
|
64
|
+
case ':':
|
|
65
|
+
return {
|
|
66
|
+
intentType: 'enterCommandLineMode',
|
|
33
67
|
};
|
|
34
68
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
69
|
+
}
|
|
70
|
+
return {
|
|
71
|
+
intentType: 'setNormalBuffer',
|
|
72
|
+
commandBuffer: commandBuffer + character,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
function commandUserInputToIntent(userInput, commandLine) {
|
|
76
|
+
if (userInput.userInputType === 'esc') {
|
|
77
|
+
return {
|
|
78
|
+
intentType: 'exitCommandLineMode',
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
if (userInput.userInputType === 'enter') {
|
|
82
|
+
return {
|
|
83
|
+
intentType: 'executeCommandLine',
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
if (userInput.userInputType === 'character') {
|
|
87
|
+
return {
|
|
88
|
+
intentType: 'setCommandLine',
|
|
89
|
+
commandLine: commandLine + userInput.string,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
switch (userInput.userInputType) {
|
|
93
|
+
case 'rightArrow':
|
|
94
|
+
return {
|
|
95
|
+
intentType: 'interactRight',
|
|
96
|
+
};
|
|
97
|
+
case 'leftArrow':
|
|
98
|
+
return {
|
|
99
|
+
intentType: 'interactLeft',
|
|
100
|
+
};
|
|
101
|
+
case 'downArrow':
|
|
102
|
+
return {
|
|
103
|
+
intentType: 'interactDown',
|
|
104
|
+
};
|
|
105
|
+
case 'upArrow':
|
|
106
|
+
return {
|
|
107
|
+
intentType: 'interactUp',
|
|
108
|
+
};
|
|
109
|
+
}
|
|
56
110
|
}
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { UnixEntryPath, State } from 'dirvi-lib';
|
|
2
|
-
export type EventMessage =
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
2
|
+
export type EventMessage =
|
|
3
|
+
| {
|
|
4
|
+
type: 'view';
|
|
5
|
+
view: State;
|
|
6
|
+
}
|
|
7
|
+
| {
|
|
8
|
+
type: 'displayed-files-paths';
|
|
9
|
+
paths: string[];
|
|
10
|
+
}
|
|
11
|
+
| {
|
|
12
|
+
type: 'file';
|
|
13
|
+
path: UnixEntryPath;
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=event-message.d.ts.map
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { EntryPath, View } from 'dirvi-lib';
|
|
2
|
-
export type PrintMessage =
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
export type PrintMessage =
|
|
3
|
+
| {
|
|
4
|
+
type: 'view';
|
|
5
|
+
view: View;
|
|
6
|
+
}
|
|
7
|
+
| {
|
|
8
|
+
type: 'file';
|
|
9
|
+
path: EntryPath;
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=print-message.d.ts.map
|
package/dist/index.d.ts
CHANGED