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

Unified Diff: tools/ddbg_service/lib/commando.dart

Issue 575853002: Add tools/ddbg_service. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: gen js Created 6 years, 3 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 | « tools/ddbg_service/bin/ddbg_service.dart ('k') | tools/ddbg_service/lib/debugger.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/ddbg_service/lib/commando.dart
diff --git a/tools/ddbg/lib/commando.dart b/tools/ddbg_service/lib/commando.dart
similarity index 96%
copy from tools/ddbg/lib/commando.dart
copy to tools/ddbg_service/lib/commando.dart
index f3ff3ea5e888ad76006a5d047364375cf35f2113..f490cf8f836784ff921d649f1d6510037220c611 100644
--- a/tools/ddbg/lib/commando.dart
+++ b/tools/ddbg_service/lib/commando.dart
@@ -1,13 +1,15 @@
-// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+library commando;
+
import 'dart:async';
import 'dart:convert';
import 'dart:io';
import 'dart:math';
-import 'terminfo.dart';
+import 'package:ddbg/terminfo.dart';
typedef List<String> CommandCompleter(List<String> commandParts);
@@ -492,6 +494,17 @@ class Commando {
_cursorPos = _move(pos, newCursorPos);
_currentLine = newLine;
}
+
+ void print(String text) {
+ bool togglePrompt = _promptShown;
+ if (togglePrompt) {
+ hide();
+ }
+ _stdout.writeln(text);
+ if (togglePrompt) {
+ show();
+ }
+ }
void hide() {
if (!_promptShown) {
@@ -687,15 +700,23 @@ List<String> _myCompleter(List<String> commandTokens) {
int _helpCount = 0;
Commando cmdo;
+var cmdoSubscription;
void _handleCommand(String rawCommand) {
String command = rawCommand.trim();
cmdo.hide();
if (command == 'quit') {
- cmdo.close().then((_) {
- print('Exiting');
- });
+ var future = cmdoSubscription.cancel();
+ if (future != null) {
+ future.then((_) {
+ print('Exiting');
+ exit(0);
+ });
+ } else {
+ print('Exiting');
+ exit(0);
+ }
} else if (command == 'help') {
switch (_helpCount) {
case 0:
@@ -727,5 +748,5 @@ void _handleCommand(String rawCommand) {
void main() {
print('[Commando demo]');
cmdo = new Commando(completer:_myCompleter);
- cmdo.commands.listen(_handleCommand);
+ cmdoSubscription = cmdo.commands.listen(_handleCommand);
}
« no previous file with comments | « tools/ddbg_service/bin/ddbg_service.dart ('k') | tools/ddbg_service/lib/debugger.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698