histedit: render a rolled up description using the proper roll colours
Users have rightfully complained that the old behaviour of completely
removing the description of a rolled commit makes it difficult to
remember what was in that commit. Instead, we now render the removed
description in red.
I couldn't think of a simpler way to do this. You can't just combine
existing curses colours into new effects; only secondary effects like
bold or underline can be logically OR'ed to generate a combined text
effect. It seems easier to just redundantly keep track of what the
roll colour should be.
--- a/hgext/histedit.py Wed Oct 30 19:34:57 2019 -0400
+++ b/hgext/histedit.py Wed Oct 30 19:19:57 2019 -0400
@@ -1499,9 +1499,12 @@
rulesscr.addstr(y, 0, b" ", curses.color_pair(COLOR_WARN))
else:
rulesscr.addstr(y, 0, b" ", curses.COLOR_BLACK)
+
if y + start == selected:
+ rollcolor = COLOR_ROLL_SELECTED
addln(rulesscr, y, 2, rule, curses.color_pair(COLOR_SELECTED))
elif y + start == pos:
+ rollcolor = COLOR_ROLL_CURRENT
addln(
rulesscr,
y,
@@ -1510,7 +1513,17 @@
curses.color_pair(COLOR_CURRENT) | curses.A_BOLD,
)
else:
+ rollcolor = COLOR_ROLL
addln(rulesscr, y, 2, rule)
+
+ if rule.action == b'roll':
+ rulesscr.addstr(
+ y,
+ 2 + len(rule.prefix),
+ rule.desc,
+ curses.color_pair(rollcolor),
+ )
+
rulesscr.noutrefresh()
def renderstring(win, state, output, diffcolors=False):