Merge lp:~gael-varoquaux/ipython/ipython-sync-frontend into lp:ipython/0.11

Proposed by Gael Varoquaux on 2009-05-16
Status: Merged
Merged at revision: not available
Proposed branch: lp:~gael-varoquaux/ipython/ipython-sync-frontend
Merge into: lp:ipython/0.11
Diff against target: None lines
To merge this branch: bzr merge lp:~gael-varoquaux/ipython/ipython-sync-frontend
Reviewer Review Type Date Requested Status
Fernando Perez 2009-05-16 Approve on 2009-07-28
Review via email: mp+6645@code.launchpad.net
To post a comment you must log in.
Gael Varoquaux (gael-varoquaux) wrote :

This is just a simple bug fix.

1175. By Gael Varoquaux on 2009-05-16

BUG: Correct some trailing wx2.6 incompatibilities

Fernando Perez (fdo.perez) wrote :

It looks fine to me, thanks.

I concur with your comment in console_widget.py that the _on_key_down (and possibly other similar functions) might best be implemented with a dict-based callback mechanism. But since that would be a more invasive change, we can postpone that thought for now.

Otherwise the fix looks good. I'll wait 48 hours on this and if nobody notices a problem and objects, I'll merge it into trunk for 0.10.

Only question: can you let me know if there are any open tickets that I should close when merging?

review: Approve
Gael Varoquaux (gael-varoquaux) wrote :

On Tue, Jul 28, 2009 at 02:28:27AM -0000, Fernando Perez wrote:
> I concur with your comment in console_widget.py that the _on_key_down
> (and possibly other similar functions) might best be implemented with a
> dict-based callback mechanism. But since that would be a more invasive
> change, we can postpone that thought for now.

Yes, a lot of it would most probably. There might a few tricky parts
though, with successive logic in the choice of the callback.

I don't have time to do this right now, though.

> Only question: can you let me know if there are any open tickets that I should close when merging?

I hada quick look and couldn't see any.

Cheers,

Gaël

Fernando Perez (fdo.perez) wrote :

On Mon, Jul 27, 2009 at 10:30 PM, Gael
Varoquaux<email address hidden> wrote:
> On Tue, Jul 28, 2009 at 02:28:27AM -0000, Fernando Perez wrote:
>> I concur with your comment in console_widget.py that the _on_key_down
>> (and possibly other similar functions) might best be implemented with a
>> dict-based callback mechanism.  But since that would be a more invasive
>> change, we can postpone that thought for now.
>
> Yes, a lot of it would most probably. There might a few tricky parts
> though, with successive logic in the choice of the callback.
>
> I don't have time to do this right now, though.

No problem, I was just thinking for future work here...

>> Only question: can you let me know if there are any open tickets that I should close when merging?
>
> I hada quick look and couldn't see any.

Perfect, thanks.

