| Index: runtime/bin/stdio_patch.dart
|
| diff --git a/runtime/bin/stdio_patch.dart b/runtime/bin/stdio_patch.dart
|
| index d6d00776add9d41b60c632c09e011f43ba044fe1..d33fbc2123d23a8d5cde76abe967abc5423af367 100644
|
| --- a/runtime/bin/stdio_patch.dart
|
| +++ b/runtime/bin/stdio_patch.dart
|
| @@ -2,10 +2,8 @@
|
| // 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.
|
|
|
| -@patch
|
| -class _StdIOUtils {
|
| - @patch
|
| - static Stdin _getStdioInputStream() {
|
| +@patch class _StdIOUtils {
|
| + @patch static Stdin _getStdioInputStream() {
|
| switch (_getStdioHandleType(0)) {
|
| case _STDIO_HANDLE_TYPE_TERMINAL:
|
| case _STDIO_HANDLE_TYPE_PIPE:
|
| @@ -18,8 +16,7 @@ class _StdIOUtils {
|
| }
|
| }
|
|
|
| - @patch
|
| - static _getStdioOutputStream(int fd) {
|
| + @patch static _getStdioOutputStream(int fd) {
|
| assert(fd == 1 || fd == 2);
|
| switch (_getStdioHandleType(fd)) {
|
| case _STDIO_HANDLE_TYPE_TERMINAL:
|
| @@ -32,8 +29,7 @@ class _StdIOUtils {
|
| }
|
| }
|
|
|
| - @patch
|
| - static int _socketType(Socket socket) {
|
| + @patch static int _socketType(Socket socket) {
|
| if (socket is _Socket) return _nativeSocketType(socket._nativeSocket);
|
| return null;
|
| }
|
| @@ -41,19 +37,17 @@ class _StdIOUtils {
|
| static int _nativeSocketType(_NativeSocket nativeSocket) {
|
| var result = _getSocketType(nativeSocket);
|
| if (result is OSError) {
|
| - throw new FileSystemException("Error retrieving socket type", "", result);
|
| + throw new FileSystemException(
|
| + "Error retrieving socket type", "", result);
|
| }
|
| return result;
|
| }
|
|
|
| - @patch
|
| - static _getStdioHandleType(int fd) native "File_GetStdioHandleType";
|
| + @patch static _getStdioHandleType(int fd) native "File_GetStdioHandleType";
|
| }
|
|
|
| -@patch
|
| -class Stdin {
|
| - @patch
|
| - int readByteSync() {
|
| +@patch class Stdin {
|
| + @patch int readByteSync() {
|
| var result = _readByte();
|
| if (result is OSError) {
|
| throw new StdinException("Error reading byte from stdin", result);
|
| @@ -61,34 +55,28 @@ class Stdin {
|
| return result;
|
| }
|
|
|
| - @patch
|
| - bool get echoMode {
|
| + @patch bool get echoMode {
|
| var result = _echoMode();
|
| if (result is OSError) {
|
| throw new StdinException("Error getting terminal echo mode", result);
|
| }
|
| return result;
|
| }
|
| -
|
| - @patch
|
| - void set echoMode(bool enabled) {
|
| + @patch void set echoMode(bool enabled) {
|
| var result = _setEchoMode(enabled);
|
| if (result is OSError) {
|
| throw new StdinException("Error setting terminal echo mode", result);
|
| }
|
| }
|
|
|
| - @patch
|
| - bool get lineMode {
|
| + @patch bool get lineMode {
|
| var result = _lineMode();
|
| if (result is OSError) {
|
| throw new StdinException("Error getting terminal line mode", result);
|
| }
|
| return result;
|
| }
|
| -
|
| - @patch
|
| - void set lineMode(bool enabled) {
|
| + @patch void set lineMode(bool enabled) {
|
| var result = _setLineMode(enabled);
|
| if (result is OSError) {
|
| throw new StdinException("Error setting terminal line mode", result);
|
| @@ -111,10 +99,8 @@ class Stdin {
|
| static _supportsAnsiEscapes() native "Stdin_AnsiSupported";
|
| }
|
|
|
| -@patch
|
| -class Stdout {
|
| - @patch
|
| - bool _hasTerminal(int fd) {
|
| +@patch class Stdout {
|
| + @patch bool _hasTerminal(int fd) {
|
| try {
|
| _terminalSize(fd);
|
| return true;
|
| @@ -123,10 +109,8 @@ class Stdout {
|
| }
|
| }
|
|
|
| - @patch
|
| - int _terminalColumns(int fd) => _terminalSize(fd)[0];
|
| - @patch
|
| - int _terminalLines(int fd) => _terminalSize(fd)[1];
|
| + @patch int _terminalColumns(int fd) => _terminalSize(fd)[0];
|
| + @patch int _terminalLines(int fd) => _terminalSize(fd)[1];
|
|
|
| static List _terminalSize(int fd) {
|
| var size = _getTerminalSize(fd);
|
| @@ -149,5 +133,6 @@ class Stdout {
|
| static _getAnsiSupported(int fd) native "Stdout_AnsiSupported";
|
| }
|
|
|
| +
|
| _getStdioHandle(_NativeSocket socket, int num) native "Socket_GetStdioHandle";
|
| _getSocketType(_NativeSocket nativeSocket) native "Socket_GetType";
|
|
|