Show More
@@ -48,7 +48,7 b' class IPythonWidget(FrontendWidget):' | |||||
48 | """ |
|
48 | """ | |
49 |
|
49 | |||
50 | # Default prompts. |
|
50 | # Default prompts. | |
51 |
in_prompt = ' |
|
51 | in_prompt = 'In [<span class="in-prompt-number">%i</span>]: ' | |
52 | out_prompt = 'Out[<span class="out-prompt-number">%i</span>]: ' |
|
52 | out_prompt = 'Out[<span class="out-prompt-number">%i</span>]: ' | |
53 |
|
53 | |||
54 | # FrontendWidget protected class attributes. |
|
54 | # FrontendWidget protected class attributes. | |
@@ -72,13 +72,14 b' class IPythonWidget(FrontendWidget):' | |||||
72 | # 'BaseFrontendMixin' abstract interface |
|
72 | # 'BaseFrontendMixin' abstract interface | |
73 | #--------------------------------------------------------------------------- |
|
73 | #--------------------------------------------------------------------------- | |
74 |
|
74 | |||
75 |
def _handle_pyout(self, |
|
75 | def _handle_pyout(self, msg): | |
76 | """ Reimplemented for IPython-style "display hook". |
|
76 | """ Reimplemented for IPython-style "display hook". | |
77 | """ |
|
77 | """ | |
78 |
|
|
78 | content = msg['content'] | |
79 | data = omsg['content']['data'] |
|
79 | prompt_number = content['prompt_number'] | |
|
80 | self._append_plain_text(content['output_sep']) | |||
80 | self._append_html(self._make_out_prompt(prompt_number)) |
|
81 | self._append_html(self._make_out_prompt(prompt_number)) | |
81 | self._append_plain_text(data + '\n') |
|
82 | self._append_plain_text(content['data'] + '\n' + content['output_sep2']) | |
82 |
|
83 | |||
83 | #--------------------------------------------------------------------------- |
|
84 | #--------------------------------------------------------------------------- | |
84 | # 'FrontendWidget' interface |
|
85 | # 'FrontendWidget' interface | |
@@ -96,7 +97,7 b' class IPythonWidget(FrontendWidget):' | |||||
96 | def _get_banner(self): |
|
97 | def _get_banner(self): | |
97 | """ Reimplemented to return IPython's default banner. |
|
98 | """ Reimplemented to return IPython's default banner. | |
98 | """ |
|
99 | """ | |
99 | return default_banner |
|
100 | return default_banner + '\n' | |
100 |
|
101 | |||
101 | def _process_execute_error(self, msg): |
|
102 | def _process_execute_error(self, msg): | |
102 | """ Reimplemented for IPython-style traceback formatting. |
|
103 | """ Reimplemented for IPython-style traceback formatting. | |
@@ -113,19 +114,20 b' class IPythonWidget(FrontendWidget):' | |||||
113 |
|
114 | |||
114 | self._append_html(traceback) |
|
115 | self._append_html(traceback) | |
115 |
|
116 | |||
116 | def _show_interpreter_prompt(self, number=None): |
|
117 | def _show_interpreter_prompt(self, number=None, input_sep='\n'): | |
117 | """ Reimplemented for IPython-style prompts. |
|
118 | """ Reimplemented for IPython-style prompts. | |
118 | """ |
|
119 | """ | |
119 | # TODO: If a number was not specified, make a prompt number request. |
|
120 | # TODO: If a number was not specified, make a prompt number request. | |
120 | if number is None: |
|
121 | if number is None: | |
121 | number = 0 |
|
122 | number = 0 | |
122 |
|
123 | |||
123 |
# Show a new prompt and save information about it so it can be |
|
124 | # Show a new prompt and save information about it so that it can be | |
124 |
# later if |
|
125 | # updated later if the prompt number turns out to be wrong. | |
125 | block = self._control.document().lastBlock() |
|
126 | self._append_plain_text(input_sep) | |
126 | self._show_prompt(self._make_in_prompt(number), html=True) |
|
127 | self._show_prompt(self._make_in_prompt(number), html=True) | |
127 | self._previous_prompt_obj = IPythonPromptBlock( |
|
128 | block = self._control.document().lastBlock() | |
128 |
|
|
129 | length = len(self._prompt) | |
|
130 | self._previous_prompt_obj = IPythonPromptBlock(block, length, number) | |||
129 |
|
131 | |||
130 | # Update continuation prompt to reflect (possibly) new prompt length. |
|
132 | # Update continuation prompt to reflect (possibly) new prompt length. | |
131 | self._set_continuation_prompt( |
|
133 | self._set_continuation_prompt( | |
@@ -161,7 +163,9 b' class IPythonWidget(FrontendWidget):' | |||||
161 | self._previous_prompt_obj = None |
|
163 | self._previous_prompt_obj = None | |
162 |
|
164 | |||
163 | # Show a new prompt with the kernel's estimated prompt number. |
|
165 | # Show a new prompt with the kernel's estimated prompt number. | |
164 |
|
|
166 | next_prompt = content['next_prompt'] | |
|
167 | self._show_interpreter_prompt(next_prompt['prompt_number'], | |||
|
168 | next_prompt['input_sep']) | |||
165 |
|
169 | |||
166 | #--------------------------------------------------------------------------- |
|
170 | #--------------------------------------------------------------------------- | |
167 | # 'IPythonWidget' interface |
|
171 | # 'IPythonWidget' interface |
General Comments 0
You need to be logged in to leave comments.
Login now