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

Unified Diff: runtime/observatory/lib/src/cli/command.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 | « no previous file | runtime/observatory/lib/src/elements/debugger.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/observatory/lib/src/cli/command.dart
diff --git a/runtime/observatory/lib/src/cli/command.dart b/runtime/observatory/lib/src/cli/command.dart
index c1da71bc772f50e34ab9ef911ed0c58f87836e33..30a78748218935bbb376cf627530e07b19fb9f33 100644
--- a/runtime/observatory/lib/src/cli/command.dart
+++ b/runtime/observatory/lib/src/cli/command.dart
@@ -151,6 +151,7 @@ class RootCommand extends _CommandBase {
// Runs a command.
Future runCommand(String line) {
+ _historyAdvance(line);
var args = _splitLine(line);
var commands = _match(args, true);
if (commands.isEmpty) {
@@ -174,6 +175,39 @@ class RootCommand extends _CommandBase {
return _match(args, preferExact);
}
+ // Command line history always contains one slot to hold the current
+ // line, so we start off with one entry.
+ List<String> history = [''];
+ int historyPos = 0;
+
+ String historyPrev(String line) {
+ if (historyPos == 0) {
+ return line;
+ }
+ history[historyPos] = line;
+ historyPos--;
+ return history[historyPos];
+ }
+
+ String historyNext(String line) {
+ if (historyPos == history.length - 1) {
+ return line;
+ }
+ history[historyPos] = line;
+ historyPos++;
+ return history[historyPos];
+ }
+
+ void _historyAdvance(String line) {
+ // Replace the last history line.
+ historyPos = history.length - 1;
+ history[historyPos] = line;
+
+ // Create an empty spot for the next line.
+ history.add('');
+ historyPos++;
+ }
+
Future run(List<String> args) {
throw 'should-not-execute-the-root-command';
}
« no previous file with comments | « no previous file | runtime/observatory/lib/src/elements/debugger.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698