@@ -50,6 +50,7 @@ export interface SelectRenderableOptions extends RenderableOptions<SelectRendera
5050 showScrollIndicator ?: boolean
5151 wrapSelection ?: boolean
5252 showDescription ?: boolean
53+ showSelectionIndicator ?: boolean
5354 font ?: keyof typeof fonts
5455 itemSpacing ?: number
5556 fastScrollStep ?: number
@@ -81,6 +82,7 @@ export class SelectRenderable extends Renderable {
8182 private _showScrollIndicator : boolean
8283 private _wrapSelection : boolean
8384 private _showDescription : boolean
85+ private _showSelectionIndicator : boolean
8486 private _font ?: keyof typeof fonts
8587 private _itemSpacing : number
8688 private linesPerItem : number
@@ -103,6 +105,7 @@ export class SelectRenderable extends Renderable {
103105 showScrollIndicator : false ,
104106 wrapSelection : false ,
105107 showDescription : true ,
108+ showSelectionIndicator : true ,
106109 itemSpacing : 0 ,
107110 fastScrollStep : 5 ,
108111 } satisfies Partial < SelectRenderableOptions >
@@ -122,6 +125,7 @@ export class SelectRenderable extends Renderable {
122125 this . _showScrollIndicator = options . showScrollIndicator ?? this . _defaultOptions . showScrollIndicator
123126 this . _wrapSelection = options . wrapSelection ?? this . _defaultOptions . wrapSelection
124127 this . _showDescription = options . showDescription ?? this . _defaultOptions . showDescription
128+ this . _showSelectionIndicator = options . showSelectionIndicator ?? this . _defaultOptions . showSelectionIndicator
125129 this . _font = options . font
126130 this . _itemSpacing = options . itemSpacing || this . _defaultOptions . itemSpacing
127131
@@ -191,32 +195,33 @@ export class SelectRenderable extends Renderable {
191195 this . frameBuffer . fillRect ( contentX , itemY , contentWidth , contentHeight , this . _selectedBackgroundColor )
192196 }
193197
194- const nameContent = `${ isSelected ? "▶ " : " " } ${ option . name } `
198+ const indicator = this . _showSelectionIndicator ? ( isSelected ? "▶ " : " " ) : ""
199+ const indicatorWidth = this . _showSelectionIndicator ? 2 : 0
200+ const nameContent = `${ indicator } ${ option . name } `
195201 const baseTextColor = this . _focused ? this . _focusedTextColor : this . _textColor
196202 const nameColor = isSelected ? this . _selectedTextColor : baseTextColor
197- let descX = contentX + 3
203+ const textX = contentX + 1 + indicatorWidth
198204
199205 if ( this . _font ) {
200- const indicator = isSelected ? "▶ " : " "
201- this . frameBuffer . drawText ( indicator , contentX + 1 , itemY , nameColor )
206+ if ( indicator ) {
207+ this . frameBuffer . drawText ( indicator , contentX + 1 , itemY , nameColor )
208+ }
202209
203- const indicatorWidth = 2
204210 renderFontToFrameBuffer ( this . frameBuffer , {
205211 text : option . name ,
206- x : contentX + 1 + indicatorWidth ,
212+ x : textX ,
207213 y : itemY ,
208214 color : nameColor ,
209215 backgroundColor : isSelected ? this . _selectedBackgroundColor : bgColor ,
210216 font : this . _font ,
211217 } )
212- descX = contentX + 1 + indicatorWidth
213218 } else {
214219 this . frameBuffer . drawText ( nameContent , contentX + 1 , itemY , nameColor )
215220 }
216221
217222 if ( this . _showDescription && itemY + this . fontHeight < contentY + contentHeight ) {
218223 const descColor = isSelected ? this . _selectedDescriptionColor : this . _descriptionColor
219- this . frameBuffer . drawText ( option . description , descX , itemY + this . fontHeight , descColor )
224+ this . frameBuffer . drawText ( option . description , textX , itemY + this . fontHeight , descColor )
220225 }
221226 }
222227
@@ -387,6 +392,18 @@ export class SelectRenderable extends Renderable {
387392 }
388393 }
389394
395+ public get showSelectionIndicator ( ) : boolean {
396+ return this . _showSelectionIndicator
397+ }
398+
399+ public set showSelectionIndicator ( show : boolean | null | undefined ) {
400+ const next = show ?? this . _defaultOptions . showSelectionIndicator
401+ if ( this . _showSelectionIndicator !== next ) {
402+ this . _showSelectionIndicator = next
403+ this . requestRender ( )
404+ }
405+ }
406+
390407 public get wrapSelection ( ) : boolean {
391408 return this . _wrapSelection
392409 }
0 commit comments