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

Unified Diff: sdk/lib/io/stdio.dart

Issue 102123010: Add getter for hasTerminal, terminalColumns and terminalLines on stdout. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add include of thread.h and fix io_patch. Created 7 years 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 | « sdk/lib/_internal/lib/io_patch.dart ('k') | tests/standalone/io/stdin_sync_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/io/stdio.dart
diff --git a/sdk/lib/io/stdio.dart b/sdk/lib/io/stdio.dart
index ab2f03a2dcdd191f8b035ad409e43cba21d574b6..ea0a382565c7bbc179ffd5f512e8bbd607a86f80 100644
--- a/sdk/lib/io/stdio.dart
+++ b/sdk/lib/io/stdio.dart
@@ -159,6 +159,49 @@ class Stdin extends _StdStream implements Stream<List<int>> {
}
+/**
+ * [Stdout] exposes methods to query the terminal for properties.
+ *
+ * Use [hasTerminal] to test if there is a terminal associated to stdout.
+ */
+class Stdout extends _StdSink implements IOSink {
+ Stdout._(IOSink sink) : super(sink);
+
+ /**
+ * Returns true if there is a terminal attached to stdout.
+ */
+ external bool get hasTerminal;
+
+ /**
+ * Get the number of columns of the terminal.
+ *
+ * If no terminal is attached to stdout, a [StdoutException] is thrown. See
+ * [hasTerminal] for more info.
+ */
+ external int get terminalColumns;
+
+ /**
+ * Get the number of lines of the terminal.
+ *
+ * If no terminal is attached to stdout, a [StdoutException] is thrown. See
+ * [hasTerminal] for more info.
+ */
+ external int get terminalLines;
+}
+
+
+class StdoutException implements IOException {
+ final String message;
+ final OSError osError;
+
+ const StdoutException(this.message, [this.osError]);
+
+ String toString() {
+ return "StdoutException: $message${osError == null ? "" : ", $osError"}";
+ }
+}
+
+
class _StdSink implements IOSink {
final IOSink _sink;
@@ -194,7 +237,7 @@ class StdioType {
Stdin _stdin;
-IOSink _stdout;
+Stdout _stdout;
IOSink _stderr;
@@ -208,7 +251,7 @@ Stdin get stdin {
/// The standard output stream of data written by this program.
-IOSink get stdout {
+Stdout get stdout {
if (_stdout == null) {
_stdout = _StdIOUtils._getStdioOutputStream(1);
}
@@ -257,7 +300,7 @@ StdioType stdioType(object) {
class _StdIOUtils {
- external static IOSink _getStdioOutputStream(int fd);
+ external static _getStdioOutputStream(int fd);
external static Stdin _getStdioInputStream();
external static int _socketType(nativeSocket);
}
« no previous file with comments | « sdk/lib/_internal/lib/io_patch.dart ('k') | tests/standalone/io/stdin_sync_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698