Skip to content
This repository was archived by the owner on Jan 13, 2025. It is now read-only.

Commit 8ae6f90

Browse files
authored
add ansiSupported (#4)
* add ansiSupported * review comments
1 parent c5ecf6a commit 8ae6f90

File tree

5 files changed

+24
-3
lines changed

5 files changed

+24
-3
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
### 1.1.0
2+
3+
* Added `ansiSupported`
4+
* Bumped minimum Dart SDK version to 1.23.0-dev.9.0
5+
16
#### 1.0.2
27

38
* Minor doc updates

lib/src/interface/local_platform.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,7 @@ class LocalPlatform extends Platform {
4646

4747
@override
4848
String get version => io.Platform.version;
49+
50+
@override
51+
bool get ansiSupported => io.Platform.ansiSupported;
4952
}

lib/src/interface/platform.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,12 @@ abstract class Platform {
114114
/// whitespace and other version and build details.
115115
String get version;
116116

117+
/// When stdio is connected to a terminal, whether ANSI codes are supported.
118+
///
119+
/// This value is hard-coded to true, except on Windows where only more recent
120+
/// versions of Windows 10 support the codes.
121+
bool get ansiSupported;
122+
117123
/// Returns a JSON-encoded representation of this platform.
118124
String toJson() {
119125
return const JsonEncoder.withIndent(' ').convert(<String, dynamic>{
@@ -129,6 +135,7 @@ abstract class Platform {
129135
'packageRoot': packageRoot,
130136
'packageConfig': packageConfig,
131137
'version': version,
138+
'ansiSupported': ansiSupported,
132139
});
133140
}
134141
}

lib/src/testing/fake_platform.dart

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class FakePlatform extends Platform {
2525
this.packageRoot,
2626
this.packageConfig,
2727
this.version,
28+
this.ansiSupported,
2829
});
2930

3031
/// Creates a new [FakePlatform] with properties whose initial values mirror
@@ -41,7 +42,8 @@ class FakePlatform extends Platform {
4142
executableArguments = new List<String>.from(platform.executableArguments),
4243
packageRoot = platform.packageRoot,
4344
packageConfig = platform.packageConfig,
44-
version = platform.version;
45+
version = platform.version,
46+
ansiSupported = platform.ansiSupported;
4547

4648
/// Creates a new [FakePlatform] with properties extracted from the encoded
4749
/// JSON string.
@@ -63,6 +65,7 @@ class FakePlatform extends Platform {
6365
packageRoot : map['packageRoot'],
6466
packageConfig : map['packageConfig'],
6567
version : map['version'],
68+
ansiSupported: map['ansiSupported'],
6669
);
6770
}
6871

@@ -101,4 +104,7 @@ class FakePlatform extends Platform {
101104

102105
@override
103106
String version;
107+
108+
@override
109+
bool ansiSupported;
104110
}

pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: platform
2-
version: 1.0.2
2+
version: 1.1.0
33
authors:
44
- Todd Volkert <[email protected]>
55
description: A pluggable, mockable platform abstraction for Dart.
@@ -9,4 +9,4 @@ dev_dependencies:
99
test: ^0.12.10
1010

1111
environment:
12-
sdk: '>=1.19.0 <2.0.0'
12+
sdk: '>=1.23.0-dev.9.0 <2.0.0'

0 commit comments

Comments
 (0)