##// END OF EJS Templates
Proper redirection of keystrokes to subprocesses.
Gael Varoquaux -
Show More
@@ -34,7 +34,7 b' class PipedProcess(Thread):'
34 34 """
35 35 process = Popen((self.command_string + ' 2>&1', ), shell=True,
36 36 universal_newlines=True,
37 stdout=PIPE, stdin=PIPE)
37 stdout=PIPE, stdin=PIPE, )
38 38 self.process = process
39 39 while True:
40 40 out_char = process.stdout.read(1)
@@ -12,6 +12,8 b' class IPythonXController(WxController):'
12 12 bindings.
13 13 """
14 14
15 debug = False
16
15 17 def __init__(self, *args, **kwargs):
16 18 WxController.__init__(self, *args, **kwargs)
17 19 self.ipython0.ask_exit = self.do_exit
@@ -276,7 +276,6 b' class WxController(PrefilterFrontEnd, ConsoleWidget):'
276 276 """ Capture the character events, let the parent
277 277 widget handle them, and put our logic afterward.
278 278 """
279 print >>sys.__stderr__, event.KeyCode
280 279 current_line_number = self.GetCurrentLine()
281 280 if event.KeyCode in (ord('c'), ord('C')) and event.ControlDown():
282 281 # Capture Control-C
@@ -290,13 +289,23 b' class WxController(PrefilterFrontEnd, ConsoleWidget):'
290 289 raise KeyboardException
291 290 # XXX: We need to make really sure we
292 291 # get back to a prompt.
293 elif self._input_state == 'subprocess' and event.KeyCode<256 \
294 and event.Modifiers in (wx.MOD_NONE, wx.MOD_WIN):
292 elif self._input_state == 'subprocess' and (
293 ( event.KeyCode<256 and
294 event.Modifiers in (wx.MOD_NONE, wx.MOD_WIN, wx.MOD_SHIFT))
295 or
296 ( event.KeyCode in (ord('d'), ord('D')) and
297 event.ControlDown())):
295 298 # We are running a process, we redirect keys.
296 299 ConsoleWidget._on_key_down(self, event, skip=skip)
297 if self.debug:
298 print >>sys.__stderr__, chr(event.KeyCode)
299 self._running_process.process.stdin.write(chr(event.KeyCode))
300 char = chr(event.KeyCode)
301 # Deal with some inconsistency in wx keycodes:
302 if char == '\r':
303 char = '\n'
304 elif not event.ShiftDown():
305 char = char.lower()
306 if event.ControlDown() and event.KeyCode in (ord('d'), ord('D')):
307 char = '\04'
308 self._running_process.process.stdin.write(char)
300 309 self._running_process.process.stdin.flush()
301 310 elif event.KeyCode in (ord('('), 57):
302 311 # Calltips
General Comments 0
You need to be logged in to leave comments. Login now