Show More
@@ -233,6 +233,10 b' class Pdb(OldPdb, object):' | |||||
233 | cst['LightBG'].colors.breakpoint_enabled = C.LightRed |
|
233 | cst['LightBG'].colors.breakpoint_enabled = C.LightRed | |
234 | cst['LightBG'].colors.breakpoint_disabled = C.Red |
|
234 | cst['LightBG'].colors.breakpoint_disabled = C.Red | |
235 |
|
235 | |||
|
236 | cst['Neutral'].colors.prompt = C.Blue | |||
|
237 | cst['Neutral'].colors.breakpoint_enabled = C.LightRed | |||
|
238 | cst['Neutral'].colors.breakpoint_disabled = C.Red | |||
|
239 | ||||
236 | self.set_colors(color_scheme) |
|
240 | self.set_colors(color_scheme) | |
237 |
|
241 | |||
238 | # Add a python parser so we can syntax highlight source while |
|
242 | # Add a python parser so we can syntax highlight source while | |
@@ -313,7 +317,7 b' class Pdb(OldPdb, object):' | |||||
313 | except KeyboardInterrupt: |
|
317 | except KeyboardInterrupt: | |
314 | pass |
|
318 | pass | |
315 |
|
319 | |||
316 | def print_stack_entry(self,frame_lineno,prompt_prefix='\n-> ', |
|
320 | def print_stack_entry(self,frame_lineno, prompt_prefix='\n-> ', | |
317 | context=None): |
|
321 | context=None): | |
318 | if context is None: |
|
322 | if context is None: | |
319 | context = self.context |
|
323 | context = self.context |
@@ -18,7 +18,7 b' def exception_colors():' | |||||
18 | """Return a color table with fields for exception reporting. |
|
18 | """Return a color table with fields for exception reporting. | |
19 |
|
19 | |||
20 | The table is an instance of ColorSchemeTable with schemes added for |
|
20 | The table is an instance of ColorSchemeTable with schemes added for | |
21 | 'Linux', 'LightBG' and 'NoColor' and fields for exception handling filled |
|
21 | 'Neutral', 'Linux', 'LightBG' and 'NoColor' and fields for exception handling filled | |
22 | in. |
|
22 | in. | |
23 |
|
23 | |||
24 | Examples: |
|
24 | Examples: | |
@@ -127,6 +127,35 b' def exception_colors():' | |||||
127 | Normal = C.Normal, |
|
127 | Normal = C.Normal, | |
128 | )) |
|
128 | )) | |
129 |
|
129 | |||
|
130 | ex_colors.add_scheme(ColorScheme( | |||
|
131 | 'Neutral', | |||
|
132 | # The color to be used for the top line | |||
|
133 | topline = C.Red, | |||
|
134 | ||||
|
135 | # The colors to be used in the traceback | |||
|
136 | filename = C.LightGreen, | |||
|
137 | lineno = C.LightGreen, | |||
|
138 | name = C.LightPurple, | |||
|
139 | vName = C.Cyan, | |||
|
140 | val = C.LightGreen, | |||
|
141 | em = C.Cyan, | |||
|
142 | ||||
|
143 | # Emphasized colors for the last frame of the traceback | |||
|
144 | normalEm = C.Cyan, | |||
|
145 | filenameEm = C.Green, | |||
|
146 | linenoEm = C.Green, | |||
|
147 | nameEm = C.Purple, | |||
|
148 | valEm = C.Blue, | |||
|
149 | ||||
|
150 | # Colors for printing the exception | |||
|
151 | excName = C.Red, | |||
|
152 | #line = C.Brown, # brown often is displayed as yellow | |||
|
153 | line = C.Red, | |||
|
154 | caret = C.Normal, | |||
|
155 | Normal = C.Normal, | |||
|
156 | )) | |||
|
157 | ||||
|
158 | ||||
130 | return ex_colors |
|
159 | return ex_colors | |
131 |
|
160 | |||
132 | class Deprec(object): |
|
161 | class Deprec(object): |
@@ -137,12 +137,10 b' class SpaceInInput(Exception): pass' | |||||
137 |
|
137 | |||
138 |
|
138 | |||
139 | def get_default_colors(): |
|
139 | def get_default_colors(): | |
140 | if sys.platform=='darwin': |
|
140 | "DEPRECATED" | |
141 | return "LightBG" |
|
141 | warn('get_default_color is Deprecated, and is `Neutral` on all platforms.', | |
142 | elif os.name=='nt': |
|
142 | DeprecationWarning, stacklevel=2) | |
143 |
|
|
143 | return 'Neutral' | |
144 | else: |
|
|||
145 | return 'Linux' |
|
|||
146 |
|
144 | |||
147 |
|
145 | |||
148 | class SeparateUnicode(Unicode): |
|
146 | class SeparateUnicode(Unicode): | |
@@ -250,8 +248,8 b' class InteractiveShell(SingletonConfigurable):' | |||||
250 | get confused with color codes, this capability can be turned off. |
|
248 | get confused with color codes, this capability can be turned off. | |
251 | """ |
|
249 | """ | |
252 | ).tag(config=True) |
|
250 | ).tag(config=True) | |
253 | colors = CaselessStrEnum(('NoColor','LightBG','Linux'), |
|
251 | colors = CaselessStrEnum(('Neutral', 'NoColor','LightBG','Linux'), | |
254 |
default_value= |
|
252 | default_value='Neutral', | |
255 | help="Set the color scheme (NoColor, Linux, or LightBG)." |
|
253 | help="Set the color scheme (NoColor, Linux, or LightBG)." | |
256 | ).tag(config=True) |
|
254 | ).tag(config=True) | |
257 | colors_force = Bool(False, help= |
|
255 | colors_force = Bool(False, help= |
@@ -325,7 +325,7 b' Currently the magic system has the following functions:""",' | |||||
325 | """ |
|
325 | """ | |
326 | def color_switch_err(name): |
|
326 | def color_switch_err(name): | |
327 | warn('Error changing %s color schemes.\n%s' % |
|
327 | warn('Error changing %s color schemes.\n%s' % | |
328 | (name, sys.exc_info()[1])) |
|
328 | (name, sys.exc_info()[1]), stacklevel=2) | |
329 |
|
329 | |||
330 |
|
330 | |||
331 | new_scheme = parameter_s.strip() |
|
331 | new_scheme = parameter_s.strip() |
@@ -67,6 +67,9 b' ColorSchemeTable class. Currently the following exist:' | |||||
67 | - LightBG: similar to Linux but swaps dark/light colors to be more readable |
|
67 | - LightBG: similar to Linux but swaps dark/light colors to be more readable | |
68 | in light background terminals. |
|
68 | in light background terminals. | |
69 |
|
69 | |||
|
70 | - Neutral: a neutral color scheme that should be readable on both light and | |||
|
71 | dark background | |||
|
72 | ||||
70 | You can implement other color schemes easily, the syntax is fairly |
|
73 | You can implement other color schemes easily, the syntax is fairly | |
71 | self-explanatory. Please send back new schemes you develop to the author for |
|
74 | self-explanatory. Please send back new schemes you develop to the author for | |
72 | possible inclusion in future releases. |
|
75 | possible inclusion in future releases. |
@@ -369,6 +369,7 b' class TerminalInteractiveShell(InteractiveShell):' | |||||
369 |
|
369 | |||
370 | We need that to add style for prompt ... etc. |
|
370 | We need that to add style for prompt ... etc. | |
371 | """ |
|
371 | """ | |
|
372 | style_overrides = {} | |||
372 | if name == 'legacy': |
|
373 | if name == 'legacy': | |
373 | legacy = self.colors.lower() |
|
374 | legacy = self.colors.lower() | |
374 | if legacy == 'linux': |
|
375 | if legacy == 'linux': | |
@@ -376,10 +377,12 b' class TerminalInteractiveShell(InteractiveShell):' | |||||
376 | style_overrides = _style_overrides_linux |
|
377 | style_overrides = _style_overrides_linux | |
377 | elif legacy == 'lightbg': |
|
378 | elif legacy == 'lightbg': | |
378 | style_overrides = _style_overrides_light_bg |
|
379 | style_overrides = _style_overrides_light_bg | |
379 |
style_cls = get_style_by_name(' |
|
380 | style_cls = get_style_by_name('pastie') | |
|
381 | elif legacy == 'neutral': | |||
380 | # The default theme needs to be visible on both a dark background |
|
382 | # The default theme needs to be visible on both a dark background | |
381 | # and a light background, because we can't tell what the terminal |
|
383 | # and a light background, because we can't tell what the terminal | |
382 | # looks like. These tweaks to the default theme help with that. |
|
384 | # looks like. These tweaks to the default theme help with that. | |
|
385 | style_cls = get_style_by_name('default') | |||
383 | style_overrides.update({ |
|
386 | style_overrides.update({ | |
384 | Token.Number: '#007700', |
|
387 | Token.Number: '#007700', | |
385 | Token.Operator: 'noinherit', |
|
388 | Token.Operator: 'noinherit', | |
@@ -387,6 +390,10 b' class TerminalInteractiveShell(InteractiveShell):' | |||||
387 | Token.Name.Function: '#2080D0', |
|
390 | Token.Name.Function: '#2080D0', | |
388 | Token.Name.Class: 'bold #2080D0', |
|
391 | Token.Name.Class: 'bold #2080D0', | |
389 | Token.Name.Namespace: 'bold #2080D0', |
|
392 | Token.Name.Namespace: 'bold #2080D0', | |
|
393 | Token.Prompt: '#009900', | |||
|
394 | Token.PromptNum: '#00ff00 bold', | |||
|
395 | Token.OutPrompt: '#990000', | |||
|
396 | Token.OutPromptNum: '#ff0000 bold', | |||
390 | }) |
|
397 | }) | |
391 | elif legacy =='nocolor': |
|
398 | elif legacy =='nocolor': | |
392 | style_cls=_NoStyle |
|
399 | style_cls=_NoStyle |
@@ -122,6 +122,32 b' LinuxColors = ColorScheme(' | |||||
122 | 'normal' : Colors.Normal # color off (usu. Colors.Normal) |
|
122 | 'normal' : Colors.Normal # color off (usu. Colors.Normal) | |
123 | } ) |
|
123 | } ) | |
124 |
|
124 | |||
|
125 | NeutralColors = ColorScheme( | |||
|
126 | 'Neutral',{ | |||
|
127 | 'header' : Colors.Red, | |||
|
128 | token.NUMBER : Colors.Cyan, | |||
|
129 | token.OP : Colors.Blue, | |||
|
130 | token.STRING : Colors.Blue, | |||
|
131 | tokenize.COMMENT : Colors.Red, | |||
|
132 | token.NAME : Colors.Normal, | |||
|
133 | token.ERRORTOKEN : Colors.Red, | |||
|
134 | ||||
|
135 | _KEYWORD : Colors.Green, | |||
|
136 | _TEXT : Colors.Blue, | |||
|
137 | ||||
|
138 | 'in_prompt' : InputTermColors.Blue, | |||
|
139 | 'in_number' : InputTermColors.LightBlue, | |||
|
140 | 'in_prompt2' : InputTermColors.Blue, | |||
|
141 | 'in_normal' : InputTermColors.Normal, # color off (usu. Colors.Normal) | |||
|
142 | ||||
|
143 | 'out_prompt' : Colors.Red, | |||
|
144 | 'out_number' : Colors.LightRed, | |||
|
145 | ||||
|
146 | 'normal' : Colors.Normal # color off (usu. Colors.Normal) | |||
|
147 | } ) | |||
|
148 | ||||
|
149 | ||||
|
150 | ||||
125 | LightBGColors = ColorScheme( |
|
151 | LightBGColors = ColorScheme( | |
126 | 'LightBG',{ |
|
152 | 'LightBG',{ | |
127 | 'header' : Colors.Red, |
|
153 | 'header' : Colors.Red, | |
@@ -132,6 +158,7 b' LightBGColors = ColorScheme(' | |||||
132 | token.NAME : Colors.Normal, |
|
158 | token.NAME : Colors.Normal, | |
133 | token.ERRORTOKEN : Colors.Red, |
|
159 | token.ERRORTOKEN : Colors.Red, | |
134 |
|
160 | |||
|
161 | ||||
135 | _KEYWORD : Colors.Green, |
|
162 | _KEYWORD : Colors.Green, | |
136 | _TEXT : Colors.Blue, |
|
163 | _TEXT : Colors.Blue, | |
137 |
|
164 | |||
@@ -147,7 +174,7 b' LightBGColors = ColorScheme(' | |||||
147 | } ) |
|
174 | } ) | |
148 |
|
175 | |||
149 | # Build table of color schemes (needed by the parser) |
|
176 | # Build table of color schemes (needed by the parser) | |
150 | ANSICodeColors = ColorSchemeTable([NoColor,LinuxColors,LightBGColors], |
|
177 | ANSICodeColors = ColorSchemeTable([NoColor,LinuxColors,LightBGColors, NeutralColors], | |
151 | _scheme_default) |
|
178 | _scheme_default) | |
152 |
|
179 | |||
153 | class Parser(Colorable): |
|
180 | class Parser(Colorable): |
@@ -16,7 +16,7 b' from traitlets.config import Configurable' | |||||
16 | from traitlets import Unicode |
|
16 | from traitlets import Unicode | |
17 |
|
17 | |||
18 |
|
18 | |||
19 | available_themes = lambda : [s for s in pygments.styles.get_all_styles()]+['NoColor','LightBG','Linux'] |
|
19 | available_themes = lambda : [s for s in pygments.styles.get_all_styles()]+['NoColor','LightBG','Linux', 'Neutral'] | |
20 |
|
20 | |||
21 | class Colorable(Configurable): |
|
21 | class Colorable(Configurable): | |
22 | """ |
|
22 | """ |
@@ -49,7 +49,7 b' class Bar(Super):' | |||||
49 |
|
49 | |||
50 | def test_loop_colors(): |
|
50 | def test_loop_colors(): | |
51 |
|
51 | |||
52 | for scheme in ('Linux', 'NoColor','LightBG'): |
|
52 | for scheme in ('Linux', 'NoColor','LightBG', 'Neutral'): | |
53 |
|
53 | |||
54 | def test_unicode_colorize(): |
|
54 | def test_unicode_colorize(): | |
55 | p = Parser() |
|
55 | p = Parser() |
General Comments 0
You need to be logged in to leave comments.
Login now