| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -67,7 +67,8 @@ def loadini(struct, configfile): | |||
| 67 | 67 | 'up_one_line': 'C-p', | |
| 68 | 68 | 'yank_from_buffer': 'C-y'}, | |
| 69 | 69 | 'gtk': { | |
| 70 | - 'font': 'monospace 10'}}) | ||
| 70 | + 'font': 'monospace 10', | ||
| 71 | + 'color_scheme': 'default'}}) | ||
| 71 | 72 | config.read(config_path) | |
| 72 | 73 | ||
| 73 | 74 | struct.dedent_after = config.getint('general', 'dedent_after') | |
@@ -106,6 +107,7 @@ def loadini(struct, configfile): | |||
| 106 | 107 | struct.gtk_font = config.get('gtk', 'font') | |
| 107 | 108 | ||
| 108 | 109 | color_scheme_name = config.get('general', 'color_scheme') | |
| 110 | + color_gtk_scheme_name = config.get('gtk', 'color_scheme') | ||
| 109 | 111 | ||
| 110 | 112 | default_colors = { | |
| 111 | 113 | 'keyword': 'y', | |
@@ -125,18 +127,44 @@ def loadini(struct, configfile): | |||
| 125 | 127 | 'prompt_more': 'g', | |
| 126 | 128 | } | |
| 127 | 129 | ||
| 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 | ||
| 128 | 149 | if color_scheme_name == 'default': | |
| 129 | 150 | struct.color_scheme = default_colors | |
| 130 | 151 | else: | |
| 131 | 152 | path = os.path.expanduser('~/.bpython/%s.theme' % (color_scheme_name,)) | |
| 132 | 153 | load_theme(struct, path, config_path, default_colors) | |
| 133 | 154 | ||
| 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 | + | ||
| 134 | 162 | # checks for valid key configuration this part still sucks | |
| 135 | 163 | for key in (struct.pastebin_key, struct.save_key): | |
| 136 | 164 | key_dispatch[key] | |
| 137 | 165 | ||
| 138 | - | ||
| 139 | - def load_theme(struct, path, inipath, default_colors): | ||
| 166 | + # TODO consolidate | ||
| 167 | + def load_gtk_theme(struct, path, inipath, default_colors): | ||
| 140 | 168 | theme = ConfigParser() | |
| 141 | 169 | try: | |
| 142 | 170 | f = open(path, 'r') | |
@@ -145,7 +173,7 @@ def load_theme(struct, path, inipath, default_colors): | |||
| 145 | 173 | (inipath, e)) | |
| 146 | 174 | sys.exit(1) | |
| 147 | 175 | theme.readfp(f) | |
| 148 | - struct.color_scheme = {} | ||
| 176 | + struct.color_gtk_scheme = {} | ||
| 149 | 177 | for k, v in chain(theme.items('syntax'), theme.items('interface')): | |
| 150 | 178 | if theme.has_option('syntax', k): | |
| 151 | 179 | struct.color_scheme[k] = theme.get('syntax', k) | |
@@ -159,6 +187,7 @@ def load_theme(struct, path, inipath, default_colors): | |||
| 159 | 187 | f.close() | |
| 160 | 188 | ||
| 161 | 189 | ||
| 190 | + | ||
| 162 | 191 | def migrate_rc(path): | |
| 163 | 192 | """Use the shlex module to convert the old configuration file to the new | |
| 164 | 193 | format. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -267,11 +267,11 @@ def __init__(self, interpreter, config): | |||
| 267 | 267 | self.on_suggestion_selection_changed) | |
| 268 | 268 | self.list_win.hide() | |
| 269 | 269 | ||
| 270 | - self.modify_base('normal', gtk.gdk.color_parse(_COLORS[self.config.color_scheme['background']])) | ||
| 270 | + self.modify_base('normal', gtk.gdk.color_parse(_COLORS[self.config.color_gtk_scheme['background']])) | ||
| 271 | 271 | ||
| 272 | 272 | self.text_buffer = self.get_buffer() | |
| 273 | 273 | tags = dict() | |
| 274 | - for (name, value) in self.config.color_scheme.iteritems(): | ||
| 274 | + for (name, value) in self.config.color_gtk_scheme.iteritems(): | ||
| 275 | 275 | tag = tags[name] = self.text_buffer.create_tag(name) | |
| 276 | 276 | for (char, prop) in zip(value, ['foreground', 'background']): | |
| 277 | 277 | if char.lower() == 'd': | |
| Back | FazBrowse Home | New Git URL |
0 commit comments