##// END OF EJS Templates
[/gui/wx] Added a checkbox to switch background color (white/black)
ldufrechou -
Show More
@@ -134,6 +134,44 b' class WxConsoleView(stc.StyledTextCtrl):'
134 134 self.CmdKeyAssign(ord('B'), stc.STC_SCMOD_CTRL, stc.STC_CMD_ZOOMIN)
135 135 self.CmdKeyAssign(ord('N'), stc.STC_SCMOD_CTRL, stc.STC_CMD_ZOOMOUT)
136 136
137 #We draw a line at position 80
138 self.SetEdgeMode(stc.STC_EDGE_LINE)
139 self.SetEdgeColumn(80)
140 self.SetEdgeColour(wx.LIGHT_GREY)
141
142 #self.SetViewWhiteSpace(True)
143 #self.SetViewEOL(True)
144 self.SetEOLMode(stc.STC_EOL_CRLF)
145 #self.SetWrapMode(stc.STC_WRAP_CHAR)
146 #self.SetWrapMode(stc.STC_WRAP_WORD)
147 self.SetBufferedDraw(True)
148 #self.SetUseAntiAliasing(True)
149 self.SetLayoutCache(stc.STC_CACHE_PAGE)
150
151 self.EnsureCaretVisible()
152
153 self.SetMargins(3,3) #text is moved away from border with 3px
154 # Suppressing Scintilla margins
155 self.SetMarginWidth(0,0)
156 self.SetMarginWidth(1,0)
157 self.SetMarginWidth(2,0)
158
159 self.background_color = background_color
160 self.buildStyles()
161
162 self.indent = 0
163 self.prompt_count = 0
164 self.color_pat = re.compile('\x01?\x1b\[(.*?)m\x02?')
165
166 self.write(intro)
167 self.setPrompt(prompt)
168 self.showPrompt()
169
170 self.autocomplete_mode = autocomplete_mode
171
172 self.Bind(wx.EVT_KEY_DOWN, self._onKeypress)
173
174 def buildStyles(self):
137 175 #we define platform specific fonts
138 176 if wx.Platform == '__WXMSW__':
139 177 faces = { 'times': 'Times New Roman',
@@ -160,35 +198,12 b' class WxConsoleView(stc.StyledTextCtrl):'
160 198 'size2': 8,
161 199 }
162 200
163 #We draw a line at position 80
164 self.SetEdgeMode(stc.STC_EDGE_LINE)
165 self.SetEdgeColumn(80)
166 self.SetEdgeColour(wx.LIGHT_GREY)
167
168 #self.SetViewWhiteSpace(True)
169 #self.SetViewEOL(True)
170 self.SetEOLMode(stc.STC_EOL_CRLF)
171 #self.SetWrapMode(stc.STC_WRAP_CHAR)
172 #self.SetWrapMode(stc.STC_WRAP_WORD)
173 self.SetBufferedDraw(True)
174 #self.SetUseAntiAliasing(True)
175 self.SetLayoutCache(stc.STC_CACHE_PAGE)
176
177 self.EnsureCaretVisible()
178
179 self.SetMargins(3,3) #text is moved away from border with 3px
180 # Suppressing Scintilla margins
181 self.SetMarginWidth(0,0)
182 self.SetMarginWidth(1,0)
183 self.SetMarginWidth(2,0)
184
185 201 # make some styles
186 if background_color != "BLACK":
202 if self.background_color != "BLACK":
187 203 self.background_color = "WHITE"
188 204 self.SetCaretForeground("BLACK")
189 205 self.ANSI_STYLES = self.ANSI_STYLES_WHITE
190 206 else:
191 self.background_color = background_color
192 207 self.SetCaretForeground("WHITE")
193 208 self.ANSI_STYLES = self.ANSI_STYLES_BLACK
194 209
@@ -202,24 +217,19 b' class WxConsoleView(stc.StyledTextCtrl):'
202 217 "fore:#FF0000,back:#0000FF,bold")
203 218 self.StyleSetSpec(stc.STC_STYLE_BRACEBAD,
204 219 "fore:#000000,back:#FF0000,bold")
205
220
206 221 for style in self.ANSI_STYLES.values():
207 222 self.StyleSetSpec(style[0], "bold,fore:%s" % style[1])
208 223
209 224 #######################################################################
210 225
211 self.indent = 0
212 self.prompt_count = 0
213 self.color_pat = re.compile('\x01?\x1b\[(.*?)m\x02?')
214
215 self.write(intro)
216 self.setPrompt(prompt)
217 self.showPrompt()
226 def setBackgroundColor(self,color):
227 self.background_color = color
228 self.buildStyles()
218 229
219 self.autocomplete_mode = autocomplete_mode
230 def getBackgroundColor(self,color):
231 return self.background_color
220 232
221 self.Bind(wx.EVT_KEY_DOWN, self._onKeypress)
222
223 233 def asyncWrite(self, text):
224 234 '''
225 235 Write given text to buffer in an asynchroneous way.
@@ -545,12 +555,15 b' class IPShellWidget(wx.Panel):'
545 555
546 556 self.cout.write = self.text_ctrl.asyncWrite
547 557
558 option_text = wx.StaticText(self,-1,'Options:')
548 559 self.completion_option = wx.CheckBox(self, -1, "Scintilla completion")
549 560 self.completion_option.SetValue(False)
550 option_text = wx.StaticText(self,-1,'Options:')
561 self.background_option = wx.CheckBox(self, -1, "White background")
562 self.background_option.SetValue(False)
551 563
552 564 self.text_ctrl.Bind(wx.EVT_KEY_DOWN, self.keyPress)
553 self.Bind(wx.EVT_CHECKBOX, self.evtCheckOptionCompletion, self.completion_option)
565 self.completion_option.Bind(wx.EVT_CHECKBOX, self.evtCheckOptionCompletion)
566 self.background_option.Bind(wx.EVT_CHECKBOX, self.evtCheckOptionBackgroundColor)
554 567
555 568 ### making the layout of the panel ###
556 569 sizer = wx.BoxSizer(wx.VERTICAL)
@@ -560,7 +573,8 b' class IPShellWidget(wx.Panel):'
560 573 option_sizer.AddMany([(10,15),
561 574 option_text,
562 575 (20,15),
563 self.completion_option
576 self.completion_option,
577 self.background_option,
564 578 ])
565 579 self.SetAutoLayout(True)
566 580 sizer.Fit(self)
@@ -753,7 +767,14 b' class IPShellWidget(wx.Panel):'
753 767 else:
754 768 self.text_ctrl.setCompletionMethod('IPYTHON')
755 769 self.text_ctrl.SetFocus()
756
770
771 def evtCheckOptionBackgroundColor(self, event):
772 if event.IsChecked():
773 self.text_ctrl.setBackgroundColor('WHITE')
774 else:
775 self.text_ctrl.setBackgroundColor('BLACK')
776 self.text_ctrl.SetFocus()
777
757 778 #------------------------ Hook Section -----------------------------------
758 779 def updateHistoryTracker(self,command_line):
759 780 '''
General Comments 0
You need to be logged in to leave comments. Login now