Skip to content

Commit 663fba9

Browse files
committed
MMTabline: Add Vim colorscheme / window use tab fill color support
Tabs can now use colors defined by the Vim colorscheme under the TabLine/TabLineFill/TabLineSel highlight groups. There are now 3 coloring modes available: default, automatic (the default mode that generates matching colors using foreground/background colors), and Vim colorscheme. The new mode looks quite nice in some colorschemes and allows user customization, but for some existing ones it doesn't quite look right as they were designed for non-GUI tabs, which is why it's not the default. MacVim window can now also use the tabline's fill color as the window background color, which allows the title bar to show as a cohesive whole when transparent title bar is set. This creates a nice look especially when the colorscheme is designed for this. Other tab coloring changes: - Tabs now support high contrast mode (macOS accessibility setting) now. The default colors will use higher contrast colors, and in all modes, the tabs will be drawn with an outline similar to other system native UI to aid visual differentiation. - Tabs will also show a dimmed text color when the window has lost focus, similar to other native title bar / tool bar UI elements. - Fixed default colors to look a little better. Previously the fill color and unselected tab background colors were the same.
1 parent a7db694 commit 663fba9

20 files changed

+461
-93
lines changed

runtime/doc/gui_mac.txt

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -310,11 +310,6 @@ KEY VALUE ~
310310
*MMScrollOneDirectionOnly* scroll along one axis only when using trackpad [bool]
311311
*MMSmoothResize* allow smooth resizing of MacVim window [bool]
312312
*MMShareFindPboard* share search text to Find Pasteboard [bool]
313-
*MMShowAddTabButton* enable "add tab" button on tabline [bool]
314-
*MMShowTabScrollButtons* enable tab scroll buttons on tabline [bool]
315-
*MMTabMinWidth* minimum width of a tab [int]
316-
*MMTabOptimumWidth* default width of a tab [int]
317-
*MMDefaultTablineColors* use default colors instead of colorscheme for tabs [bool]
318313
*MMTextInsetBottom* text area offset in pixels [int]
319314
*MMTextInsetLeft* text area offset in pixels [int]
320315
*MMTextInsetRight* text area offset in pixels [int]
@@ -327,6 +322,14 @@ KEY VALUE ~
327322
*MMUpdaterPrereleaseChannel* opt-in to pre-release software update [bool]
328323
*MMShowWhatsNewOnStartup* show "What's New" after updating to new version [bool]
329324

325+
Tabs ~
326+
*MMTabColorsMode* use default/auto/colorscheme for tab colors [int]
327+
*MMWindowUseTabBackgroundColor* use tabs background fill color as window color [bool]
328+
*MMShowAddTabButton* enable "add tab" button on tabline [bool]
329+
*MMShowTabScrollButtons* enable tab scroll buttons on tabline [bool]
330+
*MMTabMinWidth* minimum width of a tab [int]
331+
*MMTabOptimumWidth* default width of a tab [int]
332+
330333
As an example, if you have more than one mouse button and would wish to free
331334
up Ctrl-click so you can bind it to something else, then the appropriate
332335
command is: >

