##// END OF EJS Templates
Merge pull request #4292 from Carreau/more-cpl...
Matthias Bussonnier -
r12976:eb6d398a merge
parent child Browse files
Show More
@@ -9,8 +9,9 b' var IPython = (function (IPython) {'
9 var key = IPython.utils.keycodes;
9 var key = IPython.utils.keycodes;
10
10
11 function prepend_n_prc(str, n) {
11 function prepend_n_prc(str, n) {
12 for( var i =0 ; i< n ; i++)
12 for( var i =0 ; i< n ; i++){
13 { str = '%'+str }
13 str = '%'+str ;
14 }
14 return str;
15 return str;
15 }
16 }
16
17
@@ -33,7 +34,7 b' var IPython = (function (IPython) {'
33 for (var i = 0; i < B.length; i++) {
34 for (var i = 0; i < B.length; i++) {
34 var str = B[i].str;
35 var str = B[i].str;
35 var localmin = 0;
36 var localmin = 0;
36 if(drop_prct == true){
37 if(drop_prct === true){
37 while ( str.substr(0, 1) == '%') {
38 while ( str.substr(0, 1) == '%') {
38 localmin = localmin+1;
39 localmin = localmin+1;
39 str = str.substring(1);
40 str = str.substring(1);
@@ -52,13 +53,13 b' var IPython = (function (IPython) {'
52 while (s && tem2.indexOf(tem1) == -1) {
53 while (s && tem2.indexOf(tem1) == -1) {
53 tem1 = tem1.substring(0, --s);
54 tem1 = tem1.substring(0, --s);
54 }
55 }
55 if (tem1 == "" || tem2.indexOf(tem1) != 0) {
56 if (tem1 === "" || tem2.indexOf(tem1) !== 0) {
56 return {
57 return {
57 str:prepend_n_prc('', min_lead_prct),
58 str:prepend_n_prc('', min_lead_prct),
58 type: "computed",
59 type: "computed",
59 from: B[0].from,
60 from: B[0].from,
60 to: B[0].to
61 to: B[0].to
61 }
62 };
62 }
63 }
63 return {
64 return {
64 str: prepend_n_prc(tem1, min_lead_prct),
65 str: prepend_n_prc(tem1, min_lead_prct),
@@ -94,10 +95,28 b' var IPython = (function (IPython) {'
94 this.carry_on_completion(true);
95 this.carry_on_completion(true);
95 };
96 };
96
97
97 Completer.prototype.carry_on_completion = function (ff) {
98
99 // easy access for julia to monkeypatch
100 //
101 Completer.reinvoke_re = /[%0-9a-z._/\\:~-]/i;
102
103 Completer.prototype.reinvoke= function(pre_cursor, block, cursor){
104 return Completer.reinvoke_re.test(pre_cursor);
105 }
106
107 /**
108 *
109 * pass true as parameter if this is the first invocation of the completer
110 * this will prevent the completer to dissmiss itself if it is not on a
111 * word boundary like pressing tab after a space, and make it autopick the
112 * only choice if there is only one which prevent from popping the UI. as
113 * well as fast-forwarding the typing if all completion have a common
114 * shared start
115 **/
116 Completer.prototype.carry_on_completion = function (first_invocation) {
98 // Pass true as parameter if you want the commpleter to autopick when
117 // Pass true as parameter if you want the commpleter to autopick when
99 // only one completion. This function is automatically reinvoked at
118 // only one completion. This function is automatically reinvoked at
100 // each keystroke with ff = false
119 // each keystroke with first_invocation = false
101 var cur = this.editor.getCursor();
120 var cur = this.editor.getCursor();
102 var line = this.editor.getLine(cur.line);
121 var line = this.editor.getLine(cur.line);
103 var pre_cursor = this.editor.getRange({
122 var pre_cursor = this.editor.getRange({
@@ -107,18 +126,21 b' var IPython = (function (IPython) {'
107
126
108 // we need to check that we are still on a word boundary
127 // we need to check that we are still on a word boundary
109 // because while typing the completer is still reinvoking itself
128 // because while typing the completer is still reinvoking itself
110 if (!/[%0-9a-z._/\\:~-]/i.test(pre_cursor)) {
129 // so dismiss if we are on a "bad" caracter
130 if (!this.reinvoke(pre_cursor) && !first_invocation) {
111 this.close();
131 this.close();
112 return;
132 return;
113 }
133 }
114
134
115 this.autopick = false;
135 this.autopick = false;
116 if (ff != 'undefined' && ff == true) {
136 if (first_invocation) {
117 this.autopick = true;
137 this.autopick = true;
118 }
138 }
119
139
120 // We want a single cursor position.
140 // We want a single cursor position.
121 if (this.editor.somethingSelected()) return;
141 if (this.editor.somethingSelected()) {
142 return;
143 };
122
144
123 // one kernel completion came back, finish_completing will be called with the results
145 // one kernel completion came back, finish_completing will be called with the results
124 // we fork here and directly call finish completing if kernel is busy
146 // we fork here and directly call finish completing if kernel is busy
@@ -198,7 +220,9 b' var IPython = (function (IPython) {'
198 this.complete = $('<div/>').addClass('completions');
220 this.complete = $('<div/>').addClass('completions');
199 this.complete.attr('id', 'complete');
221 this.complete.attr('id', 'complete');
200
222
201 this.sel = $('<select style="width: auto"/>').attr('multiple', 'true').attr('size', Math.min(10, this.raw_result.length));
223 this.sel = $('<select style="width: auto"/>')
224 .attr('multiple', 'true')
225 .attr('size', Math.min(10, this.raw_result.length));
202 this.complete.append(this.sel);
226 this.complete.append(this.sel);
203 $('body').append(this.complete);
227 $('body').append(this.complete);
204
228
@@ -273,13 +297,13 b' var IPython = (function (IPython) {'
273 var code = event.keyCode;
297 var code = event.keyCode;
274 var that = this;
298 var that = this;
275 var special_key = false;
299 var special_key = false;
276
300
277 // detect special keys like SHIFT,PGUP,...
301 // detect special keys like SHIFT,PGUP,...
278 for( var _key in key ) {
302 for( var _key in key ) {
279 if (code == key[_key] ) {
303 if (code == key[_key] ) {
280 special_key = true;
304 special_key = true;
281 }
305 }
282 };
306 };
283
307
284 // Enter
308 // Enter
285 if (code == key.ENTER) {
309 if (code == key.ENTER) {
@@ -314,7 +338,7 b' var IPython = (function (IPython) {'
314 // need to do that to be able to move the arrow
338 // need to do that to be able to move the arrow
315 // when on the first or last line ofo a code cell
339 // when on the first or last line ofo a code cell
316 event.stopPropagation();
340 event.stopPropagation();
317 } else if (special_key != true) {
341 } else if (special_key != true) {
318 this.close();
342 this.close();
319 this.editor.focus();
343 this.editor.focus();
320 //we give focus to the editor immediately and call sell in 50 ms
344 //we give focus to the editor immediately and call sell in 50 ms
General Comments 0
You need to be logged in to leave comments. Login now