diff --git a/IPython/frontend/html/notebook/static/codemirror2/mode/python/python.css b/IPython/frontend/html/notebook/static/codemirror2/mode/python/python.css index 29909bd..0d6e5bb 100644 --- a/IPython/frontend/html/notebook/static/codemirror2/mode/python/python.css +++ b/IPython/frontend/html/notebook/static/codemirror2/mode/python/python.css @@ -3,7 +3,7 @@ span.py-special {color: #666666;} span.py-operator {color: #AA22FF; font-weight: bold;} -span.py-error {background-color: #000000; color: #FF0000;} +/*span.py-error {background-color: #000000; color: #FF0000;}*/ span.py-keyword {color: #008000; font-weight: bold;} @@ -20,4 +20,4 @@ span.py-comment {color: #408080; font-style: italic;} span.py-string, span.py-bytes, span.py-raw, -span.py-unicode {color: #BA2121;} \ No newline at end of file +span.py-unicode {color: #BA2121;} diff --git a/IPython/frontend/html/notebook/static/css/notebook.css b/IPython/frontend/html/notebook/static/css/notebook.css index b8bc3b6..5e82833 100644 --- a/IPython/frontend/html/notebook/static/css/notebook.css +++ b/IPython/frontend/html/notebook/static/css/notebook.css @@ -353,6 +353,19 @@ div.text_cell_render ol ol ol ol ol {list-style:lower-roman;} .ansigrey {color: grey;} .ansibold {font-weight: bold;} +.completions { + position: absolute; + z-index: 10; + overflow: auto; + border: 1px solid black; +} +.completions select { + background: white; + outline: none; + border: none; + padding: 0px; + margin: 0px; + font-family: monospace; +} -} \ No newline at end of file diff --git a/IPython/frontend/html/notebook/static/js/codecell.js b/IPython/frontend/html/notebook/static/js/codecell.js index 004f60b..309506c 100644 --- a/IPython/frontend/html/notebook/static/js/codecell.js +++ b/IPython/frontend/html/notebook/static/js/codecell.js @@ -10,6 +10,8 @@ var IPython = (function (IPython) { var CodeCell = function (notebook) { this.code_mirror = null; this.input_prompt_number = ' '; + this.is_completing = false; + this.completion_cursor = null; IPython.Cell.apply(this, arguments); }; @@ -43,11 +45,93 @@ var IPython = (function (IPython) { if (event.keyCode === 13 && event.shiftKey) { // Always ignore shift-enter in CodeMirror as we handle it. return true; + } else if (event.keyCode == 32 && (event.ctrlKey || event.metaKey) && !event.altKey) { + event.stop(); + var cur = editor.getCursor(); + var line = editor.getLine(cur.line); + this.is_completing = true; + this.completion_cursor = cur; + IPython.notebook.complete_cell(this, line, cur.ch); } else { + if (this.is_completing && this.completion_cursor !== editor.getCursor()) { + this.is_completing = false; + this.completion_cursor = null; + console.log("Stopped completing early"); + } return false; }; }; + + CodeCell.prototype.finish_completing = function (matched_text, matches) { + if (!this.is_completing || matches.length === 0) {return;} + // console.log("Got matches", matched_text, matches); + + var that = this; + var cur = this.completion_cursor; + var complete = $('
').addClass('completions'); + var select = $('