Show More
@@ -566,8 +566,11 b' var IPython = (function (IPython) {' | |||
|
566 | 566 | var cont = IPython.Cell.prototype.unselect.apply(this); |
|
567 | 567 | if (cont) { |
|
568 | 568 | // When a code cell is usnelected, make sure that the corresponding |
|
569 | // tooltip to that cell is closed. | |
|
569 | // tooltip and completer to that cell is closed. | |
|
570 | 570 | IPython.tooltip.remove_and_cancel_tooltip(true); |
|
571 | if (this.completer !== null) { | |
|
572 | this.completer.close(); | |
|
573 | } | |
|
571 | 574 | } |
|
572 | 575 | return cont; |
|
573 | 576 | }; |
@@ -86,8 +86,7 b' var IPython = (function (IPython) {' | |||
|
86 | 86 | |
|
87 | 87 | Completer.prototype.startCompletion = function () { |
|
88 | 88 | // call for a 'first' completion, that will set the editor and do some |
|
89 |
// special behavio |
|
|
90 | // | |
|
89 | // special behavior like autopicking if only one completion available. | |
|
91 | 90 | if (this.editor.somethingSelected()) return; |
|
92 | 91 | this.done = false; |
|
93 | 92 | // use to get focus back on opera |
@@ -215,6 +214,8 b' var IPython = (function (IPython) {' | |||
|
215 | 214 | } |
|
216 | 215 | } |
|
217 | 216 | |
|
217 | if (!this.visible) { | |
|
218 | console.log('add div'); | |
|
218 | 219 | this.complete = $('<div/>').addClass('completions'); |
|
219 | 220 | this.complete.attr('id', 'complete'); |
|
220 | 221 | |
@@ -222,11 +223,25 b' var IPython = (function (IPython) {' | |||
|
222 | 223 | // https://code.google.com/p/chromium/issues/detail?id=4579 |
|
223 | 224 | this.sel = $('<select style="width: auto"/>') |
|
224 | 225 | .attr('tabindex', -1) |
|
225 | .attr('multiple', 'true') | |
|
226 | .attr('size', Math.min(10, this.raw_result.length)); | |
|
226 | .attr('multiple', 'true'); | |
|
227 | 227 | this.complete.append(this.sel); |
|
228 | this.visible = true; | |
|
228 | 229 | $('body').append(this.complete); |
|
229 | 230 | |
|
231 | //build the container | |
|
232 | var that = this; | |
|
233 | this.sel.dblclick(function () { | |
|
234 | that.pick(); | |
|
235 | }); | |
|
236 | this.editor.on('keydown', function (event) { | |
|
237 | that.keydown(event); | |
|
238 | }); | |
|
239 | this.editor.on('keypress', function (event) { | |
|
240 | that.keypress(event); | |
|
241 | }); | |
|
242 | } | |
|
243 | this.sel.attr('size', Math.min(10, this.raw_result.length)); | |
|
244 | ||
|
230 | 245 | // After everything is on the page, compute the postion. |
|
231 | 246 | // We put it above the code if it is too close to the bottom of the page. |
|
232 | 247 | cur.ch = cur.ch-matched_text.length; |
@@ -243,26 +258,9 b' var IPython = (function (IPython) {' | |||
|
243 | 258 | this.complete.css('left', left + 'px'); |
|
244 | 259 | this.complete.css('top', top + 'px'); |
|
245 | 260 | |
|
246 | ||
|
247 | //build the container | |
|
248 | var that = this; | |
|
249 | this.sel.dblclick(function () { | |
|
250 | that.pick(); | |
|
251 | }); | |
|
252 | this.editor.on('keydown', function (event) { | |
|
253 | that.keydown(event); | |
|
254 | }); | |
|
255 | this.editor.on('keypress', function (event) { | |
|
256 | that.keypress(event); | |
|
257 | }); | |
|
258 | ||
|
261 | // Clear and fill the list. | |
|
262 | this.sel.text(''); | |
|
259 | 263 | this.build_gui_list(this.raw_result); |
|
260 | ||
|
261 | this.sel.focus(); | |
|
262 | // Opera sometimes ignores focusing a freshly created node | |
|
263 | if (window.opera) setTimeout(function () { | |
|
264 | if (!this.done) this.sel.focus(); | |
|
265 | }, 100); | |
|
266 | 264 | return true; |
|
267 | 265 | }; |
|
268 | 266 | |
@@ -282,15 +280,13 b' var IPython = (function (IPython) {' | |||
|
282 | 280 | Completer.prototype.close = function () { |
|
283 | 281 | this.done = true; |
|
284 | 282 | $('#complete').remove(); |
|
283 | this.visible = false; | |
|
285 | 284 | }; |
|
286 | 285 | |
|
287 | 286 | Completer.prototype.pick = function () { |
|
288 | 287 | this.insert(this.raw_result[this.sel[0].selectedIndex]); |
|
289 | 288 | this.close(); |
|
290 | 289 | var that = this; |
|
291 | setTimeout(function () { | |
|
292 | that.editor.focus(); | |
|
293 | }, 50); | |
|
294 | 290 | }; |
|
295 | 291 | |
|
296 | 292 | Completer.prototype.keydown = function (event) { |
@@ -306,11 +302,9 b' var IPython = (function (IPython) {' | |||
|
306 | 302 | else if (code == keycodes.esc) { |
|
307 | 303 | CodeMirror.e_stop(event); |
|
308 | 304 | this.close(); |
|
309 | this.editor.focus(); | |
|
310 | 305 | |
|
311 | 306 | } else if (code == keycodes.backspace) { |
|
312 | 307 | this.close(); |
|
313 | this.editor.focus(); | |
|
314 | 308 | } else if (code == keycodes.tab) { |
|
315 | 309 | //all the fastforwarding operation, |
|
316 | 310 | //Check that shared start is not null which can append with prefixed completion |
@@ -322,7 +316,6 b' var IPython = (function (IPython) {' | |||
|
322 | 316 | } |
|
323 | 317 | this.close(); |
|
324 | 318 | CodeMirror.e_stop(event); |
|
325 | this.editor.focus(); | |
|
326 | 319 | //reinvoke self |
|
327 | 320 | setTimeout(function () { |
|
328 | 321 | that.carry_on_completion(); |
@@ -340,6 +333,7 b' var IPython = (function (IPython) {' | |||
|
340 | 333 | // This simulates the old behavior of completion as you type, |
|
341 | 334 | // before events were disconnected and CodeMirror stopped |
|
342 | 335 | // receiving events while the completer is focused. |
|
336 | if (!this.visible) return; | |
|
343 | 337 | |
|
344 | 338 | var that = this; |
|
345 | 339 | var code = event.keyCode; |
@@ -351,17 +345,7 b' var IPython = (function (IPython) {' | |||
|
351 | 345 | code == keycodes.tab |
|
352 | 346 | ) return; |
|
353 | 347 | |
|
354 | var cur = this.editor.getCursor(); | |
|
355 | var completion = { | |
|
356 | str: String.fromCharCode(event.which), | |
|
357 | type: "introspection", | |
|
358 | from: cur, | |
|
359 | to: cur, | |
|
360 | }; | |
|
361 | this.insert(completion); | |
|
362 | ||
|
363 | 348 | this.close(); |
|
364 | this.editor.focus(); | |
|
365 | 349 | setTimeout(function () { |
|
366 | 350 | that.carry_on_completion(); |
|
367 | 351 | }, 50); |
General Comments 0
You need to be logged in to leave comments.
Login now