| OLD | NEW |
| 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 10 matching lines...) Expand all Loading... |
| 21 | 21 |
| 22 String get helpShort; | 22 String get helpShort; |
| 23 String get helpLong; | 23 String get helpLong; |
| 24 } | 24 } |
| 25 | 25 |
| 26 // TODO(turnidge): Rewrite HelpCommand so that it is a general utility | 26 // TODO(turnidge): Rewrite HelpCommand so that it is a general utility |
| 27 // provided by the cli library. | 27 // provided by the cli library. |
| 28 class HelpCommand extends DebuggerCommand { | 28 class HelpCommand extends DebuggerCommand { |
| 29 HelpCommand(Debugger debugger) : super(debugger, 'help', []); | 29 HelpCommand(Debugger debugger) : super(debugger, 'help', []); |
| 30 | 30 |
| 31 String _nameAndAlias(Command cmd) { |
| 32 if (cmd.alias == null) { |
| 33 return cmd.name; |
| 34 } else { |
| 35 return '${cmd.name}, ${cmd.alias}'; |
| 36 } |
| 37 } |
| 38 |
| 31 Future run(List<String> args) { | 39 Future run(List<String> args) { |
| 32 var con = debugger.console; | 40 var con = debugger.console; |
| 33 if (args.length == 0) { | 41 if (args.length == 0) { |
| 34 // Print list of all top-level commands. | 42 // Print list of all top-level commands. |
| 35 var commands = debugger.cmd.matchCommand([], false); | 43 var commands = debugger.cmd.matchCommand([], false); |
| 36 commands.sort((a, b) => a.name.compareTo(b.name)); | 44 commands.sort((a, b) => a.name.compareTo(b.name)); |
| 37 con.print('List of commands:\n'); | 45 con.print('List of commands:\n'); |
| 38 for (var command in commands) { | 46 for (var command in commands) { |
| 39 con.print('${command.name.padRight(12)} - ${command.helpShort}'); | 47 con.print('${_nameAndAlias(command).padRight(12)} ' |
| 48 '- ${command.helpShort}'); |
| 40 } | 49 } |
| 41 con.print( | 50 con.print( |
| 42 "\nFor more information on a specific command type 'help <command>'\n" | 51 "\nFor more information on a specific command type 'help <command>'\n" |
| 43 "\n" | 52 "\n" |
| 44 "Command prefixes are accepted (e.g. 'h' for 'help')\n" | 53 "Command prefixes are accepted (e.g. 'h' for 'help')\n" |
| 45 "Hit [TAB] to complete a command (try 'i[TAB][TAB]')\n" | 54 "Hit [TAB] to complete a command (try 'i[TAB][TAB]')\n" |
| 46 "Hit [ENTER] to repeat the last command\n"); | 55 "Hit [ENTER] to repeat the last command\n" |
| 56 "Use up/down arrow for command history\n"); |
| 47 return new Future.value(null); | 57 return new Future.value(null); |
| 48 } else { | 58 } else { |
| 49 // Print any matching commands. | 59 // Print any matching commands. |
| 50 var commands = debugger.cmd.matchCommand(args, true); | 60 var commands = debugger.cmd.matchCommand(args, true); |
| 51 commands.sort((a, b) => a.name.compareTo(b.name)); | 61 commands.sort((a, b) => a.name.compareTo(b.name)); |
| 52 if (commands.isEmpty) { | 62 if (commands.isEmpty) { |
| 53 var line = args.join(' '); | 63 var line = args.join(' '); |
| 54 con.print("No command matches '${line}'"); | 64 con.print("No command matches '${line}'"); |
| 55 return new Future.value(null); | 65 return new Future.value(null); |
| 56 } | 66 } |
| 57 con.print(''); | 67 con.print(''); |
| 58 for (var command in commands) { | 68 for (var command in commands) { |
| 59 con.printBold(command.fullName); | 69 con.printBold(_nameAndAlias(command)); |
| 60 con.print(command.helpLong); | 70 con.print(command.helpLong); |
| 61 | 71 |
| 62 var newArgs = []; | 72 var newArgs = []; |
| 63 newArgs.addAll(args.take(args.length - 1)); | 73 newArgs.addAll(args.take(args.length - 1)); |
| 64 newArgs.add(command.name); | 74 newArgs.add(command.name); |
| 65 newArgs.add(''); | 75 newArgs.add(''); |
| 66 var subCommands = debugger.cmd.matchCommand(newArgs, false); | 76 var subCommands = debugger.cmd.matchCommand(newArgs, false); |
| 67 subCommands.remove(command); | 77 subCommands.remove(command); |
| 68 if (subCommands.isNotEmpty) { | 78 if (subCommands.isNotEmpty) { |
| 69 subCommands.sort((a, b) => a.name.compareTo(b.name)); | 79 subCommands.sort((a, b) => a.name.compareTo(b.name)); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 | 118 |
| 109 String helpShort = 'Pause the isolate'; | 119 String helpShort = 'Pause the isolate'; |
| 110 | 120 |
| 111 String helpLong = | 121 String helpLong = |
| 112 'Pause the isolate.\n' | 122 'Pause the isolate.\n' |
| 113 '\n' | 123 '\n' |
| 114 'Syntax: pause\n'; | 124 'Syntax: pause\n'; |
| 115 } | 125 } |
| 116 | 126 |
| 117 class ContinueCommand extends DebuggerCommand { | 127 class ContinueCommand extends DebuggerCommand { |
| 118 ContinueCommand(Debugger debugger) : super(debugger, 'continue', []); | 128 ContinueCommand(Debugger debugger) : super(debugger, 'continue', []) { |
| 129 alias = 'c'; |
| 130 } |
| 119 | 131 |
| 120 Future run(List<String> args) { | 132 Future run(List<String> args) { |
| 121 if (debugger.isolatePaused()) { | 133 if (debugger.isolatePaused()) { |
| 122 return debugger.isolate.resume().then((_) { | 134 return debugger.isolate.resume().then((_) { |
| 123 debugger.warnOutOfDate(); | 135 debugger.warnOutOfDate(); |
| 124 }); | 136 }); |
| 125 } else { | 137 } else { |
| 126 debugger.console.print('The program must be paused'); | 138 debugger.console.print('The program must be paused'); |
| 127 return new Future.value(null); | 139 return new Future.value(null); |
| 128 } | 140 } |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 return new Future.value(null); | 195 return new Future.value(null); |
| 184 } | 196 } |
| 185 return debugger.isolate.stepInto(); | 197 return debugger.isolate.stepInto(); |
| 186 } else { | 198 } else { |
| 187 debugger.console.print('The program is already running'); | 199 debugger.console.print('The program is already running'); |
| 188 return new Future.value(null); | 200 return new Future.value(null); |
| 189 } | 201 } |
| 190 } | 202 } |
| 191 | 203 |
| 192 String helpShort = | 204 String helpShort = |
| 193 'Continue running the isolate until it reaches the next source location'; | 205 'Continue running the isolate until it reaches the next source location'; |
| 194 | 206 |
| 195 String helpLong = | 207 String helpLong = |
| 196 'Continue running the isolate until it reaches the next source ' | 208 'Continue running the isolate until it reaches the next source ' |
| 197 'location.\n' | 209 'location.\n' |
| 198 '\n' | 210 '\n' |
| 199 'Syntax: step\n'; | 211 'Syntax: step\n'; |
| 200 } | 212 } |
| 201 | 213 |
| 202 class FinishCommand extends DebuggerCommand { | 214 class FinishCommand extends DebuggerCommand { |
| 203 FinishCommand(Debugger debugger) : super(debugger, 'finish', []); | 215 FinishCommand(Debugger debugger) : super(debugger, 'finish', []); |
| (...skipping 827 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1031 span.appendText('\n'); | 1043 span.appendText('\n'); |
| 1032 } | 1044 } |
| 1033 $['consoleText'].children.add(span); | 1045 $['consoleText'].children.add(span); |
| 1034 span.scrollIntoView(); | 1046 span.scrollIntoView(); |
| 1035 } | 1047 } |
| 1036 | 1048 |
| 1037 void printBold(String line, { bool newline:true }) { | 1049 void printBold(String line, { bool newline:true }) { |
| 1038 var span = new SpanElement(); | 1050 var span = new SpanElement(); |
| 1039 span.classes.add('bold'); | 1051 span.classes.add('bold'); |
| 1040 span.appendText(line); | 1052 span.appendText(line); |
| 1041 span.appendText('\n'); | 1053 if (newline) { |
| 1054 span.appendText('\n'); |
| 1055 } |
| 1042 $['consoleText'].children.add(span); | 1056 $['consoleText'].children.add(span); |
| 1043 span.scrollIntoView(); | 1057 span.scrollIntoView(); |
| 1044 } | 1058 } |
| 1045 | 1059 |
| 1046 void newline() { | 1060 void newline() { |
| 1047 var br = new BRElement(); | 1061 var br = new BRElement(); |
| 1048 $['consoleText'].children.add(br); | 1062 $['consoleText'].children.add(br); |
| 1049 br.scrollIntoView(); | 1063 br.scrollIntoView(); |
| 1050 } | 1064 } |
| 1051 } | 1065 } |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1104 default: | 1118 default: |
| 1105 busy = false; | 1119 busy = false; |
| 1106 break; | 1120 break; |
| 1107 } | 1121 } |
| 1108 }); | 1122 }); |
| 1109 } | 1123 } |
| 1110 | 1124 |
| 1111 DebuggerInputElement.created() : super.created(); | 1125 DebuggerInputElement.created() : super.created(); |
| 1112 } | 1126 } |
| 1113 | 1127 |
| OLD | NEW |