-
Notifications
You must be signed in to change notification settings - Fork 381
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
Make use of bat as a library #116
Comments
I will try to work on this in my spare time. Let's see what I can do :) |
Hi @MarcoIeni, that sounds great! |
Started with some clippy warnings fix. See #380 Anyway I think that the best strategy might be to keep the My first approach was to remove the So we will have both |
Yes, that all makes sense. I was aware that some things aren't exposed, and also that there are some delta-specific changes in
|
From what I understood this is the function that prints to output: Lines 438 to 442 in b149425
So here I should call the bat |
Hi @MarcoIeni, I'm worried that this ticket is misleading and/or that I've been slow to give input! Delta cannot use bat for syntax highlighting. The places where I think delta may be able to use bat are related to (a) handling of the sublime syntax and theme binary assets that the bat project extremely helpfully makes available, and (b) handling of the pager process that delta, just like bat, spawns to receive its output. So that is the code that is vendored under the The reason I say delta cannot use bat for syntax highlighting is this: the fundamental task that delta has to do when it is colorizing a diff hunk is
So of course, (2), (3), and (4) all has to be done at the level of data structures representing color-annotated strings; the similarity with bat here is that bat uses syntect, and delta also does at phase (2). |
The original ticket was not very detailed, but you are not slow to give input, in fact you are really fast :) Anyway it was a good opportunity to explore the both bat and delta source code :) Now it's clearer. I will try to extract the parts of code exposed by the bat library, even if I don't think they are a lot. |
This is the maximum I achieved to extract in a clean way: MarcoIeni@1b9c6e3 I am not doing a PR because it's too little. Somehow you can extract how the Line 18 in b149425
I think that the right thing to do here is to extract the common code from the bat project and create another library, that both bat and delta will use. What do you think? If you agree we can create an issue in the bat project. |
I think I'm not quite understanding - why create separate crates rather than just exposing public functions in the existing bat crate?
The binary assets in particular, along with associated code for interacting with them, do seem like a resource which could be valuable to multiple projects. Can/should a rust crate contain large amounts of data like that? Of course, everything bat exposes publicly is a source of future maintenance work for bat developers, and restricts their ability to make backwards incompatible changes. And delta's paging code has already diverged slightly so might not be easy to abstract. So there's a question about whether it is worth it, or whether it's fine for paging and binary asset interaction to be implemented independently (albeit from a common starting point) in delta. |
Because you separate concerns:
I think that bat already does it
We should identify common code and abstract only that part. Edit: Of course you have a better understanding on this project, so it's up to you to decide if there is enough common code among the two libraries that may be useful to some purpose, in order to extract it to another crate :) |
Thanks for that suggestion, I've just done that in master e527a69 |
We do this now. |
See https://github.com/sharkdp/bat/releases/tag/v0.13.0
Currently, delta vendors some bat code, e.g. related to paging and custom themes/syntax definitions.
The text was updated successfully, but these errors were encountered: