##// END OF EJS Templates
Merge pull request #8955 from Carreau/cscheme...
Min RK -
r21807:2b1c9696 merge
parent child Browse files
Show More
@@ -33,6 +33,8 b' from IPython.core import release'
33 from IPython.utils import coloransi, py3compat
33 from IPython.utils import coloransi, py3compat
34 from traitlets import (Unicode, Instance, Dict, Bool, Int)
34 from traitlets import (Unicode, Instance, Dict, Bool, Int)
35
35
36 from IPython.utils.PyColorize import LightBGColors, LinuxColors, NoColor
37
36 #-----------------------------------------------------------------------------
38 #-----------------------------------------------------------------------------
37 # Color schemes for prompts
39 # Color schemes for prompts
38 #-----------------------------------------------------------------------------
40 #-----------------------------------------------------------------------------
@@ -42,42 +44,6 b' Colors = coloransi.TermColors # just a shorthand'
42
44
43 color_lists = dict(normal=Colors(), inp=InputColors(), nocolor=coloransi.NoColors())
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 # Utilities
48 # Utilities
83 #-----------------------------------------------------------------------------
49 #-----------------------------------------------------------------------------
@@ -104,7 +70,7 b' class LazyEvaluate(object):'
104 return format(self(), format_spec)
70 return format(self(), format_spec)
105
71
106 def multiple_replace(dict, text):
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 dictionary by its corresponding value. Returns the new string."""
74 dictionary by its corresponding value. Returns the new string."""
109
75
110 # Function by Xavier Defrang, originally found at:
76 # Function by Xavier Defrang, originally found at:
@@ -334,8 +300,8 b' class PromptManager(Configurable):'
334 super(PromptManager, self).__init__(shell=shell, **kwargs)
300 super(PromptManager, self).__init__(shell=shell, **kwargs)
335
301
336 # Prepare colour scheme table
302 # Prepare colour scheme table
337 self.color_scheme_table = coloransi.ColorSchemeTable([PColNoColors,
303 self.color_scheme_table = coloransi.ColorSchemeTable([NoColor,
338 PColLinux, PColLightBG], self.color_scheme)
304 LinuxColors, LightBGColors], self.color_scheme)
339
305
340 self._formatter = UserNSFormatter(shell)
306 self._formatter = UserNSFormatter(shell)
341 # Prepare templates & numbers of invisible characters
307 # Prepare templates & numbers of invisible characters
@@ -381,7 +347,7 b' class PromptManager(Configurable):'
381 else:
347 else:
382 colors = color_lists['inp']
348 colors = color_lists['inp']
383 colors.number, colors.prompt, colors.normal = \
349 colors.number, colors.prompt, colors.normal = \
384 scheme.in_number, scheme.in_prompt, scheme.in_normal
350 scheme.in_number, scheme.in_prompt, scheme.normal
385 if name=='in2':
351 if name=='in2':
386 colors.prompt = scheme.in_prompt2
352 colors.prompt = scheme.in_prompt2
387 else:
353 else:
@@ -85,7 +85,14 b' NoColor = ColorScheme('
85 _KEYWORD : Colors.NoColor,
85 _KEYWORD : Colors.NoColor,
86 _TEXT : Colors.NoColor,
86 _TEXT : Colors.NoColor,
87
87
88 'normal' : Colors.NoColor # color off (usu. Colors.Normal)
88 'in_prompt' : InputTermColors.NoColor, # Input prompt
89 'in_number' : InputTermColors.NoColor, # Input prompt number
90 'in_prompt2' : InputTermColors.NoColor, # Continuation prompt
91
92 'out_prompt' : InputTermColors.NoColor, # Output prompt
93 'out_number' : InputTermColors.NoColor, # Output prompt number
94
95 'normal' : InputTermColors.NoColor # color off (usu. Colors.Normal)
89 } )
96 } )
90
97
91 LinuxColors = ColorScheme(
98 LinuxColors = ColorScheme(
@@ -101,7 +108,14 b' LinuxColors = ColorScheme('
101 _KEYWORD : Colors.LightGreen,
108 _KEYWORD : Colors.LightGreen,
102 _TEXT : Colors.Yellow,
109 _TEXT : Colors.Yellow,
103
110
104 'normal' : Colors.Normal # color off (usu. Colors.Normal)
111 'in_prompt' : InputTermColors.Green,
112 'in_number' : InputTermColors.LightGreen,
113 'in_prompt2' : InputTermColors.Green,
114
115 'out_prompt' : InputTermColors.Red,
116 'out_number' : InputTermColors.LightRed,
117
118 'normal' : InputTermColors.Normal # color off (usu. Colors.Normal)
105 } )
119 } )
106
120
107 LightBGColors = ColorScheme(
121 LightBGColors = ColorScheme(
@@ -117,7 +131,14 b' LightBGColors = ColorScheme('
117 _KEYWORD : Colors.Green,
131 _KEYWORD : Colors.Green,
118 _TEXT : Colors.Blue,
132 _TEXT : Colors.Blue,
119
133
120 'normal' : Colors.Normal # color off (usu. Colors.Normal)
134 'in_prompt' : InputTermColors.Blue,
135 'in_number' : InputTermColors.LightBlue,
136 'in_prompt2' : InputTermColors.Blue,
137
138 'out_prompt' : InputTermColors.Red,
139 'out_number' : InputTermColors.LightRed,
140
141 'normal' : InputTermColors.Normal # color off (usu. Colors.Normal)
121 } )
142 } )
122
143
123 # Build table of color schemes (needed by the parser)
144 # Build table of color schemes (needed by the parser)
@@ -132,7 +132,7 b' class ColorSchemeTable(dict):'
132 active_scheme_name -> obvious
132 active_scheme_name -> obvious
133 active_colors -> actual color table of the active scheme"""
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 """Create a table of color schemes.
136 """Create a table of color schemes.
137
137
138 The table can be created empty and manually filled or it can be
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