Switch color scheme for prompts, info system and exception handlers. Currently implemented schemes: NoColor, Linux, LightBG. Color scheme names are not case-sensitive. Examples -------- To get a plain black and white terminal:: %colors nocolor
(self, parameter_s='')
| 311 | |
| 312 | @line_magic |
| 313 | def colors(self, parameter_s=''): |
| 314 | """Switch color scheme for prompts, info system and exception handlers. |
| 315 | |
| 316 | Currently implemented schemes: NoColor, Linux, LightBG. |
| 317 | |
| 318 | Color scheme names are not case-sensitive. |
| 319 | |
| 320 | Examples |
| 321 | -------- |
| 322 | To get a plain black and white terminal:: |
| 323 | |
| 324 | %colors nocolor |
| 325 | """ |
| 326 | def color_switch_err(name): |
| 327 | warn('Error changing %s color schemes.\n%s' % |
| 328 | (name, sys.exc_info()[1]), stacklevel=2) |
| 329 | |
| 330 | |
| 331 | new_scheme = parameter_s.strip() |
| 332 | if not new_scheme: |
| 333 | raise UsageError( |
| 334 | "%colors: you must specify a color scheme. See '%colors?'") |
| 335 | # local shortcut |
| 336 | shell = self.shell |
| 337 | |
| 338 | # Set shell colour scheme |
| 339 | try: |
| 340 | shell.colors = new_scheme |
| 341 | shell.refresh_style() |
| 342 | except: |
| 343 | color_switch_err('shell') |
| 344 | |
| 345 | # Set exception colors |
| 346 | try: |
| 347 | shell.InteractiveTB.set_colors(scheme = new_scheme) |
| 348 | shell.SyntaxTB.set_colors(scheme = new_scheme) |
| 349 | except: |
| 350 | color_switch_err('exception') |
| 351 | |
| 352 | # Set info (for 'object?') colors |
| 353 | if shell.color_info: |
| 354 | try: |
| 355 | shell.inspector.set_active_scheme(new_scheme) |
| 356 | except: |
| 357 | color_switch_err('object inspector') |
| 358 | else: |
| 359 | shell.inspector.set_active_scheme('NoColor') |
| 360 | |
| 361 | @line_magic |
| 362 | def xmode(self, parameter_s=''): |
nothing calls this directly
no test coverage detected