-
Notifications
You must be signed in to change notification settings - Fork 63
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
migrate ansi mod from alacritty_terminal #64
Conversation
I'd love to see what this looks like integrated with Alacritty itself. I'm also wondering if it makes sense to move more of the functionality of Or do you already have a plan for this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd really like to see this work without std too, I don't think fundamentally there are a lot of things that require std just for the dispatch part.
Features like serde deserialization probably shouldn't be provided at all. I don't see how we can offer reasonable deserialization for the types of this crate. That said, types like Line
and Column
are probably better off as just raw numbers anyways. Since the complexity of handling another type here doesn't really have much of a benefit.
Yea, I'm just trying to imagine how the |
I believe all usages of
I think it makes sense for
|
That is correct, but I don't think it makes sense to have them as part of the handler trait since they are separate things. So it should probably be a separate trait.
I've considered removing
I agree, using types for this with no methods on these types just makes things confusing. Properly naming the parameters should be sufficient and easier to handle downstream. Then people can wrap it in their types anyways. |
I've experimented with a trait for this. It seems that the I've removed the std dependencies, although I note that we can't use |
With how traits work in Rust, that would probably mean that the handler wouldn't be able to do anything with its writer. If a trait is passed as parameter unconstrained without any methods, you can't do anything with it.
I don't think 1.38.0 would help, right? Since this is still using allocations like Strings and Vecs. |
Actually, I'm thinking of something like I'm getting bogged down dealing with the |
I do mind, yes. I don't think it makes sense to merge this unless there's a complete package that makes sense. Just copy-pasting stuff over isn't really beneficial. |
@nw0 FWIW, it's completely possible to make a new set of branches which you merge into this branch. I'm not necessarily saying you should do that, since those PRs would be on your own fork, but it may help you personally. I know I often need a branch to keep my head on straight. |
I've straightened things out and have the following design as pushed above:
The obvious questions:
As regards 1.36:
The issue is really that the trait that provides |
Updating to 1.38.0 is not a problem, but even if you update you won't be able to call join here. |
I'm not sure this is desirable. Will it cause dynamic dispatch here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be updated to the latest version of Alacritty's ansi.rs and vte.
Also please do not force-push this PR if possible; it's difficult to review changes if the entire file is just rewritten.
src/ansi.rs
Outdated
@@ -0,0 +1,1625 @@ | |||
//! ANSI Terminal Stream Parsing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name of this file, this documentation and the feature isn't really great. That just describes all of this library basically.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I'm not sure how you want to deal with this. To me, the obvious questions are:
- Should this be hidden behind a feature flag? (I think so)
- Should a module be exposed, or just the Processor, Handler, etc.? (I'm not sure. We aren't adding that much new functionality, are we?)
I've put in a slightly more descriptive docstring for now, but I think answering these sooner would be helpful.
src/ansi.rs
Outdated
type Line = usize; | ||
type Column = usize; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are these type aliases for?
src/ansi.rs
Outdated
#[cfg(feature = "no_std")] | ||
let colors = str::from_utf8(color).ok()?.split('/').collect::<ArrayVec<[_; 4]>>(); | ||
#[cfg(not(feature = "no_std"))] | ||
let colors = str::from_utf8(color).ok()?.split('/').collect::<Vec<_>>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like this function can be easily rewritten to not require any of this Vec/ArrayVec?
src/ansi.rs
Outdated
if params.len() >= 2 { | ||
#[cfg(feature = "no_std")] | ||
{ | ||
let mut title = ArrayString::<[_; crate::MAX_OSC_RAW]>::new(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not familiar with ArrayString, but we have ascii as input while ArrayString most likely handles unicode. That means that the size of MAX_OSC_RAW would not be enough to store the title.
Though I see no harm in just passing params downstream and letting them handle this. Then they can decide what they want to use, no need to try and convert this into a string for them when it's trivial to do for them, but difficult to do for us.
Not sure how to structure this yet. Will iterate.
Should I use merge commits to update to the latest vte? (I ask because I've generally worked with people who insist on rebases which does mean force-pushing) |
To update on top of VTE a rebase is usually easier, yes. That will keep the history consistent though, so I don't have to re-check everything. |
This is from alacritty/alacritty#1063.
I've naively moved everything over, and put
Line
,Column
,Rgb
in a new file,term.rs
. The new modules,ansi
andterm
, are behind a feature flagansi
, which doesn't work withno_std
(depends onstd::io
).As this is separate from the main crate, not filing a PR to remove from there yet.