Mercurial > public > mercurial-scm > hg
comparison mercurial/crecord.py @ 35527:f43dc62cfe11
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.
author | Elmar Bartel <elb_hg@leo.org> |
---|---|
date | Thu, 04 Jan 2018 12:12:07 +0100 |
parents | 57c79542bebb |
children | fb2e59e92651 |
comparison
equal
deleted
inserted
replaced
35526:e8f80529abeb | 35527:f43dc62cfe11 |
---|---|
578 # dictionary mapping (fgcolor, bgcolor) pairs to the | 578 # dictionary mapping (fgcolor, bgcolor) pairs to the |
579 # corresponding curses color-pair value. | 579 # corresponding curses color-pair value. |
580 self.colorpairs = {} | 580 self.colorpairs = {} |
581 # maps custom nicknames of color-pairs to curses color-pair values | 581 # maps custom nicknames of color-pairs to curses color-pair values |
582 self.colorpairnames = {} | 582 self.colorpairnames = {} |
583 | |
584 # Honor color setting of ui section. Keep colored setup as | |
585 # long as not explicitly set to a falsy value - especially, | |
586 # when not set at all. This is to stay most compatible with | |
587 # previous (color only) behaviour. | |
588 uicolor = util.parsebool(self.ui.config('ui', 'color')) | |
589 self.usecolor = uicolor is not False | |
583 | 590 |
584 # the currently selected header, hunk, or hunk-line | 591 # the currently selected header, hunk, or hunk-line |
585 self.currentselecteditem = self.headerlist[0] | 592 self.currentselecteditem = self.headerlist[0] |
586 | 593 |
587 # updated when printing out patch-display -- the 'lines' here are the | 594 # updated when printing out patch-display -- the 'lines' here are the |
1369 bgcolor = -1 | 1376 bgcolor = -1 |
1370 if (fgcolor, bgcolor) in self.colorpairs: | 1377 if (fgcolor, bgcolor) in self.colorpairs: |
1371 colorpair = self.colorpairs[(fgcolor, bgcolor)] | 1378 colorpair = self.colorpairs[(fgcolor, bgcolor)] |
1372 else: | 1379 else: |
1373 pairindex = len(self.colorpairs) + 1 | 1380 pairindex = len(self.colorpairs) + 1 |
1374 curses.init_pair(pairindex, fgcolor, bgcolor) | 1381 if self.usecolor: |
1375 colorpair = self.colorpairs[(fgcolor, bgcolor)] = ( | 1382 curses.init_pair(pairindex, fgcolor, bgcolor) |
1376 curses.color_pair(pairindex)) | 1383 colorpair = self.colorpairs[(fgcolor, bgcolor)] = ( |
1377 if name is not None: | 1384 curses.color_pair(pairindex)) |
1378 self.colorpairnames[name] = curses.color_pair(pairindex) | 1385 if name is not None: |
1386 self.colorpairnames[name] = curses.color_pair(pairindex) | |
1387 else: | |
1388 cval = 0 | |
1389 if name is not None: | |
1390 if name == 'selected': | |
1391 cval = curses.A_REVERSE | |
1392 self.colorpairnames[name] = cval | |
1393 colorpair = self.colorpairs[(fgcolor, bgcolor)] = cval | |
1379 | 1394 |
1380 # add attributes if possible | 1395 # add attributes if possible |
1381 if attrlist is None: | 1396 if attrlist is None: |
1382 attrlist = [] | 1397 attrlist = [] |
1383 if colorpair < 256: | 1398 if colorpair < 256: |