Show More
@@ -33,6 +33,8 b' from IPython.core import release' | |||
|
33 | 33 | from IPython.utils import coloransi, py3compat |
|
34 | 34 | from traitlets import (Unicode, Instance, Dict, Bool, Int) |
|
35 | 35 | |
|
36 | from IPython.utils.PyColorize import LightBGColors, LinuxColors, NoColor | |
|
37 | ||
|
36 | 38 | #----------------------------------------------------------------------------- |
|
37 | 39 | # Color schemes for prompts |
|
38 | 40 | #----------------------------------------------------------------------------- |
@@ -42,42 +44,6 b' Colors = coloransi.TermColors # just a shorthand' | |||
|
42 | 44 | |
|
43 | 45 | color_lists = dict(normal=Colors(), inp=InputColors(), nocolor=coloransi.NoColors()) |
|
44 | 46 | |
|
45 | PColNoColors = coloransi.ColorScheme( | |
|
46 | 'NoColor', | |
|
47 | in_prompt = InputColors.NoColor, # Input prompt | |
|
48 | in_number = InputColors.NoColor, # Input prompt number | |
|
49 | in_prompt2 = InputColors.NoColor, # Continuation prompt | |
|
50 | in_normal = InputColors.NoColor, # color off (usu. Colors.Normal) | |
|
51 | ||
|
52 | out_prompt = Colors.NoColor, # Output prompt | |
|
53 | out_number = Colors.NoColor, # Output prompt number | |
|
54 | ||
|
55 | normal = Colors.NoColor # color off (usu. Colors.Normal) | |
|
56 | ) | |
|
57 | ||
|
58 | # make some schemes as instances so we can copy them for modification easily: | |
|
59 | PColLinux = coloransi.ColorScheme( | |
|
60 | 'Linux', | |
|
61 | in_prompt = InputColors.Green, | |
|
62 | in_number = InputColors.LightGreen, | |
|
63 | in_prompt2 = InputColors.Green, | |
|
64 | in_normal = InputColors.Normal, # color off (usu. Colors.Normal) | |
|
65 | ||
|
66 | out_prompt = Colors.Red, | |
|
67 | out_number = Colors.LightRed, | |
|
68 | ||
|
69 | normal = Colors.Normal | |
|
70 | ) | |
|
71 | ||
|
72 | # Slightly modified Linux for light backgrounds | |
|
73 | PColLightBG = PColLinux.copy('LightBG') | |
|
74 | ||
|
75 | PColLightBG.colors.update( | |
|
76 | in_prompt = InputColors.Blue, | |
|
77 | in_number = InputColors.LightBlue, | |
|
78 | in_prompt2 = InputColors.Blue | |
|
79 | ) | |
|
80 | ||
|
81 | 47 | #----------------------------------------------------------------------------- |
|
82 | 48 | # Utilities |
|
83 | 49 | #----------------------------------------------------------------------------- |
@@ -104,7 +70,7 b' class LazyEvaluate(object):' | |||
|
104 | 70 | return format(self(), format_spec) |
|
105 | 71 | |
|
106 | 72 | def multiple_replace(dict, text): |
|
107 | """ Replace in 'text' all occurences of any key in the given | |
|
73 | """ Replace in 'text' all occurrences of any key in the given | |
|
108 | 74 | dictionary by its corresponding value. Returns the new string.""" |
|
109 | 75 | |
|
110 | 76 | # Function by Xavier Defrang, originally found at: |
@@ -334,8 +300,8 b' class PromptManager(Configurable):' | |||
|
334 | 300 | super(PromptManager, self).__init__(shell=shell, **kwargs) |
|
335 | 301 | |
|
336 | 302 | # Prepare colour scheme table |
|
337 |
self.color_scheme_table = coloransi.ColorSchemeTable([ |
|
|
338 |
|
|
|
303 | self.color_scheme_table = coloransi.ColorSchemeTable([NoColor, | |
|
304 | LinuxColors, LightBGColors], self.color_scheme) | |
|
339 | 305 | |
|
340 | 306 | self._formatter = UserNSFormatter(shell) |
|
341 | 307 | # Prepare templates & numbers of invisible characters |
@@ -381,7 +347,7 b' class PromptManager(Configurable):' | |||
|
381 | 347 | else: |
|
382 | 348 | colors = color_lists['inp'] |
|
383 | 349 | colors.number, colors.prompt, colors.normal = \ |
|
384 |
scheme.in_number, scheme.in_prompt, scheme. |
|
|
350 | scheme.in_number, scheme.in_prompt, scheme.normal | |
|
385 | 351 | if name=='in2': |
|
386 | 352 | colors.prompt = scheme.in_prompt2 |
|
387 | 353 | else: |
@@ -84,7 +84,14 b' NoColor = ColorScheme(' | |||
|
84 | 84 | _KEYWORD : Colors.NoColor, |
|
85 | 85 | _TEXT : Colors.NoColor, |
|
86 | 86 | |
|
87 | 'normal' : Colors.NoColor # color off (usu. Colors.Normal) | |
|
87 | 'in_prompt' : InputTermColors.NoColor, # Input prompt | |
|
88 | 'in_number' : InputTermColors.NoColor, # Input prompt number | |
|
89 | 'in_prompt2' : InputTermColors.NoColor, # Continuation prompt | |
|
90 | ||
|
91 | 'out_prompt' : InputTermColors.NoColor, # Output prompt | |
|
92 | 'out_number' : InputTermColors.NoColor, # Output prompt number | |
|
93 | ||
|
94 | 'normal' : InputTermColors.NoColor # color off (usu. Colors.Normal) | |
|
88 | 95 | } ) |
|
89 | 96 | |
|
90 | 97 | LinuxColors = ColorScheme( |
@@ -99,7 +106,14 b' LinuxColors = ColorScheme(' | |||
|
99 | 106 | _KEYWORD : Colors.LightGreen, |
|
100 | 107 | _TEXT : Colors.Yellow, |
|
101 | 108 | |
|
102 | 'normal' : Colors.Normal # color off (usu. Colors.Normal) | |
|
109 | 'in_prompt' : InputTermColors.Green, | |
|
110 | 'in_number' : InputTermColors.LightGreen, | |
|
111 | 'in_prompt2' : InputTermColors.Green, | |
|
112 | ||
|
113 | 'out_prompt' : InputTermColors.Red, | |
|
114 | 'out_number' : InputTermColors.LightRed, | |
|
115 | ||
|
116 | 'normal' : InputTermColors.Normal # color off (usu. Colors.Normal) | |
|
103 | 117 | } ) |
|
104 | 118 | |
|
105 | 119 | LightBGColors = ColorScheme( |
@@ -114,7 +128,14 b' LightBGColors = ColorScheme(' | |||
|
114 | 128 | _KEYWORD : Colors.Green, |
|
115 | 129 | _TEXT : Colors.Blue, |
|
116 | 130 | |
|
117 | 'normal' : Colors.Normal # color off (usu. Colors.Normal) | |
|
131 | 'in_prompt' : InputTermColors.Blue, | |
|
132 | 'in_number' : InputTermColors.LightBlue, | |
|
133 | 'in_prompt2' : InputTermColors.Blue, | |
|
134 | ||
|
135 | 'out_prompt' : InputTermColors.Red, | |
|
136 | 'out_number' : InputTermColors.LightRed, | |
|
137 | ||
|
138 | 'normal' : InputTermColors.Normal # color off (usu. Colors.Normal) | |
|
118 | 139 | } ) |
|
119 | 140 | |
|
120 | 141 | # Build table of color schemes (needed by the parser) |
@@ -132,7 +132,7 b' class ColorSchemeTable(dict):' | |||
|
132 | 132 | active_scheme_name -> obvious |
|
133 | 133 | active_colors -> actual color table of the active scheme""" |
|
134 | 134 | |
|
135 | def __init__(self,scheme_list=None,default_scheme=''): | |
|
135 | def __init__(self, scheme_list=None, default_scheme=''): | |
|
136 | 136 | """Create a table of color schemes. |
|
137 | 137 | |
|
138 | 138 | The table can be created empty and manually filled or it can be |
General Comments 0
You need to be logged in to leave comments.
Login now