##// END OF EJS Templates
color: replace effect-specific reset control codes with general purpose one
Brodie Rao -
r7459:3fb5c142 default
parent child Browse files
Show More
@@ -67,39 +67,34 b' from mercurial import cmdutil, commands,'
67 from mercurial.i18n import _
67 from mercurial.i18n import _
68
68
69 # start and stop parameters for effects
69 # start and stop parameters for effects
70 _effect_params = { 'none': (0, 0),
70 _effect_params = {'none': 0,
71 'black': (30, 39),
71 'black': 30,
72 'red': (31, 39),
72 'red': 31,
73 'green': (32, 39),
73 'green': 32,
74 'yellow': (33, 39),
74 'yellow': 33,
75 'blue': (34, 39),
75 'blue': 34,
76 'magenta': (35, 39),
76 'magenta': 35,
77 'cyan': (36, 39),
77 'cyan': 36,
78 'white': (37, 39),
78 'white': 37,
79 'bold': (1, 22),
79 'bold': 1,
80 'italic': (3, 23),
80 'italic': 3,
81 'underline': (4, 24),
81 'underline': 4,
82 'inverse': (7, 27),
82 'inverse': 7,
83 'black_background': (40, 49),
83 'black_background': 40,
84 'red_background': (41, 49),
84 'red_background': 41,
85 'green_background': (42, 49),
85 'green_background': 42,
86 'yellow_background': (43, 49),
86 'yellow_background': 43,
87 'blue_background': (44, 49),
87 'blue_background': 44,
88 'purple_background': (45, 49),
88 'purple_background': 45,
89 'cyan_background': (46, 49),
89 'cyan_background': 46,
90 'white_background': (47, 49), }
90 'white_background': 47}
91
91
92 def render_effects(text, *effects):
92 def render_effects(text, *effects):
93 'Wrap text in commands to turn on each effect.'
93 'Wrap text in commands to turn on each effect.'
94 start = [ str(_effect_params['none'][0]) ]
94 start = [str(_effect_params[e]) for e in ('none',) + effects]
95 stop = []
96 for effect in effects:
97 start.append(str(_effect_params[effect][0]))
98 stop.append(str(_effect_params[effect][1]))
99 stop.append(str(_effect_params['none'][1]))
100 start = '\033[' + ';'.join(start) + 'm'
95 start = '\033[' + ';'.join(start) + 'm'
101 stop = '\033[' + ';'.join(stop) + 'm'
96 stop = '\033[' + str(_effect_params['none']) + 'm'
102 return start + text + stop
97 return ''.join([start, text, stop])
103
98
104 def colorstatus(orig, ui, repo, *pats, **opts):
99 def colorstatus(orig, ui, repo, *pats, **opts):
105 '''run the status command with colored output'''
100 '''run the status command with colored output'''
@@ -1,25 +1,25 b''
1 adding a
1 adding a
2 % default context
2 % default context
3 diff -r cf9f4ba66af2 a
3 diff -r cf9f4ba66af2 a
4 --- a/a
4 --- a/a
5 +++ b/a
5 +++ b/a
6 @@ -2,7 +2,7 @@
6 @@ -2,7 +2,7 @@
7 c
7 c
8 a
8 a
9 a
9 a
10 -b
10 -b
11 +dd
11 +dd
12 a
12 a
13 a
13 a
14 c
14 c
15 % --unified=2
15 % --unified=2
16 diff -r cf9f4ba66af2 a
16 diff -r cf9f4ba66af2 a
17 --- a/a
17 --- a/a
18 +++ b/a
18 +++ b/a
19 @@ -3,5 +3,5 @@
19 @@ -3,5 +3,5 @@
20 a
20 a
21 a
21 a
22 -b
22 -b
23 +dd
23 +dd
24 a
24 a
25 a
25 a
@@ -1,125 +1,125 b''
1 hg status in repo root:
1 hg status in repo root:
2 ? a/1/in_a_1
2 ? a/1/in_a_1
3 ? a/in_a
3 ? a/in_a
4 ? b/1/in_b_1
4 ? b/1/in_b_1
5 ? b/2/in_b_2
5 ? b/2/in_b_2
6 ? b/in_b
6 ? b/in_b
7 ? in_root
7 ? in_root
8 hg status . in repo root:
8 hg status . in repo root:
9 ? a/1/in_a_1
9 ? a/1/in_a_1
10 ? a/in_a
10 ? a/in_a
11 ? b/1/in_b_1
11 ? b/1/in_b_1
12 ? b/2/in_b_2
12 ? b/2/in_b_2
13 ? b/in_b
13 ? b/in_b
14 ? in_root
14 ? in_root
15 hg status in a:
15 hg status in a:
16 ? a/1/in_a_1
16 ? a/1/in_a_1
17 ? a/in_a
17 ? a/in_a
18 ? b/1/in_b_1
18 ? b/1/in_b_1
19 ? b/2/in_b_2
19 ? b/2/in_b_2
20 ? b/in_b
20 ? b/in_b
21 ? in_root
21 ? in_root
22 hg status . in a:
22 hg status . in a:
23 ? 1/in_a_1
23 ? 1/in_a_1
24 ? in_a
24 ? in_a
25 hg status .. in a:
25 hg status .. in a:
26 ? 1/in_a_1
26 ? 1/in_a_1
27 ? in_a
27 ? in_a
28 ? ../b/1/in_b_1
28 ? ../b/1/in_b_1
29 ? ../b/2/in_b_2
29 ? ../b/2/in_b_2
30 ? ../b/in_b
30 ? ../b/in_b
31 ? ../in_root
31 ? ../in_root
32 hg status in b:
32 hg status in b:
33 ? a/1/in_a_1
33 ? a/1/in_a_1
34 ? a/in_a
34 ? a/in_a
35 ? b/1/in_b_1
35 ? b/1/in_b_1
36 ? b/2/in_b_2
36 ? b/2/in_b_2
37 ? b/in_b
37 ? b/in_b
38 ? in_root
38 ? in_root
39 hg status . in b:
39 hg status . in b:
40 ? 1/in_b_1
40 ? 1/in_b_1
41 ? 2/in_b_2
41 ? 2/in_b_2
42 ? in_b
42 ? in_b
43 hg status .. in b:
43 hg status .. in b:
44 ? ../a/1/in_a_1
44 ? ../a/1/in_a_1
45 ? ../a/in_a
45 ? ../a/in_a
46 ? 1/in_b_1
46 ? 1/in_b_1
47 ? 2/in_b_2
47 ? 2/in_b_2
48 ? in_b
48 ? in_b
49 ? ../in_root
49 ? ../in_root
50 hg status in a/1:
50 hg status in a/1:
51 ? a/1/in_a_1
51 ? a/1/in_a_1
52 ? a/in_a
52 ? a/in_a
53 ? b/1/in_b_1
53 ? b/1/in_b_1
54 ? b/2/in_b_2
54 ? b/2/in_b_2
55 ? b/in_b
55 ? b/in_b
56 ? in_root
56 ? in_root
57 hg status . in a/1:
57 hg status . in a/1:
58 ? in_a_1
58 ? in_a_1
59 hg status .. in a/1:
59 hg status .. in a/1:
60 ? in_a_1
60 ? in_a_1
61 ? ../in_a
61 ? ../in_a
62 hg status in b/1:
62 hg status in b/1:
63 ? a/1/in_a_1
63 ? a/1/in_a_1
64 ? a/in_a
64 ? a/in_a
65 ? b/1/in_b_1
65 ? b/1/in_b_1
66 ? b/2/in_b_2
66 ? b/2/in_b_2
67 ? b/in_b
67 ? b/in_b
68 ? in_root
68 ? in_root
69 hg status . in b/1:
69 hg status . in b/1:
70 ? in_b_1
70 ? in_b_1
71 hg status .. in b/1:
71 hg status .. in b/1:
72 ? in_b_1
72 ? in_b_1
73 ? ../2/in_b_2
73 ? ../2/in_b_2
74 ? ../in_b
74 ? ../in_b
75 hg status in b/2:
75 hg status in b/2:
76 ? a/1/in_a_1
76 ? a/1/in_a_1
77 ? a/in_a
77 ? a/in_a
78 ? b/1/in_b_1
78 ? b/1/in_b_1
79 ? b/2/in_b_2
79 ? b/2/in_b_2
80 ? b/in_b
80 ? b/in_b
81 ? in_root
81 ? in_root
82 hg status . in b/2:
82 hg status . in b/2:
83 ? in_b_2
83 ? in_b_2
84 hg status .. in b/2:
84 hg status .. in b/2:
85 ? ../1/in_b_1
85 ? ../1/in_b_1
86 ? in_b_2
86 ? in_b_2
87 ? ../in_b
87 ? ../in_b
88 adding .hgignore
88 adding .hgignore
89 adding deleted
89 adding deleted
90 adding modified
90 adding modified
91 adding removed
91 adding removed
92 hg status:
92 hg status:
93 A added
93 A added
94 R removed
94 R removed
95 ! deleted
95 ! deleted
96 ? unknown
96 ? unknown
97 hg status modified added removed deleted unknown never-existed ignored:
97 hg status modified added removed deleted unknown never-existed ignored:
98 never-existed: No such file or directory
98 never-existed: No such file or directory
99 A added
99 A added
100 R removed
100 R removed
101 ! deleted
101 ! deleted
102 ? unknown
102 ? unknown
103 hg status -C:
103 hg status -C:
104 A added
104 A added
105 A copied
105 A copied
106  modified
106  modified
107 R removed
107 R removed
108 ! deleted
108 ! deleted
109 ? unknown
109 ? unknown
110 hg status -A:
110 hg status -A:
111 A added
111 A added
112 A copied
112 A copied
113  modified
113  modified
114 R removed
114 R removed
115 ! deleted
115 ! deleted
116 ? unknown
116 ? unknown
117 I ignored
117 I ignored
118 C .hgignore
118 C .hgignore
119 C modified
119 C modified
120 hg status ignoreddir/file:
120 hg status ignoreddir/file:
121 hg status -i ignoreddir/file:
121 hg status -i ignoreddir/file:
122 I ignoreddir/file
122 I ignoreddir/file
123 adding .hgignore
123 adding .hgignore
124 adding deleted
124 adding deleted
125 adding modified
125 adding modified
General Comments 0
You need to be logged in to leave comments. Login now