[PATCH V2] crecord: honor "ui.color = no" config option
Elmar Bartel
elb_hg at leo.org
Fri Jan 5 10:27:24 UTC 2018
mercurial/crecord.py | 26 +++++++++++++++++++++-----
1 files changed, 21 insertions(+), 5 deletions(-)
# HG changeset patch
# User Elmar Bartel <elb_hg at leo.org>
# Date 1515064327 -3600
# Thu Jan 04 12:12:07 2018 +0100
# Node ID cf99164fad24d96b7508d86085377faf4494a18f
# Parent 31fe397f2bdab5fea4752947e70549e7a7d04f75
crecord: honor "ui.color = no" config option
The current implementation of crecord ignores the ui.color setting.
This patch checks the ui.color config option and does the curses setup
without colors when the option is set to a falsy value. For other (or
missing) setting of ui.color, curses setup is done as before and uses
colors.
diff -r 31fe397f2bda -r cf99164fad24 mercurial/crecord.py
--- a/mercurial/crecord.py Wed Dec 27 00:24:53 2017 +0530
+++ b/mercurial/crecord.py Thu Jan 04 12:12:07 2018 +0100
@@ -581,6 +581,13 @@ class curseschunkselector(object):
# maps custom nicknames of color-pairs to curses color-pair values
self.colorpairnames = {}
+ # Honor color setting of ui section. Keep colored setup as
+ # long as not explicitly set to a falsy value - especially,
+ # when not set at all. This is to stay most compatible with
+ # previous (color only) behaviour.
+ uicolor= util.parsebool(self.ui.config('ui', 'color'))
+ self.usecolor = uicolor is not False
+
# the currently selected header, hunk, or hunk-line
self.currentselecteditem = self.headerlist[0]
@@ -1371,11 +1378,20 @@ class curseschunkselector(object):
colorpair = self.colorpairs[(fgcolor, bgcolor)]
else:
pairindex = len(self.colorpairs) + 1
- curses.init_pair(pairindex, fgcolor, bgcolor)
- colorpair = self.colorpairs[(fgcolor, bgcolor)] = (
- curses.color_pair(pairindex))
- if name is not None:
- self.colorpairnames[name] = curses.color_pair(pairindex)
+ if self.usecolor:
+ curses.init_pair(pairindex, fgcolor, bgcolor)
+ colorpair = self.colorpairs[(fgcolor, bgcolor)] = (
+ curses.color_pair(pairindex))
+ if name is not None:
+ self.colorpairnames[name] = curses.color_pair(
+ pairindex)
+ else:
+ cval = 0
+ if name is not None:
+ if name == 'selected':
+ cval = curses.A_REVERSE
+ self.colorpairnames[name] = cval
+ colorpair = self.colorpairs[(fgcolor, bgcolor)] = cval
# add attributes if possible
if attrlist is None:
More information about the Mercurial-devel
mailing list