@@ -135,7 +135,7 @@ def DEBUG(s):
135135
136136
137137def get_color (name ):
138- return colors [OPTS .color_scheme [name ]]
138+ return colors [OPTS .color_scheme [name ]. lower () ]
139139
140140def get_colpair (name ):
141141 return curses .color_pair (get_color (name ) + 1 )
@@ -1099,17 +1099,18 @@ def echo(self, s, redraw=True):
10991099
11001100 a = get_colpair ('output' )
11011101 if '\x01 ' in s :
1102- rx = re .search ('\x01 ([a- z])([a -z]?)' , s )
1102+ rx = re .search ('\x01 ([A-Za- z])([A-Za -z]?)' , s )
11031103 if rx :
1104- p = self ._C [rx .groups ()[0 ]]
1105- if rx .groups ()[1 ]:
1106- p *= self ._C [rx .groups ()[1 ]]
1107-
1108- a = curses .color_pair (int (p ) + 1 )
1109- s = re .sub ('\x01 [a-z][a-z]?' , '' , s )
1110- if '\x02 ' in s :
1111- a = a | curses .A_BOLD
1112- s = s .replace ('\x02 ' , '' )
1104+ fg = rx .groups ()[0 ]
1105+ bg = rx .groups ()[1 ]
1106+ col_num = self ._C [fg .lower ()]
1107+ if bg :
1108+ col_num *= self ._C [bg .lower ()]
1109+
1110+ a = curses .color_pair (int (col_num ) + 1 )
1111+ s = re .sub ('\x01 [A-Za-z][A-Za-z]?' , '' , s )
1112+ if fg .upper ():
1113+ a = a | curses .A_BOLD
11131114 s = s .replace ('\x03 ' , '' )
11141115 s = s .replace ('\x01 ' , '' )
11151116
@@ -1925,33 +1926,30 @@ def loadini(configfile):
19251926 'string' : 'g' ,
19261927 'error' : 'r' ,
19271928 'number' : 'g' ,
1928- 'operator' : 'c ' ,
1929- 'punctuation' : 'y ' ,
1929+ 'operator' : 'C ' ,
1930+ 'punctuation' : 'c ' ,
19301931 'token' : 'g' ,
19311932 'background' : 'k' ,
19321933 'output' : 'w' ,
19331934 'main' : 'c' ,
1934- 'prompt' : 'r ' ,
1935+ 'prompt' : 'y ' ,
19351936 'prompt_more' : 'g' ,
19361937 }
19371938 else :
19381939 path = os .path .expanduser ('~/.bpython/%s.theme' % (color_scheme_name ,))
1939- # XXX ConfigParser doesn't raise an IOError if it tries to read a file
1940- # that doesn't exist which isn't helpful to us:
1941- if not os .path .isfile (path ):
1942- raise IOError ("'%s' is not a readable file" % (path ,))
1943- load_theme (color_scheme_name )
1944-
1945- def load_theme (name ):
1946- path = os .path .expanduser ('~/.bpython/%s.theme' % (name ,))
1940+ load_theme (path )
1941+
1942+ def load_theme (path ):
19471943 theme = CP ()
1948- theme .read (path )
1944+ f = open (path , 'r' )
1945+ theme .readfp (f )
19491946 OPTS .color_scheme = {}
19501947 for k , v in chain (theme .items ('syntax' ), theme .items ('interface' )):
19511948 if theme .has_option ('syntax' , k ):
19521949 OPTS .color_scheme [k ] = theme .get ('syntax' , k )
19531950 else :
19541951 OPTS .color_scheme [k ] = theme .get ('interface' , k )
1952+ f .close ()
19551953
19561954
19571955class FakeDict (object ):
0 commit comments