Patchwork [1,of,2,V2] chistedit: use default curses colours

mail settings
Submitter Jordi Gutiérrez Hermoso
Date April 5, 2019, 6:56 p.m.
Message ID <ede500c898adaab1d78f.1554490597@chloe>
Download mbox | patch
Permalink /patch/39517/
State Accepted
Headers show


Jordi Gutiérrez Hermoso - April 5, 2019, 6:56 p.m.
# HG changeset patch
# User Jordi Gutiérrez Hermoso <>
# Date 1554490485 14400
#      Fri Apr 05 14:54:45 2019 -0400
# Node ID ede500c898adaab1d78f5e048fe84774c9f01fea
# Parent  a975821d0938615b8cb235f12cc6461a42dcfbd8
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.

The call may error out if the terminal doesn't support colors, but as
far as I can tell, everything still works. If we need a more careful
handling of lack of colours, blame me for not doing it now.


diff --git a/hgext/ b/hgext/
--- a/hgext/
+++ b/hgext/
@@ -1238,6 +1238,11 @@  def patchcontents(state):
     return displayer.hunk[rule.ctx.rev()].splitlines()
 def _chisteditmain(repo, rules, stdscr):
+    try:
+        curses.use_default_colors()
+    except curses.error:
+        pass
     # 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)