mercurial/crecord.py
changeset 30555 9b674957e2e4
parent 30554 f3cff00c7a00
child 30556 5129ed3c2548
--- a/mercurial/crecord.py	Wed Nov 23 22:23:15 2016 +0000
+++ b/mercurial/crecord.py	Mon Nov 28 23:33:02 2016 +0000
@@ -946,15 +946,39 @@
         self.linesprintedtopadsofar += linesprinted
         return t
 
+    def _getstatuslinesegments(self):
+        """-> [str]. return segments"""
+        segments = [
+            _('Select hunks to record'),
+            '-',
+            _('[x]=selected **=collapsed'),
+            _('c: confirm'),
+            _('q: abort'),
+            _('arrow keys: move/expand/collapse'),
+            _('space: select'),
+            _('?: help'),
+        ]
+        return segments
+
     def _getstatuslines(self):
         """() -> [str]. return short help used in the top status window"""
         if self.errorstr is not None:
             lines = [self.errorstr, _('Press any key to continue')]
         else:
-            lines = [_("SELECT CHUNKS: (j/k/up/dn/pgup/pgdn) move cursor; "
-                       "(space/A) toggle hunk/all; (e)dit hunk;"),
-                     _(" (f)old/unfold; (c)onfirm applied; (q)uit; (?) help "
-                       "| [X]=hunk applied **=folded, toggle [a]mend mode")]
+            # wrap segments to lines
+            segments = self._getstatuslinesegments()
+            width = self.xscreensize
+            lines = []
+            lastwidth = width
+            for s in segments:
+                w = encoding.colwidth(s)
+                sep = ' ' * (1 + (s and s[0] not in '-['))
+                if lastwidth + w + len(sep) >= width:
+                    lines.append(s)
+                    lastwidth = w
+                else:
+                    lines[-1] += sep + s
+                    lastwidth += w + len(sep)
         if len(lines) != self.numstatuslines:
             self.numstatuslines = len(lines)
             self.statuswin.resize(self.numstatuslines, self.xscreensize)