@@ -118,7 +118,8 @@ def main(self, canvas):
118118                    if  difference  >  0 :
119119                        self .current_line  -=  difference 
120120                        self .current_line  =  max (0 , self .current_line )
121-                         self .current_line  =  min (self .current_line , len (wrapped_lines )- 1 )
121+                         self .current_line  =  min (self .current_line ,
122+                                 len (wrapped_lines )- n_entries )
122123                    album_cover .x  =  self .columns // 2 
123124                    self .print_metadata ()
124125
@@ -138,47 +139,54 @@ def main(self, canvas):
138139                utils .delete_line ()
139140
140141                key  =  key_poller .poll ()
141-                 if  key  ==   'q' :
142-                     os . system ( 'clear' ) 
143-                     break 
144-                 elif   key   ==   'j' : 
145-                     if   rows   -   start_row   ==  n_entries :
142+                 if  key  is   not   None :
143+                     if   key   ==   'q' : 
144+                          os . system ( 'clear' ) 
145+                          break 
146+                     elif   key   ==   'j'   or   ord ( key )  ==  5 :
146147                        self .current_line  +=  1 
147-                         self .current_line  =  min (self .current_line , len (wrapped_lines )- 1 )
148-                 elif  key  ==  'k' :
149-                     self .current_line  +=  - 1 
150-                     self .current_line  =  max (self .current_line , 0 )
151-                 elif  key  ==  'e' :
152-                     try :
153-                         EDITOR  =  os .environ .get ('EDITOR' )
154-                         call ([EDITOR , self .lyrics_file ])
155-                         self .update_lyrics ()
148+                         self .current_line  =  min (self .current_line ,
149+                                 len (wrapped_lines )- n_entries )
150+                     elif  key  ==  'k'  or  ord (key ) ==  25 :
151+                         self .current_line  +=  - 1 
152+                         self .current_line  =  max (self .current_line , 0 )
153+                     elif  key  ==  'e' :
154+                         try :
155+                             EDITOR  =  os .environ .get ('EDITOR' )
156+                             call ([EDITOR , self .lyrics_file ])
157+                             self .update_lyrics ()
158+                             self .print_metadata ()
159+                             utils .hide_cursor ()
160+                         except  TypeError :
161+                             os .system ('clear' )
162+                             print ('$EDITOR is not set' )
163+                             time .sleep (1 )
164+                     elif  key  ==  'r' :
156165                        self .print_metadata ()
157-                         utils .hide_cursor ()
158-                     except  TypeError :
166+                     elif  key  ==  'd' :
167+                         os .remove (self .lyrics_file )
168+                         self .update_lyrics ()
169+                     elif  key  ==  'n' :
170+                         self .spotify .next ()
171+                     elif  key  ==  'p' :
172+                         self .spotify .prev ()
173+                     elif  key  ==  't' :
174+                         self .spotify .toggle ()
175+                     elif  key  ==  'h' :
159176                        os .system ('clear' )
160-                         print ('$EDITOR is not set' )
161-                         time .sleep (1 )
162-                 elif  key  ==  'r' :
163-                     self .print_metadata ()
164-                 elif  key  ==  'd' :
165-                     os .remove (self .lyrics_file )
166-                     self .update_lyrics ()
167-                 elif  key  ==  'n' :
168-                     self .spotify .next ()
169-                 elif  key  ==  'p' :
170-                     self .spotify .prev ()
171-                 elif  key  ==  't' :
172-                     self .spotify .toggle ()
173-                 elif  key  ==  'h' :
174-                     os .system ('clear' )
175-                     album_cover .visibility  =  ueberzug .Visibility .INVISIBLE 
176-                     utils .move_cursor (0 , 0 )
177-                     utils .print_help ()
178-                     time .sleep (5 )
179-                     self .print_metadata ()
180-                     album_cover .visibility  =  ueberzug .Visibility .VISIBLE 
181-                     key_poller .flush ()
177+                         album_cover .visibility  =  ueberzug .Visibility .INVISIBLE 
178+                         utils .move_cursor (0 , 0 )
179+                         utils .print_help ()
180+                         time .sleep (5 )
181+                         self .print_metadata ()
182+                         album_cover .visibility  =  ueberzug .Visibility .VISIBLE 
183+                         key_poller .flush ()
184+                     elif  key  ==  'g' :
185+                         modified_key  =  key_poller .poll (timeout = 1.0 )
186+                         if  modified_key  ==  'g' :
187+                             self .current_line  =  0 
188+                     elif  key  ==  'G' :
189+                         self .current_line  =  len (wrapped_lines )- n_entries 
182190
183191
184192def  main ():
0 commit comments