##// END OF EJS Templates
Add a banner.
Gael Varoquaux -
Show More
@@ -62,15 +62,23 b' class LineFrontEndBase(FrontEndBase):'
62 62 # Set to true for debug output
63 63 debug = False
64 64
65 # A banner to print at startup
66 banner = None
67
65 68 #--------------------------------------------------------------------------
66 69 # FrontEndBase interface
67 70 #--------------------------------------------------------------------------
68 71
69 def __init__(self, shell=None, history=None, *args, **kwargs):
72 def __init__(self, shell=None, history=None, banner=None, *args, **kwargs):
70 73 if shell is None:
71 74 shell = Interpreter()
72 75 FrontEndBase.__init__(self, shell=shell, history=history)
73
76
77 if banner is not None:
78 self.banner = banner
79 if self.banner is not None:
80 self.write(self.banner, refresh=False)
81
74 82 self.new_prompt(self.input_prompt_template.substitute(number=1))
75 83
76 84
@@ -59,7 +59,6 b' class PrefilterFrontEnd(LineFrontEndBase):'
59 59 """
60 60
61 61 def __init__(self, *args, **kwargs):
62 LineFrontEndBase.__init__(self, *args, **kwargs)
63 62 self.save_output_hooks()
64 63 # Instanciate an IPython0 interpreter to be able to use the
65 64 # prefiltering.
@@ -69,9 +68,6 b' class PrefilterFrontEnd(LineFrontEndBase):'
69 68 lambda s, string: self.write("\n"+string))
70 69 self.ipython0.write = self.write
71 70 self._ip = _ip = IPApi(self.ipython0)
72 # XXX: Hack: mix the two namespaces
73 self.shell.user_ns = self.ipython0.user_ns
74 self.shell.user_global_ns = self.ipython0.user_global_ns
75 71 # Make sure the raw system call doesn't get called, as we don't
76 72 # have a stdin accessible.
77 73 self._ip.system = self.system_call
@@ -81,6 +77,15 b' class PrefilterFrontEnd(LineFrontEndBase):'
81 77 'ls -CF')
82 78 # And now clean up the mess created by ipython0
83 79 self.release_output()
80 if not 'banner' in kwargs:
81 kwargs['banner'] = self.ipython0.BANNER + """
82 This is the wx frontend, by Gael Varoquaux. This is EXPERIMENTAL code."""
83
84 LineFrontEndBase.__init__(self, *args, **kwargs)
85 # XXX: Hack: mix the two namespaces
86 self.shell.user_ns = self.ipython0.user_ns
87 self.shell.user_global_ns = self.ipython0.user_global_ns
88
84 89 self.shell.output_trap = RedirectorOutputTrap(
85 90 out_callback=self.write,
86 91 err_callback=self.write,
@@ -175,7 +175,7 b' class ConsoleWidget(editwindow.EditWindow):'
175 175
176 176 The prompt can be given with ascii escape sequences.
177 177 """
178 self.write(prompt)
178 self.write(prompt, refresh=False)
179 179 # now we update our cursor giving end of prompt
180 180 self.current_prompt_pos = self.GetLength()
181 181 self.current_prompt_line = self.GetCurrentLine()
@@ -253,7 +253,6 b' class ConsoleWidget(editwindow.EditWindow):'
253 253 self.SetIndent(4)
254 254 self.SetTabWidth(4)
255 255
256 self.EnsureCaretVisible()
257 256 # we don't want scintilla's autocompletion to choose
258 257 # automaticaly out of a single choice list, as we pop it up
259 258 # automaticaly
@@ -300,7 +299,6 b' class ConsoleWidget(editwindow.EditWindow):'
300 299 self.StyleSetSpec(stc.STC_P_OPERATOR, p['operator'])
301 300 self.StyleSetSpec(stc.STC_P_COMMENTBLOCK, p['comment'])
302 301
303
304 302 def _on_key_down(self, event, skip=True):
305 303 """ Key press callback used for correcting behavior for
306 304 console-like interfaces: the cursor is constraint to be after
@@ -16,6 +16,7 b' You need wxPython to run this application.'
16 16 from wx_frontend import WxController
17 17 import __builtin__
18 18
19
19 20 class IPythonXController(WxController):
20 21 """ Sub class of WxController that adds some application-specific
21 22 bindings.
@@ -26,6 +27,9 b' class IPythonXController(WxController):'
26 27 def __init__(self, *args, **kwargs):
27 28 WxController.__init__(self, *args, **kwargs)
28 29 self.ipython0.ask_exit = self.do_exit
30 # Scroll to top
31 maxrange = self.GetScrollRange(wx.VERTICAL)
32 self.ScrollLines(-maxrange)
29 33
30 34
31 35 def _on_key_down(self, event, skip=True):
General Comments 0
You need to be logged in to leave comments. Login now