1from thonny import get_workbench 2from thonny.workbench import SyntaxThemeSettings 3 4 5def default_light() -> SyntaxThemeSettings: 6 default_fg = "black" 7 default_bg = "#fdfdfd" 8 light_fg = "DarkGray" 9 string_fg = "DarkGreen" 10 open_string_bg = "#c3f9d3" 11 gutter_foreground = "#999999" 12 gutter_background = "#e0e0e0" 13 14 return { 15 "TEXT": { 16 "foreground": default_fg, 17 "insertbackground": default_fg, 18 "background": default_bg, 19 }, 20 "GUTTER": {"foreground": gutter_foreground, "background": gutter_background}, 21 "breakpoint": {"foreground": "crimson"}, 22 "current_line": {"background": "#f5f5f5"}, 23 "definition": {"foreground": "DarkBlue", "font": "BoldEditorFont"}, 24 "class_definition": {}, 25 "function_definition": {}, 26 "string": {"foreground": string_fg}, 27 "string3": {"foreground": string_fg, "background": None, "font": "EditorFont"}, 28 "open_string": {"foreground": string_fg, "background": open_string_bg}, 29 "open_string3": { 30 "foreground": string_fg, 31 "background": open_string_bg, 32 "font": "EditorFont", 33 }, 34 "tab": {"background": "#f5ecd7"}, 35 "keyword": {"foreground": "#7f0055", "font": "BoldEditorFont"}, 36 "builtin": {"foreground": "#7f0055"}, 37 "number": {"foreground": "#B04600"}, 38 "comment": {"foreground": light_fg}, 39 "welcome": {"foreground": light_fg}, 40 "magic": {"foreground": light_fg}, 41 "prompt": {"foreground": "purple", "font": "BoldEditorFont"}, 42 "stdin": {"foreground": "Blue"}, 43 "stdout": {"foreground": "Black"}, 44 "stderr": {"foreground": "#CC0000"}, # same as ANSI red 45 "value": {"foreground": "DarkBlue"}, 46 "function_call": {}, 47 "method_call": {}, 48 "hyperlink": {"foreground": "#3A66DD", "underline": True}, 49 # paren matcher 50 "surrounding_parens": {"foreground": "Blue", "font": "BoldEditorFont"}, 51 "unclosed_expression": {"background": "LightGray"}, 52 # find/replace 53 "found": {"foreground": "blue", "underline": True}, 54 "current_found": {"foreground": "white", "background": "red"}, 55 "matched_name": {"background": "#e6ecfe"}, 56 "local_name": {"font": "ItalicEditorFont"}, 57 # debugger 58 "active_focus": {"background": "#F8FC9A", "borderwidth": 1, "relief": "solid"}, 59 "suspended_focus": {"background": "", "borderwidth": 1, "relief": "solid"}, 60 "completed_focus": {"background": "#BBEDB2", "borderwidth": 1, "relief": "flat"}, 61 "exception_focus": {"background": "#FFBFD6", "borderwidth": 1, "relief": "solid"}, 62 "expression_box": {"background": "#DCEDF2", "foreground": default_fg}, 63 "black_fg": {"foreground": "#2E3436"}, 64 "black_bg": {"background": "#2E3436"}, 65 "bright_black_fg": {"foreground": "#555753"}, 66 "bright_black_bg": {"background": "#555753"}, 67 "dim_black_fg": {"foreground": "#1E2224"}, 68 "dim_black_bg": {"background": "#1E2224"}, 69 "red_fg": {"foreground": "#CC0000"}, 70 "red_bg": {"background": "#CC0000"}, 71 "bright_red_fg": {"foreground": "#EF2929"}, 72 "bright_red_bg": {"background": "#EF2929"}, 73 "dim_red_fg": {"foreground": "#880000"}, 74 "dim_red_bg": {"background": "#880000"}, 75 "green_fg": {"foreground": "#4E9A06"}, 76 "green_bg": {"background": "#4E9A06"}, 77 "bright_green_fg": {"foreground": "#8AE234"}, 78 "bright_green_bg": {"background": "#8AE234"}, 79 "dim_green_fg": {"foreground": "#346704"}, 80 "dim_green_bg": {"background": "#346704"}, 81 "yellow_fg": {"foreground": "#C4A000"}, 82 "yellow_bg": {"background": "#C4A000"}, 83 "bright_yellow_fg": {"foreground": "#FCE94F"}, 84 "bright_yellow_bg": {"background": "#FCE94F"}, 85 "dim_yellow_fg": {"foreground": "#836B00"}, 86 "dim_yellow_bg": {"background": "#836B00"}, 87 "blue_fg": {"foreground": "#3465A4"}, 88 "blue_bg": {"background": "#3465A4"}, 89 "bright_blue_fg": {"foreground": "#729FCF"}, 90 "bright_blue_bg": {"background": "#729FCF"}, 91 "dim_blue_fg": {"foreground": "#22436D"}, 92 "dim_blue_bg": {"background": "#22436D"}, 93 "magenta_fg": {"foreground": "#75507B"}, 94 "magenta_bg": {"background": "#75507B"}, 95 "bright_magenta_fg": {"foreground": "#AD7FA8"}, 96 "bright_magenta_bg": {"background": "#AD7FA8"}, 97 "dim_magenta_fg": {"foreground": "#4E3552"}, 98 "dim_magenta_bg": {"background": "#4E3552"}, 99 "cyan_fg": {"foreground": "#06989A"}, 100 "cyan_bg": {"background": "#06989A"}, 101 "bright_cyan_fg": {"foreground": "#34E2E2"}, 102 "bright_cyan_bg": {"background": "#34E2E2"}, 103 "dim_cyan_fg": {"foreground": "#046567"}, 104 "dim_cyan_bg": {"background": "#046567"}, 105 "white_fg": {"foreground": "#D3D7CF"}, 106 "white_bg": {"background": "#D3D7CF"}, 107 "bright_white_fg": {"foreground": "#EEEEEC"}, 108 "bright_white_bg": {"background": "#EEEEEC"}, 109 "dim_white_fg": {"foreground": "#8D8F8A"}, 110 "dim_white_bg": {"background": "#8D8F8A"}, 111 "fore_fg": {"foreground": default_fg}, 112 "fore_bg": {"background": default_fg}, 113 "bright_fore_fg": {"foreground": "#000000"}, 114 "bright_fore_bg": {"background": "#000000"}, 115 "dim_fore_fg": {"foreground": "#222222"}, 116 "dim_fore_bg": {"background": "#222222"}, 117 "back_fg": {"foreground": default_bg}, 118 "back_bg": {"background": default_bg}, 119 "bright_back_fg": {"foreground": "#ffffff"}, 120 "bright_back_bg": {"background": "#ffffff"}, 121 "dim_back_fg": {"foreground": "#e0e0e0"}, 122 "dim_back_bg": {"background": "#e0e0e0"}, 123 "intense_io": {"font": "BoldIOFont"}, 124 "italic_io": {"font": "ItalicIOFont"}, 125 "intense_italic_io": {"font": "BoldItalicIOFont"}, 126 "underline": {"underline": True}, 127 "strikethrough": {"overstrike": True}, 128 } 129 130 131def default_dark() -> SyntaxThemeSettings: 132 default_fg = "#B3B3B3" 133 default_bg = "#2d2d2d" 134 string_fg = "#8DC76F" 135 open_string_bg = "#224533" 136 gutter_foreground = "#606060" 137 gutter_background = "#323232" 138 139 # s.configure("Local.Code", foreground="#BCCAE8") 140 # s.configure("MatchedName.Code", background="#193022") 141 142 return { 143 "TEXT": { 144 "foreground": default_fg, 145 "insertbackground": default_fg, 146 "background": default_bg, 147 }, 148 "GUTTER": {"foreground": gutter_foreground, "background": gutter_background}, 149 "breakpoint": {"foreground": "pink"}, 150 "current_line": {"background": "#363636"}, 151 "sel": {"foreground": "#eeeeee", "background": "#6E6E6E"}, 152 "definition": {"foreground": default_fg}, 153 "class_definition": {}, 154 "function_definition": {}, 155 "string": {"foreground": string_fg}, 156 "string3": {"foreground": string_fg, "background": None, "font": "EditorFont"}, 157 "open_string": {"foreground": string_fg, "background": open_string_bg}, 158 "open_string3": { 159 "foreground": string_fg, 160 "background": open_string_bg, 161 "font": "EditorFont", 162 }, 163 "tab": {"background": "#424034"}, 164 "builtin": {"foreground": "#A9B1C9"}, 165 "keyword": {"foreground": "#A9B1C9", "font": "BoldEditorFont"}, 166 "number": {"foreground": "#FFCABF"}, 167 "comment": {"foreground": "#D4D44E"}, 168 "welcome": {"foreground": "pink"}, 169 "magic": {"foreground": "pink"}, 170 # shell 171 "prompt": {"foreground": "#5BEBBB", "font": "BoldEditorFont"}, 172 "stdin": {"foreground": "LightBlue"}, 173 "stdout": {"foreground": "LightGray"}, 174 "stderr": {"foreground": "#EB5B83"}, 175 "value": {"foreground": "#EBEB5B"}, 176 "function_call": {}, 177 "method_call": {}, 178 "hyperlink": {"foreground": "#619DC7", "underline": True}, 179 # paren matcher 180 "surrounding_parens": {"foreground": "#F0995B", "font": "BoldEditorFont"}, 181 "unclosed_expression": {"background": "#000000"}, 182 # find/replace 183 "found": {"underline": True}, 184 "current_found": {"foreground": "white", "background": "red"}, 185 "matched_name": {"background": "#474747"}, 186 "local_name": {"font": "ItalicEditorFont"}, 187 # debugger 188 "active_focus": {"background": "#807238", "borderwidth": 1, "relief": "solid"}, 189 "suspended_focus": {"background": "", "borderwidth": 1, "relief": "solid"}, 190 "completed_focus": {"background": "#807238", "borderwidth": 1, "relief": "flat"}, 191 "exception_focus": {"background": "#FFBFD6", "borderwidth": 1, "relief": "solid"}, 192 "expression_box": {"background": "#506E67", "foreground": default_fg}, 193 "black_fg": {"foreground": "#2E3436"}, 194 "black_bg": {"background": "#2E3436"}, 195 "bright_black_fg": {"foreground": "#555753"}, 196 "bright_black_bg": {"background": "#555753"}, 197 "dim_black_fg": {"foreground": "#1E2224"}, 198 "dim_black_bg": {"background": "#1E2224"}, 199 "red_fg": {"foreground": "#CC0000"}, 200 "red_bg": {"background": "#CC0000"}, 201 "bright_red_fg": {"foreground": "#EF2929"}, 202 "bright_red_bg": {"background": "#EF2929"}, 203 "dim_red_fg": {"foreground": "#880000"}, 204 "dim_red_bg": {"background": "#880000"}, 205 "green_fg": {"foreground": "#4E9A06"}, 206 "green_bg": {"background": "#4E9A06"}, 207 "bright_green_fg": {"foreground": "#8AE234"}, 208 "bright_green_bg": {"background": "#8AE234"}, 209 "dim_green_fg": {"foreground": "#346704"}, 210 "dim_green_bg": {"background": "#346704"}, 211 "yellow_fg": {"foreground": "#C4A000"}, 212 "yellow_bg": {"background": "#C4A000"}, 213 "bright_yellow_fg": {"foreground": "#FCE94F"}, 214 "bright_yellow_bg": {"background": "#FCE94F"}, 215 "dim_yellow_fg": {"foreground": "#836B00"}, 216 "dim_yellow_bg": {"background": "#836B00"}, 217 "blue_fg": {"foreground": "#3465A4"}, 218 "blue_bg": {"background": "#3465A4"}, 219 "bright_blue_fg": {"foreground": "#729FCF"}, 220 "bright_blue_bg": {"background": "#729FCF"}, 221 "dim_blue_fg": {"foreground": "#22436D"}, 222 "dim_blue_bg": {"background": "#22436D"}, 223 "magenta_fg": {"foreground": "#75507B"}, 224 "magenta_bg": {"background": "#75507B"}, 225 "bright_magenta_fg": {"foreground": "#AD7FA8"}, 226 "bright_magenta_bg": {"background": "#AD7FA8"}, 227 "dim_magenta_fg": {"foreground": "#4E3552"}, 228 "dim_magenta_bg": {"background": "#4E3552"}, 229 "cyan_fg": {"foreground": "#06989A"}, 230 "cyan_bg": {"background": "#06989A"}, 231 "bright_cyan_fg": {"foreground": "#34E2E2"}, 232 "bright_cyan_bg": {"background": "#34E2E2"}, 233 "dim_cyan_fg": {"foreground": "#046567"}, 234 "dim_cyan_bg": {"background": "#046567"}, 235 "white_fg": {"foreground": "#D3D7CF"}, 236 "white_bg": {"background": "#D3D7CF"}, 237 "bright_white_fg": {"foreground": "#EEEEEC"}, 238 "bright_white_bg": {"background": "#EEEEEC"}, 239 "dim_white_fg": {"foreground": "#8D8F8A"}, 240 "dim_white_bg": {"background": "#8D8F8A"}, 241 "fore_fg": {"foreground": default_fg}, 242 "fore_bg": {"background": default_fg}, 243 "bright_fore_fg": {"foreground": "#ffffff"}, 244 "bright_fore_bg": {"background": "#ffffff"}, 245 "dim_fore_fg": {"foreground": "#e0e0e0"}, 246 "dim_fore_bg": {"background": "#e0e0e0"}, 247 "back_fg": {"foreground": default_bg}, 248 "back_bg": {"background": default_bg}, 249 "bright_back_fg": {"foreground": "#000000"}, 250 "bright_back_bg": {"background": "#000000"}, 251 "dim_back_fg": {"foreground": "#222222"}, 252 "dim_back_bg": {"background": "#222222"}, 253 "intense_io": {"font": "BoldIOFont"}, 254 "italic_io": {"font": "ItalicIOFont"}, 255 "intense_italic_io": {"font": "BoldItalicIOFont"}, 256 "underline": {"underline": True}, 257 "strikethrough": {"overstrike": True}, 258 } 259 260 261def default_dark_green() -> SyntaxThemeSettings: 262 open_string_bg = "#453B22" 263 gutter_background = "#33402F" 264 265 return { 266 "TEXT": {"background": "#273627"}, 267 "GUTTER": {"background": gutter_background}, 268 "current_line": {"background": "#2E402E"}, 269 "sel": {"background": "#6E6E6E"}, 270 "unclosed_expression": {"background": "#0F1F15"}, 271 "open_string": {"background": open_string_bg}, 272 "open_string3": {"background": open_string_bg}, 273 "keyword": {"foreground": "#88CFB6", "font": "BoldEditorFont"}, 274 "builtin": {"foreground": "#88CFB6"}, 275 # debugger 276 "active_focus": {"background": "#807238"}, 277 "completed_focus": {"background": "#807238"}, 278 "exception_focus": {"background": "#FFBFD6"}, 279 "expression_box": {"background": "#506E67"}, 280 } 281 282 283def default_dark_blue() -> SyntaxThemeSettings: 284 open_string_bg = "#224533" 285 gutter_background = "#2F3640" 286 return { 287 "TEXT": {"background": "#272936"}, 288 "GUTTER": {"background": gutter_background}, 289 "current_line": {"background": "#2D3040"}, 290 "sel": {"background": "#6E6E6E"}, 291 "unclosed_expression": {"background": "#100B21"}, 292 "open_string": {"background": open_string_bg}, 293 "open_string3": {"background": open_string_bg}, 294 "keyword": {"foreground": "#8899CF", "font": "BoldEditorFont"}, 295 "builtin": {"foreground": "#8899CF"}, 296 # debugger 297 "active_focus": {"background": "#807238"}, 298 "completed_focus": {"background": "#807238"}, 299 "exception_focus": {"background": "#FFBFD6"}, 300 "expression_box": {"background": "#506E67"}, 301 } 302 303 304def idle_classic() -> SyntaxThemeSettings: 305 string_fg = "#00aa00" 306 return { 307 "TEXT": {"foreground": "black", "insertbackground": "black", "background": "white"}, 308 "GUTTER": {"foreground": "gray", "background": "#efefef"}, 309 "sel": {"foreground": "black", "background": "gray"}, 310 "number": {"foreground": "black"}, 311 "definition": {"foreground": "#0000ff", "font": "EditorFont"}, 312 "string": {"foreground": string_fg}, 313 "string3": {"foreground": string_fg}, 314 "open_string": {"foreground": string_fg}, 315 "open_string3": {"foreground": string_fg}, 316 "keyword": {"foreground": "#ff7700", "font": "EditorFont"}, 317 "builtin": {"foreground": "#900090"}, 318 "comment": {"foreground": "#dd0000"}, 319 "prompt": {"foreground": "#770000"}, 320 "stdin": {"foreground": "black"}, 321 "stdout": {"foreground": "Blue"}, 322 "value": {"foreground": "Blue"}, 323 "stderr": {"foreground": "Red"}, 324 "found": {"foreground": "", "underline": True}, 325 "current_found": {"foreground": "white", "background": "black"}, 326 } 327 328 329def idle_dark() -> SyntaxThemeSettings: 330 normal_fg = "white" 331 string_fg = "#02ff02" 332 333 return { 334 "TEXT": {"foreground": normal_fg, "insertbackground": normal_fg, "background": "#002240"}, 335 "sel": {"foreground": "#FFFFFF", "background": "#7e7e7e"}, 336 "number": {"foreground": normal_fg}, 337 "definition": {"foreground": "#5e5eff", "font": "EditorFont"}, 338 "string": {"foreground": string_fg}, 339 "string3": {"foreground": string_fg}, 340 "open_string": {"foreground": string_fg}, 341 "open_string3": {"foreground": string_fg}, 342 "keyword": {"foreground": "#ff8000", "font": "EditorFont"}, 343 "builtin": {"foreground": "#ff00ff"}, 344 "comment": {"foreground": "#dd0000"}, 345 "welcome": {"foreground": "#dd0000"}, 346 "prompt": {"foreground": "#ff4d4d"}, 347 "stdin": {"foreground": normal_fg}, 348 "stdout": {"foreground": "#c2d1fa"}, 349 "value": {"foreground": "#c2d1fa"}, 350 "stderr": {"foreground": "#ffb3b3"}, 351 "found": {"foreground": "", "underline": True}, 352 "current_found": {"foreground": "#002240", "background": "#fbfbfb"}, 353 } 354 355 356def desert_sunset() -> SyntaxThemeSettings: 357 normal_fg = "#f0e68c" 358 string_fg = "#ffa0a0" 359 360 return { 361 "TEXT": {"foreground": normal_fg, "insertbackground": normal_fg, "background": "#333333"}, 362 "GUTTER": {"foreground": "gray", "background": "#404040"}, 363 "sel": {"foreground": "#000000", "background": "gray"}, 364 "number": {"foreground": normal_fg}, 365 "definition": {"foreground": "#98fb98"}, 366 "string": {"foreground": string_fg}, 367 "string3": {"foreground": string_fg}, 368 "open_string": {"foreground": string_fg}, 369 "open_string3": {"foreground": string_fg}, 370 "keyword": {"foreground": "#cc6600"}, 371 "builtin": {"foreground": "#519e51"}, 372 "comment": {"foreground": "#87ceeb"}, 373 "welcome": {"foreground": "#87ceeb"}, 374 "prompt": {"foreground": "#87ceeb"}, 375 "stdin": {"foreground": normal_fg}, 376 "stdout": {"foreground": "#eeeeee"}, 377 "value": {"foreground": "#eeeeee"}, 378 "stderr": {"foreground": "#ff595b"}, 379 "found": {"foreground": "", "underline": True}, 380 "current_found": {"foreground": "#ffffff", "background": "#333333"}, 381 } 382 383 384def zenburn() -> SyntaxThemeSettings: 385 # https://github.com/mig/gedit-themes/blob/master/zenburn.xml 386 # https://github.com/trusktr/gedit-color-schemes/blob/master/gtksourceview-3.0/styles/zenburn.xml 387 normal_fg = "#dcdccc" 388 string_fg = "#cc9393" 389 390 return { 391 "TEXT": {"foreground": normal_fg, "insertbackground": normal_fg, "background": "#3f3f3f"}, 392 "GUTTER": {"foreground": "#7f8f8f", "background": "#464646"}, 393 "current_line": {"background": "#4A4A4A"}, 394 "sel": {"foreground": "white", "background": "#506070"}, 395 "number": {"foreground": "#8cd0d3"}, 396 "definition": {"foreground": "#f4a020", "font": "BoldEditorFont"}, 397 "string": {"foreground": string_fg}, 398 "string3": {"foreground": string_fg}, 399 "open_string": {"foreground": string_fg}, 400 "open_string3": {"foreground": string_fg}, 401 "keyword": {"foreground": "#f0dfaf", "font": "BoldEditorFont"}, 402 "builtin": {"foreground": "#efef8f"}, 403 "comment": {"foreground": "#7f9f7f"}, 404 "welcome": {"foreground": "#7f9f7f"}, 405 "prompt": {"foreground": "#87ceeb"}, 406 "stdin": {"foreground": normal_fg}, 407 "stdout": {"foreground": "#eeeeee"}, 408 "value": {"foreground": "#eeeeee"}, 409 "stderr": {"foreground": "#ff3e40"}, 410 # paren matcher 411 "surrounding_parens": {"foreground": "white", "font": "BoldEditorFont"}, 412 } 413 414 415def load_plugin() -> None: 416 get_workbench().add_syntax_theme("Default Light", None, default_light) 417 get_workbench().add_syntax_theme("Default Dark", None, default_dark) 418 get_workbench().add_syntax_theme("Default Dark Green", "Default Dark", default_dark_green) 419 get_workbench().add_syntax_theme("Default Dark Blue", "Default Dark", default_dark_blue) 420 get_workbench().add_syntax_theme("Desert Sunset", "Default Dark", desert_sunset) 421 get_workbench().add_syntax_theme("Zenburn", "Default Dark", zenburn) 422 get_workbench().add_syntax_theme("IDLE Classic", "Default Light", idle_classic) 423 424 # Comments in IDLE Dark really hurt the eyes 425 # get_workbench().add_syntax_theme("IDLE Dark", "Default Dark", idle_dark) 426 427 get_workbench().set_default("view.syntax_theme", "Default Light") 428