26
26
extensions for multiline input.
27
27
"""
28
28
29
- import sys , os
29
+ import sys
30
+ import os
30
31
from pyrepl import commands
31
32
from pyrepl .historical_reader import HistoricalReader
32
33
from pyrepl .completing_reader import CompletingReader
35
36
36
37
ENCODING = sys .getfilesystemencoding () or 'latin1' # XXX review
37
38
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
+ ]
64
66
65
67
# ____________________________________________________________
66
68
69
+
67
70
class ReadlineConfig (object ):
68
71
readline_completer = None
69
72
completer_delims = dict .fromkeys (' \t \n `~!@#$%^&*()-=+[{]}\\ |;:\' ",<>/?' )
70
73
71
- class ReadlineAlikeReader (HistoricalReader , CompletingReader ):
72
74
75
+ class ReadlineAlikeReader (HistoricalReader , CompletingReader ):
73
76
assume_immutable_completions = False
74
77
use_brackets = False
75
78
sort_in_column = True
@@ -156,10 +159,11 @@ def after_command(self, cmd):
156
159
if self .pos > len (self .buffer ):
157
160
self .pos = len (self .buffer )
158
161
162
+
159
163
class maybe_accept (commands .Command ):
160
164
def do (self ):
161
165
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
163
167
#
164
168
# if there are already several lines and the cursor
165
169
# is not on the last one, always insert a new \n.
@@ -171,7 +175,6 @@ def do(self):
171
175
else :
172
176
self .finish = 1
173
177
174
- # ____________________________________________________________
175
178
176
179
class _ReadlineWrapper (object ):
177
180
reader = None
@@ -369,6 +372,7 @@ def insert_text(self, text):
369
372
# ____________________________________________________________
370
373
# Stubs
371
374
375
+
372
376
def _make_stub (_name , _ret ):
373
377
def stub (* args , ** kwds ):
374
378
import warnings
@@ -380,16 +384,16 @@ def stub(*args, **kwds):
380
384
('read_init_file' , None ),
381
385
('redisplay' , None ),
382
386
('set_pre_input_hook' , None ),
383
- ]:
387
+ ]:
384
388
assert _name not in globals (), _name
385
389
_make_stub (_name , _ret )
386
390
387
- # ____________________________________________________________
388
391
389
392
def _setup ():
390
393
global _old_raw_input
391
394
if _old_raw_input is not None :
392
- return # don't run _setup twice
395
+ return
396
+ # don't run _setup twice
393
397
394
398
try :
395
399
f_in = sys .stdin .fileno ()
0 commit comments