comparison hgext/color.py @ 31123:df0a0734304a

color: update main documentation Now that the feature no longer lives in the extension, we document it in the help of the core config. This include the new 'ui.color' option introduced in the previous changesets. As a result the color extensions can now be deprecated. This is a documentation patch only; color is still disabled by default.
author Pierre-Yves David <pierre-yves.david@ens-lyon.org>
date Tue, 21 Feb 2017 20:04:55 +0100
parents c4e8fa2b1c40
children e86eb75e74ce
comparison
equal deleted inserted replaced
31122:53a60e95f154 31123:df0a0734304a
3 # Copyright (C) 2007 Kevin Christen <kevin.christen@gmail.com> 3 # Copyright (C) 2007 Kevin Christen <kevin.christen@gmail.com>
4 # 4 #
5 # This software may be used and distributed according to the terms of the 5 # This software may be used and distributed according to the terms of the
6 # GNU General Public License version 2 or any later version. 6 # GNU General Public License version 2 or any later version.
7 7
8 '''colorize output from some commands 8 '''enable Mercurial color mode (DEPRECATED)
9 9
10 The color extension colorizes output from several Mercurial commands. 10 This extensions enable Mercurial color mode. The feature is now directly
11 For example, the diff command shows additions in green and deletions 11 available in Mercurial core. You can access it using::
12 in red, while the status command shows modified files in magenta. Many
13 other commands have analogous colors. It is possible to customize
14 these colors.
15 12
16 Effects 13 [ui]
17 ------- 14 color = auto
18 15
19 Other effects in addition to color, like bold and underlined text, are 16 See :hg:`help color` for details.
20 also available. By default, the terminfo database is used to find the
21 terminal codes used to change color and effect. If terminfo is not
22 available, then effects are rendered with the ECMA-48 SGR control
23 function (aka ANSI escape codes).
24
25 The available effects in terminfo mode are 'blink', 'bold', 'dim',
26 'inverse', 'invisible', 'italic', 'standout', and 'underline'; in
27 ECMA-48 mode, the options are 'bold', 'inverse', 'italic', and
28 'underline'. How each is rendered depends on the terminal emulator.
29 Some may not be available for a given terminal type, and will be
30 silently ignored.
31
32 If the terminfo entry for your terminal is missing codes for an effect
33 or has the wrong codes, you can add or override those codes in your
34 configuration::
35
36 [color]
37 terminfo.dim = \E[2m
38
39 where '\E' is substituted with an escape character.
40
41 Labels
42 ------
43
44 Text receives color effects depending on the labels that it has. Many
45 default Mercurial commands emit labelled text. You can also define
46 your own labels in templates using the label function, see :hg:`help
47 templates`. A single portion of text may have more than one label. In
48 that case, effects given to the last label will override any other
49 effects. This includes the special "none" effect, which nullifies
50 other effects.
51
52 Labels are normally invisible. In order to see these labels and their
53 position in the text, use the global --color=debug option. The same
54 anchor text may be associated to multiple labels, e.g.
55
56 [log.changeset changeset.secret|changeset: 22611:6f0a53c8f587]
57
58 The following are the default effects for some default labels. Default
59 effects may be overridden from your configuration file::
60
61 [color]
62 status.modified = blue bold underline red_background
63 status.added = green bold
64 status.removed = red bold blue_background
65 status.deleted = cyan bold underline
66 status.unknown = magenta bold underline
67 status.ignored = black bold
68
69 # 'none' turns off all effects
70 status.clean = none
71 status.copied = none
72
73 qseries.applied = blue bold underline
74 qseries.unapplied = black bold
75 qseries.missing = red bold
76
77 diff.diffline = bold
78 diff.extended = cyan bold
79 diff.file_a = red bold
80 diff.file_b = green bold
81 diff.hunk = magenta
82 diff.deleted = red
83 diff.inserted = green
84 diff.changed = white
85 diff.tab =
86 diff.trailingwhitespace = bold red_background
87
88 # Blank so it inherits the style of the surrounding label
89 changeset.public =
90 changeset.draft =
91 changeset.secret =
92
93 resolve.unresolved = red bold
94 resolve.resolved = green bold
95
96 bookmarks.active = green
97
98 branches.active = none
99 branches.closed = black bold
100 branches.current = green
101 branches.inactive = none
102
103 tags.normal = green
104 tags.local = black bold
105
106 rebase.rebased = blue
107 rebase.remaining = red bold
108
109 shelve.age = cyan
110 shelve.newest = green bold
111 shelve.name = blue bold
112
113 histedit.remaining = red bold
114
115 Custom colors
116 -------------
117
118 Because there are only eight standard colors, this module allows you
119 to define color names for other color slots which might be available
120 for your terminal type, assuming terminfo mode. For instance::
121
122 color.brightblue = 12
123 color.pink = 207
124 color.orange = 202
125
126 to set 'brightblue' to color slot 12 (useful for 16 color terminals
127 that have brighter colors defined in the upper eight) and, 'pink' and
128 'orange' to colors in 256-color xterm's default color cube. These
129 defined colors may then be used as any of the pre-defined eight,
130 including appending '_background' to set the background to that color.
131
132 Modes
133 -----
134
135 By default, the color extension will use ANSI mode (or win32 mode on
136 Windows) if it detects a terminal. To override auto mode (to enable
137 terminfo mode, for example), set the following configuration option::
138
139 [color]
140 mode = terminfo
141
142 Any value other than 'ansi', 'win32', 'terminfo', or 'auto' will
143 disable color.
144
145 Note that on some systems, terminfo mode may cause problems when using
146 color with the pager extension and less -R. less with the -R option
147 will only display ECMA-48 color codes, and terminfo mode may sometimes
148 emit codes that less doesn't understand. You can work around this by
149 either using ansi mode (or auto mode), or by using less -r (which will
150 pass through all terminal control codes, not just color control
151 codes).
152
153 On some systems (such as MSYS in Windows), the terminal may support
154 a different color mode than the pager (activated via the "pager"
155 extension). It is possible to define separate modes depending on whether
156 the pager is active::
157
158 [color]
159 mode = auto
160 pagermode = ansi
161
162 If ``pagermode`` is not defined, the ``mode`` will be used.
163 ''' 17 '''
164 18
165 from __future__ import absolute_import 19 from __future__ import absolute_import
166 20
167 from mercurial import ( 21 from mercurial import color
168 color,
169 commands
170 )
171 22
172 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for 23 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
173 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should 24 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
174 # be specifying the version(s) of Mercurial they are tested with, or 25 # be specifying the version(s) of Mercurial they are tested with, or
175 # leave the attribute unspecified. 26 # leave the attribute unspecified.
176 testedwith = 'ships-with-hg-core' 27 testedwith = 'ships-with-hg-core'
177 28
178 def extsetup(ui): 29 def extsetup(ui):
179 # change default color config 30 # change default color config
180 color._enabledbydefault = True 31 color._enabledbydefault = True
181 for idx, entry in enumerate(commands.globalopts):
182 if entry[1] == 'color':
183 patch = (entry[3].replace(' (EXPERIMENTAL)', ''),)
184 new = entry[:3] + patch + entry[4:]
185 commands.globalopts[idx] = new
186 break