2626extensions for multiline input.
2727"""
2828
29- import sys , os
29+ import sys
30+ import os
3031from pyrepl import commands
3132from pyrepl .historical_reader import HistoricalReader
3233from pyrepl .completing_reader import CompletingReader
3536
3637ENCODING = sys .getfilesystemencoding () or 'latin1' # XXX review
3738
38- __all__ = ['add_history' ,
39- 'clear_history' ,
40- 'get_begidx' ,
41- 'get_completer' ,
42- 'get_completer_delims' ,
43- 'get_current_history_length' ,
44- 'get_endidx' ,
45- 'get_history_item' ,
46- 'get_history_length' ,
47- 'get_line_buffer' ,
48- 'insert_text' ,
49- 'parse_and_bind' ,
50- 'read_history_file' ,
51- 'read_init_file' ,
52- 'redisplay' ,
53- 'remove_history_item' ,
54- 'replace_history_item' ,
55- 'set_completer' ,
56- 'set_completer_delims' ,
57- 'set_history_length' ,
58- 'set_pre_input_hook' ,
59- 'set_startup_hook' ,
60- 'write_history_file' ,
61- # ---- multiline extensions ----
62- 'multiline_input' ,
63- ]
39+ __all__ = [
40+ 'add_history' ,
41+ 'clear_history' ,
42+ 'get_begidx' ,
43+ 'get_completer' ,
44+ 'get_completer_delims' ,
45+ 'get_current_history_length' ,
46+ 'get_endidx' ,
47+ 'get_history_item' ,
48+ 'get_history_length' ,
49+ 'get_line_buffer' ,
50+ 'insert_text' ,
51+ 'parse_and_bind' ,
52+ 'read_history_file' ,
53+ 'read_init_file' ,
54+ 'redisplay' ,
55+ 'remove_history_item' ,
56+ 'replace_history_item' ,
57+ 'set_completer' ,
58+ 'set_completer_delims' ,
59+ 'set_history_length' ,
60+ 'set_pre_input_hook' ,
61+ 'set_startup_hook' ,
62+ 'write_history_file' ,
63+ # ---- multiline extensions ----
64+ 'multiline_input' ,
65+ ]
6466
6567# ____________________________________________________________
6668
69+
6770class ReadlineConfig (object ):
6871 readline_completer = None
6972 completer_delims = dict .fromkeys (' \t \n `~!@#$%^&*()-=+[{]}\\ |;:\' ",<>/?' )
7073
71- class ReadlineAlikeReader (HistoricalReader , CompletingReader ):
7274
75+ class ReadlineAlikeReader (HistoricalReader , CompletingReader ):
7376 assume_immutable_completions = False
7477 use_brackets = False
7578 sort_in_column = True
@@ -156,10 +159,11 @@ def after_command(self, cmd):
156159 if self .pos > len (self .buffer ):
157160 self .pos = len (self .buffer )
158161
162+
159163class maybe_accept (commands .Command ):
160164 def do (self ):
161165 r = self .reader
162- r .dirty = 1 # this is needed to hide the completion menu, if visible
166+ r .dirty = 1 # this is needed to hide the completion menu, if visible
163167 #
164168 # if there are already several lines and the cursor
165169 # is not on the last one, always insert a new \n.
@@ -171,7 +175,6 @@ def do(self):
171175 else :
172176 self .finish = 1
173177
174- # ____________________________________________________________
175178
176179class _ReadlineWrapper (object ):
177180 reader = None
@@ -369,6 +372,7 @@ def insert_text(self, text):
369372# ____________________________________________________________
370373# Stubs
371374
375+
372376def _make_stub (_name , _ret ):
373377 def stub (* args , ** kwds ):
374378 import warnings
@@ -380,16 +384,16 @@ def stub(*args, **kwds):
380384 ('read_init_file' , None ),
381385 ('redisplay' , None ),
382386 ('set_pre_input_hook' , None ),
383- ]:
387+ ]:
384388 assert _name not in globals (), _name
385389 _make_stub (_name , _ret )
386390
387- # ____________________________________________________________
388391
389392def _setup ():
390393 global _old_raw_input
391394 if _old_raw_input is not None :
392- return # don't run _setup twice
395+ return
396+ # don't run _setup twice
393397
394398 try :
395399 f_in = sys .stdin .fileno ()
0 commit comments