| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -248,7 +248,7 @@ def next_token_inside_string(s, inside_string): | |||
| 248 | 248 | ||
| 249 | 249 | class Interpreter(code.InteractiveInterpreter): | |
| 250 | 250 | ||
| 251 | - def __init__(self, locals=None, encoding=sys.getdefaultencoding()): | ||
| 251 | + def __init__(self, encoding): | ||
| 252 | 252 | """The syntaxerror callback can be set at any time and will be called | |
| 253 | 253 | on a caught syntax error. The purpose for this in bpython is so that | |
| 254 | 254 | the repl can be instantiated after the interpreter (which it | |
@@ -260,7 +260,7 @@ def __init__(self, locals=None, encoding=sys.getdefaultencoding()): | |||
| 260 | 260 | self.encoding = encoding | |
| 261 | 261 | self.syntaxerror_callback = None | |
| 262 | 262 | # Unfortunately code.InteractiveInterpreter is a classic class, so no super() | |
| 263 | - code.InteractiveInterpreter.__init__(self, locals) | ||
| 263 | + code.InteractiveInterpreter.__init__(self) | ||
| 264 | 264 | ||
| 265 | 265 | def runsource(self, source): | |
| 266 | 266 | source = '# coding: %s\n%s' % (self.encoding, | |
@@ -1080,8 +1080,6 @@ def undo(self, n=1): | |||
| 1080 | 1080 | ||
| 1081 | 1081 | self.history = self.history[:-n] | |
| 1082 | 1082 | self.reevaluate() | |
| 1083 | - # This will unhighlight highlighted parens | ||
| 1084 | - self.print_line(self.s) | ||
| 1085 | 1083 | ||
| 1086 | 1084 | def enter_hist(self): | |
| 1087 | 1085 | """Set flags for entering into the history by pressing up/down""" | |
@@ -1233,8 +1231,6 @@ def repl(self): | |||
| 1233 | 1231 | if inp: | |
| 1234 | 1232 | self.rl_hist.append(inp + '\n') | |
| 1235 | 1233 | more = self.push(inp) or self.paste_mode | |
| 1236 | - if not more: | ||
| 1237 | - self.s = '' | ||
| 1238 | 1234 | ||
| 1239 | 1235 | def size(self): | |
| 1240 | 1236 | """Set instance attributes for x and y top left corner coordinates | |
@@ -1478,19 +1474,17 @@ def p_key(self): | |||
| 1478 | 1474 | elif self.c == 'KEY_DC': # Del | |
| 1479 | 1475 | self.delete() | |
| 1480 | 1476 | self.complete() | |
| 1481 | - # Redraw (as there might have been highlighted parens) | ||
| 1482 | - self.print_line(self.s) | ||
| 1483 | 1477 | return '' | |
| 1484 | 1478 | ||
| 1485 | - elif self.c in key_dispatch[OPTS.undo_key]: # C-r | ||
| 1479 | + elif self.c in key_dispatch['C-r']: # C-r | ||
| 1486 | 1480 | self.undo() | |
| 1487 | 1481 | return '' | |
| 1488 | 1482 | ||
| 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 | ||
| 1490 | 1484 | self.back() | |
| 1491 | 1485 | return '' | |
| 1492 | 1486 | ||
| 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 | ||
| 1494 | 1488 | self.fwd() | |
| 1495 | 1489 | return '' | |
| 1496 | 1490 | ||
@@ -1514,30 +1508,30 @@ def p_key(self): | |||
| 1514 | 1508 | # Redraw (as there might have been highlighted parens) | |
| 1515 | 1509 | self.print_line(self.s) | |
| 1516 | 1510 | ||
| 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 | ||
| 1518 | 1512 | self.cut_to_buffer() | |
| 1519 | 1513 | return '' | |
| 1520 | 1514 | ||
| 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 | ||
| 1522 | 1516 | self.yank_from_buffer() | |
| 1523 | 1517 | return '' | |
| 1524 | 1518 | ||
| 1525 | - elif self.c in key_dispatch[OPTS.clear_word_key]: | ||
| 1519 | + elif self.c in key_dispatch['C-w']: | ||
| 1526 | 1520 | self.bs_word() | |
| 1527 | 1521 | self.complete() | |
| 1528 | 1522 | return '' | |
| 1529 | 1523 | ||
| 1530 | - elif self.c in key_dispatch[OPTS.clear_line_key]: | ||
| 1524 | + elif self.c in key_dispatch['C-u']: | ||
| 1531 | 1525 | self.clrtobol() | |
| 1532 | 1526 | return '' | |
| 1533 | 1527 | ||
| 1534 | - elif self.c in key_dispatch[OPTS.clear_screen_key]: | ||
| 1528 | + elif self.c in key_dispatch['C-l']: | ||
| 1535 | 1529 | self.s_hist = [self.s_hist[-1]] | |
| 1536 | 1530 | self.highlighted_paren = None | |
| 1537 | 1531 | self.redraw() | |
| 1538 | 1532 | return '' | |
| 1539 | 1533 | ||
| 1540 | - elif self.c in key_dispatch[OPTS.exit_key]: | ||
| 1534 | + elif self.c in key_dispatch['C-d']: | ||
| 1541 | 1535 | if not self.s: | |
| 1542 | 1536 | self.do_exit = True | |
| 1543 | 1537 | return None | |
@@ -1709,7 +1703,7 @@ def reprint_line(lineno, s, to_replace=[]): | |||
| 1709 | 1703 | # Marker found | |
| 1710 | 1704 | tokens[i] = (Parenthesis, value) | |
| 1711 | 1705 | break | |
| 1712 | - elif opening and under_cursor and not newline: | ||
| 1706 | + elif opening and under_cursor: | ||
| 1713 | 1707 | if self.cpos: | |
| 1714 | 1708 | tokens[i] = (Parenthesis.UnderCursor, value) | |
| 1715 | 1709 | else: | |
@@ -2126,8 +2120,7 @@ def main_curses(scr, args, interactive=True): | |||
| 2126 | 2120 | ||
| 2127 | 2121 | curses.raw(True) | |
| 2128 | 2122 | ||
| 2129 | - interpreter = Interpreter(dict(__name__='__main__', __doc__=None), | ||
| 2130 | - getpreferredencoding()) | ||
| 2123 | + interpreter = Interpreter(getpreferredencoding()) | ||
| 2131 | 2124 | ||
| 2132 | 2125 | repl = Repl(main_win, interpreter, statusbar, idle) | |
| 2133 | 2126 | interpreter.syntaxerror_callback = repl.clear_current_line | |
| Back | FazBrowse Home | New Git URL |
0 commit comments