runtime/doc/tags

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5645,7 +5645,6 @@ MMAllowForceClickLookUp gui_mac.txt /*MMAllowForceClickLookUp*
56455645
MMAppearanceModeSelection gui_mac.txt /*MMAppearanceModeSelection*
56465646
MMCellWidthMultiplier gui_mac.txt /*MMCellWidthMultiplier*
56475647
MMCmdLineAlignBottom gui_mac.txt /*MMCmdLineAlignBottom*
5648-
MMDefaultTablineColors gui_mac.txt /*MMDefaultTablineColors*
56495648
MMDialogsTrackPwd gui_mac.txt /*MMDialogsTrackPwd*
56505649
MMDisableLaunchAnimation gui_mac.txt /*MMDisableLaunchAnimation*
56515650
MMDisableTablineAnimation gui_mac.txt /*MMDisableTablineAnimation*
@@ -5666,6 +5665,7 @@ MMShowAddTabButton gui_mac.txt /*MMShowAddTabButton*
56665665
MMShowTabScrollButtons gui_mac.txt /*MMShowTabScrollButtons*
56675666
MMShowWhatsNewOnStartup gui_mac.txt /*MMShowWhatsNewOnStartup*
56685667
MMSmoothResize gui_mac.txt /*MMSmoothResize*
5668+
MMTabColorsMode gui_mac.txt /*MMTabColorsMode*
56695669
MMTabMinWidth gui_mac.txt /*MMTabMinWidth*
56705670
MMTabOptimumWidth gui_mac.txt /*MMTabOptimumWidth*
56715671
MMTextInsetBottom gui_mac.txt /*MMTextInsetBottom*
@@ -5678,6 +5678,7 @@ MMTranslateCtrlClick gui_mac.txt /*MMTranslateCtrlClick*
56785678
MMUpdaterPrereleaseChannel gui_mac.txt /*MMUpdaterPrereleaseChannel*
56795679
MMUseMouseTime gui_mac.txt /*MMUseMouseTime*
56805680
MMVerticalSplit gui_mac.txt /*MMVerticalSplit*
5681+
MMWindowUseTabBackgroundColor gui_mac.txt /*MMWindowUseTabBackgroundColor*
56815682
MMZoomBoth gui_mac.txt /*MMZoomBoth*
56825683
MS-DOS os_msdos.txt /*MS-DOS*
56835684
MS-Windows os_win32.txt /*MS-Windows*

src/MacVim/Base.lproj/Preferences.xib

Lines changed: 53 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -280,11 +280,11 @@
280280
<point key="canvasLocation" x="137.5" y="-17"/>
281281
</customView>
282282
<customView id="hr4-G4-3ZG" userLabel="Appearance">
283-
<rect key="frame" x="0.0" y="0.0" width="483" height="405"/>
283+
<rect key="frame" x="0.0" y="0.0" width="483" height="447"/>
284284
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
285285
<subviews>
286286
<customView id="fw0-VK-Nbz" userLabel="Dark mode selection">
287-
<rect key="frame" x="19" y="227" width="433" height="156"/>
287+
<rect key="frame" x="19" y="269" width="433" height="156"/>
288288
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
289289
<subviews>
290290
<textField focusRingType="none" verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" id="T40-Os-PUf" userLabel="Dark mode selection">
@@ -345,11 +345,11 @@
345345
</subviews>
346346
</customView>
347347
<customView id="7af-iK-4r7" userLabel="Titlebar appearance">
348-
<rect key="frame" x="19" y="144" width="433" height="75"/>
348+
<rect key="frame" x="19" y="169" width="433" height="92"/>
349349
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
350350
<subviews>
351351
<textField focusRingType="none" verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" id="9Rk-gT-kVC" userLabel="Titlebar appearance">
352-
<rect key="frame" x="-2" y="57" width="187" height="17"/>
352+
<rect key="frame" x="-2" y="74" width="187" height="17"/>
353353
<autoresizingMask key="autoresizingMask" flexibleMinY="YES"/>
354354
<textFieldCell key="cell" sendsActionOnEndEditing="YES" alignment="right" title="Window appearance:" id="HEH-Lo-v4I" userLabel="Titlebar appearance:">
355355
<font key="font" metaFont="system"/>
@@ -358,7 +358,7 @@
358358
</textFieldCell>
359359
</textField>
360360
<button id="7ie-0J-0Zr">
361-
<rect key="frame" x="189" y="56" width="244" height="18"/>
361+
<rect key="frame" x="189" y="73" width="244" height="18"/>
362362
<autoresizingMask key="autoresizingMask" flexibleMinY="YES"/>
363363
<buttonCell key="cell" type="check" title="Transparent title bar" bezelStyle="regularSquare" imagePosition="left" alignment="left" inset="2" id="hzd-hj-Pth">
364364
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
@@ -369,8 +369,21 @@
369369
<binding destination="58" name="value" keyPath="values.MMTitlebarAppearsTransparent" id="pQP-eb-JXS"/>
370370
</connections>
371371
</button>
372+
<button id="W5G-Qq-B7Z">
373+
<rect key="frame" x="189" y="55" width="190" height="18"/>
374+
<autoresizingMask key="autoresizingMask" flexibleMinY="YES"/>
375+
<string key="toolTip">Use tab bar's background color for the window title bar color as well. This creates a seamless pane when transparent title bar is also set.</string>
376+
<buttonCell key="cell" type="check" title="Use tabs background color" bezelStyle="regularSquare" imagePosition="left" alignment="left" inset="2" id="om2-70-baY">
377+
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
378+
<font key="font" metaFont="system"/>
379+
</buttonCell>
380+
<connections>
381+
<action selector="tabsPropertiesChanged:" target="-1" id="D9I-8s-GXi"/>
382+
<binding destination="58" name="value" keyPath="values.MMWindowUseTabBackgroundColor" id="8yg-KT-59b"/>
383+
</connections>
384+
</button>
372385
<button id="Hqh-Ql-2od">
373-
<rect key="frame" x="189" y="38" width="244" height="18"/>
386+
<rect key="frame" x="189" y="37" width="244" height="18"/>
374387
<autoresizingMask key="autoresizingMask" flexibleMinY="YES"/>
375388
<buttonCell key="cell" type="check" title="Hidden title bar" bezelStyle="regularSquare" imagePosition="left" alignment="left" inset="2" id="W40-cB-m1U">
376389
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
@@ -394,7 +407,7 @@
394407
</connections>
395408
</button>
396409
<button id="s2M-pj-U8e">
397-
<rect key="frame" x="189" y="-1" width="244" height="18"/>
410+
<rect key="frame" x="189" y="1" width="244" height="18"/>
398411
<autoresizingMask key="autoresizingMask" flexibleMinY="YES"/>
399412
<buttonCell key="cell" type="check" title="No drop shadows" bezelStyle="regularSquare" imagePosition="left" alignment="left" inset="2" id="VM8-tg-mVV">
400413
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
@@ -408,9 +421,39 @@
408421
</subviews>
409422
</customView>
410423
<customView id="C3B-cu-RC2" userLabel="Tabs">
411-
<rect key="frame" x="20" y="118" width="432" height="18"/>
424+
<rect key="frame" x="20" y="118" width="432" height="43"/>
412425
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
413426
<subviews>
427+
<textField focusRingType="none" verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" id="qMc-Md-UwA" userLabel="Tabs">
428+
<rect key="frame" x="-2" y="25" width="187" height="17"/>
429+
<autoresizingMask key="autoresizingMask" flexibleMinY="YES"/>
430+
<textFieldCell key="cell" sendsActionOnEndEditing="YES" alignment="right" title="Tabs:" id="iUO-3c-iff" userLabel="Tabs:">
431+
<font key="font" metaFont="system"/>
432+
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
433+
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
434+
</textFieldCell>
435+
</textField>
436+
<popUpButton verticalHuggingPriority="750" id="Ncf-jw-6ZJ" userLabel="Tab colors">
437+
<rect key="frame" x="188" y="18" width="248" height="26"/>
438+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
439+
<popUpButtonCell key="cell" type="push" title="Default colors" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" inset="2" selectedItem="OhI-Q1-7PP" id="GVe-19-lXP" userLabel="Tab colors">
440+
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
441+
<font key="font" metaFont="message"/>
442+
<menu key="menu" title="OtherViews" id="VE4-hh-it9">
443+
<items>
444+
<menuItem title="Default colors" state="on" toolTip="Use default tab colors based on macOS light / dark modes." id="OhI-Q1-7PP" userLabel="Default Colors"/>
445+
<menuItem title="Automatic colors" toolTip="Automatically pick matching colors based on the current Vim foreground/background colors." id="CPh-w1-24K"/>
446+
<menuItem title="Use Vim colorscheme" id="Nqs-aD-DWs" userLabel="Use Vim colorscheme">
447+
<string key="toolTip">Use tab colors from Vim's colorscheme, using TabLine/TabLineSel/TabLineFill highlight groups. Some colorschemes will work better than others under this setting.</string>
448+
</menuItem>
449+
</items>
450+
</menu>
451+
</popUpButtonCell>
452+
<connections>
453+
<action selector="tabsPropertiesChanged:" target="-1" id="zcR-FW-4Ui"/>
454+
<binding destination="58" name="selectedIndex" keyPath="values.MMTabColorsMode" id="LCa-Uo-szO"/>
455+
</connections>
456+
</popUpButton>
414457
<button id="rCZ-9B-5RL">
415458
<rect key="frame" x="189" y="-1" width="244" height="18"/>
416459
<autoresizingMask key="autoresizingMask" flexibleMinY="YES"/>
@@ -423,15 +466,6 @@
423466
<binding destination="58" name="value" keyPath="values.MMShowTabScrollButtons" id="KHi-zu-Jz2"/>
424467
</connections>
425468
</button>
426-
<textField focusRingType="none" verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" id="qMc-Md-UwA" userLabel="Tabs">
427-
<rect key="frame" x="-2" y="0.0" width="187" height="17"/>
428-
<autoresizingMask key="autoresizingMask" flexibleMinY="YES"/>
429-
<textFieldCell key="cell" sendsActionOnEndEditing="YES" alignment="right" title="Tabs:" id="iUO-3c-iff" userLabel="Tabs:">
430-
<font key="font" metaFont="system"/>
431-
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
432-
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
433-
</textFieldCell>
434-
</textField>
435469
</subviews>
436470
</customView>
437471
<customView id="BpJ-rH-ona" userLabel="Full Screen">
@@ -535,7 +569,7 @@
535569
</subviews>
536570
</customView>
537571
</subviews>
538-
<point key="canvasLocation" x="137.5" y="457.5"/>
572+
<point key="canvasLocation" x="137.5" y="478.5"/>
539573
</customView>
540574
<customView id="Bnq-Nx-GJH" userLabel="Input">
541575
<rect key="frame" x="0.0" y="0.0" width="483" height="110"/>
@@ -622,7 +656,7 @@
622656
</subviews>
623657
</customView>
624658
</subviews>
625-
<point key="canvasLocation" x="138" y="775"/>
659+
<point key="canvasLocation" x="138" y="913"/>
626660
</customView>
627661
<customView id="620" userLabel="Advanced">
628662
<rect key="frame" x="0.0" y="0.0" width="483" height="367"/>

src/MacVim/MMAppController.m

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,9 @@ + (void)registerDefaults
178178
[NSNumber numberWithInt:210], MMTabOptimumWidthKey,
179179
[NSNumber numberWithBool:YES], MMShowAddTabButtonKey,
180180
[NSNumber numberWithBool:NO], MMShowTabScrollButtonsKey,
181+
[NSNumber numberWithInt:MMTabColorsModeAutomatic],
182+
MMTabColorsModeKey,
183+
[NSNumber numberWithBool:NO], MMWindowUseTabBackgroundColorKey,
181184
[NSNumber numberWithInt:2], MMTextInsetLeftKey,
182185
[NSNumber numberWithInt:1], MMTextInsetRightKey,
183186
[NSNumber numberWithInt:1], MMTextInsetTopKey,
@@ -1238,7 +1241,7 @@ - (void)refreshAllAppearances
12381241
- (void)refreshAllTabProperties
12391242
{
12401243
for (MMVimController *vc in vimControllers) {
1241-
[vc.windowController.vimView refreshTabProperties];
1244+
[vc.windowController refreshTabProperties];
12421245
}
12431246
}
12441247

src/MacVim/MMBackend.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
- (void)setBackgroundColor:(int)color;
6363
- (void)setForegroundColor:(int)color;
6464
- (void)setSpecialColor:(int)color;
65+
- (void)setTablineColors:(int[6])colors;
6566
- (void)setDefaultColorsBackground:(int)bg foreground:(int)fg;
6667
- (NSConnection *)connection;
6768
- (NSDictionary *)actionDict;

src/MacVim/MMBackend.m

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,17 @@ - (void)setSpecialColor:(int)color
293293
specialColor = MM_COLOR(color);
294294
}
295295

296+
- (void)setTablineColors:(int[6])colors
297+
{
298+
unsigned tabColors[6];
299+
for (int i = 0; i < 6; i++) {
300+
tabColors[i] = MM_COLOR(colors[i]);
301+
}
302+
NSMutableData *data = [NSMutableData data];
303+
[data appendBytes:&tabColors length:sizeof(tabColors)];
304+
[self queueMessage:SetTablineColorsMsgID data:data];
305+
}
306+
296307
- (void)setDefaultColorsBackground:(int)bg foreground:(int)fg
297308
{
298309
defaultBackgroundColor = MM_COLOR_WITH_TRANSP(bg,p_transp);

src/MacVim/MMTabline/MMTab.m

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
#import "MMTabline.h"
44
#import "MMHoverButton.h"
55

6-
#import "MacVim.h" // for availability macros
6+
// Only imported for AVAILABLE_MAC_OS
7+
#import "MacVim.h"
78

8-
#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_13
9+
#if !defined(MAC_OS_X_VERSION_10_13) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_13
910
typedef NSString * NSAnimatablePropertyKey;
1011
#endif
1112

@@ -46,7 +47,7 @@ - (instancetype)initWithFrame:(NSRect)frameRect tabline:(MMTabline *)tabline
4647
[self addSubview:_closeButton];
4748

4849
_titleLabel = [NSTextField new];
49-
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_11
50+
#if defined(MAC_OS_X_VERSION_10_11) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_11
5051
if (AVAILABLE_MAC_OS(10,11)) {
5152
_titleLabel.font = [NSFont systemFontOfSize:NSFont.smallSystemFontSize weight:NSFontWeightSemibold];
5253
} else
@@ -109,27 +110,29 @@ - (void)setFillColor:(NSColor *)fillColor
109110

110111
- (void)setState:(MMTabState)state
111112
{
113+
const BOOL hasFocus = (self.window == nil) || [self.window isKeyWindow];
114+
112115
// Transitions to and from MMTabStateSelected
113116
// DO NOT animate so that UX feels snappier.
114117
if (state == MMTabStateSelected) {
115118
_closeButton.fgColor = _tabline.tablineSelFgColor;
116-
_titleLabel.textColor = _tabline.tablineSelFgColor;
119+
_titleLabel.textColor = hasFocus ? _tabline.tablineSelFgColor : _tabline.tablineUnfocusedSelFgColor;
117120
self.fillColor = _tabline.tablineSelBgColor;
118121
}
119122
else if (state == MMTabStateUnselected) {
120123
if (_state == MMTabStateSelected) {
121124
_closeButton.fgColor = _tabline.tablineFgColor;
122-
_titleLabel.textColor = _tabline.tablineFgColor;
125+
_titleLabel.textColor = hasFocus ? _tabline.tablineFgColor : _tabline.tablineUnfocusedFgColor;
123126
self.fillColor = _tabline.tablineBgColor;
124127
} else {
125128
_closeButton.animator.fgColor = _tabline.tablineFgColor;
126-
_titleLabel.animator.textColor = _tabline.tablineFgColor;
129+
_titleLabel.animator.textColor = hasFocus ? _tabline.tablineFgColor : _tabline.tablineUnfocusedFgColor;
127130
self.animator.fillColor = _tabline.tablineBgColor;
128131
}
129132
}
130133
else { // state == MMTabStateUnselectedHover
131134
_closeButton.animator.fgColor = _tabline.tablineSelFgColor;
132-
_titleLabel.animator.textColor = _tabline.tablineSelFgColor;
135+
_titleLabel.animator.textColor = hasFocus ? _tabline.tablineSelFgColor : _tabline.tablineUnfocusedSelFgColor;
133136
self.animator.fillColor = self.unselectedHoverColor;
134137
}
135138
_state = state;
@@ -164,6 +167,11 @@ - (void)drawRect:(NSRect)dirtyRect
164167
[p transformUsingAffineTransform:transform];
165168
}
166169
[p fill];
170+
NSColor *strokeColor = _tabline.tablineStrokeColor;
171+
if (strokeColor != nil) {
172+
[strokeColor set];
173+
[p stroke];
174+
}
167175
}
168176

169177
@end

0 commit comments

Comments
 (0)