Patchwork chistedit: use default curses colours

login
register
mail settings
Submitter Jordi Gutiérrez Hermoso
Date April 4, 2019, 3:13 a.m.
Message ID <263cec9c08fc1b517847.1554347596@chloe>
Download mbox | patch
Permalink /patch/39473/
State Superseded
Headers show

Comments

Jordi Gutiérrez Hermoso - April 4, 2019, 3:13 a.m.
# HG changeset patch
# User Jordi Gutiérrez Hermoso <jordigh@octave.org>
# Date 1554347266 14400
#      Wed Apr 03 23:07:46 2019 -0400
# Node ID 263cec9c08fc1b517847fe53f27b47978be127f4
# Parent  4ee906aa7b60fb6b113e4dc187fbb5a8f42e557c
chistedit: use default curses colours

Terminals will define default colours (for example, white text on
black background), but curses doesn't obey those default colours
unless told to do so.

Calling `curses.use_default_colors` makes curses obey the default
terminal colours. One of the most obvious effects is that this allows
transparency on terminals that support it.

This also brings chistedit closer in appearance to crecord, which also
uses default colours.
Pulkit Goyal - April 5, 2019, 2:51 p.m.
On Thu, Apr 4, 2019 at 6:15 AM Jordi Gutiérrez Hermoso <jordigh@octave.org>
wrote:

> # HG changeset patch
> # User Jordi Gutiérrez Hermoso <jordigh@octave.org>
> # Date 1554347266 14400
> #      Wed Apr 03 23:07:46 2019 -0400
> # Node ID 263cec9c08fc1b517847fe53f27b47978be127f4
> # Parent  4ee906aa7b60fb6b113e4dc187fbb5a8f42e557c
> chistedit: use default curses colours
>
> Terminals will define default colours (for example, white text on
> black background), but curses doesn't obey those default colours
> unless told to do so.
>
> Calling `curses.use_default_colors` makes curses obey the default
> terminal colours. One of the most obvious effects is that this allows
> transparency on terminals that support it.
>
> This also brings chistedit closer in appearance to crecord, which also
> uses default colours.
>
> diff --git a/hgext/histedit.py b/hgext/histedit.py
> --- a/hgext/histedit.py
> +++ b/hgext/histedit.py
> @@ -1238,6 +1238,8 @@ def patchcontents(state):
>      return displayer.hunk[rule.ctx.rev()].splitlines()
>
>  def _chisteditmain(repo, rules, stdscr):
> +    curses.use_default_colors()
>

This can raise curses.error. We need to catch that. Related:
https://www.mercurial-scm.org/repo/hg-committed/rev/fb2e59e92651c33918987b9bbf84cedb37ac2557

Patch

diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -1238,6 +1238,8 @@  def patchcontents(state):
     return displayer.hunk[rule.ctx.rev()].splitlines()
 
 def _chisteditmain(repo, rules, stdscr):
+    curses.use_default_colors()
+
     # initialize color pattern
     curses.init_pair(COLOR_HELP, curses.COLOR_WHITE, curses.COLOR_BLUE)
     curses.init_pair(COLOR_SELECTED, curses.COLOR_BLACK, curses.COLOR_WHITE)