Show More
@@ -199,15 +199,27 b' var IPython = (function (IPython) {' | |||
|
199 | 199 | this.complete.attr('id', 'complete'); |
|
200 | 200 | |
|
201 | 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 | 202 | this.complete.append(this.sel); |
|
209 | ||
|
210 | 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 | 223 | //build the container |
|
212 | 224 | var that = this; |
|
213 | 225 | this.sel.dblclick(function () { |
@@ -233,12 +245,12 b' var IPython = (function (IPython) {' | |||
|
233 | 245 | } |
|
234 | 246 | |
|
235 | 247 | Completer.prototype.build_gui_list = function (completions) { |
|
236 | // Need to clear the all list | |
|
237 | 248 | for (var i = 0; i < completions.length; ++i) { |
|
238 | 249 | var opt = $('<option/>').text(completions[i].str).addClass(completions[i].type); |
|
239 | 250 | this.sel.append(opt); |
|
240 | 251 | } |
|
241 | 252 | this.sel.children().first().attr('selected', 'true'); |
|
253 | this.sel.scrollTop(0); | |
|
242 | 254 | } |
|
243 | 255 | |
|
244 | 256 | Completer.prototype.close = function () { |
General Comments 0
You need to be logged in to leave comments.
Login now