@@ -67,7 +67,8 @@ def loadini(struct, configfile):
6767 'up_one_line' : 'C-p' ,
6868 'yank_from_buffer' : 'C-y' },
6969 'gtk' : {
70- 'font' : 'monospace 10' }})
70+ 'font' : 'monospace 10' ,
71+ 'color_scheme' : 'default' }})
7172 config .read (config_path )
7273
7374 struct .dedent_after = config .getint ('general' , 'dedent_after' )
@@ -106,6 +107,7 @@ def loadini(struct, configfile):
106107 struct .gtk_font = config .get ('gtk' , 'font' )
107108
108109 color_scheme_name = config .get ('general' , 'color_scheme' )
110+ color_gtk_scheme_name = config .get ('gtk' , 'color_scheme' )
109111
110112 default_colors = {
111113 'keyword' : 'y' ,
@@ -125,18 +127,44 @@ def loadini(struct, configfile):
125127 'prompt_more' : 'g' ,
126128 }
127129
130+ default_gtk_colors = {
131+ 'keyword' : 'b' ,
132+ 'name' : 'k' ,
133+ 'comment' : 'b' ,
134+ 'string' : 'm' ,
135+ 'error' : 'r' ,
136+ 'number' : 'G' ,
137+ 'operator' : 'B' ,
138+ 'punctuation' : 'g' ,
139+ 'token' : 'C' ,
140+ 'background' : 'w' ,
141+ 'output' : 'k' ,
142+ 'main' : 'c' ,
143+ 'paren' : 'R' ,
144+ 'prompt' : 'b' ,
145+ 'prompt_more' : 'g' ,
146+ }
147+
148+ # TODO consolidate
128149 if color_scheme_name == 'default' :
129150 struct .color_scheme = default_colors
130151 else :
131152 path = os .path .expanduser ('~/.bpython/%s.theme' % (color_scheme_name ,))
132153 load_theme (struct , path , config_path , default_colors )
133154
155+ if color_gtk_scheme_name == 'default' :
156+ struct .color_gtk_scheme = default_gtk_colors
157+ else :
158+ path = os .path .expanduser ('~/.bpython/%s.theme' % (color_gtk_scheme_name ,))
159+ load_gtk_theme (struct , path , config_path , default_gtk_colors )
160+
161+
134162 # checks for valid key configuration this part still sucks
135163 for key in (struct .pastebin_key , struct .save_key ):
136164 key_dispatch [key ]
137165
138-
139- def load_theme (struct , path , inipath , default_colors ):
166+ # TODO consolidate
167+ def load_gtk_theme (struct , path , inipath , default_colors ):
140168 theme = ConfigParser ()
141169 try :
142170 f = open (path , 'r' )
@@ -145,7 +173,7 @@ def load_theme(struct, path, inipath, default_colors):
145173 (inipath , e ))
146174 sys .exit (1 )
147175 theme .readfp (f )
148- struct .color_scheme = {}
176+ struct .color_gtk_scheme = {}
149177 for k , v in chain (theme .items ('syntax' ), theme .items ('interface' )):
150178 if theme .has_option ('syntax' , k ):
151179 struct .color_scheme [k ] = theme .get ('syntax' , k )
@@ -159,6 +187,7 @@ def load_theme(struct, path, inipath, default_colors):
159187 f .close ()
160188
161189
190+
162191def migrate_rc (path ):
163192 """Use the shlex module to convert the old configuration file to the new
164193 format.
0 commit comments