comparison hgext/color.py @ 22772:b186b3ef4b54

color: reorganise and sectionify the help text The color docstring was getting long. This splits it up into bite-sized sections and rearranges the order of the paragraphs a little to match these sections.
author Jordi Gutiérrez Hermoso <jordigh@octave.org>
date Mon, 06 Oct 2014 08:18:03 -0400
parents d6274291fac1
children 122f5c3f3308
comparison
equal deleted inserted replaced
22771:d6274291fac1 22772:b186b3ef4b54
11 For example, the diff command shows additions in green and deletions 11 For example, the diff command shows additions in green and deletions
12 in red, while the status command shows modified files in magenta. Many 12 in red, while the status command shows modified files in magenta. Many
13 other commands have analogous colors. It is possible to customize 13 other commands have analogous colors. It is possible to customize
14 these colors. 14 these colors.
15 15
16 Effects
17 -------
18
16 Other effects in addition to color, like bold and underlined text, are 19 Other effects in addition to color, like bold and underlined text, are
17 also available. By default, the terminfo database is used to find the 20 also available. By default, the terminfo database is used to find the
18 terminal codes used to change color and effect. If terminfo is not 21 terminal codes used to change color and effect. If terminfo is not
19 available, then effects are rendered with the ECMA-48 SGR control 22 available, then effects are rendered with the ECMA-48 SGR control
20 function (aka ANSI escape codes). 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 Labels
33 ------
21 34
22 Text receives color effects depending on the labels that it has. Many 35 Text receives color effects depending on the labels that it has. Many
23 default Mercurial commands emit labelled text. You can also define 36 default Mercurial commands emit labelled text. You can also define
24 your own labels in templates using the label function, see :hg:`help 37 your own labels in templates using the label function, see :hg:`help
25 templates`. A single portion of text may have more than one label. In 38 templates`. A single portion of text may have more than one label. In
88 shelve.newest = green bold 101 shelve.newest = green bold
89 shelve.name = blue bold 102 shelve.name = blue bold
90 103
91 histedit.remaining = red bold 104 histedit.remaining = red bold
92 105
93 The available effects in terminfo mode are 'blink', 'bold', 'dim', 106 Custom colors
94 'inverse', 'invisible', 'italic', 'standout', and 'underline'; in 107 -------------
95 ECMA-48 mode, the options are 'bold', 'inverse', 'italic', and 108
96 'underline'. How each is rendered depends on the terminal emulator. 109 Because there are only eight standard colors, this module allows you
97 Some may not be available for a given terminal type, and will be 110 to define color names for other color slots which might be available
98 silently ignored. 111 for your terminal type, assuming terminfo mode. For instance::
112
113 color.brightblue = 12
114 color.pink = 207
115 color.orange = 202
116
117 to set 'brightblue' to color slot 12 (useful for 16 color terminals
118 that have brighter colors defined in the upper eight) and, 'pink' and
119 'orange' to colors in 256-color xterm's default color cube. These
120 defined colors may then be used as any of the pre-defined eight,
121 including appending '_background' to set the background to that color.
122
123 Modes
124 -----
125
126 By default, the color extension will use ANSI mode (or win32 mode on
127 Windows) if it detects a terminal. To override auto mode (to enable
128 terminfo mode, for example), set the following configuration option::
129
130 [color]
131 mode = terminfo
132
133 Any value other than 'ansi', 'win32', 'terminfo', or 'auto' will
134 disable color.
99 135
100 Note that on some systems, terminfo mode may cause problems when using 136 Note that on some systems, terminfo mode may cause problems when using
101 color with the pager extension and less -R. less with the -R option 137 color with the pager extension and less -R. less with the -R option
102 will only display ECMA-48 color codes, and terminfo mode may sometimes 138 will only display ECMA-48 color codes, and terminfo mode may sometimes
103 emit codes that less doesn't understand. You can work around this by 139 emit codes that less doesn't understand. You can work around this by
104 either using ansi mode (or auto mode), or by using less -r (which will 140 either using ansi mode (or auto mode), or by using less -r (which will
105 pass through all terminal control codes, not just color control 141 pass through all terminal control codes, not just color control
106 codes). 142 codes).
107
108 Because there are only eight standard colors, this module allows you
109 to define color names for other color slots which might be available
110 for your terminal type, assuming terminfo mode. For instance::
111
112 color.brightblue = 12
113 color.pink = 207
114 color.orange = 202
115
116 to set 'brightblue' to color slot 12 (useful for 16 color terminals
117 that have brighter colors defined in the upper eight) and, 'pink' and
118 'orange' to colors in 256-color xterm's default color cube. These
119 defined colors may then be used as any of the pre-defined eight,
120 including appending '_background' to set the background to that color.
121
122 By default, the color extension will use ANSI mode (or win32 mode on
123 Windows) if it detects a terminal. To override auto mode (to enable
124 terminfo mode, for example), set the following configuration option::
125
126 [color]
127 mode = terminfo
128
129 Any value other than 'ansi', 'win32', 'terminfo', or 'auto' will
130 disable color.
131 ''' 143 '''
132 144
133 import os 145 import os
134 146
135 from mercurial import cmdutil, commands, dispatch, extensions, ui as uimod, util 147 from mercurial import cmdutil, commands, dispatch, extensions, ui as uimod, util