@@ -129,12 +129,16 @@ class BPythonEdit(urwid.Edit):
129
129
130
130
This is currently a one-way operation, but that is just because
131
131
I only need and test the readwrite->readonly transition.
132
+
133
+ - move_cursor_to_coords is ignored
134
+ (except for internal calls from keypress or mouse_event).
132
135
"""
133
136
134
137
def __init__ (self , * args , ** kwargs ):
135
138
self ._bpy_text = ''
136
139
self ._bpy_attr = []
137
140
self ._bpy_selectable = True
141
+ self ._bpy_may_move_cursor = False
138
142
urwid .Edit .__init__ (self , * args , ** kwargs )
139
143
140
144
def make_readonly (self ):
@@ -182,6 +186,25 @@ def get_pref_col(self, size):
182
186
return 'left'
183
187
return urwid .Edit .get_pref_col (self , size )
184
188
189
+ def move_cursor_to_coords (self , * args ):
190
+ if self ._bpy_may_move_cursor :
191
+ return urwid .Edit .move_cursor_to_coords (self , * args )
192
+ return False
193
+
194
+ def keypress (self , * args ):
195
+ self ._bpy_may_move_cursor = True
196
+ try :
197
+ return urwid .Edit .keypress (self , * args )
198
+ finally :
199
+ self ._bpy_may_move_cursor = False
200
+
201
+ def mouse_event (self , * args ):
202
+ self ._bpy_may_move_cursor = True
203
+ try :
204
+ return urwid .Edit .mouse_event (self , * args )
205
+ finally :
206
+ self ._bpy_may_move_cursor = False
207
+
185
208
186
209
class Tooltip (urwid .BoxWidget ):
187
210
@@ -460,6 +483,8 @@ def prompt(self, more):
460
483
self .stdout_hist += '... '
461
484
462
485
urwid .connect_signal (self .edit , 'change' , self .on_input_change )
486
+ # Do this after connecting the change signal handler:
487
+ self .edit .insert_text (4 * self .next_indentation () * ' ' )
463
488
self .edits .append (self .edit )
464
489
self .listbox .body .append (self .edit )
465
490
self .listbox .set_focus (len (self .listbox .body ) - 1 )
0 commit comments