##// END OF EJS Templates
Merge pull request #4281 from ellisonbg/complete_above...
Matthias Bussonnier -
r12907:3ad718f0 merge
parent child Browse files
Show More
@@ -199,15 +199,27 b' var IPython = (function (IPython) {'
199 this.complete.attr('id', 'complete');
199 this.complete.attr('id', 'complete');
200
200
201 this.sel = $('<select style="width: auto"/>').attr('multiple', 'true').attr('size', Math.min(10, this.raw_result.length));
201 this.sel = $('<select style="width: auto"/>').attr('multiple', 'true').attr('size', Math.min(10, this.raw_result.length));
202 //var pos = this.editor.cursorCoords();
203 var cur = this.editor.getCursor();
204 cur.ch = cur.ch-matched_text.length;
205 var pos = this.editor.cursorCoords(cur);
206 this.complete.css('left', pos.left-3 + 'px');
207 this.complete.css('top', pos.bottom+1 + 'px');
208 this.complete.append(this.sel);
202 this.complete.append(this.sel);
209
210 $('body').append(this.complete);
203 $('body').append(this.complete);
204
205 // After everything is on the page, compute the postion.
206 // We put it above the code if it is too close to the bottom of the page.
207 var cur = this.editor.getCursor();
208 cur.ch = cur.ch-matched_text.length;
209 var pos = this.editor.cursorCoords(cur);
210 var left = pos.left-3;
211 var top;
212 var cheight = this.complete.height();
213 var wheight = $(window).height();
214 if (pos.bottom+cheight+5 > wheight) {
215 top = pos.top-cheight-4;
216 } else {
217 top = pos.bottom+1;
218 }
219 this.complete.css('left', left + 'px');
220 this.complete.css('top', top + 'px');
221
222
211 //build the container
223 //build the container
212 var that = this;
224 var that = this;
213 this.sel.dblclick(function () {
225 this.sel.dblclick(function () {
@@ -233,12 +245,12 b' var IPython = (function (IPython) {'
233 }
245 }
234
246
235 Completer.prototype.build_gui_list = function (completions) {
247 Completer.prototype.build_gui_list = function (completions) {
236 // Need to clear the all list
237 for (var i = 0; i < completions.length; ++i) {
248 for (var i = 0; i < completions.length; ++i) {
238 var opt = $('<option/>').text(completions[i].str).addClass(completions[i].type);
249 var opt = $('<option/>').text(completions[i].str).addClass(completions[i].type);
239 this.sel.append(opt);
250 this.sel.append(opt);
240 }
251 }
241 this.sel.children().first().attr('selected', 'true');
252 this.sel.children().first().attr('selected', 'true');
253 this.sel.scrollTop(0);
242 }
254 }
243
255
244 Completer.prototype.close = function () {
256 Completer.prototype.close = function () {
General Comments 0
You need to be logged in to leave comments. Login now