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