-
-
Notifications
You must be signed in to change notification settings - Fork 681
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
Tabs #1120
Tabs #1120
Conversation
Hi, I haven't taken a close look yet, but is there a reason you are implementing a new tab control instead of using an external third party one like those used by iTerm? |
A couple reasons: ease and functionality. Ease: The variant of PSMTabBarControl in iTerm2 is pretty big: 33 files (16 objc, 17 header) and 6,200 lines of code. My implementation is 6 files (3 objc, 3 header) and 660 lines of code. It was a lot easier and less work starting from scratch than understanding and customizing a large codebase just for tabs with the specific functionality I was targeting. It is easier to debug and maintain a significantly smaller base. Functionality: I was targeting specific functionality. I wanted to eliminate the overflow menu that MacVim and iTerm2 have when there are too many tabs for the window. With scrolling tabs, you always see the selected tab. You can always drag to reorder any tab, not just those that aren't hidden in a menu. It means the + tab button is always available and never overloaded with the >> menu button. Since MacVim is Vim, I wanted to design tabs that would work with Vim's Tabline highlight group so users could customize their tabline in MacVim just as they do in Vim. So the parts of my tabs correspond to Tabline, TablineSel, and TablineFill. The MMTabline class has properties for these. I couldn't figure out how to access these colors from MacVim, so for now I generate these properties algorithmically based on MMVimView's default foreground and background colors. It seems to work for the ones I tested: For closing multiple tabs, I wanted to mimic Chrome's behavior where tabs conveniently slide under your mouse and then resize when you leave the tabline. I don't think I could do this with PSMTabBarControl: Overall, I was looking for specific functionality and it was a lot easier to achieve what I was after by starting from scratch. At around 660 lines of code, I don't think it resulted in a lot of new code. FWIW, I believe the executable is also around 300K smaller. |
I see. Ok it will probably take me some time to review this and there's a backlog of other PRs and issues to fix for Big Sur so this will likely not make it in the next release. I'll get to it though! |
d247599
to
da2a243
Compare
Thank you for taking the time to look at this. I know you're busy and no one asked for tabs - I was just scratching my own itch.
|
|
|
|
If you want to see to see how That said, I was looking at builtin and other popular colorschemes, and I'm not 100% sure their tabline colors would look good in the GUI. I recommend manually plugging in the color for debugging first to see if it even looks good. It sounds good in theory but those colors were designed with the terminal-based tablines in mind and may not look as good as you hope. |
|
|
|
|
|
|
Mouse wheel scrolling: Yeah but most users are not going to know to do that (holding shift). It's just unnecessarily difficult. So here's my suggestion: On trackpad / magic mouse, use horizontal scrolling just like now because it's more intuitive. On a regular mouse, use vertical scrolling because most mouse only have that. The best way I know to tell whether it's a regular mouse or a trackpad (or Magic Mouse) is by using Also, thanks for going the extra mile to test it with a mouse! For reference, this behavior also seems to be how macOS native tabs work. Actually, to be more accurate, seems like native tab doesn't care whether you shift-scroll or scroll, so maybe they just allow either X or Y axis for scrolling, so I think that option seems ok as well. |
Left/right buttons: I see. Hmm, I can kind of see that. I'm still wonder what "glitchy" means in this case. Are the tabs jumping around? I was imagining it would just push the tabs to the right, so I'm curious. Is the code easy to enable in the code right now? I may play around with it. Otherwise, I think maybe we could make it disabled by default. I definitely think we should keep the feature but most people may not need it, so we just want to have the option for those who do. |
Mouse wheel scrolling: How do I get the scrolling deltas? I had tried overriding Left/right: By glitchy I meant having the buttons continually appear and disappear as you scrolled back and forth. It's more jarring than having them dim. I think it's also a bit of an anti-pattern to have UI controls just disappear. For example, browser back/forward buttons don't disappear when there is no history, they just dim. For sure, you can certainly play around with it! I noticed once I plugged in my mouse that scroll bars appeared on all my windows. Unplugging the mouse made them automatically disappear. I wonder how the presence of the mouse was detected and if the buttons could automatically toggle based on that. |
Hmm, I think it has to do with how the NSWindow is configured. I thought you are overriding |
When I overrode |
Mouse wheel scrolling: I think I've got it working. Rather than overriding |
Hi @sfsam I haven't checked up on the progress here much. Is this ready to merge and should I take a closer look? Was just curious since the title still says "WIP" |
Hi @ychin. Yes it's ready for you to take a closer look. |
@sfsam thank you to Keep working on that feature! |
I'm sorry that this has fallen by the wayside for me. I need to get back to taking a look and merging this. Since you seem to have kept up merging from upstream is this ready to go @sfsam ? |
Hi. Yes @ychin it is ready for you to take a look. I've just been sporadically keeping it up to date with the current state of MacVim. Since this is a big change, I'm nervous about it and hope it can be tested by folks who use GUI tabs regularly, both for functionality as well as for bugs. On a personal note, I have some "family/life things" that I need to take care of. They are starting to swallow me up and consequently most of my attention and energy is focused there. |
Oh sure that's fine. Given that this pr has sat unreviewed for so long I do appreciate you having merged and kept it up to date so far. If you do not mind me fixing up the PR here and there I may do so just so we can merge it. |
Thanks @ychin. Sounds good. |
7283c1d
to
be60240
Compare
@ychin ping :) |
28af7b9
to
90714ff
Compare
Sorry for the slow update. I had been procrastinating on this. I have been running this and reviewing the change and it should be merged soon. There are some issues with backwards compatibility when testing on older macOS and also some minor behavior decisions that I want to change (scrolling behavior) but for the most part this is fine. Will be pushing some of those changes to this branch soon. I'm not proud that this has be languishing this on the PR queue for so long. |
I just did a pass and pushed a commit to the branch with misc fixes and cleanups and make it cross-compatible with older macOS versions. @sfsam, feel free to squash them into one commit and rebase (there is a tiny merge conflict that is easy to resolve). Otherwise I will do that and merge it in near future. Just wanted to give you a chance to look at the changes first. There are some other fixes I want to do after this is merged but want to merge this in first. Some things to fix up include getting the "scroll to current tab" behavior a little better (it's using some heuristics in Sorry for the delay in getting this merged after years of inactivity. Procrastination was a powerful force. |
Thanks to the both of you for your efforts, even if they spanned years :) |
Thanks, @ychin. No need to apologize for the delay. I greatly appreciate the time and effort you've put in to improve MacVim all these years. |
Ok this is merged! Thanks for keeping your branch mostly up to date all these years and the great work. I learned a couple things about the macOS animation system from it. I'll push out another pre-release update soon after a couple fix ups and see if any one sees any issues with it and this should then go out in a proper release (r181) next month or so. |
This PR introduces a new tabline UI to replace PSMTabControl.
Rather than trying to mimic the ever-changing style of macOS, these tabs look like tabs. The rollover animations fade in & out instead of simply toggling on & off and there are some animations for closing and adding tabs as well.
Unlike PSMTabBarControl, there is no overflow menu. Instead, tabs scroll horizontally when there are too many to fit in the window at once.
There are properties for colors that match the Tabline* highlight group so that the tabs can match the user's colorscheme. However, I couldn't figure out how to get colorscheme colors programatically so for now colors are algorithmically generated based on the default foreground and background colors set in MMVimView.m.
The implementation uses ARC. It was build on macOS Mojave with Xcode 10.
I realize no one asked for this. I made it to scratch an itch and learn a little about MacVim. I'm putting it here in case others find it interesting or useful. This seems to work for me so far, but I'm no Vim or MacVim expert so it is possible I've majorly missed the mark!