##// END OF EJS Templates
Make 'Paste Above' the default paste behavior....
Make 'Paste Above' the default paste behavior. Destructive paste mapped to Ctrl-M V is a surprising choice given that there was no drag-to-select on the area being replaced (there is a weaker notion of "selected cell" but this does not map to will-be-replaced- by-paste in the minds of participants in an unscientific poll at PyConCA). Destructive paste is still available as the last paste option in the Edit menu, qualified as "Paste Cell Replace".

File last commit:

r8595:f1c11554
r8715:2a45e0e8
Show More
iostream.py
95 lines | 3.0 KiB | text/x-python | PythonLexer
import sys
import time
from io import StringIO
from session import extract_header, Message
from IPython.utils import io, text
from IPython.utils import py3compat
#-----------------------------------------------------------------------------
# Globals
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
# Stream classes
#-----------------------------------------------------------------------------
class OutStream(object):
"""A file like object that publishes the stream to a 0MQ PUB socket."""
# The time interval between automatic flushes, in seconds.
flush_interval = 0.05
topic=None
def __init__(self, session, pub_socket, name):
self.encoding = 'UTF-8'
self.session = session
self.pub_socket = pub_socket
self.name = name
self.parent_header = {}
self._new_buffer()
def set_parent(self, parent):
self.parent_header = extract_header(parent)
def close(self):
self.pub_socket = None
def flush(self):
#io.rprint('>>>flushing output buffer: %s<<<' % self.name) # dbg
if self.pub_socket is None:
raise ValueError(u'I/O operation on closed file')
else:
data = self._buffer.getvalue()
if data:
content = {u'name':self.name, u'data':data}
msg = self.session.send(self.pub_socket, u'stream', content=content,
parent=self.parent_header, ident=self.topic)
if hasattr(self.pub_socket, 'flush'):
# socket itself has flush (presumably ZMQStream)
self.pub_socket.flush()
self._buffer.close()
self._new_buffer()
def isatty(self):
return False
def __next__(self):
raise IOError('Read not supported on a write only stream.')
if not py3compat.PY3:
next = __next__
def read(self, size=-1):
raise IOError('Read not supported on a write only stream.')
def readline(self, size=-1):
raise IOError('Read not supported on a write only stream.')
def write(self, string):
if self.pub_socket is None:
raise ValueError('I/O operation on closed file')
else:
# Make sure that we're handling unicode
if not isinstance(string, unicode):
string = string.decode(self.encoding, 'replace')
self._buffer.write(string)
current_time = time.time()
if self._start <= 0:
self._start = current_time
elif current_time - self._start > self.flush_interval:
self.flush()
def writelines(self, sequence):
if self.pub_socket is None:
raise ValueError('I/O operation on closed file')
else:
for string in sequence:
self.write(string)
def _new_buffer(self):
self._buffer = StringIO()
self._start = -1