#!/usr/bin/env python """emano - paste.py""" def paste(editor, text=None): if text is None: # @@ bytes? unicode? clipboard = editor.clipboard else: clipboard = text if not clipboard: editor.statwin.notice('Error: nothing to paste', 1) return # Argh at this code grr = type(clipboard) if grr('\r\n') in clipboard: sep = grr('\r\n') else: sep = grr('\n') lines = clipboard.split(sep) print >> open('/desktop/emano.debug', 'w'), `clipboard`, `sep`, `lines` clipboard = editor.doc.linesep.join(lines) y, x, q, p = editor.mainwin.position() nq, np = editor.doc.insert(q, p, clipboard) # @@ does this work? if q != nq: # ooh, if only it were p/np... editor.doc.setStartchar(q, 0) editor.mainwin.moveTo(nq, np) msg = 'Pasted %s bytes from clipboard' % len(clipboard) editor.statwin.notice(msg) editor.doc.prevcommand = ('paste',) if __name__=="__main__": print __doc__