@@ -2,6 +2,7 @@ import { mapValues, pickBy } from "lodash";
22import { KeyMap , SectionName , TokenType } from "./TokenTypeHelpers" ;
33import { SectionTypes , TokenTypeValueMap } from "./TokenTypes" ;
44import { VscodeApi } from "@cursorless/vscode-common" ;
5+ import { TextEditorCursorStyle } from "vscode" ;
56
67const LEGACY_PLURAL_SECTION_NAMES : Record < string , string > = {
78 action : "actions" ,
@@ -11,9 +12,34 @@ const LEGACY_PLURAL_SECTION_NAMES: Record<string, string> = {
1112 scope : "scopes" ,
1213} ;
1314
15+ /**
16+ * Maps from the raw cursor style config value to the corresponding
17+ * TextEditorCursorStyle enum value.
18+ */
19+ const cursorStyleMap = {
20+ line : TextEditorCursorStyle . Line ,
21+ block : TextEditorCursorStyle . Block ,
22+ underline : TextEditorCursorStyle . Underline ,
23+ [ "line-thin" ] : TextEditorCursorStyle . LineThin ,
24+ [ "block-outline" ] : TextEditorCursorStyle . BlockOutline ,
25+ [ "underline-thin" ] : TextEditorCursorStyle . UnderlineThin ,
26+ } satisfies Record < string , TextEditorCursorStyle > ;
27+
1428export class KeyboardConfig {
1529 constructor ( private vscodeApi : VscodeApi ) { }
1630
31+ getCursorStyle ( ) : TextEditorCursorStyle {
32+ const rawCursorStyle = this . vscodeApi . workspace
33+ . getConfiguration ( "cursorless.experimental.keyboard.modal" )
34+ . get < keyof typeof cursorStyleMap > ( "cursorStyle" ) ;
35+
36+ if ( rawCursorStyle == null ) {
37+ return TextEditorCursorStyle . BlockOutline ;
38+ }
39+
40+ return cursorStyleMap [ rawCursorStyle ] ;
41+ }
42+
1743 /**
1844 * Returns a keymap for a given config section that is intended to be further
1945 * processed by eg {@link getSectionEntries} or {@link getSingularSectionEntry}.
0 commit comments