# HG changeset patch # User Jun Wu # Date 1480374774 0 # Node ID d4035372db8dc0cc27dcc7145ce9b496f9cd4796 # Parent 03fae9048fa1eb301c30d089edf533f01efb94c5 crecord: move status window text calculation to a separate method We will do some changes there in the next patches. The new method would also be the "source of truth" of the content of the status window (so if the status window needs more than 2 lines, it would be calculated from the new method). Also, moved "statuswin.refresh" to make the code compact and easier to read. diff -r 03fae9048fa1 -r d4035372db8d mercurial/crecord.py --- a/mercurial/crecord.py Mon Nov 28 04:34:01 2016 -0800 +++ b/mercurial/crecord.py Mon Nov 28 23:12:54 2016 +0000 @@ -946,6 +946,17 @@ self.linesprintedtopadsofar += linesprinted return t + 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")] + return [util.ellipsis(l, self.xscreensize - 1) for l in lines] + def updatescreen(self): self.statuswin.erase() self.chunkpad.erase() @@ -954,25 +965,13 @@ # print out the status lines at the top try: - if self.errorstr is not None: - printstring(self.statuswin, self.errorstr, pairname='legend') - printstring(self.statuswin, 'Press any key to continue', - pairname='legend') - self.statuswin.refresh() - return - line1 = _("SELECT CHUNKS: (j/k/up/dn/pgup/pgdn) move cursor; " - "(space/A) toggle hunk/all; (e)dit hunk;") - line2 = _(" (f)old/unfold; (c)onfirm applied; (q)uit; (?) help " - "| [X]=hunk applied **=folded, toggle [a]mend mode") - - printstring(self.statuswin, - util.ellipsis(line1, self.xscreensize - 1), - pairname="legend") - printstring(self.statuswin, - util.ellipsis(line2, self.xscreensize - 1), - pairname="legend") + for line in self._getstatuslines(): + printstring(self.statuswin, line, pairname="legend") + self.statuswin.refresh() except curses.error: pass + if self.errorstr is not None: + return # print out the patch in the remaining part of the window try: @@ -985,9 +984,6 @@ except curses.error: pass - # refresh([pminrow, pmincol, sminrow, smincol, smaxrow, smaxcol]) - self.statuswin.refresh() - def getstatusprefixstring(self, item): """ create a string to prefix a line with which indicates whether 'item'