| Index: sdk/lib/io/stdio.dart
|
| diff --git a/sdk/lib/io/stdio.dart b/sdk/lib/io/stdio.dart
|
| index 9888d9516887274093a83634259ef1b50f627802..e4bdf01ff05c7bb0b6d68ba8c53d1a743d319d0c 100644
|
| --- a/sdk/lib/io/stdio.dart
|
| +++ b/sdk/lib/io/stdio.dart
|
| @@ -149,29 +149,17 @@ class Stdin extends _StdStream implements Stream<List<int>> {
|
|
|
|
|
| /**
|
| - * [Stdout] represents the [IOSink] for either `stdout` or `stderr`.
|
| + * [Stdout] exposes methods to query the terminal for properties.
|
| *
|
| - * It provides a *blocking* `IOSink`, so using this to write will block until
|
| - * the output is written.
|
| - *
|
| - * In some situations this blocking behavior is undesirable as it does not
|
| - * provide the same non-blocking behavior as dart:io in general exposes.
|
| - * Use the property [nonBlocking] to get an `IOSink` which has the non-blocking
|
| - * behavior.
|
| - *
|
| - * This class can also be used to check whether `stdout` or `stderr` is
|
| - * connected to a terminal and query some terminal properties.
|
| + * Use [hasTerminal] to test if there is a terminal associated to stdout.
|
| */
|
| class Stdout extends _StdSink implements IOSink {
|
| - final int _fd;
|
| - IOSink _nonBlocking;
|
| -
|
| - Stdout._(IOSink sink, this._fd) : super(sink);
|
| + Stdout._(IOSink sink) : super(sink);
|
|
|
| /**
|
| * Returns true if there is a terminal attached to stdout.
|
| */
|
| - bool get hasTerminal => _hasTerminal(_fd);
|
| + external bool get hasTerminal;
|
|
|
| /**
|
| * Get the number of columns of the terminal.
|
| @@ -179,7 +167,7 @@ class Stdout extends _StdSink implements IOSink {
|
| * If no terminal is attached to stdout, a [StdoutException] is thrown. See
|
| * [hasTerminal] for more info.
|
| */
|
| - int get terminalColumns => _terminalColumns(_fd);
|
| + external int get terminalColumns;
|
|
|
| /**
|
| * Get the number of lines of the terminal.
|
| @@ -187,21 +175,7 @@ class Stdout extends _StdSink implements IOSink {
|
| * If no terminal is attached to stdout, a [StdoutException] is thrown. See
|
| * [hasTerminal] for more info.
|
| */
|
| - int get terminalLines => _terminalLines(_fd);
|
| -
|
| - external bool _hasTerminal(int fd);
|
| - external int _terminalColumns(int fd);
|
| - external int _terminalLines(int fd);
|
| -
|
| - /**
|
| - * Get a non-blocking `IOSink`.
|
| - */
|
| - IOSink get nonBlocking {
|
| - if (_nonBlocking == null) {
|
| - _nonBlocking = new IOSink(new _FileStreamConsumer.fromStdio(_fd));
|
| - }
|
| - return _nonBlocking;
|
| - }
|
| + external int get terminalLines;
|
| }
|
|
|
|
|
| @@ -216,34 +190,6 @@ class StdoutException implements IOException {
|
| }
|
| }
|
|
|
| -class _StdConsumer implements StreamConsumer<List<int>> {
|
| - final _file;
|
| -
|
| - _StdConsumer(int fd) : _file = _File._openStdioSync(fd);
|
| -
|
| - Future addStream(Stream<List<int>> stream) {
|
| - var completer = new Completer();
|
| - var sub;
|
| - sub = stream.listen(
|
| - (data) {
|
| - try {
|
| - _file.writeFromSync(data);
|
| - } catch (e, s) {
|
| - sub.cancel();
|
| - completer.completeError(e, s);
|
| - }
|
| - },
|
| - onError: completer.completeError,
|
| - onDone: completer.complete,
|
| - cancelOnError: true);
|
| - return completer.future;
|
| - }
|
| -
|
| - Future close() {
|
| - _file.closeSync();
|
| - return new Future.value();
|
| - }
|
| -}
|
|
|
| class _StdSink implements IOSink {
|
| final IOSink _sink;
|
| @@ -281,7 +227,7 @@ class StdioType {
|
|
|
| Stdin _stdin;
|
| Stdout _stdout;
|
| -Stdout _stderr;
|
| +IOSink _stderr;
|
|
|
|
|
| /// The standard input stream of data read by this program.
|
| @@ -303,7 +249,7 @@ Stdout get stdout {
|
|
|
|
|
| /// The standard output stream of errors written by this program.
|
| -Stdout get stderr {
|
| +IOSink get stderr {
|
| if (_stderr == null) {
|
| _stderr = _StdIOUtils._getStdioOutputStream(2);
|
| }
|
|
|