Patchwork [3,of,3] histedit: render a rolled up description using the proper roll colours

login
register
mail settings
Submitter Jordi Gutiérrez Hermoso
Date Nov. 7, 2019, 8:31 p.m.
Message ID <4d0d2d692de029b4838d.1573158708@chloe>
Download mbox | patch
Permalink /patch/42907/
State New
Headers show

Comments

Jordi Gutiérrez Hermoso - Nov. 7, 2019, 8:31 p.m.
# HG changeset patch
# User Jordi Gutiérrez Hermoso <jordigh@octave.org>
# Date 1572477597 14400
#      Wed Oct 30 19:19:57 2019 -0400
# Node ID 4d0d2d692de029b4838d8fc12a48004749db9480
# Parent  47446180a5ee16af1c90bb20a8dca92fa9d5f794
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.
Yuya Nishihara - Nov. 9, 2019, 2:06 a.m.
On Thu, 07 Nov 2019 15:31:48 -0500, Jordi Gutiérrez Hermoso wrote:
> # HG changeset patch
> # User Jordi Gutiérrez Hermoso <jordigh@octave.org>
> # Date 1572477597 14400
> #      Wed Oct 30 19:19:57 2019 -0400
> # Node ID 4d0d2d692de029b4838d8fc12a48004749db9480
> # Parent  47446180a5ee16af1c90bb20a8dca92fa9d5f794
> histedit: render a rolled up description using the proper roll colours

> @@ -1508,7 +1511,12 @@ pgup/K: move patch up, pgdn/J: move patc
>                      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))

Nit: exceeds 80-column rule. Maybe you need to run black.

Patch

diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -1497,9 +1497,12 @@  pgup/K: move patch up, pgdn/J: move patc
                 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,
@@ -1508,7 +1511,12 @@  pgup/K: move patch up, pgdn/J: move patc
                     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):