-
Notifications
You must be signed in to change notification settings - Fork 618
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
support delta along with ANSI support #1140
Conversation
Hi hasufell, thank you for catching. I'll fix those. ps |
@ulwlu hi, here to respond to your call for tests at #542 (comment) . Your branch compiles and works for me (Arch Linux / Kitty 0.23.1, ncurses 6.2, delta 0.8.3) 🙂. In addition to the weird line highlight already reported, I was surprised to see delta-within-tig uses a gray background. I'm not sure why, as pure delta outside of tig uses a black background. My Screencast below (pure delta at the beginning from 0:00 to 0:07, delta-in-tig afterwards): delta-in-tig-screencast-ronjouch.mp4 |
@ronjouch Hi, thank you for catching and details. I'm still not sure if this is caused by coloring problem, but I'm thinking delta gave some background color info with '--trur-color =never' that is not close to real true-color. I'll check it anyway. Thank you very much |
Much obliged; thank you for the work on this!
@ulwlu I did a bit more monkeying around with my Kitty color config. The problem doesn't appear by default. But with my Kitty color config (pasted below), it does.
|
Another details. Have you tried side-by-side mode? It seems to work but only until 80 chars. So, I was thinking to use I've also observed a weird highlighting, gray background. I am using konsole. |
Also noticed that when there are many files and you press enter to the filename (in the commit header), it doesn't jump to beginning of the file in the diff. Instead I received this error:
|
Hi. I've successfully fixed those, but I've come up with a better design. So I've decided to refactor it, which should take about a week. Tig can't accept formatter options. I can fix that but it will be on another PR since it has some impact on another function. Currently could you set config locally? |
Apologies, I didn't understand. What do you mean by set config locally? Having an alias or something like that to avoid options? |
Sorry for the lack of explanation, please do the following at this time. git config delta.width 250 From your explanation, I think you don't want to set it to global. However, tig does not accept options now, so please set locally like this inside repositories that you use tig. Currently tig searches only executable binary, so alias doesn't work either. I will probably fix it to accept options if jonas agreed. Also, in the original issue I asked what to do with the side-by-side option inside tig. If you have time, please feel free to post something like "allow tigrc to accept options and allow users to set width freely", so that someone may post an another idea. |
Also another problem I found is that in navigation mode for delta doesn't work: I am just reporting the problems I found. Thanks a lot for the fantastic work, @ulwlu! |
I haven't checked the implementation details but this looks a bit weird on light terminals like gnome-terminal or xterm because it draws dark backgrounds. |
@krobelus Hi. Yes that occured because of here. I noticed that and fixed it into default_bg. Thank you for catching. |
Maybe some of the changes can be separated in other PRs and add basic |
@pablospe sorry to be late. I was busy with my work and time flies so fast. That sounds great, I wanna add at least one more feature then.
These can be called basic feature, and we can add some features such as jumping to the file hunks. I probably can add in this year, or at least next January p.s. on 2022/1/21I finally have some time to focus on this, so I start working on it. I'm sorry for the delay, but I had a service launch on 1/16 at work and had been so busy until that, and in my personal life. p.s. on 2022/2/4 |
Hi, |
@fengyichui
|
@ulwlu Sorry, I don't quite understand, do you mean it's already supported or need other PRs ? |
it needs an other PR. |
@ulwlu Thanks for your answer. |
Looking forward to seeing this merged, awesome, thanks! |
Can we merge this? |
Hey @koutcher, any chance we can get this merged? I'd love this feature |
Yes, but don’t hold your breath, there is still much to do before it can make it to master. @ulwlu, thank you very much for this PR, it is a great work and I think it is really an important contribution for Tig. I’m sad I can’t find enough time these days to give it the review it deserves, and @jonas doesn’t seem to have more availabilities either. So, here are some first considerations, but I can’t guarantee there won’t be more:
diff --git a/src/draw.c b/src/draw.c
index fd183e5a..e6ba33ad 100644
--- a/src/draw.c
+++ b/src/draw.c
@@ -168,7 +168,7 @@ draw_text_expanded(struct view *view, enum line_type type, const char *string, i
size_t pos = string_expand(text, sizeof(text), string, length, opt_tab_size);
size_t col = view->col;
- if (opt_diff_highlight && *opt_diff_highlight && strcmp(opt_diff_highlight, "delta") == 0 && strstr(string, "\033[") != NULL) {
+ if (strstr(string, "\033[") != NULL) {
if (draw_chars_with_ansi(view, type, text, -1, max_width, use_tilde))
return true;
} else {
|
Thank you @koutcher for reviewing. I think your considerations are all reasonable and I want to get started on them (especially the 256x256 fixed array, which I thought same thing when I created it. I didn't see any performance degradation in memory or speed after creation, but I'll look again to see if there are any other workarounds). Actually, I will start working for a new company next week and will be a bit busy, so I will start
Yes. I didn't put else where else is not necessary. Thanks again for taking the time to review this. |
@koutcher
Currently it is necessary, however, it's still only one required option so we can ask users to add that option I already have the fixed code referring to your reviews (except 256x256 fixed array). However, unfortunately, due to my current company rules, I can't continue to Open Source Projects anymore. |
@ulwlu, please do. As I'm not a delta or any other fancy diff user, I'll create a feature branch to allow contributions until it is mature enough to be merged. Thanks again for your time. |
@koutcher |
For Apple Silicon (M1)/ Homebrew-managed ./configure \
LDFLAGS="-L/opt/homebrew/opt/ncurses/lib" \
CPPFLAGS="-I/opt/homebrew/opt/ncurses/include" \
PKG_CONFIG_PATH="/opt/homebrew/opt/ncurses/lib/pkgconfig" (was getting based on ╰─ brew info ncurses
==> ncurses: stable 6.3 (bottled) [keg-only]
Text-based UI library
https://invisible-island.net/ncurses/announce.html
/opt/homebrew/Cellar/ncurses/6.3 (3,968 files, 9.6MB)
Poured from bottle on 2022-03-17 at 16:24:05
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/ncurses.rb
License: MIT
==> Dependencies
Build: pkg-config ✔
==> Caveats
ncurses is keg-only, which means it was not symlinked into /opt/homebrew,
because macOS already provides this software and installing another version in
parallel can cause all kinds of trouble.
If you need to have ncurses first in your PATH, run:
echo 'export PATH="/opt/homebrew/opt/ncurses/bin:$PATH"' >> ~/.zshrc
For compilers to find ncurses you may need to set:
export LDFLAGS="-L/opt/homebrew/opt/ncurses/lib"
export CPPFLAGS="-I/opt/homebrew/opt/ncurses/include"
For pkg-config to find ncurses you may need to set:
export PKG_CONFIG_PATH="/opt/homebrew/opt/ncurses/lib/pkgconfig" |
I'm not entirely sure. Does this PR helps towards adding |
@FdelMazo |
This MR is pretty cool. Does anyone know when it will be released? |
Someone else just being here to ask if there are plans to get this in 😇 |
In the meanwhile, I ended up using this shortcuts (in the .tigrc):
First shortcut Obviously this is PR is a better solution, but for now this is a workaround that works for me. I hope this PR gets merged soon. |
@pablospe, GH does not allow to reopen a PR from a deleted account. The latest status from the original author is already accessible in the ansi-support branch: https://github.com/jonas/tig/tree/ansi-support. |
In that case, I will create a new PR pointing: https://github.com/jonas/tig/tree/ansi-support. Few questions: |
I'm leaving this comment here for people who want to try delta in Installation Instructionsgit clone https://github.com/jonas/tig/
cd tig
# Checkout branch of the project which contains the PR additions
git checkout ansi-support
make configure
# `ncurses` is almost always installable by your package manager, and almost always already installed on your system as it is needed for many TUI programs. The paths given here are the ones used by the package manager.
./configure LDFLAGS="-L/usr/lib" CPPFLAGS="-I/usr/include"
# This will install `tig` to ~/.local/bin, the recommended user path by the XDG specs. If needed, replace it by the path you want but leave out the `/bin/` part as this will be added by `make` already.
make prefix=$HOME/.local/
make install prefix=$HOME/.local/
# Configure `tig` to use `delta` in diffs
echo "set diff-highlight = \"delta\"" >> ~/.tigrc This should work. However I have to note, (while the majority are displayed with |
Let's move the discussion to: Notes:
|
#542 (comment)
how to use delta in tig
It requires ncurse 6.1 or higher.