Show More
@@ -11,14 +11,15 b' var IPython = (function(IPython ) {' | |||||
11 |
|
11 | |||
12 | // what is the common start of all completions |
|
12 | // what is the common start of all completions | |
13 | function sharedStart(B){ |
|
13 | function sharedStart(B){ | |
14 | if(B.length == 1){return B[0]} |
|
14 | if(B.length == 1){return B[0];} | |
15 | var A = new Array() |
|
15 | var A = new Array(); | |
16 | for(var i=0; i< B.length; i++) |
|
16 | for(var i=0; i< B.length; i++) | |
17 | { |
|
17 | { | |
18 | A.push(B[i].str); |
|
18 | A.push(B[i].str); | |
19 | } |
|
19 | } | |
20 | if(A.length > 1 ){ |
|
20 | if(A.length > 1 ){ | |
21 |
var tem1, tem2, s |
|
21 | var tem1, tem2, s; | |
|
22 | A = A.slice(0).sort(); | |||
22 | tem1 = A[0]; |
|
23 | tem1 = A[0]; | |
23 | s = tem1.length; |
|
24 | s = tem1.length; | |
24 | tem2 = A.pop(); |
|
25 | tem2 = A.pop(); | |
@@ -40,7 +41,7 b' var IPython = (function(IPython ) {' | |||||
40 | this.editor = cell.code_mirror; |
|
41 | this.editor = cell.code_mirror; | |
41 | // if last caractere before cursor is not in this, we stop completing |
|
42 | // if last caractere before cursor is not in this, we stop completing | |
42 | this.reg = /[0-9a-z.]/i; // casse insensitive |
|
43 | this.reg = /[0-9a-z.]/i; // casse insensitive | |
43 | } |
|
44 | }; | |
44 |
|
45 | |||
45 | Completer.prototype.kernelCompletionRequest = function(){ |
|
46 | Completer.prototype.kernelCompletionRequest = function(){ | |
46 | var cur = this.editor.getCursor(); |
|
47 | var cur = this.editor.getCursor(); | |
@@ -48,7 +49,7 b' var IPython = (function(IPython ) {' | |||||
48 | // one could fork here and directly call finish completing if kernel is busy |
|
49 | // one could fork here and directly call finish completing if kernel is busy | |
49 | var callbacks = {'complete_reply': $.proxy(this.finish_completing,this)}; |
|
50 | var callbacks = {'complete_reply': $.proxy(this.finish_completing,this)}; | |
50 | IPython.notebook.kernel.complete(line, cur.ch, callbacks); |
|
51 | IPython.notebook.kernel.complete(line, cur.ch, callbacks); | |
51 | } |
|
52 | }; | |
52 |
|
53 | |||
53 |
|
54 | |||
54 | Completer.prototype.startCompletion = function() |
|
55 | Completer.prototype.startCompletion = function() | |
@@ -60,7 +61,7 b' var IPython = (function(IPython ) {' | |||||
60 | this.done = false; |
|
61 | this.done = false; | |
61 | // use to get focus back on opera |
|
62 | // use to get focus back on opera | |
62 | this.carryOnCompletion(true); |
|
63 | this.carryOnCompletion(true); | |
63 | } |
|
64 | }; | |
64 |
|
65 | |||
65 | Completer.prototype.carryOnCompletion = function(ff) { |
|
66 | Completer.prototype.carryOnCompletion = function(ff) { | |
66 | // Pass true as parameter if you want the commpleter to autopick when |
|
67 | // Pass true as parameter if you want the commpleter to autopick when | |
@@ -83,7 +84,7 b' var IPython = (function(IPython ) {' | |||||
83 |
|
84 | |||
84 | //one kernel completion came back, finish_completing will be called with the results |
|
85 | //one kernel completion came back, finish_completing will be called with the results | |
85 | this.kernelCompletionRequest(); |
|
86 | this.kernelCompletionRequest(); | |
86 | } |
|
87 | }; | |
87 |
|
88 | |||
88 | Completer.prototype.finish_completing =function (content) { |
|
89 | Completer.prototype.finish_completing =function (content) { | |
89 | // let's build a function that wrap all that stuff into what is needed |
|
90 | // let's build a function that wrap all that stuff into what is needed | |
@@ -104,7 +105,7 b' var IPython = (function(IPython ) {' | |||||
104 | type : "introspection", |
|
105 | type : "introspection", | |
105 | from : {line: cur.line, ch: cur.ch-matched_text.length}, |
|
106 | from : {line: cur.line, ch: cur.ch-matched_text.length}, | |
106 | to : {line: cur.line, ch: cur.ch} |
|
107 | to : {line: cur.line, ch: cur.ch} | |
107 | }) |
|
108 | }); | |
108 | } |
|
109 | } | |
109 |
|
110 | |||
110 | // one the 2 sources results have been merge, deal with it |
|
111 | // one the 2 sources results have been merge, deal with it | |
@@ -117,15 +118,14 b' var IPython = (function(IPython ) {' | |||||
117 | if (this.autopick == true && this.raw_result.length == 1) |
|
118 | if (this.autopick == true && this.raw_result.length == 1) | |
118 |
|
|
119 | { | |
119 |
|
|
120 | this.insert(this.raw_result[0]); | |
120 |
|
|
121 | return; | |
121 |
|
|
122 | } | |
122 |
|
123 | |||
123 | if (this.raw_result.length == 1) |
|
124 | if (this.raw_result.length == 1) | |
124 | { |
|
125 | { | |
125 | // test if first and only completion totally matches |
|
126 | // test if first and only completion totally matches | |
126 | // what is typed, in this case dismiss |
|
127 | // what is typed, in this case dismiss | |
127 | var str = this.raw_result[0].str |
|
128 | var str = this.raw_result[0].str; | |
128 | var cur = this.editor.getCursor(); |
|
|||
129 | var pre_cursor = this.editor.getRange({line:cur.line,ch:cur.ch-str.length},cur); |
|
129 | var pre_cursor = this.editor.getRange({line:cur.line,ch:cur.ch-str.length},cur); | |
130 | if(pre_cursor == str) |
|
130 | if(pre_cursor == str) | |
131 | { this.close(); return ; } |
|
131 | { this.close(); return ; } | |
@@ -148,9 +148,9 b' var IPython = (function(IPython ) {' | |||||
148 | $('body').append(this.complete); |
|
148 | $('body').append(this.complete); | |
149 | //build the container |
|
149 | //build the container | |
150 | var that = this; |
|
150 | var that = this; | |
151 | this.sel.dblclick(function(){that.pick()}); |
|
151 | this.sel.dblclick(function(){that.pick();}); | |
152 | this.sel.blur(this.close); |
|
152 | this.sel.blur(this.close); | |
153 | this.sel.keydown(function(event){that.keydown(event)}); |
|
153 | this.sel.keydown(function(event){that.keydown(event);}); | |
154 |
|
154 | |||
155 | this.build_gui_list(this.raw_result); |
|
155 | this.build_gui_list(this.raw_result); | |
156 |
|
156 | |||
@@ -191,6 +191,7 b' var IPython = (function(IPython ) {' | |||||
191 |
|
191 | |||
192 | Completer.prototype.keydown = function(event) { |
|
192 | Completer.prototype.keydown = function(event) { | |
193 | var code = event.keyCode; |
|
193 | var code = event.keyCode; | |
|
194 | var that = this; | |||
194 | // Enter |
|
195 | // Enter | |
195 | if (code == key.enter) {CodeMirror.e_stop(event); this.pick();} |
|
196 | if (code == key.enter) {CodeMirror.e_stop(event); this.pick();} | |
196 | // Escape or backspace |
|
197 | // Escape or backspace | |
@@ -209,7 +210,6 b' var IPython = (function(IPython ) {' | |||||
209 | CodeMirror.e_stop(event); |
|
210 | CodeMirror.e_stop(event); | |
210 | this.editor.focus(); |
|
211 | this.editor.focus(); | |
211 | //reinvoke self |
|
212 | //reinvoke self | |
212 | var that = this; |
|
|||
213 | setTimeout(function(){that.carryOnCompletion();}, 50); |
|
213 | setTimeout(function(){that.carryOnCompletion();}, 50); | |
214 | } |
|
214 | } | |
215 | else if (code == key.upArrow || code == key.downArrow) { |
|
215 | else if (code == key.upArrow || code == key.downArrow) { | |
@@ -220,7 +220,6 b' var IPython = (function(IPython ) {' | |||||
220 | else if (code != key.upArrow && code != key.downArrow) { |
|
220 | else if (code != key.upArrow && code != key.downArrow) { | |
221 | this.close(); this.editor.focus(); |
|
221 | this.close(); this.editor.focus(); | |
222 | //we give focus to the editor immediately and call sell in 50 ms |
|
222 | //we give focus to the editor immediately and call sell in 50 ms | |
223 | var that = this; |
|
|||
224 | setTimeout(function(){that.carryOnCompletion();}, 50); |
|
223 | setTimeout(function(){that.carryOnCompletion();}, 50); | |
225 | } |
|
224 | } | |
226 | } |
|
225 | } |
1 | NO CONTENT: modified file |
|
NO CONTENT: modified file |
@@ -9,7 +9,7 b'' | |||||
9 | // Tooltip |
|
9 | // Tooltip | |
10 | //============================================================================ |
|
10 | //============================================================================ | |
11 | // |
|
11 | // | |
12 |
// you can set the autocall time by setting `IPython. |
|
12 | // you can set the autocall time by setting `IPython.tooltip.time_before_tooltip` in ms | |
13 |
|
13 | |||
14 | var IPython = (function (IPython) { |
|
14 | var IPython = (function (IPython) { | |
15 |
|
15 | |||
@@ -95,9 +95,6 b' var IPython = (function (IPython) {' | |||||
95 | this.tooltip.append(this.text); |
|
95 | this.tooltip.append(this.text); | |
96 | }; |
|
96 | }; | |
97 |
|
97 | |||
98 | // will resend the request on behalf on the cell which invoked the tooltip |
|
|||
99 | // to show in it in pager. This is done so to be sure of having the same |
|
|||
100 | // result as invoking `something?` |
|
|||
101 | Tooltip.prototype.showInPager = function() |
|
98 | Tooltip.prototype.showInPager = function() | |
102 | { |
|
99 | { | |
103 | var that = this; |
|
100 | var that = this; |
General Comments 0
You need to be logged in to leave comments.
Login now