From 5829983263257b354ee60ff76eef487d90baf0ee 2011-07-26 21:22:41
From: Brian Granger <ellisonbg@gmail.com>
Date: 2011-07-26 21:22:41
Subject: [PATCH] Added complete method of JS kernel object.

---

diff --git a/IPython/frontend/html/notebook/static/js/kernel.js b/IPython/frontend/html/notebook/static/js/kernel.js
index b5ec75c..bdebda2 100644
--- a/IPython/frontend/html/notebook/static/js/kernel.js
+++ b/IPython/frontend/html/notebook/static/js/kernel.js
@@ -67,6 +67,18 @@ var IPython = (function (IPython) {
     }
 
 
+    Kernel.prototype.complete = function (line, cursor_pos) {
+        var content = {
+            text : '',
+            line : line,
+            cursor_pos : cursor_pos
+        };
+        var msg = this.get_msg("complete_request", content);
+        this.shell_channel.send(JSON.stringify(msg));
+        return msg.header.msg_id;
+    }
+
+
     Kernel.prototype.interrupt = function () {
         $.post(this.kernel_url + "/interrupt");
     };
diff --git a/IPython/frontend/html/notebook/static/js/notebook.js b/IPython/frontend/html/notebook/static/js/notebook.js
index 2bbd93d..44ddd07 100644
--- a/IPython/frontend/html/notebook/static/js/notebook.js
+++ b/IPython/frontend/html/notebook/static/js/notebook.js
@@ -402,9 +402,11 @@ var IPython = (function (IPython) {
         var cell = this.cell_for_msg(reply.parent_header.msg_id);
         if (msg_type === "execute_reply") {
             cell.set_input_prompt(content.execution_count);
+        } else if (msg_type === "complete_reply") {
+            console.log(content);
         };
         var payload = content.payload || [];
-        this.handle_payload(content.payload);
+        this.handle_payload(payload);
     };