-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Copy pathmode.ts
79 lines (69 loc) · 1.95 KB
/
mode.ts
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
import * as vscode from 'vscode';
import { VimState } from '../state/vimState';
export enum ModeName {
Normal,
Insert,
Visual,
VisualBlock,
VisualLine,
SearchInProgressMode,
CommandlineInProgress,
Replace,
EasyMotionMode,
EasyMotionInputMode,
SurroundInputMode,
Disabled,
}
export enum VSCodeVimCursorType {
Block,
Line,
LineThin,
Underline,
TextDecoration,
Native,
}
export abstract class Mode {
public readonly name: ModeName;
public readonly cursorType: VSCodeVimCursorType;
public readonly isVisualMode: boolean;
private readonly _statusBarText: string;
private static readonly _cursorMap = new Map([
[VSCodeVimCursorType.Block, vscode.TextEditorCursorStyle.Block],
[VSCodeVimCursorType.Line, vscode.TextEditorCursorStyle.Line],
[VSCodeVimCursorType.LineThin, vscode.TextEditorCursorStyle.LineThin],
[VSCodeVimCursorType.Underline, vscode.TextEditorCursorStyle.Underline],
[VSCodeVimCursorType.TextDecoration, vscode.TextEditorCursorStyle.LineThin],
[VSCodeVimCursorType.Native, vscode.TextEditorCursorStyle.Block],
]);
private _isActive: boolean;
constructor(
name: ModeName,
statusBarText: string,
cursorType: VSCodeVimCursorType,
isVisualMode: boolean = false
) {
this.name = name;
this.cursorType = cursorType;
this.isVisualMode = isVisualMode;
this._statusBarText = statusBarText;
this._isActive = false;
}
get friendlyName(): string {
return ModeName[this.name];
}
get isActive(): boolean {
return this._isActive;
}
set isActive(val: boolean) {
this._isActive = val;
}
getStatusBarText(vimState: VimState): string {
return this._statusBarText.toLocaleUpperCase();
}
getStatusBarCommandText(vimState: VimState): string {
return vimState.recordedState.commandString;
}
public static translateCursor(cursorType: VSCodeVimCursorType) {
return this._cursorMap.get(cursorType) as vscode.TextEditorCursorStyle;
}
}