summaryrefslogtreecommitdiff
path: root/paste/evalexception
diff options
context:
space:
mode:
authorianb <devnull@localhost>2005-11-13 00:07:26 +0000
committerianb <devnull@localhost>2005-11-13 00:07:26 +0000
commit6ff36643ce7bfb31aadbf029e90e953bd002131e (patch)
treed69bfce677a28913308b6c6b6fc53c134652aa4b /paste/evalexception
parenta2c5af078f4d720e509d813d4b10421e48ebc868 (diff)
downloadpaste-6ff36643ce7bfb31aadbf029e90e953bd002131e.tar.gz
Added history (up and down arrows). Made compacted variables have expanding link
Diffstat (limited to 'paste/evalexception')
-rw-r--r--paste/evalexception/media/debug.js57
-rw-r--r--paste/evalexception/middleware.py6
2 files changed, 61 insertions, 2 deletions
diff --git a/paste/evalexception/media/debug.js b/paste/evalexception/media/debug.js
index 21c23f6..64d47f2 100644
--- a/paste/evalexception/media/debug.js
+++ b/paste/evalexception/media/debug.js
@@ -46,6 +46,12 @@ function submitInput(button, framecount) {
var output = $(button.getAttribute('output-to'));
var url = debug_base
+ '/exec_input';
+ var history = input.form.history;
+ input.historyPosition = 0;
+ if (! history) {
+ history = input.form.history = [];
+ }
+ history.push(input.value);
var vars = {
framecount: framecount,
debugcount: debug_count,
@@ -92,6 +98,7 @@ function expandInput(button) {
var text = 'Contract';
} else {
stdops['type'] = 'text';
+ stdops['onkeypress'] = 'upArrow(this)';
var newEl = MochiKit.DOM.INPUT(stdops);
var text = 'Expand';
}
@@ -102,3 +109,53 @@ function expandInput(button) {
button.value = text;
return false;
}
+
+function upArrow(input, event) {
+ if (window.event) {
+ event = window.event;
+ }
+ if (event.keyCode != 38 && event.keyCode != 40) {
+ // not an up- or down-arrow
+ return true;
+ }
+ var dir = event.keyCode == 38 ? 1 : -1;
+ var history = input.form.history;
+ if (! history) {
+ history = input.form.history = [];
+ }
+ var pos = input.historyPosition || 0;
+ if (! pos && dir == -1) {
+ return true;
+ }
+ if (! pos && input.value) {
+ history.push(input.value);
+ pos = 1;
+ }
+ pos += dir;
+ if (history.length-pos < 0) {
+ pos = 1;
+ }
+ if (history.length-pos > history.length-1) {
+ input.value = '';
+ return true;
+ }
+ input.historyPosition = pos;
+ var line = history[history.length-pos];
+ input.value = line;
+}
+
+function expandLong(anchor) {
+ var span = anchor;
+ while (span) {
+ if (span.style && span.style.display == 'none') {
+ break;
+ }
+ span = span.nextSibling;
+ }
+ if (! span) {
+ return false;
+ }
+ MochiKit.DOM.showElement(span);
+ MochiKit.DOM.hideElement(anchor);
+ return false;
+}
diff --git a/paste/evalexception/middleware.py b/paste/evalexception/middleware.py
index 1f5148a..18f8b5f 100644
--- a/paste/evalexception/middleware.py
+++ b/paste/evalexception/middleware.py
@@ -336,8 +336,10 @@ def make_table(items):
if len(value) > 100:
# @@: This can actually break the HTML :(
# should I truncate before quoting?
+ orig_value = value
value = value[:100]
- value += '<span style="background-color: #999">...</span>'
+ value += '<a class="switch_source" style="background-color: #999" href="#" onclick="return expandLong(this)">...</a>'
+ value += '<span style="display: none">%s</span>' % orig_value[100:]
value = formatter.make_wrappable(value)
if i % 2:
attr = ' class="even"'
@@ -404,7 +406,7 @@ def input_form(framecount, debug_info):
display: none"></div>
<input type="text" name="input" id="debug_input_%(framecount)s"
style="width: 100%%"
- autocomplete="off"><br>
+ autocomplete="off" onkeypress="upArrow(this, event)"><br>
<input type="submit" value="Execute" name="submitbutton"
onclick="return submitInput(this, %(framecount)s)"
id="submit_%(framecount)s"