[PATCH] crecord: honor "ui.color = no" config option
Elmar Bartel
elb_hg at leo.org
Thu Jan 4 11:40:39 UTC 2018
mercurial/crecord.py | 21 ++++++++++++++++-----
1 files changed, 16 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 04fe74a8269a68c78a57a9f3698f1c87eff09e74
# 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 was set to "no". With other (or missing)
setting of ui.color, curses setup is done as before and uses colors.
diff -r 31fe397f2bda -r 04fe74a8269a 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,8 @@ class curseschunkselector(object):
# maps custom nicknames of color-pairs to curses color-pair values
self.colorpairnames = {}
+ self.usecolor = self.ui.config('ui', 'color') != 'no'
+
# the currently selected header, hunk, or hunk-line
self.currentselecteditem = self.headerlist[0]
@@ -1371,11 +1373,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