Show More
@@ -18,7 +18,6 b' var IPython = (function (IPython) {' | |||
|
18 | 18 | var CodeCell = function (notebook) { |
|
19 | 19 | this.code_mirror = null; |
|
20 | 20 | this.input_prompt_number = null; |
|
21 | this.completion_cursor = null; | |
|
22 | 21 | this.outputs = []; |
|
23 | 22 | this.collapsed = false; |
|
24 | 23 | this.tooltip_timeout = null; |
@@ -254,9 +253,7 b' var IPython = (function (IPython) {' | |||
|
254 | 253 | }; |
|
255 | 254 | |
|
256 | 255 | |
|
257 |
// called when completion came back from the kernel. |
|
|
258 | // curent cell for (more) completion merge the resuults with the ones | |
|
259 | // comming from the kernel and forward it to the completer | |
|
256 | // called when completion came back from the kernel. just forward | |
|
260 | 257 | CodeCell.prototype.finish_completing = function (matched_text, matches) { |
|
261 | 258 | this.completer.finish_completing(matched_text,matches); |
|
262 | 259 | } |
@@ -1,7 +1,6 b'' | |||
|
1 | 1 | // function completer. |
|
2 | 2 | // |
|
3 | 3 | // completer should be a class that take an cell instance |
|
4 | // | |
|
5 | 4 | |
|
6 | 5 | var IPython = (function(IPython ) { |
|
7 | 6 | // that will prevent us from misspelling |
@@ -45,11 +44,9 b' var IPython = (function(IPython ) {' | |||
|
45 | 44 | } |
|
46 | 45 | |
|
47 | 46 | Completer.prototype.kernelCompletionRequest = function(){ |
|
48 | var cur = this.editor.getCursor(); | |
|
49 | // Autocomplete the current line. | |
|
47 | var cur = this.editor.getCursor(); | |
|
50 | 48 | var line = this.editor.getLine(cur.line); |
|
51 | // one could fork here and directly call finish completing | |
|
52 | // if kernel is busy | |
|
49 | // one could fork here and directly call finish completing if kernel is busy | |
|
53 | 50 | IPython.notebook.complete_cell(this.cell, line, cur.ch); |
|
54 | 51 | } |
|
55 | 52 | |
@@ -65,12 +62,11 b' var IPython = (function(IPython ) {' | |||
|
65 | 62 | this.carryOnCompletion(true); |
|
66 | 63 | } |
|
67 | 64 | |
|
68 | Completer.prototype.carryOnCompletion = function(ff) | |
|
69 | { | |
|
70 | // pass true as parameter if you want the commpleter to autopick | |
|
71 | // when only one completion | |
|
72 | // as this function is automatically reinvoked at each keystroke with | |
|
73 | // ff = false | |
|
65 | Completer.prototype.carryOnCompletion = function(ff) { | |
|
66 | // Pass true as parameter if you want the commpleter to autopick when | |
|
67 | // only one completion. This function is automatically reinvoked at | |
|
68 | // each keystroke with ff = false | |
|
69 | ||
|
74 | 70 | var cur = this.editor.getCursor(); |
|
75 | 71 | var pre_cursor = this.editor.getRange({line:cur.line,ch:cur.ch-1},cur); |
|
76 | 72 | |
@@ -80,9 +76,8 b' var IPython = (function(IPython ) {' | |||
|
80 | 76 | |
|
81 | 77 | this.autopick = false; |
|
82 | 78 | if( ff != 'undefined' && ff==true) |
|
83 | { | |
|
84 | this.autopick=true; | |
|
85 | } | |
|
79 | { this.autopick=true; } | |
|
80 | ||
|
86 | 81 | // We want a single cursor position. |
|
87 | 82 | if (this.editor.somethingSelected()) return; |
|
88 | 83 | |
@@ -91,25 +86,23 b' var IPython = (function(IPython ) {' | |||
|
91 | 86 | } |
|
92 | 87 | |
|
93 | 88 | Completer.prototype.finish_completing =function (matched_text, matches) { |
|
94 |
// let's build a function that wrap all that stuff into what is needed |
|
|
95 | // new completer: | |
|
96 | // | |
|
89 | // let's build a function that wrap all that stuff into what is needed | |
|
90 | // for the new completer: | |
|
91 | ||
|
97 | 92 | var cur = this.editor.getCursor(); |
|
98 | 93 | var results = CodeMirror.contextHint(this.editor); |
|
99 | 94 | |
|
100 | // append the introspection result, in order, at | |
|
101 |
// |
|
|
102 |
// |
|
|
95 | // append the introspection result, in order, at at the beginning of | |
|
96 | // the table and compute the replacement range from current cursor | |
|
97 | // positon and matched_text length. | |
|
103 | 98 | for(var i= matches.length-1; i>=0 ;--i) |
|
104 | 99 | { |
|
105 | 100 | results.unshift( |
|
106 | { | |
|
107 | str : matches[i], | |
|
101 | { str : matches[i], | |
|
108 | 102 | type : "introspection", |
|
109 | 103 | from : {line: cur.line, ch: cur.ch-matched_text.length}, |
|
110 | 104 | to : {line: cur.line, ch: cur.ch} |
|
111 | } | |
|
112 | ) | |
|
105 | }) | |
|
113 | 106 | } |
|
114 | 107 | |
|
115 | 108 | // one the 2 sources results have been merge, deal with it |
@@ -127,15 +120,13 b' var IPython = (function(IPython ) {' | |||
|
127 | 120 | |
|
128 | 121 | if (this.raw_result.length == 1) |
|
129 | 122 | { |
|
130 | // test if first and only completion totally matches | |
|
131 | // what is typed, in this case dismiss | |
|
132 | var str = this.raw_result[0].str | |
|
133 | var cur = this.editor.getCursor(); | |
|
134 | var pre_cursor = this.editor.getRange({line:cur.line,ch:cur.ch-str.length},cur); | |
|
135 |
if(pre_cursor == str) |
|
|
136 | this.close(); | |
|
137 | return ; | |
|
138 | } | |
|
123 | // test if first and only completion totally matches | |
|
124 | // what is typed, in this case dismiss | |
|
125 | var str = this.raw_result[0].str | |
|
126 | var cur = this.editor.getCursor(); | |
|
127 | var pre_cursor = this.editor.getRange({line:cur.line,ch:cur.ch-str.length},cur); | |
|
128 | if(pre_cursor == str) | |
|
129 | { this.close(); return ; } | |
|
139 | 130 | } |
|
140 | 131 | |
|
141 | 132 | this.complete = $('<div/>').addClass('completions'); |
@@ -160,12 +151,10 b' var IPython = (function(IPython ) {' | |||
|
160 | 151 | this.sel.keydown(function(event){that.keydown(event)}); |
|
161 | 152 | |
|
162 | 153 | this.build_gui_list(this.raw_result); |
|
163 | //CodeMirror.connect(that.sel, "dblclick", function(){that.pick()}); | |
|
164 | 154 | |
|
165 | 155 | this.sel.focus(); |
|
166 | 156 | // Opera sometimes ignores focusing a freshly created node |
|
167 | 157 | if (window.opera) setTimeout(function(){if (!this.done) this.sel.focus();}, 100); |
|
168 | // why do we return true ? | |
|
169 | 158 | return true; |
|
170 | 159 | } |
|
171 | 160 | |
@@ -182,11 +171,6 b' var IPython = (function(IPython ) {' | |||
|
182 | 171 | this.sel.append(opt); |
|
183 | 172 | } |
|
184 | 173 | this.sel.children().first().attr('selected','true'); |
|
185 | ||
|
186 | //sel.size = Math.min(10, completions.length); | |
|
187 | // Hack to hide the scrollbar. | |
|
188 | //if (completions.length <= 10) | |
|
189 | //this.complete.style.width = (this.sel.clientWidth - 1) + "px"; | |
|
190 | 174 | } |
|
191 | 175 | |
|
192 | 176 | Completer.prototype.close = function() { |
General Comments 0
You need to be logged in to leave comments.
Login now