@@ -37,16 +37,16 @@ def _make_unctrl_map():
37
37
for i in range (256 ):
38
38
c = unichr (i )
39
39
if not uc_map .has_key (c ):
40
- uc_map [c ] = u'\\ %03o' % i
40
+ uc_map [c ] = u'\\ %03o' % i
41
41
return uc_map
42
42
43
43
# disp_str proved to be a bottleneck for large inputs, so it's been
44
44
# rewritten in C; it's not required though.
45
45
try :
46
46
raise ImportError # currently it's borked by the unicode support
47
-
47
+
48
48
from _pyrepl_utils import disp_str , init_unctrl_map
49
-
49
+
50
50
init_unctrl_map (_make_unctrl_map ())
51
51
52
52
del init_unctrl_map
@@ -118,7 +118,7 @@ def make_default_syntax_table():
118
118
(r'\C-x\C-u' , 'upcase-region' ),
119
119
(r'\C-y' , 'yank' ),
120
120
(r'\C-z' , 'suspend' ),
121
-
121
+
122
122
(r'\M-b' , 'backward-word' ),
123
123
(r'\M-c' , 'capitalize-word' ),
124
124
(r'\M-d' , 'kill-word' ),
@@ -303,7 +303,7 @@ def calc_screen(self):
303
303
304
304
def process_prompt (self , prompt ):
305
305
""" Process the prompt.
306
-
306
+
307
307
This means calculate the length of the prompt. The character \x01
308
308
and \x02 are used to bracket ANSI control sequences and need to be
309
309
excluded from the length calculation. So also a copy of the prompt
@@ -372,7 +372,7 @@ def bol(self, p=None):
372
372
while p >= 0 and b [p ] <> '\n ' :
373
373
p -= 1
374
374
return p + 1
375
-
375
+
376
376
def eol (self , p = None ):
377
377
"""Return the 0-based index of the line break following p most
378
378
immediately.
@@ -463,7 +463,7 @@ def after_command(self, cmd):
463
463
"""This function is called to allow post command cleanup."""
464
464
if getattr (cmd , "kills_digit_arg" , 1 ):
465
465
if self .arg is not None :
466
- self .dirty = 1
466
+ self .dirty = 1
467
467
self .arg = None
468
468
469
469
def prepare (self ):
@@ -575,13 +575,15 @@ def handle1(self, block=1):
575
575
def push_char (self , char ):
576
576
self .console .push_char (char )
577
577
self .handle1 (0 )
578
-
579
- def readline (self , returns_unicode = False ):
578
+
579
+ def readline (self , returns_unicode = False , startup_hook = None ):
580
580
"""Read a line. The implementation of this method also shows
581
581
how to drive Reader if you want more control over the event
582
582
loop."""
583
583
self .prepare ()
584
584
try :
585
+ if startup_hook is not None :
586
+ startup_hook ()
585
587
self .refresh ()
586
588
while not self .finished :
587
589
self .handle1 ()
0 commit comments