Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Multiline entry support

  • Loading branch information...
commit cce11cd375705081ad31dc611e3736a607e56283 1 parent a0cf5f8
@jamesgao authored
View
42 IPython/frontend/html/css/notebook.css
@@ -10,22 +10,26 @@
background:white;
}
-.side_box {
+.sidebox {
margin:6px;
margin-bottom:16px;
+}
+.sidebox .inside {
padding:8px;
border:1px solid #CCC;
min-height:20px;
overflow:auto;
}
-
-p.side_title{
- margin:-6px 0px -20px 20px;
- padding:2px;
+.sidebox .title {
+ margin:-13px 0px -20px 20px;
+ padding:5px;
float:left;
background:white;
}
+/*
+ * History box
+ */
#history {
height:30%;
}
@@ -34,7 +38,9 @@ p.side_title{
text-decoration:none;
display:block;
}
-
+/*
+ * Status bar
+ */
#statusbar {
position:absolute;
bottom:6px;
@@ -49,10 +55,17 @@ p.side_title{
margin-left:10px;
float:right;
}
+
+/*
+ * Messages
+ */
#messages {
width:80%;
float:left;
}
+#messages .selected {
+ background:#CCC;
+}
.message {
border:1px solid #CCC;
border-radius:3px;
@@ -77,6 +90,11 @@ p.side_title{
width:90%;
margin-bottom:4px;
}
+.inputText {
+ height:12pt;
+ width:100%;
+ border:none;
+}
.message .output_header {
color:red;
float:left;
@@ -87,12 +105,10 @@ p.side_title{
width:90%;
}
-pre.input input {
- width:100%;
- border:none;
- padding:0px;
-}
+/*
+ * Tab completer
+ */
.completer {
position:absolute;
background:white;
@@ -107,10 +123,10 @@ pre.input input {
float:left;
margin:0px 3px;
}
-.selection {
+.completer .selection {
padding:2px;
cursor:pointer;
}
-.selected {
+.completer .selected {
background-color:#CCC;
}
View
73 IPython/frontend/html/js/ui.js
@@ -23,21 +23,24 @@ StatusBar.prototype.set = function(status) {
function History(obj) {
this.obj = $("#"+obj)
+ this.history = []
// gethistory(-1)
}
History.prototype.append = function(hist) {
for (var i in hist) {
+ this.history.push(hist[i])
var obj = $(document.createElement("a"))
obj.addClass("history_element")
- obj.attr("href", "javascript:kernhistory.click(\""+hist[i]+"\")")
- obj.html("["+i+"]: "+hist[i])
+ obj.attr("href", "javascript:kernhistory.click("+(this.history.length-1)+")")
+ var code = hist[i].replace(/\n/g, "<br />")
+ obj.html("["+i+"]: "+code)
this.obj.append(obj)
}
this.obj.scrollTo(this.obj.children().last())
}
-History.prototype.click = function (code) {
+History.prototype.click = function (id) {
var msg = manager.get()
- msg.code = code
+ msg.code = this.history[id]
msg.activate()
}
@@ -239,38 +242,61 @@ Message.prototype.setOutput = function(value, header) {
}
/***********************************************************************
- * Handles python input, including autocompletion, submission, etc
+ * Handles python input, submission, etc
***********************************************************************/
function InputArea(msg) {
this.msg = msg
this.activate()
}
InputArea.prototype.activate = function () {
- this.text = $(document.createElement("input")).val(this.msg.code)
+ this.text = $(document.createElement("textarea")).val(this.msg.code)
+ this.text.addClass("inputText")
this.msg.input.html(this.text)
- this.text.focus()
+ this.lh = this.text.height()
+ this.nlines = this.msg.code.split("\n").length
+ this.update()
var thisObj = this
this.text.keydown(function (e) {thisObj.keyfunc(e)})
+ this.text.keyup(function (e) {
+ thisObj.msg.code = e.target.value
+ thisObj.update()
+ })
+
+ this.text.focus()
}
InputArea.prototype.keyfunc = function (e) {
- if (e.which == 13)
- this.submit(e.target.value)
- else if (e.which == 38) {
- manager.get("-1").activate()
- } else if (e.which == 40) {
- manager.get("+1").activate()
- } else if (e.which == 9) {
- e.preventDefault()
- var thisObj = this
- var pos = this.text.getSelection().end
- tabcomplete(this.text.val(), pos,
- function(matches) {thisObj.complete(matches)}
- )
+ if (this.nlines > 1) {
+ 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.msg.code = e.target.value
+ if (e.which == 13) {
+ if (e.ctrlKey) {
+ this.text.val(this.text.val()+"\n")
+ } else
+ this.submit(e.target.value)
+ } else if (e.which == 38) {
+ manager.get("-1").activate()
+ } else if (e.which == 40) {
+ manager.get("+1").activate()
+ } else if (e.which == 9) {
+ e.preventDefault()
+ var thisObj = this
+ var pos = this.text.getSelection().end
+ tabcomplete(this.text.val(), pos,
+ function(matches) {thisObj.complete(matches)}
+ )
+ }
}
}
+InputArea.prototype.update = function (nlines) {
+ this.nlines = this.msg.code.split("\n").length + (nlines?nlines:0)
+ this.text.animate({height: this.lh*(this.nlines) }, 100)
+}
InputArea.prototype.submit = function (code) {
this.msg.code = code
if (code == "")
@@ -352,6 +378,9 @@ function Selector(parent, matches) {
thisObj.set(thisObj.selectors[thisObj.cursor].match); f()
} //Perhaps implement vim keys?
})
+ $(document).click(function (e){
+ thisObj.remove();
+ })
}
Selector.prototype.deselect = function () {
for (var i in this.selectors)
@@ -398,7 +427,7 @@ Selection.prototype.active = function () {
this.parent.deselect()
this.parent.cursor = this.idx
this.obj.addClass("selected")
- $.scrollTo(this.obj)
+// $.scrollTo(this.obj)
}
Selection.prototype.clear = function () {
this.obj.removeClass("selected")
View
15 IPython/frontend/html/notebook.html
@@ -17,14 +17,19 @@
<body>
<div id="messages"></div>
<div id="sidebar">
- <p class='side_title'>History</p>
- <div id="history" class='side_box'>
+ <div class='sidebox'>
+ <p class='title'>History</p>
+ <div id="history" class='inside'>
+ </div>
</div>
- <p class='side_title'>Variables</p>
- <div id="namespace" class='side_box'>
- <span>Namespace display not implemented</span>
+ <div class='sidebox'>
+ <p class='title'>Variables</p>
+ <div id="namespace" class='inside'>
+ <span>Namespace display not implemented</span>
+ </div>
</div>
+
<div id="statusbar"></div>
</div>
</body>
Please sign in to comment.
Something went wrong with that request. Please try again.