1
- from functools import partial
1
+ import curtsies . termformatconstants
2
2
import re
3
3
4
- from bpython .lazyre import LazyReCompile
5
-
6
- import curtsies .termformatconstants
7
- from curtsies .termformatconstants import FG_COLORS , BG_COLORS
8
4
from curtsies .formatstring import fmtstr , FmtStr
5
+ from curtsies .termformatconstants import FG_COLORS , BG_COLORS
6
+ from functools import partial
9
7
8
+ from bpython .lazyre import LazyReCompile
10
9
11
- colors = curtsies .termformatconstants .colors + ("default" , )
12
- cnames = dict (zip ("krgybmcwd" , colors ))
10
+
11
+ COLORS = curtsies .termformatconstants .colors + ("default" ,)
12
+ CNAMES = dict (zip ("krgybmcwd" , COLORS ))
13
13
14
14
15
15
def func_for_letter (l , default = "k" ):
@@ -18,13 +18,13 @@ def func_for_letter(l, default="k"):
18
18
l = default
19
19
elif l == "D" :
20
20
l = default .upper ()
21
- return partial (fmtstr , fg = cnames [l .lower ()], bold = l .isupper ())
21
+ return partial (fmtstr , fg = CNAMES [l .lower ()], bold = l .isupper ())
22
22
23
23
24
24
def color_for_letter (l , default = "k" ):
25
25
if l == "d" :
26
26
l = default
27
- return cnames [l .lower ()]
27
+ return CNAMES [l .lower ()]
28
28
29
29
30
30
def parse (s ):
@@ -46,23 +46,22 @@ def parse(s):
46
46
def fs_from_match (d ):
47
47
atts = {}
48
48
if d ["fg" ]:
49
-
50
49
# this isn't according to spec as I understand it
51
50
if d ["fg" ].isupper ():
52
51
d ["bold" ] = True
53
52
# TODO figure out why boldness isn't based on presence of \x02
54
53
55
- color = cnames [d ["fg" ].lower ()]
54
+ color = CNAMES [d ["fg" ].lower ()]
56
55
if color != "default" :
57
56
atts ["fg" ] = FG_COLORS [color ]
58
57
if d ["bg" ]:
59
58
if d ["bg" ] == "I" :
60
59
# hack for finding the "inverse"
61
- color = colors [
62
- (colors .index (color ) + (len (colors ) // 2 )) % len (colors )
60
+ color = COLORS [
61
+ (COLORS .index (color ) + (len (COLORS ) // 2 )) % len (COLORS )
63
62
]
64
63
else :
65
- color = cnames [d ["bg" ].lower ()]
64
+ color = CNAMES [d ["bg" ].lower ()]
66
65
if color != "default" :
67
66
atts ["bg" ] = BG_COLORS [color ]
68
67
if d ["bold" ]:
0 commit comments