Show More
@@ -101,21 +101,28 b' class LineFrontEndBase(FrontEndBase):' | |||
|
101 | 101 | if raw_string is None: |
|
102 | 102 | raw_string = string |
|
103 | 103 | # Create a false result, in case there is an exception |
|
104 | result = dict(number=self.prompt_number) | |
|
104 | self.last_result = dict(number=self.prompt_number) | |
|
105 | 105 | try: |
|
106 | 106 | self.history.input_cache[-1] = raw_string |
|
107 | 107 | result = self.shell.execute(python_string) |
|
108 | self.last_result = result | |
|
108 | 109 | self.render_result(result) |
|
109 |
except |
|
|
110 | except: | |
|
110 | 111 | self.show_traceback() |
|
111 | 112 | finally: |
|
112 | self.prompt_number += 1 | |
|
113 | self.new_prompt(self.prompt % (result['number'] + 1)) | |
|
114 | # Start a new empty history entry | |
|
115 | self._add_history(None, '') | |
|
116 | # The result contains useful information that can be used | |
|
117 | # elsewhere. | |
|
118 | self.last_result = result | |
|
113 | self.after_execute() | |
|
114 | ||
|
115 | ||
|
116 | def after_execute(self): | |
|
117 | """ All the operations required after an execution to put the | |
|
118 | terminal back in a shape where it is usable. | |
|
119 | """ | |
|
120 | self.prompt_number += 1 | |
|
121 | self.new_prompt(self.prompt % (self.last_result['number'] + 1)) | |
|
122 | # Start a new empty history entry | |
|
123 | self._add_history(None, '') | |
|
124 | # The result contains useful information that can be used | |
|
125 | # elsewhere. | |
|
119 | 126 | |
|
120 | 127 | |
|
121 | 128 | def _on_enter(self): |
@@ -124,13 +131,15 b' class LineFrontEndBase(FrontEndBase):' | |||
|
124 | 131 | """ |
|
125 | 132 | current_buffer = self.get_current_edit_buffer() |
|
126 | 133 | cleaned_buffer = self.prefilter_input(current_buffer) |
|
127 | if self.is_complete(cleaned_buffer): | |
|
134 | if self.is_complete(cleaned_buffer + '\n'): | |
|
135 | # The '\n' is important in case prefiltering empties the | |
|
136 | # line, to get a new prompt. | |
|
128 | 137 | self.execute(cleaned_buffer, raw_string=current_buffer) |
|
129 | 138 | else: |
|
130 | 139 | if len(current_buffer.split('\n'))>1: |
|
131 |
self.write( |
|
|
140 | self.write(self._get_indent_string(current_buffer)) | |
|
132 | 141 | else: |
|
133 |
self.write(' |
|
|
142 | self.write('\t') | |
|
134 | 143 | |
|
135 | 144 | |
|
136 | 145 | #-------------------------------------------------------------------------- |
@@ -138,7 +147,7 b' class LineFrontEndBase(FrontEndBase):' | |||
|
138 | 147 | #-------------------------------------------------------------------------- |
|
139 | 148 | |
|
140 | 149 | def _get_indent_string(self, string): |
|
141 | print >>sys.__stderr__, string.split('\n') | |
|
150 | string = string.replace('\t', ' '*4) | |
|
142 | 151 | string = string.split('\n')[-1] |
|
143 | 152 | indent_chars = len(string) - len(string.lstrip()) |
|
144 | 153 | indent_string = '\t'*(indent_chars // 4) + \ |
@@ -343,6 +343,7 b' class ConsoleWidget(editwindow.EditWindow):' | |||
|
343 | 343 | if event.KeyCode in (13, wx.WXK_NUMPAD_ENTER) and \ |
|
344 | 344 | event.Modifiers in (wx.MOD_NONE, wx.MOD_WIN): |
|
345 | 345 | catched = True |
|
346 | self.write('\n') | |
|
346 | 347 | self._on_enter() |
|
347 | 348 | |
|
348 | 349 | elif event.KeyCode == wx.WXK_HOME: |
@@ -32,7 +32,7 b' from IPython.frontend.prefilterfrontend import PrefilterFrontEnd' | |||
|
32 | 32 | class IPythonWxController(PrefilterFrontEnd, ConsoleWidget): |
|
33 | 33 | |
|
34 | 34 | output_prompt = \ |
|
35 |
' |
|
|
35 | '\x01\x1b[0;31m\x02Out[\x01\x1b[1;31m\x02%i\x01\x1b[0;31m\x02]: \x01\x1b[0m\x02' | |
|
36 | 36 | |
|
37 | 37 | #-------------------------------------------------------------------------- |
|
38 | 38 | # Public API |
General Comments 0
You need to be logged in to leave comments.
Login now