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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/observatory/lib/src/cli/command.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library debugger_page_element; 5 library debugger_page_element;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:html'; 8 import 'dart:html';
9 import 'observatory_element.dart'; 9 import 'observatory_element.dart';
10 import 'package:observatory/cli.dart'; 10 import 'package:observatory/cli.dart';
(...skipping 789 matching lines...) Expand 10 before | Expand all | Expand 10 after
800 if (command == '' && lastCommand != null) { 800 if (command == '' && lastCommand != null) {
801 command = lastCommand; 801 command = lastCommand;
802 } 802 }
803 console.printBold('\$ $command'); 803 console.printBold('\$ $command');
804 return cmd.runCommand(command).then((_) { 804 return cmd.runCommand(command).then((_) {
805 lastCommand = command; 805 lastCommand = command;
806 }).catchError((e, s) { 806 }).catchError((e, s) {
807 console.print('ERROR $e\n$s'); 807 console.print('ERROR $e\n$s');
808 }); 808 });
809 } 809 }
810
811 String historyPrev(String command) {
812 return cmd.historyPrev(command);
813 }
814
815 String historyNext(String command) {
816 return cmd.historyNext(command);
817 }
810 } 818 }
811 819
812 @CustomTag('debugger-page') 820 @CustomTag('debugger-page')
813 class DebuggerPageElement extends ObservatoryElement { 821 class DebuggerPageElement extends ObservatoryElement {
814 @published Isolate isolate; 822 @published Isolate isolate;
815 823
816 isolateChanged(oldValue) { 824 isolateChanged(oldValue) {
817 if (isolate != null) { 825 if (isolate != null) {
818 debugger.isolate = isolate; 826 debugger.isolate = isolate;
819 } 827 }
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
1042 } 1050 }
1043 } 1051 }
1044 1052
1045 @CustomTag('debugger-input') 1053 @CustomTag('debugger-input')
1046 class DebuggerInputElement extends ObservatoryElement { 1054 class DebuggerInputElement extends ObservatoryElement {
1047 @published Isolate isolate; 1055 @published Isolate isolate;
1048 @published String text = ''; 1056 @published String text = '';
1049 @observable ObservatoryDebugger debugger; 1057 @observable ObservatoryDebugger debugger;
1050 @observable bool busy = false; 1058 @observable bool busy = false;
1051 1059
1052 void _notBusy() {
1053 busy = false;
1054 }
1055
1056 @override 1060 @override
1057 void ready() { 1061 void ready() {
1058 super.ready(); 1062 super.ready();
1059 var textBox = $['textBox']; 1063 var textBox = $['textBox'];
1060 textBox.select(); 1064 textBox.select();
1061 textBox.onKeyDown.listen((KeyboardEvent e) { 1065 textBox.onKeyDown.listen((KeyboardEvent e) {
1062 // TODO(turnidge): Ignore *all* key events while busy. 1066 if (busy) {
1067 e.preventDefault();
1068 return;
1069 }
1070 busy = true;
1063 switch (e.keyCode) { 1071 switch (e.keyCode) {
1064 case KeyCode.TAB: 1072 case KeyCode.TAB:
1065 e.preventDefault(); 1073 e.preventDefault();
1066 if (!busy) { 1074 int cursorPos = textBox.selectionStart;
1067 busy = true; 1075 debugger.complete(text.substring(0, cursorPos)).then((completion) {
1068 int cursorPos = textBox.selectionStart; 1076 text = completion + text.substring(cursorPos);
1069 debugger.complete(text.substring(0, cursorPos)).then((completion) { 1077 // TODO(turnidge): Move the cursor to the end of the
1070 text = completion + text.substring(cursorPos); 1078 // completion, rather than the end of the string.
1071 // TODO(turnidge): Move the cursor to the end of the 1079 }).whenComplete(() {
1072 // completion, rather than the end of the string. 1080 busy = false;
1073 }).whenComplete(_notBusy); 1081 });
1074 }
1075 break; 1082 break;
1083
1076 case KeyCode.ENTER: 1084 case KeyCode.ENTER:
1077 if (!busy) { 1085 var command = text;
1078 busy = true; 1086 debugger.run(command).whenComplete(() {
1079 var command = text;
1080 text = ''; 1087 text = '';
1081 debugger.run(command).whenComplete(_notBusy); 1088 busy = false;
1082 } 1089 });
1090 break;
1091
1092 case KeyCode.UP:
1093 e.preventDefault();
1094 text = debugger.historyPrev(text);
1095 busy = false;
1096 break;
1097
1098 case KeyCode.DOWN:
1099 e.preventDefault();
1100 text = debugger.historyNext(text);
1101 busy = false;
1102 break;
1103
1104 default:
1105 busy = false;
1083 break; 1106 break;
1084 } 1107 }
1085 }); 1108 });
1086 } 1109 }
1087 1110
1088 DebuggerInputElement.created() : super.created(); 1111 DebuggerInputElement.created() : super.created();
1089 } 1112 }
1090 1113
OLDNEW
« 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