-
Notifications
You must be signed in to change notification settings - Fork 70
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
Add Visual Indication to Identify Modified Files in Tabline #52
Add Visual Indication to Identify Modified Files in Tabline #52
Conversation
Just my two cents, I prefer a visual indication without text (something that is not straightfoward on TUI but is on GUI), like a different color in a certain place of the tab, a light fade, a yellow fill on the leftmost rectangle of the tab, etc.. That said, it's only a matter of taste and this is already better than what we have (and a direct reference to neovim's original behavior), so I'm fine with it. |
In theory, that could be done with css, right? I do agree that it would look better to have something fancier, and I have no problem working on implementing it for this PR, but it may take some work. I don’t know much about how gnvim implements the css styling atm, so any help would be appreciated. Also, a visual indication like what you stated could set apart gnvim from other neovim frontends, since afaik other nvim GUIs don’t have that (just something simple e.g. the vscode-like dot in Oni), so I’m all for it (as long as it remains obvious that the tab has a modified buffer). |
I fiddled around with it, this is a style that could work (you'd have to change to use a variable: if not modified use the line above, if modified the one below in diff --git a/src/ui/tabline.rs b/src/ui/tabline.rs
index 689de72..075348c 100644
--- a/src/ui/tabline.rs
+++ b/src/ui/tabline.rs
@@ -162,10 +162,12 @@ impl Tabline {
background-color: #{normal_bg};
border: none;
box-shadow: inset -2px -70px 10px -70px rgba(0,0,0,0.75);
+ box-shadow: inset 73px 0px 0px -70px rgba(244, 226, 66, 0.4);
}}
tab:checked {{
border: none;
box-shadow: inset 73px 0px 0px -70px #{selected_fg};
+ box-shadow: inset 73px 0px 0px -70px rgba(244, 226, 66, 1);
}}
tab:checked, tab:checked > label {{
color: #{selected_fg};
@@ -173,6 +175,7 @@ impl Tabline {
}}
tab:hover {{
box-shadow: inset 73px 0px 0px -70px #{selected_fg};
+ box-shadow: inset 73px 0px 0px -70px rgba(244, 226, 66, 0.80);
}}
",
font_wild = self.font.as_wild_css(FontUnit::Point), |
The biggest downside of this approach is that colors might not be the best way forward, if we get colors from the colorscheme then we have inconsistent UI (modified indicator color changes between gnvim colorschemes), if not we may have issues (e.g. a weird yellow background colorscheme, but that's a very edge case, I hope). Given above, and considering that the '+' solution is what vim already does and users expect, I think it is a safer approach in terms of complexity and UX. |
I do like the idea, and it looks good, but at first the difference between the second and third tabs was a bit hard for me to see. I think varying colors (i.e. one color for active/inactive that varies in shade like you showed, but maybe a slightly/completely different color for modified) may be easier to see and understand, but the problems you said are good points to consider. Not to mention that this whole idea would add more code to determine if the tab’s buffer is modified and to change the css accordingly. I can work on it, but it could always be done in a later PR if not this one, assuming we want to go forward with the idea. (I definitely like your idea more than the ‘+’ icon in the tabline, since it fits the GUI better, so I’ll tinker with it.) |
Yeah, good points. I think we can start with this iteration and revisit it later, if we deem necessary, what do you think? |
Yeah, I think that’s a good idea. That way we can go ahead and get this feature in gnvim, since it is nice to have, and beautify it in the future. We could also, after this PR is over, open up an issue for beautifying this feature’s look, so that we have a place to work on it and an issue to reference in a future PR. Think we should do that? (Also, thanks @badosu for all the help on polishing/fixing/changing this PR and my other one, and on the corresponding issues. Helps a lot, and I really appreciate it.) |
This commit abstracts the logic that checks if a tab in the tabline has a modified buffer or not to a function (`get_tab_label`) which does that check, and returns the corresponding tab_label to be used in the tabline. It also handles some errors that would have previously caused gnvim to crash.
I abstracted the tab_label logic, and also handled some possible errors. Let me know what you think about the way I handled the errors. They needed to be handled because gnvim would crash when I went back and forth between modified tabs (not exactly sure how to reproduce, but I think it was sending the requests from the tabpage too quickly/frequently to nvim), which is no good. After handling the errors by just setting |
Thanks @vhakulinen, will push those changes in a bit (once I get to my computer). Concerning using the I’m not sure that the dot complements gnvim’s tabline (which is longer & bigger than vscode’s, for example). I like the idea of something that sets gnvim apart from the other Neovim GUIs, whether that be something like what badosu sketched out or something else. What do you think? Again, this isn’t essential for this PR (although if it isn’t much trouble I’d be glad to implement it here, and am not against the idea), so we can always revisit it. Thanks again for the instructive moment (still learning core Rust and it’s idioms). |
I did some experimentation with unicode circles/bullets (● black circle 25cf) : Might be interesting to test some variations, see: https://stackoverflow.com/questions/12971187/what-would-be-the-unicode-character-for-big-bullet-in-the-middle-of-the-characte |
That looks pretty good! If we are going to do something text-based, that is probably the way to go (looks much better than a plus sign). We should maybe look into some other unicode symbols too (and verify that a fairly large amount of fonts support them, especially the popular fonts). Also, is the additional code that would be necessary to do something css-based worth the look we'd get, or should we stick to text? I haven't tried to actually implement a css-based indication, so I am not sure atm. |
I think an initial approach with text is better for an initial iteration, e.g. replacing Unfortunately I did not find a circle/bullet character that actually stays in the middle of the line height, not sure if it depends on font. Anyway, either of + or ● is fine by me. |
Agreed.
Interesting. Is this important enough that we should stick to using
They definitely both communicate that a tab has a modified buffer, but I think I prefer What do you think @vhakulinen? |
I personally prefer the dot, but we can make the character it self configurable (especially if the dot's position varies between fonts). I'll merge this. |
This PR makes gnvim show the

+
symbol for a modified file in the tabline:See #51.
I implemented this based off of vhakulinen's info in #51, but feedback/suggestions are much appreciated.