-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
std::fmt
traits compatible version of PrettyPrinter::print
#956
Comments
Sounds good to me 👍
are you sure? 😄 I'm afraid that might be a bit more involved (especially the error handling part), but I could be wrong. |
It might not be the easiest first issue out there, but it's a great way to learn Rust "by fire", so to speak 😂. The way everything comes together in If you think we should remove the label because of how involved the process of integrating it would be, I wouldn't be against it though haha. |
I should note that I had to make similar changes to Specifically, I don't know what kind of windows support y'all have, but it could not be fixed in a backwards compatible way for athre0z/color-backtrace#27 for reference A quick look at your toml only shows ansi color code deps so this may be a non issue. |
To do color we enable ANSI support in the Windows terminal, so there shouldn't be any issues as far as side-effects go. The error handling might be a bit more complex, but capturing the output as a string (to write to the formatter) or supporting writing to arbitrary |
Hey there, I was trying to implement writing to a
To me, it looks like Thanks for your work on |
Is this issue open? Can I work on it? |
@hedonhermdev I for one am not working on it |
@yaahc If you are still interested in this, maybe you could answer the questions by @niklasmohrin? Otherwise, I'd like to close this. |
I'm not sure the exact best way to make this work within
You might be able to add an alternative to |
I took a look at this, and found a problem which leads to this being way harder than expected. Here's what I have written: fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
for (index, input) in self.inputs.into_iter().enumerate() {
let is_first = index == 0;
let result = if input.is_stdin() {
self.controller
.print_input(input, f, io::stdin().lock(), None, is_first)
} else {
// Use dummy stdin since stdin is actually not used (#1902)
self.controller
.print_input(input, f, io::empty(), None, is_first)
};
if let Err(error) = result {
return Err(fmt::Error);
}
}
Ok(())
} The call to
The
I think |
Thank you for working on this.
If we need to do a breaking change that's fine, we want to do that before v1.0.0 anyway. I'm removing |
very much needed feature 🙏 |
Stumbled upon this issue while trying to use Bat for syntax highlighting in Gex. Forgive me if this is naive, but I think that perhaps rather than implementing If this sounds reasonable I'd be happy to give a go working on an implementation. |
As far as I can tell bat as a library only supports writing to stdout, I'm interested in seeing if I can integrate
bat
withcolor-backtrace
/color-spantrace
andeyre
. To do this I need bat to write to astd::fmt::Formatter
and return afmt::Result
instead of printing tostdout
(i assume?) and returning abat::error::Error
.So assuming I'm not misreading the docs...
Proposal
Implement the
Display
trait forPrettyPrinter
where<PrettyPrinter as fmt::Display>::fmt
acts as an alternative toPrettyPrinter::print
.The text was updated successfully, but these errors were encountered: