changeset 1946:827bb478d8af

primitivus: paste is now detected, and put in edit bar, so use can check and validate it
author Goffi <goffi@goffi.org>
date Thu, 21 Apr 2016 20:20:40 +0200
parents 2c75011d7b2d
children be4b143cf123
files frontends/src/primitivus/primitivus
diffstat 1 files changed, 17 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/frontends/src/primitivus/primitivus	Tue Apr 19 20:09:02 2016 +0200
+++ b/frontends/src/primitivus/primitivus	Thu Apr 21 20:20:40 2016 +0200
@@ -361,6 +361,23 @@
     def inputFilter(self, input_, raw):
         if self.__saved_overlay and input_ != a_key['OVERLAY_HIDE']:
             return
+
+        if len(input_) > 1: # XXX: it may be needed to increase this value if buffer
+                            #      or other things result in several chars at once
+                            #      (e.g. using Primitivus through ssh). Need some testing
+                            #      and experience to adjust value.
+            log.debug(u"Paste detected")
+            try:
+                edit_bar = self.editBar
+            except AttributeError:
+                log.warning(u"Paste discarded: there is no edit bar yet")
+            else:
+                # XXX: if a paste is detected, we append it directly to the edit bar text
+                #      so the use can check it and press [enter] if it's OK
+                buf_paste = u''.join((unichr(k) for k in raw))
+                edit_bar.set_edit_text(u'{}{}'.format(edit_bar.edit_text, buf_paste))
+                return
+
         for i in input_:
             if isinstance(i,tuple):
                 if i[0] == 'mouse press':