##// END OF EJS Templates
Make `ipython console` aware of clear_output changes.
Jonathan Frederic -
Show More
@@ -43,6 +43,7 b' class ZMQTerminalInteractiveShell(TerminalInteractiveShell):'
43 """A subclass of TerminalInteractiveShell that uses the 0MQ kernel"""
43 """A subclass of TerminalInteractiveShell that uses the 0MQ kernel"""
44 _executing = False
44 _executing = False
45 _execution_state = Unicode('')
45 _execution_state = Unicode('')
46 _pending_clearoutput = False
46 kernel_timeout = Float(60, config=True,
47 kernel_timeout = Float(60, config=True,
47 help="""Timeout for giving up on a kernel (in seconds).
48 help="""Timeout for giving up on a kernel (in seconds).
48
49
@@ -241,13 +242,22 b' class ZMQTerminalInteractiveShell(TerminalInteractiveShell):'
241 self._execution_state = sub_msg["content"]["execution_state"]
242 self._execution_state = sub_msg["content"]["execution_state"]
242 elif msg_type == 'stream':
243 elif msg_type == 'stream':
243 if sub_msg["content"]["name"] == "stdout":
244 if sub_msg["content"]["name"] == "stdout":
245 if self._pending_clearoutput:
246 print("\r", file=io.stdout, end="")
247 self._pending_clearoutput = False
244 print(sub_msg["content"]["data"], file=io.stdout, end="")
248 print(sub_msg["content"]["data"], file=io.stdout, end="")
245 io.stdout.flush()
249 io.stdout.flush()
246 elif sub_msg["content"]["name"] == "stderr" :
250 elif sub_msg["content"]["name"] == "stderr" :
251 if self._pending_clearoutput:
252 print("\r", file=io.stderr, end="")
253 self._pending_clearoutput = False
247 print(sub_msg["content"]["data"], file=io.stderr, end="")
254 print(sub_msg["content"]["data"], file=io.stderr, end="")
248 io.stderr.flush()
255 io.stderr.flush()
249
256
250 elif msg_type == 'pyout':
257 elif msg_type == 'pyout':
258 if self._pending_clearoutput:
259 print("\r", file=io.stdout, end="")
260 self._pending_clearoutput = False
251 self.execution_count = int(sub_msg["content"]["execution_count"])
261 self.execution_count = int(sub_msg["content"]["execution_count"])
252 format_dict = sub_msg["content"]["data"]
262 format_dict = sub_msg["content"]["data"]
253 self.handle_rich_data(format_dict)
263 self.handle_rich_data(format_dict)
@@ -267,6 +277,12 b' class ZMQTerminalInteractiveShell(TerminalInteractiveShell):'
267 if 'text/plain' in data:
277 if 'text/plain' in data:
268 print(data['text/plain'])
278 print(data['text/plain'])
269
279
280 elif msg_type == 'clear_output':
281 if sub_msg["content"]["wait"]:
282 self._pending_clearoutput = True
283 else:
284 print("\r", file=io.stdout, end="")
285
270 _imagemime = {
286 _imagemime = {
271 'image/png': 'png',
287 'image/png': 'png',
272 'image/jpeg': 'jpeg',
288 'image/jpeg': 'jpeg',
General Comments 0
You need to be logged in to leave comments. Login now