reslop 0.1.4 → 0.1.6
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/CHANGELOG.md +19 -1
- package/README.md +19 -20
- package/lib/cli.js +20 -16
- package/lib/detect.js +2 -40
- package/lib/diff.js +71 -2
- package/lib/files.js +5 -1
- package/lib/git.js +322 -12
- package/lib/highlight/bash.js +228 -0
- package/lib/highlight/core.js +194 -0
- package/lib/highlight/css.js +76 -0
- package/lib/highlight/csv.js +66 -0
- package/lib/highlight/dart.js +261 -0
- package/lib/highlight/dot.js +54 -0
- package/lib/highlight/html.js +90 -0
- package/lib/highlight/js.js +571 -0
- package/lib/highlight/json.js +54 -0
- package/lib/highlight/log.js +60 -0
- package/lib/highlight/txt.js +41 -0
- package/lib/highlight.js +32 -1299
- package/lib/keys.js +98 -26
- package/lib/render.js +574 -84
- package/lib/review.js +145 -3
- package/lib/select.js +7 -12
- package/lib/session.js +759 -50
- package/lib/sys.js +4 -0
- package/lib/update.js +302 -0
- package/package.json +1 -1
package/lib/keys.js
CHANGED
|
@@ -1,20 +1,76 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const ACTIONS = {
|
|
4
|
-
add:
|
|
5
|
-
unstage:
|
|
6
|
-
revert:
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
feedback:
|
|
12
|
-
todo:
|
|
13
|
-
|
|
4
|
+
add: ['a'],
|
|
5
|
+
unstage: ['u'],
|
|
6
|
+
revert: ['d'],
|
|
7
|
+
commit: ['c'],
|
|
8
|
+
prev: ['left', 'p', 'k'],
|
|
9
|
+
next: ['right', 'n', 'j'],
|
|
10
|
+
layout: ['m'],
|
|
11
|
+
feedback: ['f'],
|
|
12
|
+
todo: ['t'],
|
|
13
|
+
code: ['e'],
|
|
14
|
+
reload: ['r'],
|
|
15
|
+
branch: ['b'],
|
|
16
|
+
pull: ['p'],
|
|
17
|
+
push: ['s'],
|
|
18
|
+
quit: ['q', 'ctrl-c'],
|
|
14
19
|
};
|
|
15
20
|
const ACTION_IDS = Object.keys(ACTIONS);
|
|
16
21
|
|
|
17
|
-
const
|
|
22
|
+
const BRANCH_ACTIONS = {
|
|
23
|
+
newBranch: ['n'],
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const ACTION_HOT = {
|
|
27
|
+
prev: '←',
|
|
28
|
+
next: '→',
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const ACTION_LABEL = {
|
|
32
|
+
revert: 'drop',
|
|
33
|
+
layout: 'mode',
|
|
34
|
+
code: 'edit',
|
|
35
|
+
newBranch: 'new',
|
|
36
|
+
quit: 'q',
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const DIFF_DISABLED = ['reload', 'branch', 'pull', 'push'];
|
|
40
|
+
const FILES_DISABLED = ['layout', 'feedback', 'code'];
|
|
41
|
+
const TODO_DISABLED = [
|
|
42
|
+
'add',
|
|
43
|
+
'unstage',
|
|
44
|
+
'revert',
|
|
45
|
+
'layout',
|
|
46
|
+
'feedback',
|
|
47
|
+
'code',
|
|
48
|
+
'reload',
|
|
49
|
+
'branch',
|
|
50
|
+
'pull',
|
|
51
|
+
'push',
|
|
52
|
+
];
|
|
53
|
+
const BRANCHES_DISABLED = [
|
|
54
|
+
'add',
|
|
55
|
+
'unstage',
|
|
56
|
+
'revert',
|
|
57
|
+
'commit',
|
|
58
|
+
'layout',
|
|
59
|
+
'feedback',
|
|
60
|
+
'todo',
|
|
61
|
+
'code',
|
|
62
|
+
'reload',
|
|
63
|
+
'branch',
|
|
64
|
+
'pull',
|
|
65
|
+
'push',
|
|
66
|
+
];
|
|
67
|
+
|
|
68
|
+
const disabledActions = (pane, item) => {
|
|
69
|
+
if (pane === 'files') return FILES_DISABLED;
|
|
70
|
+
if (pane === 'branches') return BRANCHES_DISABLED;
|
|
71
|
+
if (item && item.origin === 'todo') return TODO_DISABLED;
|
|
72
|
+
return DIFF_DISABLED;
|
|
73
|
+
};
|
|
18
74
|
|
|
19
75
|
const SCROLL = {
|
|
20
76
|
up: 'scrollUp',
|
|
@@ -31,9 +87,20 @@ const SCROLL = {
|
|
|
31
87
|
};
|
|
32
88
|
|
|
33
89
|
const KEY_TO_ACTION = {};
|
|
90
|
+
const PANE_ONLY = ['branch', 'pull', 'push'];
|
|
91
|
+
const FILES_KEYS = {};
|
|
92
|
+
for (const id of PANE_ONLY) {
|
|
93
|
+
for (const key of ACTIONS[id]) FILES_KEYS[key] = id;
|
|
94
|
+
}
|
|
95
|
+
const BRANCH_KEYS = {};
|
|
96
|
+
for (const id of Object.keys(BRANCH_ACTIONS)) {
|
|
97
|
+
for (const key of BRANCH_ACTIONS[id]) BRANCH_KEYS[key] = id;
|
|
98
|
+
}
|
|
99
|
+
const PANE_KEYS = { files: FILES_KEYS, branches: BRANCH_KEYS };
|
|
34
100
|
|
|
35
101
|
for (const id of ACTION_IDS) {
|
|
36
|
-
|
|
102
|
+
if (PANE_ONLY.includes(id)) continue;
|
|
103
|
+
for (const key of ACTIONS[id]) KEY_TO_ACTION[key] = id;
|
|
37
104
|
}
|
|
38
105
|
|
|
39
106
|
for (const key of Object.keys(SCROLL)) KEY_TO_ACTION[key] = SCROLL[key];
|
|
@@ -166,23 +233,23 @@ const decodeChunk = (text, carry = '') => {
|
|
|
166
233
|
return { events, carry: '' };
|
|
167
234
|
};
|
|
168
235
|
|
|
169
|
-
const actionFromKey = (key) =>
|
|
236
|
+
const actionFromKey = (key, pane) => {
|
|
237
|
+
const paneKeys = PANE_KEYS[pane];
|
|
238
|
+
if (paneKeys && paneKeys[key]) return paneKeys[key];
|
|
239
|
+
return KEY_TO_ACTION[key] ?? null;
|
|
240
|
+
};
|
|
170
241
|
|
|
171
|
-
const
|
|
242
|
+
const actionKeys = (id) => ACTIONS[id] ?? BRANCH_ACTIONS[id] ?? [];
|
|
172
243
|
|
|
173
|
-
const
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
if (label.includes(key)) return key;
|
|
179
|
-
}
|
|
180
|
-
return actionHot(action);
|
|
181
|
-
};
|
|
244
|
+
const actionHot = (id) => ACTION_HOT[id] ?? actionKeys(id)[0];
|
|
245
|
+
|
|
246
|
+
const actionLabel = (id) => ACTION_HOT[id] ?? ACTION_LABEL[id] ?? id;
|
|
247
|
+
|
|
248
|
+
const actionLetter = actionHot;
|
|
182
249
|
|
|
183
|
-
const buttonWord = (
|
|
184
|
-
const word = (
|
|
185
|
-
const mark = actionLetter(
|
|
250
|
+
const buttonWord = (id) => {
|
|
251
|
+
const word = actionLabel(id);
|
|
252
|
+
const mark = actionLetter(id);
|
|
186
253
|
if (word.includes(mark)) return word;
|
|
187
254
|
return `${mark}${word}`;
|
|
188
255
|
};
|
|
@@ -197,7 +264,12 @@ const hitAction = (hits, x) => {
|
|
|
197
264
|
module.exports = {
|
|
198
265
|
ACTIONS,
|
|
199
266
|
ACTION_IDS,
|
|
267
|
+
BRANCH_ACTIONS,
|
|
268
|
+
DIFF_DISABLED,
|
|
200
269
|
FILES_DISABLED,
|
|
270
|
+
TODO_DISABLED,
|
|
271
|
+
BRANCHES_DISABLED,
|
|
272
|
+
disabledActions,
|
|
201
273
|
decodeChunk,
|
|
202
274
|
actionFromKey,
|
|
203
275
|
actionHot,
|