-
Notifications
You must be signed in to change notification settings - Fork 112
Expand file tree
/
Copy pathpydev_ipython_console_010.py
More file actions
87 lines (57 loc) · 2.63 KB
/
pydev_ipython_console_010.py
File metadata and controls
87 lines (57 loc) · 2.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
from IPython.frontend.prefilterfrontend import PrefilterFrontEnd
from pydev_console_utils import Null
import sys
original_stdout = sys.stdout
original_stderr = sys.stderr
#=======================================================================================================================
# PyDevFrontEnd
#=======================================================================================================================
class PyDevFrontEnd(PrefilterFrontEnd):
def __init__(self, *args, **kwargs):
PrefilterFrontEnd.__init__(self, *args, **kwargs)
#Disable the output trap: we want all that happens to go to the output directly
self.shell.output_trap = Null()
self._curr_exec_lines = []
self._continuation_prompt = ''
def capture_output(self):
pass
def release_output(self):
pass
def continuation_prompt(self):
return self._continuation_prompt
def write(self, txt, refresh=True):
original_stdout.write(txt)
def new_prompt(self, prompt):
self.input_buffer = ''
#The java side takes care of this part.
#self.write(prompt)
def show_traceback(self):
import traceback;traceback.print_exc()
def write_out(self, txt, *args, **kwargs):
original_stdout.write(txt)
def write_err(self, txt, *args, **kwargs):
original_stderr.write(txt)
def getNamespace(self):
return self.shell.user_ns
def addExec(self, line):
if self._curr_exec_lines:
if not line:
self._curr_exec_lines.append(line)
#Would be the line below, but we've set the continuation_prompt to ''.
#buf = self.continuation_prompt() + ('\n' + self.continuation_prompt()).join(self._curr_exec_lines)
buf = '\n'.join(self._curr_exec_lines)
self.input_buffer = buf + '\n'
if self._on_enter():
del self._curr_exec_lines[:]
return False #execute complete (no more)
return True #needs more
else:
self._curr_exec_lines.append(line)
return True #needs more
else:
self.input_buffer = line
if not self._on_enter():
#Did not execute
self._curr_exec_lines.append(line)
return True #needs more
return False #execute complete (no more)