This will then go in when I merge later this week, unless somebody
spots a problem.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'IPython/frontend/wx/console_widget.py'
2--- IPython/frontend/wx/console_widget.py 2009-04-20 21:25:20 +0000
3+++ IPython/frontend/wx/console_widget.py 2009-05-16 13:08:31 +0000
4@@ -447,29 +447,30 @@
5 # different callbacks share local variables?
6
7 # Intercept some specific keys.
8- if event.KeyCode == ord('L') and event.ControlDown() :
9+ key_code = event.GetKeyCode()
10+ if key_code == ord('L') and event.ControlDown() :
11 self.scroll_to_bottom()
12- elif event.KeyCode == ord('K') and event.ControlDown() :
13+ elif key_code == ord('K') and event.ControlDown() :
14 self.input_buffer = ''
15- elif event.KeyCode == ord('A') and event.ControlDown() :
16+ elif key_code == ord('A') and event.ControlDown() :
17 self.GotoPos(self.GetLength())
18 self.SetSelectionStart(self.current_prompt_pos)
19 self.SetSelectionEnd(self.GetCurrentPos())
20 catched = True
21- elif event.KeyCode == ord('E') and event.ControlDown() :
22+ elif key_code == ord('E') and event.ControlDown() :
23 self.GotoPos(self.GetLength())
24 catched = True
25- elif event.KeyCode == wx.WXK_PAGEUP:
26+ elif key_code == wx.WXK_PAGEUP:
27 self.ScrollPages(-1)
28- elif event.KeyCode == wx.WXK_PAGEDOWN:
29+ elif key_code == wx.WXK_PAGEDOWN:
30 self.ScrollPages(1)
31- elif event.KeyCode == wx.WXK_HOME:
32- self.GotoPos(self.GetLength())
33- elif event.KeyCode == wx.WXK_END:
34- self.GotoPos(self.GetLength())
35- elif event.KeyCode == wx.WXK_UP and event.ShiftDown():
36+ elif key_code == wx.WXK_HOME:
37+ self.GotoPos(self.GetLength())
38+ elif key_code == wx.WXK_END:
39+ self.GotoPos(self.GetLength())
40+ elif key_code == wx.WXK_UP and event.ShiftDown():
41 self.ScrollLines(-1)
42- elif event.KeyCode == wx.WXK_DOWN and event.ShiftDown():
43+ elif key_code == wx.WXK_DOWN and event.ShiftDown():
44 self.ScrollLines(1)
45 else:
46 catched = False
47@@ -477,13 +478,12 @@
48 if self.AutoCompActive():
49 event.Skip()
50 else:
51- if event.KeyCode in (13, wx.WXK_NUMPAD_ENTER) and \
52- event.Modifiers in (wx.MOD_NONE, wx.MOD_WIN,
53- wx.MOD_SHIFT):
54+ if key_code in (13, wx.WXK_NUMPAD_ENTER):
55+ # XXX: not catching modifiers, to be wx2.6-compatible
56 catched = True
57 if not self.enter_catched:
58 self.CallTipCancel()
59- if event.Modifiers == wx.MOD_SHIFT:
60+ if event.ShiftDown():
61 # Try to force execution
62 self.GotoPos(self.GetLength())
63 self.write('\n' + self.continuation_prompt(),
64@@ -493,19 +493,18 @@
65 self._on_enter()
66 self.enter_catched = True
67
68- elif event.KeyCode == wx.WXK_HOME:
69- if event.Modifiers in (wx.MOD_NONE, wx.MOD_WIN):
70+ elif key_code == wx.WXK_HOME:
71+ if not event.ShiftDown():
72 self.GotoPos(self.current_prompt_pos)
73 catched = True
74-
75- elif event.Modifiers == wx.MOD_SHIFT:
76+ else:
77 # FIXME: This behavior is not ideal: if the selection
78 # is already started, it will jump.
79 self.SetSelectionStart(self.current_prompt_pos)
80 self.SetSelectionEnd(self.GetCurrentPos())
81 catched = True
82
83- elif event.KeyCode == wx.WXK_UP:
84+ elif key_code == wx.WXK_UP:
85 if self.GetCurrentLine() > self.current_prompt_line:
86 if self.GetCurrentLine() == self.current_prompt_line + 1 \
87 and self.GetColumn(self.GetCurrentPos()) < \
88@@ -515,18 +514,18 @@
89 event.Skip()
90 catched = True
91
92- elif event.KeyCode in (wx.WXK_LEFT, wx.WXK_BACK):
93+ elif key_code in (wx.WXK_LEFT, wx.WXK_BACK):
94 if not self._keep_cursor_in_buffer(self.GetCurrentPos() - 1):
95 event.Skip()
96 catched = True
97
98- elif event.KeyCode == wx.WXK_RIGHT:
99+ elif key_code == wx.WXK_RIGHT:
100 if not self._keep_cursor_in_buffer(self.GetCurrentPos() + 1):
101 event.Skip()
102 catched = True
103
104
105- elif event.KeyCode == wx.WXK_DELETE:
106+ elif key_code == wx.WXK_DELETE:
107 if not self._keep_cursor_in_buffer(self.GetCurrentPos() - 1):
108 event.Skip()
109 catched = True
110@@ -535,7 +534,7 @@
111 # Put the cursor back in the edit region
112 if not self._keep_cursor_in_buffer():
113 if not (self.GetCurrentPos() == self.GetLength()
114- and event.KeyCode == wx.WXK_DELETE):
115+ and key_code == wx.WXK_DELETE):
116 event.Skip()
117 catched = True
118
119
120=== modified file 'IPython/frontend/wx/wx_frontend.py'
121--- IPython/frontend/wx/wx_frontend.py 2009-04-20 21:25:20 +0000
122+++ IPython/frontend/wx/wx_frontend.py 2009-05-16 13:08:31 +0000
123@@ -389,7 +389,8 @@
124 """
125 # FIXME: This method needs to be broken down in smaller ones.
126 current_line_num = self.GetCurrentLine()
127- if event.KeyCode in (ord('c'), ord('C')) and event.ControlDown():
128+ key_code = event.GetKeyCode()
129+ if key_code in (ord('c'), ord('C')) and event.ControlDown():
130 # Capture Control-C
131 if self._input_state == 'subprocess':
132 if self.debug:
133@@ -403,40 +404,39 @@
134 # XXX: We need to make really sure we
135 # get back to a prompt.
136 elif self._input_state == 'subprocess' and (
137- ( event.KeyCode<256 and
138- not event.ControlDown() )
139+ ( key_code <256 and not event.ControlDown() )
140 or
141- ( event.KeyCode in (ord('d'), ord('D')) and
142+ ( key_code in (ord('d'), ord('D')) and
143 event.ControlDown())):
144 # We are running a process, we redirect keys.
145 ConsoleWidget._on_key_down(self, event, skip=skip)
146- char = chr(event.KeyCode)
147+ char = chr(key_code)
148 # Deal with some inconsistency in wx keycodes:
149 if char == '\r':
150 char = '\n'
151 elif not event.ShiftDown():
152 char = char.lower()
153- if event.ControlDown() and event.KeyCode in (ord('d'), ord('D')):
154+ if event.ControlDown() and key_code in (ord('d'), ord('D')):
155 char = '\04'
156 self._running_process.process.stdin.write(char)
157 self._running_process.process.stdin.flush()
158- elif event.KeyCode in (ord('('), 57, 53):
159+ elif key_code in (ord('('), 57, 53):
160 # Calltips
161 event.Skip()
162 self.do_calltip()
163- elif self.AutoCompActive() and not event.KeyCode == ord('\t'):
164+ elif self.AutoCompActive() and not key_code == ord('\t'):
165 event.Skip()
166- if event.KeyCode in (wx.WXK_BACK, wx.WXK_DELETE):
167+ if key_code in (wx.WXK_BACK, wx.WXK_DELETE):
168 wx.CallAfter(self._popup_completion, create=True)
169- elif not event.KeyCode in (wx.WXK_UP, wx.WXK_DOWN, wx.WXK_LEFT,
170+ elif not key_code in (wx.WXK_UP, wx.WXK_DOWN, wx.WXK_LEFT,
171 wx.WXK_RIGHT, wx.WXK_ESCAPE):
172 wx.CallAfter(self._popup_completion)
173 else:
174 # Up history
175- if event.KeyCode == wx.WXK_UP and (
176- ( current_line_num == self.current_prompt_line and
177- event.Modifiers in (wx.MOD_NONE, wx.MOD_WIN) )
178- or event.ControlDown() ):
179+ if key_code == wx.WXK_UP and (
180+ event.ControlDown() or
181+ current_line_num == self.current_prompt_line
182+ ):
183 new_buffer = self.get_history_previous(
184 self.input_buffer)
185 if new_buffer is not None:
186@@ -446,16 +446,17 @@
187 self.GotoPos(self.current_prompt_pos)
188 # Down history
189 elif event.KeyCode == wx.WXK_DOWN and (
190- ( current_line_num == self.LineCount -1 and
191- event.Modifiers in (wx.MOD_NONE, wx.MOD_WIN) )
192- or event.ControlDown() ):
193+ event.ControlDown() or
194+ current_line_num == self.LineCount -1
195+ ):
196 new_buffer = self.get_history_next()
197 if new_buffer is not None:
198 self.input_buffer = new_buffer
199 # Tab-completion
200 elif event.KeyCode == ord('\t'):
201 current_line, current_line_num = self.CurLine
202- if not re.match(r'^\s*$', current_line):
203+ if not re.match(r'^%s\s*$' % self.continuation_prompt(),
204+ current_line):
205 self.complete_current_input()
206 if self.AutoCompActive():
207 wx.CallAfter(self._popup_completion, create=True)
208
209=== modified file 'IPython/kernel/scripts/ipcluster.py' (properties changed: +x to -x)

Subscribers

People subscribed via source and target branches