@@ -248,7 +248,7 @@ def next_token_inside_string(s, inside_string):
248248
249249class Interpreter (code .InteractiveInterpreter ):
250250
251- def __init__ (self , locals = None , encoding = sys . getdefaultencoding () ):
251+ def __init__ (self , encoding ):
252252 """The syntaxerror callback can be set at any time and will be called
253253 on a caught syntax error. The purpose for this in bpython is so that
254254 the repl can be instantiated after the interpreter (which it
@@ -260,7 +260,7 @@ def __init__(self, locals=None, encoding=sys.getdefaultencoding()):
260260 self .encoding = encoding
261261 self .syntaxerror_callback = None
262262# Unfortunately code.InteractiveInterpreter is a classic class, so no super()
263- code .InteractiveInterpreter .__init__ (self , locals )
263+ code .InteractiveInterpreter .__init__ (self )
264264
265265 def runsource (self , source ):
266266 source = '# coding: %s\n %s' % (self .encoding ,
@@ -1080,8 +1080,6 @@ def undo(self, n=1):
10801080
10811081 self .history = self .history [:- n ]
10821082 self .reevaluate ()
1083- # This will unhighlight highlighted parens
1084- self .print_line (self .s )
10851083
10861084 def enter_hist (self ):
10871085 """Set flags for entering into the history by pressing up/down"""
@@ -1233,8 +1231,6 @@ def repl(self):
12331231 if inp :
12341232 self .rl_hist .append (inp + '\n ' )
12351233 more = self .push (inp ) or self .paste_mode
1236- if not more :
1237- self .s = ''
12381234
12391235 def size (self ):
12401236 """Set instance attributes for x and y top left corner coordinates
@@ -1478,19 +1474,17 @@ def p_key(self):
14781474 elif self .c == 'KEY_DC' : # Del
14791475 self .delete ()
14801476 self .complete ()
1481- # Redraw (as there might have been highlighted parens)
1482- self .print_line (self .s )
14831477 return ''
14841478
1485- elif self .c in key_dispatch [OPTS . undo_key ]: # C-r
1479+ elif self .c in key_dispatch ['C-r' ]: # C-r
14861480 self .undo ()
14871481 return ''
14881482
1489- elif self .c in ('KEY_UP' , ) + key_dispatch [OPTS . up_one_line_key ]: # Cursor Up/C-p
1483+ elif self .c in ('KEY_UP' , ) + key_dispatch ['C-p' ]: # Cursor Up/C-p
14901484 self .back ()
14911485 return ''
14921486
1493- elif self .c in ('KEY_DOWN' , ) + key_dispatch [OPTS . down_one_line_key ]: # Cursor Down/C-n
1487+ elif self .c in ('KEY_DOWN' , ) + key_dispatch ['C-n' ]: # Cursor Down/C-n
14941488 self .fwd ()
14951489 return ''
14961490
@@ -1514,30 +1508,30 @@ def p_key(self):
15141508 # Redraw (as there might have been highlighted parens)
15151509 self .print_line (self .s )
15161510
1517- elif self .c in key_dispatch [OPTS . cut_to_buffer_key ]: # cut to buffer
1511+ elif self .c in key_dispatch ['C-k' ]: # cut to buffer
15181512 self .cut_to_buffer ()
15191513 return ''
15201514
1521- elif self .c in key_dispatch [OPTS . yank_from_buffer_key ]: # yank from buffer
1515+ elif self .c in key_dispatch ['C-y' ]: # yank from buffer
15221516 self .yank_from_buffer ()
15231517 return ''
15241518
1525- elif self .c in key_dispatch [OPTS . clear_word_key ]:
1519+ elif self .c in key_dispatch ['C-w' ]:
15261520 self .bs_word ()
15271521 self .complete ()
15281522 return ''
15291523
1530- elif self .c in key_dispatch [OPTS . clear_line_key ]:
1524+ elif self .c in key_dispatch ['C-u' ]:
15311525 self .clrtobol ()
15321526 return ''
15331527
1534- elif self .c in key_dispatch [OPTS . clear_screen_key ]:
1528+ elif self .c in key_dispatch ['C-l' ]:
15351529 self .s_hist = [self .s_hist [- 1 ]]
15361530 self .highlighted_paren = None
15371531 self .redraw ()
15381532 return ''
15391533
1540- elif self .c in key_dispatch [OPTS . exit_key ]:
1534+ elif self .c in key_dispatch ['C-d' ]:
15411535 if not self .s :
15421536 self .do_exit = True
15431537 return None
@@ -1709,7 +1703,7 @@ def reprint_line(lineno, s, to_replace=[]):
17091703 # Marker found
17101704 tokens [i ] = (Parenthesis , value )
17111705 break
1712- elif opening and under_cursor and not newline :
1706+ elif opening and under_cursor :
17131707 if self .cpos :
17141708 tokens [i ] = (Parenthesis .UnderCursor , value )
17151709 else :
@@ -2126,8 +2120,7 @@ def main_curses(scr, args, interactive=True):
21262120
21272121 curses .raw (True )
21282122
2129- interpreter = Interpreter (dict (__name__ = '__main__' , __doc__ = None ),
2130- getpreferredencoding ())
2123+ interpreter = Interpreter (getpreferredencoding ())
21312124
21322125 repl = Repl (main_win , interpreter , statusbar , idle )
21332126 interpreter .syntaxerror_callback = repl .clear_current_line
0 commit comments