@@ -47,7 +47,7 @@ async function api<T>(path: string): Promise<T | null> {
4747}
4848
4949async function main ( ) {
50- const renderer = await createCliRenderer ( { exitOnCtrlC : true , targetFps : 30 } ) ;
50+ const renderer = await createCliRenderer ( { exitOnCtrlC : true , targetFps : 30 , useMouse : true } ) ;
5151
5252 // --- static layout ---
5353 const rootCol = new BoxRenderable ( renderer , {
@@ -93,7 +93,7 @@ async function main() {
9393 main . add ( scroll ) ;
9494
9595 const footer = new TextRenderable ( renderer , {
96- content : "↑/↓ select [ / ] scroll r refresh q quit" ,
96+ content : "↑/↓ select click sidebar [ / ] scroll wheel scroll r refresh q quit" ,
9797 paddingLeft : 1 ,
9898 height : 1 ,
9999 fg : muted ,
@@ -134,6 +134,12 @@ async function main() {
134134 for ( const child of node . getChildren ( ) . slice ( ) ) node . remove ( child . id ) ;
135135 }
136136
137+ function selectSnippet ( id : string ) {
138+ selectedId = id ;
139+ renderSidebar ( ) ;
140+ void showSelected ( ) ;
141+ }
142+
137143 function renderSidebar ( ) {
138144 clearChildren ( sidebar ) ;
139145 if ( flat . length === 0 ) {
@@ -154,6 +160,14 @@ async function main() {
154160 content : label ,
155161 fg : selected ? heading : undefined ,
156162 bg : selected ? ( resolveColor ( "subtle" ) ?? undefined ) : undefined ,
163+ height : 1 ,
164+ width : "100%" ,
165+ selectable : false ,
166+ onMouseUp ( event ) {
167+ if ( event . button !== 0 ) return ;
168+ event . stopPropagation ( ) ;
169+ selectSnippet ( snip . id ) ;
170+ } ,
157171 } ) ,
158172 ) ;
159173 }
@@ -195,9 +209,7 @@ async function main() {
195209 if ( flat . length === 0 ) return ;
196210 const cur = selectedIndex ( ) ;
197211 const next = Math . max ( 0 , Math . min ( flat . length - 1 , ( cur < 0 ? 0 : cur ) + delta ) ) ;
198- selectedId = flat [ next ] . id ;
199- renderSidebar ( ) ;
200- void showSelected ( ) ;
212+ selectSnippet ( flat [ next ] . id ) ;
201213 }
202214
203215 renderer . keyInput . on ( "keypress" , ( key ) => {
0 commit comments