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

Side by Side Diff: sdk/lib/io/stdio.dart

Issue 19627004: Add echo and line modes to Stdin. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add missing files. Created 7 years, 5 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
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 part of dart.io; 5 part of dart.io;
6 6
7 const int _STDIO_HANDLE_TYPE_TERMINAL = 0; 7 const int _STDIO_HANDLE_TYPE_TERMINAL = 0;
8 const int _STDIO_HANDLE_TYPE_PIPE = 1; 8 const int _STDIO_HANDLE_TYPE_PIPE = 1;
9 const int _STDIO_HANDLE_TYPE_FILE = 2; 9 const int _STDIO_HANDLE_TYPE_FILE = 2;
10 const int _STDIO_HANDLE_TYPE_SOCKET = 3; 10 const int _STDIO_HANDLE_TYPE_SOCKET = 3;
(...skipping 24 matching lines...) Expand all
35 Function close; 35 Function close;
36 _StdinEventSink(this.add, this.addError, this.close); 36 _StdinEventSink(this.add, this.addError, this.close);
37 } 37 }
38 38
39 /** 39 /**
40 * [Stdin] allows both synchronous and asynchronous reads from the standard 40 * [Stdin] allows both synchronous and asynchronous reads from the standard
41 * input stream. 41 * input stream.
42 * 42 *
43 * Mixing synchronous and asynchronous reads is undefined. 43 * Mixing synchronous and asynchronous reads is undefined.
44 */ 44 */
45 class Stdin extends _StdStream { 45 class Stdin extends _StdStream implements Stream<List<int>> {
46 Stdin._(Stream<List<int>> stream) : super(stream); 46 Stdin._(Stream<List<int>> stream) : super(stream);
47 47
48 /** 48 /**
49 * Synchronously read a line from stdin. This call will block until a full 49 * Synchronously read a line from stdin. This call will block until a full
50 * line is available. The line will contain the newline character(s). 50 * line is available. The line will contain the newline character(s).
51 * 51 *
52 * If end-of-file is reached, `null` is returned. 52 * If end-of-file is reached, `null` is returned.
53 * 53 *
54 * If end-of-file is reached after some data has already been read, that data 54 * If end-of-file is reached after some data has already been read, that data
55 * is returned. 55 * is returned.
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 decoder.handleDone(sink); 91 decoder.handleDone(sink);
92 break; 92 break;
93 } 93 }
94 } 94 }
95 95
96 if (empty) return null; 96 if (empty) return null;
97 return line.toString(); 97 return line.toString();
98 } 98 }
99 99
100 /** 100 /**
101 * Enable or disable echo mode on the [Stdin].
102 *
103 * If disabled, input from to console will not be echoed.
104 *
105 * Default depends on the parent process, but usually enabled.
106 */
107 external void set echoMode(bool enabled);
108
109 /**
110 * Enable or disable line mode on the [Stdin].
111 *
112 * If enabled, characters are delayed until a new-line character is entered.
113 * If disabled, characters will be available as typed.
114 *
115 * Default depends on the parent process, but usually enabled.
116 */
117 external void set lineMOde(bool enabled);
118
119 /**
101 * Synchronously read a byte from stdin. This call will block until a byte is 120 * Synchronously read a byte from stdin. This call will block until a byte is
102 * available. 121 * available.
103 * 122 *
104 * If at end of file, -1 is returned. 123 * If at end of file, -1 is returned.
105 */ 124 */
106 external int readByteSync(); 125 external int readByteSync();
107 } 126 }
108 127
109 128
110 class _StdSink implements IOSink { 129 class _StdSink implements IOSink {
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 } 213 }
195 return StdioType.OTHER; 214 return StdioType.OTHER;
196 } 215 }
197 216
198 217
199 class _StdIOUtils { 218 class _StdIOUtils {
200 external static IOSink _getStdioOutputStream(int fd); 219 external static IOSink _getStdioOutputStream(int fd);
201 external static Stdin _getStdioInputStream(); 220 external static Stdin _getStdioInputStream();
202 external static int _socketType(nativeSocket); 221 external static int _socketType(nativeSocket);
203 } 222 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698