changeset 2939:18a98a541f7a

jp (xmlui manager): basic handling of multi-lines text in TextBoxWidget
author Goffi <goffi@goffi.org>
date Fri, 03 May 2019 20:49:27 +0200
parents 48985ef7682f
children ef554aca3eb1
files sat_frontends/jp/cmd_file.py sat_frontends/jp/xmlui_manager.py
diffstat 2 files changed, 24 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/sat_frontends/jp/cmd_file.py	Fri May 03 20:48:19 2019 +0200
+++ b/sat_frontends/jp/cmd_file.py	Fri May 03 20:49:27 2019 +0200
@@ -756,7 +756,7 @@
 
     def _FISInviteCb(self):
         self.disp(
-            _(u'invitation sent do {entity}').format(entity=self.args.jid)
+            _(u'invitation sent to {entity}').format(entity=self.args.jid)
         )
         self.host.quit()
 
--- a/sat_frontends/jp/xmlui_manager.py	Fri May 03 20:48:19 2019 +0200
+++ b/sat_frontends/jp/xmlui_manager.py	Fri May 03 20:49:27 2019 +0200
@@ -236,6 +236,29 @@
 
 class TextBoxWidget(xmlui_base.TextWidget, StringWidget):
     type = u"textbox"
+    # TODO: use a more advanced input method
+
+    def show(self):
+        self.verboseName()
+        if self.read_only:
+            self.disp(self.value)
+        else:
+            if self.value:
+                self.disp(A.color(C.A_HEADER, u"↓ current value ↓\n", A.FG_CYAN, self.value,
+                                  ""))
+
+            values = []
+            while True:
+                try:
+                    if not values:
+                        line = raw_input(A.color(C.A_HEADER, u"[Ctrl-D to finish]> "))
+                    else:
+                        line = raw_input()
+                    values.append(line)
+                except EOFError:
+                   break
+
+            self.value = u'\n'.join(values).rstrip()
 
 
 class XHTMLBoxWidget(xmlui_base.XHTMLBoxWidget, StringWidget):