@@ -293,13 +293,17 @@ def __init__(self) -> None:
293
293
class StreamsView (urwid .Frame ):
294
294
def __init__ (self , streams_btn_list : List [Any ], view : Any ) -> None :
295
295
self .view = view
296
- self . log = urwid . SimpleFocusListWalker ( streams_btn_list )
296
+ # Create Stream List Box
297
297
self .streams_btn_list = streams_btn_list
298
- self .focus_index_before_search = 0
298
+ self .log = urwid . SimpleFocusListWalker ( streams_btn_list )
299
299
list_box = urwid .ListBox (self .log )
300
+ # Create Stream Search Box
300
301
self .stream_search_box = PanelSearchBox (self ,
301
302
'SEARCH_STREAMS' ,
302
303
self .update_streams )
304
+ self .focus_index_before_search = 0
305
+ self .in_search_mode = False
306
+ # Create Stream View Frame
303
307
super ().__init__ (list_box , header = urwid .LineBox (
304
308
self .stream_search_box , tlcorner = '─' , tline = '' , lline = '' ,
305
309
trcorner = '─' , blcorner = '─' , rline = '' ,
@@ -356,6 +360,7 @@ def mouse_event(self, size: urwid_Size, event: str, button: int, col: int,
356
360
357
361
def keypress (self , size : urwid_Size , key : str ) -> Optional [str ]:
358
362
if is_command_key ('SEARCH_STREAMS' , key ):
363
+ self .in_search_mode = True
359
364
self .set_focus ('header' )
360
365
return key
361
366
elif is_command_key ('GO_BACK' , key ):
@@ -365,27 +370,33 @@ def keypress(self, size: urwid_Size, key: str) -> Optional[str]:
365
370
self .set_focus ('body' )
366
371
self .log .set_focus (self .focus_index_before_search )
367
372
self .view .controller .update_screen ()
373
+ self .in_search_mode = False
368
374
return key
369
375
return_value = super ().keypress (size , key )
370
- _ , self .focus_index_before_search = self .log .get_focus ()
376
+ if not self .in_search_mode :
377
+ _ , self .focus_index_before_search = self .log .get_focus ()
371
378
return return_value
372
379
373
380
374
381
class TopicsView (urwid .Frame ):
375
382
def __init__ (self , topics_btn_list : List [Any ], view : Any ,
376
383
stream_button : Any ) -> None :
377
384
self .view = view
378
- self .log = urwid .SimpleFocusListWalker (topics_btn_list )
379
- self .topics_btn_list = topics_btn_list
380
385
self .stream_button = stream_button
381
- self .focus_index_before_search = 0
386
+ # Create Topic List Box
387
+ self .topics_btn_list = topics_btn_list
388
+ self .log = urwid .SimpleFocusListWalker (topics_btn_list )
382
389
self .list_box = urwid .ListBox (self .log )
390
+ # Create Topic Search Box
383
391
self .topic_search_box = PanelSearchBox (self ,
384
392
'SEARCH_TOPICS' ,
385
393
self .update_topics )
394
+ self .focus_index_before_search = 0
395
+ self .in_search_mode = False
386
396
self .header_list = urwid .Pile ([self .stream_button ,
387
397
urwid .Divider ('─' ),
388
398
self .topic_search_box ])
399
+ # Create Topic View Frame
389
400
super ().__init__ (self .list_box , header = urwid .LineBox (
390
401
self .header_list , tlcorner = '─' , tline = '' , lline = '' ,
391
402
trcorner = '─' , blcorner = '─' , rline = '' ,
@@ -452,6 +463,7 @@ def keypress(self, size: urwid_Size, key: str) -> Optional[str]:
452
463
self .view .show_left_panel (visible = False )
453
464
self .view .body .focus_col = 1
454
465
if is_command_key ('SEARCH_TOPICS' , key ):
466
+ self .in_search_mode = True
455
467
self .set_focus ('header' )
456
468
self .header_list .set_focus (2 )
457
469
return key
@@ -462,9 +474,11 @@ def keypress(self, size: urwid_Size, key: str) -> Optional[str]:
462
474
self .set_focus ('body' )
463
475
self .log .set_focus (self .focus_index_before_search )
464
476
self .view .controller .update_screen ()
477
+ self .in_search_mode = False
465
478
return key
466
479
return_value = super ().keypress (size , key )
467
- _ , self .focus_index_before_search = self .log .get_focus ()
480
+ if not self .in_search_mode :
481
+ _ , self .focus_index_before_search = self .log .get_focus ()
468
482
return return_value
469
483
470
484
0 commit comments