@@ -1562,120 +1562,119 @@ def clrtobol(self):
15621562 self .scr .redrawwin ()
15631563 self .scr .refresh ()
15641564
1565- def p_key (self ):
1565+ def p_key (self , key ):
15661566 """Process a keypress"""
15671567
1568- if self . c is None :
1568+ if key is None :
15691569 return ''
15701570
1571- if self . c == chr (8 ): # C-Backspace (on my computer anyway!)
1571+ if key == chr (8 ): # C-Backspace (on my computer anyway!)
15721572 self .clrtobol ()
1573- self . c = '\n '
1573+ key = '\n '
15741574 # Don't return; let it get handled
1575- if self . c == chr (27 ):
1575+ if key == chr (27 ):
15761576 return ''
15771577
1578- if self . c in (chr (127 ), 'KEY_BACKSPACE' ):
1578+ if key in (chr (127 ), 'KEY_BACKSPACE' ):
15791579 self .bs ()
15801580 self .complete ()
15811581 return ''
15821582
1583- elif self . c == 'KEY_DC' : # Del
1583+ elif key == 'KEY_DC' : # Del
15841584 self .delete ()
15851585 self .complete ()
15861586 # Redraw (as there might have been highlighted parens)
15871587 self .print_line (self .s )
15881588 return ''
15891589
1590- elif self . c in key_dispatch [OPTS .undo_key ]: # C-r
1590+ elif key in key_dispatch [OPTS .undo_key ]: # C-r
15911591 self .undo ()
15921592 return ''
15931593
1594- elif self . c in ('KEY_UP' , ) + key_dispatch [OPTS .up_one_line_key ]: # Cursor Up/C-p
1594+ elif key in ('KEY_UP' , ) + key_dispatch [OPTS .up_one_line_key ]: # Cursor Up/C-p
15951595 self .back ()
15961596 return ''
15971597
1598- elif self . c in ('KEY_DOWN' , ) + key_dispatch [OPTS .down_one_line_key ]: # Cursor Down/C-n
1598+ elif key in ('KEY_DOWN' , ) + key_dispatch [OPTS .down_one_line_key ]: # Cursor Down/C-n
15991599 self .fwd ()
16001600 return ''
16011601
1602- elif self . c == 'KEY_LEFT' : # Cursor Left
1602+ elif key == 'KEY_LEFT' : # Cursor Left
16031603 self .mvc (1 )
16041604 # Redraw (as there might have been highlighted parens)
16051605 self .print_line (self .s )
16061606
1607- elif self . c == 'KEY_RIGHT' : # Cursor Right
1607+ elif key == 'KEY_RIGHT' : # Cursor Right
16081608 self .mvc (- 1 )
16091609 # Redraw (as there might have been highlighted parens)
16101610 self .print_line (self .s )
16111611
1612- elif self . c in ("KEY_HOME" , '^A' , chr (1 )): # home or ^A
1612+ elif key in ("KEY_HOME" , '^A' , chr (1 )): # home or ^A
16131613 self .home ()
16141614 # Redraw (as there might have been highlighted parens)
16151615 self .print_line (self .s )
16161616
1617- elif self . c in ("KEY_END" , '^E' , chr (5 )): # end or ^E
1617+ elif key in ("KEY_END" , '^E' , chr (5 )): # end or ^E
16181618 self .end ()
16191619 # Redraw (as there might have been highlighted parens)
16201620 self .print_line (self .s )
16211621
1622- elif self . c in key_dispatch [OPTS .cut_to_buffer_key ]: # cut to buffer
1622+ elif key in key_dispatch [OPTS .cut_to_buffer_key ]: # cut to buffer
16231623 self .cut_to_buffer ()
16241624 return ''
16251625
1626- elif self . c in key_dispatch [OPTS .yank_from_buffer_key ]: # yank from buffer
1626+ elif key in key_dispatch [OPTS .yank_from_buffer_key ]: # yank from buffer
16271627 self .yank_from_buffer ()
16281628 return ''
16291629
1630- elif self . c in key_dispatch [OPTS .clear_word_key ]:
1630+ elif key in key_dispatch [OPTS .clear_word_key ]:
16311631 self .bs_word ()
16321632 self .complete ()
16331633 return ''
16341634
1635- elif self . c in key_dispatch [OPTS .clear_line_key ]:
1635+ elif key in key_dispatch [OPTS .clear_line_key ]:
16361636 self .clrtobol ()
16371637 return ''
16381638
1639- elif self . c in key_dispatch [OPTS .clear_screen_key ]:
1639+ elif key in key_dispatch [OPTS .clear_screen_key ]:
16401640 self .s_hist = [self .s_hist [- 1 ]]
16411641 self .highlighted_paren = None
16421642 self .redraw ()
16431643 return ''
16441644
1645- elif self . c in key_dispatch [OPTS .exit_key ]:
1645+ elif key in key_dispatch [OPTS .exit_key ]:
16461646 if not self .s :
16471647 self .do_exit = True
16481648 return None
16491649 else :
16501650 return ''
16511651
1652- elif self . c in key_dispatch [OPTS .save_key ]:
1652+ elif key in key_dispatch [OPTS .save_key ]:
16531653 self .write2file ()
16541654 return ''
16551655
1656- elif self . c in key_dispatch [OPTS .pastebin_key ]:
1656+ elif key in key_dispatch [OPTS .pastebin_key ]:
16571657 self .pastebin ()
16581658 return ''
16591659
1660- elif self . c in key_dispatch [OPTS .last_output_key ]:
1660+ elif key in key_dispatch [OPTS .last_output_key ]:
16611661 page (self .stdout_hist [self .prev_block_finished :- 4 ])
16621662 return ''
16631663
1664- elif self . c == '\n ' :
1664+ elif key == '\n ' :
16651665 self .lf ()
16661666 return None
16671667
1668- elif self . c == '\t ' :
1668+ elif key == '\t ' :
16691669 return self .tab ()
16701670
1671- elif len (self . c ) == 1 and not unicodedata .category (self . c ) == 'Cc' :
1672- self .addstr (self . c )
1671+ elif len (key ) == 1 and not unicodedata .category (key ) == 'Cc' :
1672+ self .addstr (key )
16731673 self .print_line (self .s )
16741674
16751675 else :
16761676 return ''
16771677
1678-
16791678 return True
16801679
16811680 def tab (self ):
@@ -1924,19 +1923,16 @@ def get_line(self):
19241923
19251924 if not self .paste_mode :
19261925 for _ in range (indent_spaces // OPTS .tab_length ):
1927- self .c = '\t '
1928- self .p_key ()
1926+ self .p_key ('\t ' )
19291927
19301928 if indent and not self .paste_mode :
1931- self .c = '\t '
1932- self .p_key ()
1929+ self .p_key ('\t ' )
19331930
1934- self .c = None
19351931 self .cpos = 0
19361932
19371933 while True :
1938- self . c = self .get_key ()
1939- if self .p_key () is None :
1934+ key = self .get_key ()
1935+ if self .p_key (key ) is None :
19401936 return self .s
19411937
19421938 def clear_current_line (self ):
0 commit comments