-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.ts
More file actions
87 lines (75 loc) · 1.85 KB
/
Copy pathtypes.ts
File metadata and controls
87 lines (75 loc) · 1.85 KB
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
export enum Commands {
CREATE = "create",
}
export type State = {
text: string;
focusedField: number;
isFile: boolean;
prefix: boolean;
cursorPosition: number;
};
export type SearchState = {
selectedIndex: number;
query: string;
cursorPosition: number;
items: StashItem[];
};
export type StashItem = {
name: string;
type: "file" | "directory";
path: string;
mtime: Date;
size: number;
matchedIndices: Array<number>;
score: number;
};
export const ANSI = {
bold: "\x1b[1m",
green: "\x1b[32m",
red: "\x1b[31m",
cyan: "\x1b[36m",
reset: "\x1b[0m",
dim: "\x1b[2m",
inverse: "\x1b[7m",
cursorHome: "\x1b[H", // shorthand for \x1b[0;0H. We omit 0;0 and default to 1;1 cursor row;col terminal position
cursorHide: "\x1b[?25l",
cursorShow: "\x1b[?25h",
clearScreen: "\x1b[2J",
// keys
escape: "\x1b",
enter: "\r",
tab: "\t",
backspace: "\x7f",
backspaceAlt: "\x08",
arrowDown: "\x1b[B",
arrowUp: "\x1b[A",
arrowLeft: "\x1b[D",
arrowRight: "\x1b[C",
space: " ",
// Home and End keys to move cursor to beginning and end of line
home: "\x1b[H", // same code as cursorHome but different purpose depending on context
homeAlt: "\x1bOH",
home2: "\x1b[1~",
end: "\x1b[F",
endAlt: "\x1bOF",
end2: "\x1b[4~",
// Option + arrow keys to move cursor by word left and right
optionLeft: "\x1bb",
optionRight: "\x1bf",
optionLeftAlt: "\x1b[1;3D",
optionRightAlt: "\x1b[1;3C",
// Cmd + arrow keys to move cursor by line left and right
cmdLeft: "\x1b[1;9D",
cmdRight: "\x1b[1;9C",
// Ctrl+A / Ctrl+E (readline style, sent by macOS Terminal for Cmd+arrows)
ctrlA: "\x01",
ctrlE: "\x05",
// Ctrl + D
ctrlD: "\x04",
// Ctrl + arrow keys to move cursor by word left and right on Windows/Linux
ctrlLeft: "\x1b[1;5D",
ctrlRight: "\x1b[1;5C",
};
export type Config = {
stashDir: string;
};