@@ -34,6 +34,10 @@ import { HelpComponent } from "./component/help.ts";
34
34
import { consume , type Event } from "./event.ts" ;
35
35
36
36
const SCHEDULER_INTERVAL = 10 ;
37
+ const MATCHER_ICON = " " ;
38
+ const SORTER_ICON = " " ;
39
+ const RENDERER_ICON = " " ;
40
+ const PREVIEWER_ICON = " " ;
37
41
38
42
type ReservedCallback = (
39
43
denops : Denops ,
@@ -62,6 +66,10 @@ export type PickerResult<T extends Detail> = {
62
66
63
67
export type PickerOptions = {
64
68
schedulerInterval ?: number ;
69
+ matcherIcon ?: string ;
70
+ sorterIcon ?: string ;
71
+ rendererIcon ?: string ;
72
+ previewerIcon ?: string ;
65
73
} ;
66
74
67
75
export class Picker < T extends Detail > implements AsyncDisposable {
@@ -81,12 +89,20 @@ export class Picker<T extends Detail> implements AsyncDisposable {
81
89
readonly #helpComponent: HelpComponent ;
82
90
readonly #helpWidthRatio = 0.98 ;
83
91
readonly #helpHeightRatio = 0.3 ;
92
+ readonly #matcherIcon: string ;
93
+ readonly #sorterIcon: string ;
94
+ readonly #rendererIcon: string ;
95
+ readonly #previewerIcon: string ;
84
96
#selection: Set < unknown > = new Set ( ) ;
85
97
86
98
constructor ( params : PickerParams < T > , options : PickerOptions = { } ) {
87
99
this . #schedulerInterval = options . schedulerInterval ?? SCHEDULER_INTERVAL ;
88
100
this . #name = params . name ;
89
101
this . #coordinator = params . coordinator ;
102
+ this . #matcherIcon = options . matcherIcon ?? MATCHER_ICON ;
103
+ this . #sorterIcon = options . sorterIcon ?? SORTER_ICON ;
104
+ this . #rendererIcon = options . rendererIcon ?? RENDERER_ICON ;
105
+ this . #previewerIcon = options . previewerIcon ?? PREVIEWER_ICON ;
90
106
91
107
// Components
92
108
const { theme, zindex = 50 } = params ;
@@ -151,6 +167,20 @@ export class Picker<T extends Detail> implements AsyncDisposable {
151
167
return { row, col, width, height } ;
152
168
}
153
169
170
+ #getExtensionIndicator( ) : string {
171
+ const { matcherIndex } = this . #matchProcessor;
172
+ const { sorterIndex } = this . #sortProcessor;
173
+ const { rendererIndex } = this . #renderProcessor;
174
+ const { previewerIndex } = this . #previewProcessor ?? { } ;
175
+ const matcherIndicator = `${ this . #matcherIcon} ${ matcherIndex + 1 } ` ;
176
+ const sorterIndicator = `${ this . #sorterIcon} ${ sorterIndex + 1 } ` ;
177
+ const rendererIndicator = `${ this . #rendererIcon} ${ rendererIndex + 1 } ` ;
178
+ const previewerIndicator = previewerIndex !== undefined
179
+ ? `${ this . #previewerIcon} ${ previewerIndex + 1 } `
180
+ : "" ;
181
+ return `${ matcherIndicator } ${ sorterIndicator } ${ rendererIndicator } ${ previewerIndicator } ` ;
182
+ }
183
+
154
184
async open (
155
185
denops : Denops ,
156
186
{ signal } : { signal ?: AbortSignal } ,
@@ -264,6 +294,7 @@ export class Picker<T extends Detail> implements AsyncDisposable {
264
294
if ( args . length > 0 ) {
265
295
this . #inputComponent. title = `${ this . #name} :${ args . join ( " " ) } ` ;
266
296
}
297
+ this . #listComponent. title = this . #getExtensionIndicator( ) ;
267
298
268
299
// Start mainloop
269
300
let action : string | undefined ;
@@ -441,6 +472,7 @@ export class Picker<T extends Detail> implements AsyncDisposable {
441
472
}
442
473
}
443
474
this . #matchProcessor. matcherIndex = index ;
475
+ this . #listComponent. title = this . #getExtensionIndicator( ) ;
444
476
reserve ( ( denops ) => {
445
477
this . #matchProcessor. start ( denops , {
446
478
items : this . #collectProcessor. items ,
@@ -453,6 +485,7 @@ export class Picker<T extends Detail> implements AsyncDisposable {
453
485
}
454
486
case "switch-matcher-at" :
455
487
this . #matchProcessor. matcherIndex = event . index ;
488
+ this . #listComponent. title = this . #getExtensionIndicator( ) ;
456
489
reserve ( ( denops ) => {
457
490
this . #matchProcessor. start ( denops , {
458
491
items : this . #collectProcessor. items ,
@@ -472,6 +505,7 @@ export class Picker<T extends Detail> implements AsyncDisposable {
472
505
}
473
506
}
474
507
this . #sortProcessor. sorterIndex = index ;
508
+ this . #listComponent. title = this . #getExtensionIndicator( ) ;
475
509
reserve ( ( denops ) => {
476
510
// NOTE:
477
511
// We need to restart from the matcher processor because
@@ -486,6 +520,7 @@ export class Picker<T extends Detail> implements AsyncDisposable {
486
520
}
487
521
case "switch-sorter-at" :
488
522
this . #sortProcessor. sorterIndex = event . index ;
523
+ this . #listComponent. title = this . #getExtensionIndicator( ) ;
489
524
reserve ( ( denops ) => {
490
525
// NOTE:
491
526
// We need to restart from the matcher processor because
@@ -507,6 +542,7 @@ export class Picker<T extends Detail> implements AsyncDisposable {
507
542
}
508
543
}
509
544
this . #renderProcessor. rendererIndex = index ;
545
+ this . #listComponent. title = this . #getExtensionIndicator( ) ;
510
546
reserve ( ( denops ) => {
511
547
// NOTE:
512
548
// We need to restart from the matcher processor because
@@ -521,6 +557,7 @@ export class Picker<T extends Detail> implements AsyncDisposable {
521
557
}
522
558
case "switch-renderer-at" :
523
559
this . #renderProcessor. rendererIndex = event . index ;
560
+ this . #listComponent. title = this . #getExtensionIndicator( ) ;
524
561
reserve ( ( denops ) => {
525
562
// NOTE:
526
563
// We need to restart from the matcher processor because
@@ -543,6 +580,7 @@ export class Picker<T extends Detail> implements AsyncDisposable {
543
580
}
544
581
}
545
582
this . #previewProcessor. previewerIndex = index ;
583
+ this . #listComponent. title = this . #getExtensionIndicator( ) ;
546
584
reserve ( ( denops ) => {
547
585
this . #previewProcessor?. start ( denops , {
548
586
item : this . #matchProcessor. items [ this . #renderProcessor. cursor ] ,
@@ -553,6 +591,7 @@ export class Picker<T extends Detail> implements AsyncDisposable {
553
591
case "switch-previewer-at" :
554
592
if ( ! this . #previewProcessor) break ;
555
593
this . #previewProcessor. previewerIndex = event . index ;
594
+ this . #listComponent. title = this . #getExtensionIndicator( ) ;
556
595
reserve ( ( denops ) => {
557
596
this . #previewProcessor?. start ( denops , {
558
597
item : this . #matchProcessor. items [ this . #renderProcessor. cursor ] ,
0 commit comments