summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorMarcin Zawada <marcinzw@gmail.com>2017-07-27 19:36:17 +0200
committerMarcin Zawada <marcinzw@gmail.com>2017-07-27 19:36:17 +0200
commitfdfefa521c85cb0d18cadd652234b1e164df4704 (patch)
tree6269a40fcaf9a2f68646d78f10ba467f63c0824b
parent1bbee381f5c25f903cd70d2d56d6204cadf373dd (diff)
downloadranger-fdfefa521c85cb0d18cadd652234b1e164df4704.tar.gz
Movement for long questions
Enable movement of questions given in console mode that exceed the
terminal width
-rw-r--r--ranger/gui/widgets/console.py18
1 files changed, 12 insertions, 6 deletions
diff --git a/ranger/gui/widgets/console.py b/ranger/gui/widgets/console.py
index 2d905f62..272f76c1 100644
--- a/ranger/gui/widgets/console.py
+++ b/ranger/gui/widgets/console.py
@@ -92,7 +92,7 @@ class Console(Widget):  # pylint: disable=too-many-instance-attributes,too-many-
         if self.question_queue:
             assert isinstance(self.question_queue[0], tuple)
             assert len(self.question_queue[0]) == 3
-            self.addstr(0, 0, self.question_queue[0][0])
+            self.addstr(0, 0, self.question_queue[0][0][self.pos:])
             return
 
         self.addstr(0, 0, self.prompt)
@@ -273,22 +273,28 @@ class Console(Widget):  # pylint: disable=too-many-instance-attributes,too-many-
         if direction.horizontal():
             # Ensure that the pointer is moved utf-char-wise
             if self.fm.py3:
+                if self.question_queue:
+                    umax = len(self.question_queue[0][0]) + 1 - self.wid
+                else:
+                    umax = len(self.line) + 1
                 self.pos = direction.move(
                     direction=direction.right(),
                     minimum=0,
-                    maximum=len(self.line) + 1,
+                    maximum=umax,
                     current=self.pos)
             else:
-                if self.fm.py3:
-                    uchar = list(self.line)
-                    upos = len(self.line[:self.pos])
+                if self.question_queue:
+                    uchar = list(self.question_queue[0][0].decode('utf-8', 'ignore'))
+                    upos = len(self.question_queue[0][0][:self.pos].decode('utf-8', 'ignore'))
+                    umax = len(uchar) + 1 - self.wid
                 else:
                     uchar = list(self.line.decode('utf-8', 'ignore'))
                     upos = len(self.line[:self.pos].decode('utf-8', 'ignore'))
+                    umax = len(uchar) + 1
                 newupos = direction.move(
                     direction=direction.right(),
                     minimum=0,
-                    maximum=len(uchar) + 1,
+                    maximum=umax,
                     current=upos)
                 self.pos = len(''.join(uchar[:newupos]).encode('utf-8', 'ignore'))