google / ansicolor-dart Goto Github PK
View Code? Open in Web Editor NEWLicense: Apache License 2.0
License: Apache License 2.0
so I don't always have to call toString()
on things before passing them to AnsiPen.write/call.
https://www.dartlang.org/articles/style-guide/#prefer-using-lowercamelcase-for-constant-names
color_disabled
is the biggest offender since it's not a constant, the others are a recent change to the style guide, which I'm not sure the entire dart community is aware of or in agreement with (but I personally am).
Please publish a stable NNBD release~
IMO it would be better suited as a script than a function in the main library:
pub global activate ansicolor
pub global run ansicolor:demo
Currently when you try to nest styles it doesn't work because when a pen is done writing it resets all styles, not just its own. Here's one take on an API to do this:
i.e. style guide updates, and then eventually bump to 1.0.0 stable?
(Happy to help out here)
Small error, but perhaps could cause a great amount of bewildering for beginners:
In the example with a background as a peach, foreground as white, rgb(r: 1.0, g: 0.8, b: 0.2)
should be rgb(r: 1.0, g: 0.8, b: 0.2, bg = true)
, otherwise it will be recognized as a foreground color.
Hi, I try to print with color in vs code and I only get a normal print color.
AnsiPen printRed = new AnsiPen()..red(bold: true);
print(printRed("Bright white foreground") + " this text is default fg/bg");
Output: flutter: ^[[38;5;9mBright white foreground^[[0m this text is default f<…>
We have basic ansi support: https://github.com/dart-lang/io/blob/master/lib/src/ansi_code.dart
Would be interesting to combine efforts and reduce duplication?
color_disabled
is global state, and since ansi color is kind of a cross-cutting concern, two different parts of an application could easily mess up each other's state. I think the best way to handle this would be to provide a means to run code in a Zone
which exposes a Zone local colorDisabled
value, which each ansi pen can read from.
I have a mechanism for this in the clock package:
https://github.com/seaneagan/clock/blob/master/lib/src/zoned_value.dart
Which I use for the withClock
method seen here:
I got some logs like these on iOS:
flutter: ^[[38;5;246mI/17:21:00
flutter: ^[[38;5;246mI/17:21:00
flutter: ^[[38;5;246mI/17:21:00
flutter: ^[[38;5;246mI/17:21:00
flutter: ^[[38;5;246mI/17:21:00
flutter: ^[[38;5;246mI/17:21:00
flutter doctor:
[✓] Flutter (Channel stable, 2.0.4, on Mac OS X 10.15.5 19F101 darwin-x64, locale en-AS)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
[✓] Xcode - develop for iOS and macOS
[✓] Android Studio (version 4.1)
[✓] IntelliJ IDEA Ultimate Edition (version 2020.3.1)
[✓] VS Code (version 1.55.2)
[✓] Proxy Configuration
[✓] Connected device (1 available)
flutter devices: (iphone 6p)
Phone (mobile) • b6a915834fadb0f*********accbe869c39966e9f • ios • iOS 12.5.1
How can I solve this problem?
I was using version 1.0.2, then I updated to version 1.1.1 and it stopped working (i.e. the letters are not colored).
-Reverted this project back to version 1.0.2, run a flutter clean
, run project - not working.
-Created a new flutter project with only this package (v 1.1.1) - doesn't work.
-Installed other alternative ansi styling packages - they also not working now
-Opened my another project that was using version 1.0.2 - working ok.
here is my flutter doctor:
[✓] Flutter (Channel stable, 1.22.5, on macOS 11.1 20C69 darwin-x64, locale en)
• Flutter version 1.22.5 at /Users/tema/programs/flutter
• Framework revision 7891006299 (5 weeks ago), 2020-12-10 11:54:40 -0800
• Engine revision ae90085a84
• Dart version 2.10.4
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
• Android SDK at /Users/tema/Library/Android/sdk
• Platform android-30, build-tools 30.0.3
• ANDROID_HOME = /Users/tema/Library/Android/sdk
• Java binary at: /Applications/Android
Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build
1.8.0_242-release-1644-b3-6915495)
• All Android licenses accepted.
[✗] Xcode - develop for iOS and macOS
✗ Xcode installation is incomplete; a full installation is necessary for iOS
development.
Download at: https://developer.apple.com/xcode/download/
Or install Xcode via the App Store.
Once installed, run:
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
sudo xcodebuild -runFirstLaunch
✗ CocoaPods not installed.
CocoaPods is used to retrieve the iOS and macOS platform side's plugin
code that responds to your plugin usage on the Dart side.
Without CocoaPods, plugins will not work on iOS or macOS.
For more info, see https://flutter.dev/platform-plugins
To install:
sudo gem install cocoapods
[!] Android Studio (version 4.1)
• Android Studio at /Applications/Android Studio.app/Contents
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
• Java version OpenJDK Runtime Environment (build
1.8.0_242-release-1644-b3-6915495)
[✓] VS Code (version 1.52.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.18.1
[✓] Connected device (1 available)
• Redmi Go (mobile) • 192.168.88.230:5555 • android-arm • Android 8.1.0 (API
27)
I created a package to detect color support:
https://github.com/seaneagan/supports_color
If #4 were fixed using Zones as suggested, then you just initialize the "color disabled" value in the root Zone to the value from the supports_color
package, and if folks want to override it, they just use the API provided by #4 to do so.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.