Comments (8)
Not currently but I'd like to provide this functionality eventually. However, I don't want to just "not color". Instead, I'd like to provide a tiered API where the user can construct a low level terminal directly if they need fine control or a higher level "colored output" object if they just want "smart coloring".
from term.
This is a blocker for some of my things. I would really like to have the option "Either term::stderr() or std::io::stderr() if the former fails" - even if this means without color - no problem for me!
from term.
You can do what rust and cargo do for now.
On February 24, 2016 8:34:54 AM EST, Matthias Beyer [email protected] wrote:
This is a blocker for some of my things. I would really like to have
the option "Either term::stderr() or std::io::stderr() if the former
fails" - even if this means without color - no problem for me!
Reply to this email directly or view it on GitHub:
#57 (comment)
Steven Allen
from term.
What do they do?
from term.
They have enums that abstract over Stdout and a Terminal. That is, something like:
enum Output {
Terminal(StdoutTerminal),
Stdout(Stdout),
}
impl Output {
fn new() -> Output {
if let Ok(term) = term::stdout() {
if term.supports_color() {
return Output::Terminal(term);
}
}
return Output::Stdout(std::io::stdout());
}
fn print_error(&mut self, msg: &str) -> io::Result<()> {
match *self {
Terminal(ref term) => { /* ... */ },
Stdout(ref out) => { /* ... */ },
}
}
}
This is obviously not a very good solution (which is why I'm leaving this issue open).
from term.
Any progress here?
Edit: I ask because I need support for this in https://github.com/matthiasbeyer/imag/pull/212 and https://github.com/matthiasbeyer/imag/pull/213
from term.
Sorry, I'm kind of swamped with school work at the moment (trying to finish a masters thesis) and doing this right is non-trivial. Basically, I've been re-writing term to,
- Have a global interface (configured globally) like
std::io
's stdout. No more passing around aTerminal
object. IMO, this is almost always what users want. - Never color the wrong text. This is currently a big problem on Windows and a lesser problem on unix.
- Reduce the number of places where things can go wrong. Currently, we can know that something won't work up-front but don't report this to the user till they try to use the feature.
- Proper, reliable buffering. Line, full (print on flush), and no buffering.
- Pluggable and configurable. Users need to be able to drop in their own terminal endpoints. This is especially useful for testing.
- Just do the right thing. (this is the feature you're looking for).
Unfortunately, it took me a while to realize that a global interface was the right one so I still have quite a bit of work to do.
from term.
Sorry, I'm kind of swamped with school work at the moment (trying to finish a masters thesis)
Hey, no problem! 😄 I can fully understand that, I'm working on my bachelors thesis at the moment.
Have a global interface [...] IMO, this is almost always what users want.
Sounds good, yes. The other points sound good as well.
I just wanted to ping you whether you are still working on this or whether this is abandoned. Awesome to hear/read that you want progress as well! Thank you a lot! I didn't want to annoy or push you, just a simple "anyone alive here"-ping 👍
from term.
Related Issues (20)
- Please relase a new version HOT 3
- Support parsing termcap HOT 11
- Check isatty == false before coloring HOT 11
- tag version v0.4.0? HOT 2
- Better MSYS2 support HOT 14
- WinConsole's tty check is inaccurate HOT 1
- All Terminal methods leak memory on Windows HOT 7
- better support for multithreaded programs HOT 9
- Use `el` not `dl` to erase a line?
- How to store and pass around `Terminal` of any type. HOT 3
- `Terminal` should probably buffer
- panic with operation not supported by the terminal while libterm works fine HOT 3
- Term crashes on FreeBSD HOT 7
- No output to stdout when no TTY attached in Docker container HOT 2
- term::stdout() returns None unexpectedly HOT 3
- terminfo problem while using rogcat HOT 2
- Write plain text when running under a start/stop daemon like systemd ?
- [LFM] Looking For Maintainer HOT 11
- Last release was in February 2018 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from term.