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

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

Issue 2753233002: [dart:io] Move Platform.ansiSupported to {Stdin,Stdout}.supportsAnsiEscapes (Closed)
Patch Set: Fix typo Created 3 years, 9 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
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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 * If enabled, characters are delayed until a new-line character is entered. 130 * If enabled, characters are delayed until a new-line character is entered.
131 * If disabled, characters will be available as typed. 131 * If disabled, characters will be available as typed.
132 * 132 *
133 * Default depends on the parent process, but usually enabled. 133 * Default depends on the parent process, but usually enabled.
134 * 134 *
135 * On Windows this mode can only be disabled if [echoMode] is disabled as well . 135 * On Windows this mode can only be disabled if [echoMode] is disabled as well .
136 */ 136 */
137 external void set lineMode(bool enabled); 137 external void set lineMode(bool enabled);
138 138
139 /** 139 /**
140 * Whether connected to a terminal that supports ANSI escape sequences.
141 *
142 * Not all terminals are recognized, and not all recognized terminals can
143 * report whether they support ANSI escape sequences, so this value is a
144 * best-effort attempt at detecting the support.
145 *
146 * The actual escape sequence support may differ between terminals,
147 * with some terminals supporting more escape sequences than others,
148 * and some terminals even differing in behavior for the same escape
149 * sequence.
150 *
151 * The ANSI color selection is generally supported.
152 *
153 * Currently, a `TERM` environment variable containing the string `xterm`
154 * will be taken as evidence that ANSI escape sequences are supported.
155 * On Windows, only versions of Windows 10 after v.1511
156 * ("TH2", OS build 10586) will be detected as supporting the output of
157 * ANSI escape sequences, and only versions after v.1607 ("Anniversery
158 * Update", OS build 14393) will be detected as supporting the input of
159 * ANSI escape sequences.
160 */
161 external bool get supportsAnsiEscapes;
162
163 /**
140 * Synchronously read a byte from stdin. This call will block until a byte is 164 * Synchronously read a byte from stdin. This call will block until a byte is
141 * available. 165 * available.
142 * 166 *
143 * If at end of file, -1 is returned. 167 * If at end of file, -1 is returned.
144 */ 168 */
145 external int readByteSync(); 169 external int readByteSync();
146 } 170 }
147 171
148 /** 172 /**
149 * [Stdout] represents the [IOSink] for either `stdout` or `stderr`. 173 * [Stdout] represents the [IOSink] for either `stdout` or `stderr`.
(...skipping 21 matching lines...) Expand all
171 bool get hasTerminal => _hasTerminal(_fd); 195 bool get hasTerminal => _hasTerminal(_fd);
172 196
173 /** 197 /**
174 * Get the number of columns of the terminal. 198 * Get the number of columns of the terminal.
175 * 199 *
176 * If no terminal is attached to stdout, a [StdoutException] is thrown. See 200 * If no terminal is attached to stdout, a [StdoutException] is thrown. See
177 * [hasTerminal] for more info. 201 * [hasTerminal] for more info.
178 */ 202 */
179 int get terminalColumns => _terminalColumns(_fd); 203 int get terminalColumns => _terminalColumns(_fd);
180 204
181 /** 205 /*
182 * Get the number of lines of the terminal. 206 * Get the number of lines of the terminal.
183 * 207 *
184 * If no terminal is attached to stdout, a [StdoutException] is thrown. See 208 * If no terminal is attached to stdout, a [StdoutException] is thrown. See
185 * [hasTerminal] for more info. 209 * [hasTerminal] for more info.
186 */ 210 */
187 int get terminalLines => _terminalLines(_fd); 211 int get terminalLines => _terminalLines(_fd);
188 212
213 /**
214 * Whether connected to a terminal that supports ANSI escape sequences.
215 *
216 * Not all terminals are recognized, and not all recognized terminals can
217 * report whether they support ANSI escape sequences, so this value is a
218 * best-effort attempt at detecting the support.
219 *
220 * The actual escape sequence support may differ between terminals,
221 * with some terminals supporting more escape sequences than others,
222 * and some terminals even differing in behavior for the same escape
223 * sequence.
224 *
225 * The ANSI color selection is generally supported.
226 *
227 * Currently, a `TERM` environment variable containing the string `xterm`
228 * will be taken as evidence that ANSI escape sequences are supported.
229 * On Windows, only versions of Windows 10 after v.1511
230 * ("TH2", OS build 10586) will be detected as supporting the output of
231 * ANSI escape sequences, and only versions after v.1607 ("Anniversery
232 * Update", OS build 14393) will be detected as supporting the input of
233 * ANSI escape sequences.
234 */
235 bool get supportsAnsiEscapes => _supportsAnsiEscapes(_fd);
236
189 external bool _hasTerminal(int fd); 237 external bool _hasTerminal(int fd);
190 external int _terminalColumns(int fd); 238 external int _terminalColumns(int fd);
191 external int _terminalLines(int fd); 239 external int _terminalLines(int fd);
240 external static bool _supportsAnsiEscapes(int fd);
192 241
193 /** 242 /**
194 * Get a non-blocking `IOSink`. 243 * Get a non-blocking `IOSink`.
195 */ 244 */
196 IOSink get nonBlocking { 245 IOSink get nonBlocking {
197 if (_nonBlocking == null) { 246 if (_nonBlocking == null) {
198 _nonBlocking = new IOSink(new _FileStreamConsumer.fromStdio(_fd)); 247 _nonBlocking = new IOSink(new _FileStreamConsumer.fromStdio(_fd));
199 } 248 }
200 return _nonBlocking; 249 return _nonBlocking;
201 } 250 }
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 } 449 }
401 450
402 class _StdIOUtils { 451 class _StdIOUtils {
403 external static _getStdioOutputStream(int fd); 452 external static _getStdioOutputStream(int fd);
404 external static Stdin _getStdioInputStream(); 453 external static Stdin _getStdioInputStream();
405 454
406 /// Returns the socket type or `null` if [socket] is not a builtin socket. 455 /// Returns the socket type or `null` if [socket] is not a builtin socket.
407 external static int _socketType(Socket socket); 456 external static int _socketType(Socket socket);
408 external static _getStdioHandleType(int fd); 457 external static _getStdioHandleType(int fd);
409 } 458 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698