Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

I think I may have fixed the message tracking bugs. Now, all messages…

… will actually display! Also, tweaked the styling
  • Loading branch information...
commit 2117482c5db764d6d71b09e1bf8e36788d87ab7b 1 parent 310913d
James Gao authored
5 IPython/frontend/html/css/defaults.css
View
@@ -3,7 +3,10 @@ body {
font-size:10pt;
margin:5px;
}
-pre, p { margin:0px; }
+pre, p {
+ margin:0px;
+ font-family:monospace;
+}
.cblue { color: blue }
.ccyan { color: teal }
.cgreen { color: green }
18 IPython/frontend/html/css/notebook.css
View
@@ -12,13 +12,14 @@
.sidebox {
margin:6px;
- margin-bottom:16px;
+ margin-bottom:36px;
}
.sidebox .inside {
padding:8px;
border:1px solid #CCC;
min-height:20px;
- overflow:auto;
+ overflow-x:hidden;
+ overflow-y:auto;
}
.sidebox .title {
margin:-15px 0px -20px 20px;
@@ -30,10 +31,11 @@
/*
* History box
*/
-#history {
- overflow:auto;
- height:30%;
+#history { height:30% }
+#history .inside {
+ height:100%;
}
+#history .item { width:1024px; }
#history .item > p {
float:left;
margin-right:3px;
@@ -97,9 +99,11 @@
margin-bottom:4px;
}
.inputText {
- height:12pt;
+ font-size:10pt;
width:100%;
- border:none;
+ padding:0;
+ border:none;
+ outline:none;
}
.message .output_header {
color:red;
17 IPython/frontend/html/js/communicate.js
View
@@ -1,4 +1,5 @@
function CometGetter() {
+ this.queue = []
this.start()
this.request()
}
@@ -16,21 +17,17 @@ CometGetter.prototype.request = function () {
}
CometGetter.prototype.complete = function(json, status, request) {
this.request()
- this.process(json)
-}
-CometGetter.prototype.process = function (json) {
- var thisObj = this
if (json.msg_type == "status") {
statusbar.set(json.content.execution_state)
} else if (this.pause) {
- setTimeout(function () { thisObj.process(json) }, 1)
- } else {
- //Ignore first pyin due to connect call
- manager.process(json)
- }
+ this.queue.push(json)
+ } else
+ manager.process(json, false, !this.pause)
}
CometGetter.prototype.start = function () {
this.pause = false
+ while (this.queue.length > 0)
+ manager.process(this.queue.pop())
}
CometGetter.prototype.stop = function () {
this.pause = true
@@ -56,9 +53,9 @@ function execute(code, msg) {
type: "POST",
data: {type:"execute", code:code},
success: function(json, status, request) {
- comet.start()
if (json != null)
manager.process(json, msg)
+ comet.start()
}
})
}
2  IPython/frontend/html/js/notebook.js
View
@@ -7,7 +7,7 @@ $(document).ready(function() {
comet = new CometGetter()
manager = new Manager("messages")
statusbar = new StatusBar("statusbar")
- kernhistory = new History("history")
+ kernhistory = new History("history .inside")
//Startup POST, set some globals
$.ajax({
type: "POST",
79 IPython/frontend/html/js/ui.js
View
@@ -59,7 +59,7 @@ function Manager(obj) {
thisObj.deactivate(thisObj.ondeck)
})
- this.exec_msg = null
+ this.buf_out = null
}
Manager.prototype.get = function (msg_id) {
if (typeof(msg_id) == "undefined") {
@@ -97,13 +97,13 @@ Manager.prototype.deactivate = function (current) {
}
}
}
-Manager.prototype.process = function (json, origin) {
+Manager.prototype.process = function (json, origin, immediate) {
var id = json.parent_header.msg_id
var type = json.msg_type
//execute() calls always include an originating message
//By this point, we know the correct ID for that message, so let's set it
- if (typeof(origin) != "undefined") {
+ if (origin) {
if (type != "execute_reply")
throw Exception("Received other message with an origin??")
this.messages[id] = origin
@@ -113,32 +113,45 @@ Manager.prototype.process = function (json, origin) {
}
}
+ //comet might have some buffered calls if it's paused, let's tacle first!
+ while (comet.queue.length > 0)
+ this.process(comet.queue.pop())
+
var msg = this.get(id)
if (type == "execute_reply") {
exec_count = json.content.execution_count
+ var data = null
//If this reply has an SVG, let's add it
if (json.content.payload.length > 0) {
var payload = json.content.payload[0]
if (typeof(payload['format']) != "undefined") {
var format = payload['format']
if (format == "svg") {
- var data = payload['data']
+ data = payload['data']
//Remove the doctype from the top, otherwise no way to embed
data = data.split("\n").slice(4).join("\n")
- this.exec_msg = data
} else if (format == "png") {
- var png = document.createElement("img")
- png.src = "data:image/png;"+payload['data']
- this.exec_msg = png
+ data = $(document.createElement("img"))
+ data.attr("src", "data:image/png;"+payload['data'])
}
} else if (typeof(payload["text"]) != "undefined") {
- //Text payloads don't have pyout's, so dump immediately
- msg.setOutput(fixConsole(payload["text"]))
+ data = fixConsole(payload["text"])
}
+
} else
- //Execute returned nothing, we need to flush in case older message
+ //Execute returned nothing, we need to flush in case of older messages
msg.clearOutput()
-
+
+ //Flush everything to output, including possible pyout/stream from pub
+ var obj = $(document.createElement("div"))
+ var head = typeof(this.buf_out) == "object" && this.buf_out != null
+ if (this.buf_out != null) {
+ obj.html(head?this.buf_out[0]:this.buf_out)
+ obj.append("<br />")
+ this.buf_out = null
+ }
+ msg.setOutput(obj.append(data), head)
+
//Open a new input object
manager.get().activate()
} else if (type == "pyin") {
@@ -151,29 +164,29 @@ Manager.prototype.process = function (json, origin) {
kernhistory.append(data)
}
} else {
- var obj = $(document.createElement("div"))
- if (this.exec_msg != null) {
- obj.append(this.exec_msg)
- this.exec_msg = null
- }
-
+ //If a message arrives, remove current ondeck and readd later
var removed = false
if (this.ondeck != null && this.ondeck.code == "") {
this.ondeck.remove()
removed = true
}
+
if (type == "stream") {
- obj.append(fixConsole(json.content.data))
- msg.setOutput(obj)
+ this.buf_out = fixConsole(json.content.data)
} else if (type == "pyout") {
exec_count = json.content.execution_count
msg.num = json.content.execution_count
- obj.append(fixConsole(json.content.data))
- msg.setOutput(obj, true)
+ this.buf_out = [fixConsole(json.content.data)]
} else if (type == "pyerr") {
- obj.append(fixConsole(json.content.traceback.join("\n")))
- msg.setOutput(obj)
+ this.buf_out = fixConsole(json.content.traceback.join("\n"))
}
+
+ if (immediate) {
+ var head = typeof(this.buf_out) == "object"
+ msg.setOutput(head?this.buf_out[0]:this.buf_out, head )
+ this.buf_out = null
+ }
+
if (removed) this.get().activate()
}
@@ -251,7 +264,8 @@ Message.prototype.setOutput = function(value, header) {
var thisObj = this
this.output.animate({opacity:1, height:h}, {duration:200, complete:
function () { thisObj.output.attr("style", null);
- $.scrollTo(manager.ondeck.outer) }
+ if (manager.ondeck != null)
+ $.scrollTo(manager.ondeck.outer) }
})
var head = header?"Out [<span class='cbold'>"+this.num+"</span>]:":""
@@ -271,8 +285,8 @@ function InputArea(msg) {
}
InputArea.prototype.activate = function () {
this.text = $(document.createElement("textarea")).val(this.msg.code)
- this.text.addClass("inputText")
- this.msg.input.html(this.text)
+ this.text.addClass("inputText").attr("rows", 1)
+ this.msg.input.html(this.text.attr("spellcheck", "false"))
this.lh = this.text.height()
this.nlines = this.msg.code.split("\n").length
this.text.height(this.lh*this.nlines)
@@ -292,8 +306,9 @@ InputArea.prototype.keyfunc = function (e) {
if (e.which == 13) {
if (e.shiftKey)
this.submit(e.target.value)
- else if (e.ctrlKey) {
- this.text.val(this.text.val()+"\n")
+ else {
+ this.insert("\n")
+ e.preventDefault()
}
this.update(1)
}
@@ -379,7 +394,11 @@ InputArea.prototype.indent = function () {
this.text.val(code.slice(0,pos)+tabs+code.slice(pos))
}
-
+InputArea.prototype.insert = function (txt) {
+ var pos = this.text.getSelection().end
+ txt = this.text.val().slice(0,pos)+txt+this.text.val().slice(pos)
+ this.text.val(txt)
+}
/***********************************************************************
4 IPython/frontend/html/notebook.html
View
@@ -17,9 +17,9 @@
<body>
<div id="messages"></div>
<div id="sidebar">
- <div class='sidebox'>
+ <div id="history" class='sidebox'>
<p class='title'>History</p>
- <div id="history" class='inside'>
+ <div class='inside'>
</div>
</div>
Please sign in to comment.
Something went wrong with that request. Please try again.