Skip to content

Commit 8dcf3d2

Browse files
committed
feat: add cursor style enums and default config
1 parent 3a0a611 commit 8dcf3d2

3 files changed

Lines changed: 62 additions & 7 deletions

File tree

‎lib/defaults.ts‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
export type FocusedStyle = "block" | "bar" | "underline";
2+
export type UnfocusedStyle = "dim" | "outline" | "underline" | "hide";
3+
export type FocusProviderName = "auto" | "tmux" | "herdr" | "static";
4+
5+
export const FOCUSED_STYLES: readonly FocusedStyle[] = ["block", "bar", "underline"];
6+
export const UNFOCUSED_STYLES: readonly UnfocusedStyle[] = ["dim", "outline", "underline", "hide"];
7+
export const BLINK_RATES: readonly number[] = [400, 500, 600, 800, 1000];
8+
export const FOCUS_PROVIDERS: readonly FocusProviderName[] = ["auto", "tmux", "herdr", "static"];
9+
10+
export interface CursorConfig {
11+
enabled: boolean;
12+
focusedStyle: FocusedStyle;
13+
unfocusedStyle: UnfocusedStyle;
14+
blink: boolean;
15+
blinkRate: number;
16+
focusProvider: FocusProviderName;
17+
}
18+
19+
export const DEFAULT_CONFIG: CursorConfig = {
20+
enabled: true,
21+
focusedStyle: "block",
22+
unfocusedStyle: "dim",
23+
blink: false,
24+
blinkRate: 600,
25+
focusProvider: "auto",
26+
};

‎tests/defaults.test.ts‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { test } from "node:test";
2+
import assert from "node:assert/strict";
3+
import {
4+
DEFAULT_CONFIG,
5+
FOCUSED_STYLES,
6+
UNFOCUSED_STYLES,
7+
BLINK_RATES,
8+
FOCUS_PROVIDERS,
9+
} from "../lib/defaults.ts";
10+
11+
test("default config has expected shape", () => {
12+
assert.deepEqual(DEFAULT_CONFIG, {
13+
enabled: true,
14+
focusedStyle: "block",
15+
unfocusedStyle: "dim",
16+
blink: false,
17+
blinkRate: 600,
18+
focusProvider: "auto",
19+
});
20+
});
21+
22+
test("focused styles enum", () => {
23+
assert.deepEqual(FOCUSED_STYLES, ["block", "bar", "underline"]);
24+
});
25+
26+
test("unfocused styles enum", () => {
27+
assert.deepEqual(UNFOCUSED_STYLES, ["dim", "outline", "underline", "hide"]);
28+
});
29+
30+
test("blink rates enum", () => {
31+
assert.deepEqual(BLINK_RATES, [400, 500, 600, 800, 1000]);
32+
});
33+
34+
test("focus providers enum", () => {
35+
assert.deepEqual(FOCUS_PROVIDERS, ["auto", "tmux", "herdr", "static"]);
36+
});

‎tests/smoke.test.ts‎

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)