-
-
Notifications
You must be signed in to change notification settings - Fork 685
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
base: master
Are you sure you want to change the base?
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. |
Yes, I've tried this PR, but my main issue with it is that it doesn't follow the transparent title bar logic. And this is something I genuinely love about MacVIm. I'm sure @sfsam did a great job, and if anything this looks better than what we have now, but just falls short of perfection due to the inability of this design to adapt whenever the title bar is transparent. This is what this PR looks like on my machine & my config: Note: the left and right buttons in the left do nothing. |
What does not following transparent title bar logic mean? You want the gray area to the right to be just the background color? Note that the above proposal of "tabs in titlebar" is something else (e.g. iTerm calls them "minimal style") |
When I say transparent title bar logic, I have in mind the "Titlebar appearance -> Transparent" setting, which displays the title bar within the canvas of the editor and embeds into
I say simply move the existing tab bar in the proposal to the title bar, and yes, make its background transparent, not gray. |
Sure, that's not really what transparent titlebars are for. The purpose of transparent titlebars is to make it use the background color, instead of drawing the macOS titlebar. It would be a new feature request to embed the tab bars within the titlebars, and it would be called something else (e.g. "minimal", "compact", etc) That aside I don't think embedding the Vim editing area itself within the titlebar makes sense, because you won't be able to click on things (you either can't click on those area of the editing area, or the title bar). You can already set MacVim titlebar to "hidden", with the obvious drawback that you can drag it around.
That could be a future option but definitely not the default. It breaks what the default assumptions of how tabs should work in most applications. FWIW Safari during Monterey beta tried doing that and it was so unpopular that they reverted back to the regular tabs, with the "compact" mode as an option. Edit: this style of tabs also breaks tool bars, and I think you are getting less space for your tabs (if you have a lot of tabs), so I'm personally not too big a fan of them as I think they only work well if you have a couple tabs. I'm not opposed to adding them in the future but just want to point out that features like this have a lot of knock-on effects (e.g. the tool bar issue that I just mentioned) |
b42da16
to
29d2d5a
Compare
@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 :) |
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!