Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(552)

Unified Diff: runtime/observatory/lib/src/elements/debugger.dart

Issue 928543003: Add command line history to Observatory debugger. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/observatory/lib/src/cli/command.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/observatory/lib/src/elements/debugger.dart
diff --git a/runtime/observatory/lib/src/elements/debugger.dart b/runtime/observatory/lib/src/elements/debugger.dart
index 5aef04129e792da976443f461b124cfb52213672..e9d1623a7b622a34b17d4f7ab23a23e9d990f58c 100644
--- a/runtime/observatory/lib/src/elements/debugger.dart
+++ b/runtime/observatory/lib/src/elements/debugger.dart
@@ -807,6 +807,14 @@ class ObservatoryDebugger extends Debugger {
console.print('ERROR $e\n$s');
});
}
+
+ String historyPrev(String command) {
+ return cmd.historyPrev(command);
+ }
+
+ String historyNext(String command) {
+ return cmd.historyNext(command);
+ }
}
@CustomTag('debugger-page')
@@ -1049,37 +1057,52 @@ class DebuggerInputElement extends ObservatoryElement {
@observable ObservatoryDebugger debugger;
@observable bool busy = false;
- void _notBusy() {
- busy = false;
- }
-
@override
void ready() {
super.ready();
var textBox = $['textBox'];
textBox.select();
textBox.onKeyDown.listen((KeyboardEvent e) {
- // TODO(turnidge): Ignore *all* key events while busy.
+ if (busy) {
+ e.preventDefault();
+ return;
+ }
+ busy = true;
switch (e.keyCode) {
case KeyCode.TAB:
e.preventDefault();
- if (!busy) {
- busy = true;
- int cursorPos = textBox.selectionStart;
- debugger.complete(text.substring(0, cursorPos)).then((completion) {
- text = completion + text.substring(cursorPos);
- // TODO(turnidge): Move the cursor to the end of the
- // completion, rather than the end of the string.
- }).whenComplete(_notBusy);
- }
+ int cursorPos = textBox.selectionStart;
+ debugger.complete(text.substring(0, cursorPos)).then((completion) {
+ text = completion + text.substring(cursorPos);
+ // TODO(turnidge): Move the cursor to the end of the
+ // completion, rather than the end of the string.
+ }).whenComplete(() {
+ busy = false;
+ });
break;
+
case KeyCode.ENTER:
- if (!busy) {
- busy = true;
- var command = text;
+ var command = text;
+ debugger.run(command).whenComplete(() {
text = '';
- debugger.run(command).whenComplete(_notBusy);
- }
+ busy = false;
+ });
+ break;
+
+ case KeyCode.UP:
+ e.preventDefault();
+ text = debugger.historyPrev(text);
+ busy = false;
+ break;
+
+ case KeyCode.DOWN:
+ e.preventDefault();
+ text = debugger.historyNext(text);
+ busy = false;
+ break;
+
+ default:
+ busy = false;
break;
}
});
« no previous file with comments | « runtime/observatory/lib/src/cli/command.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698