Skip to content

Commit 5de428c

Browse files
authored
Merge pull request #1038 from ychin/dark-mode-selection-customization
Add dark mode customization / appearance preferences panel
2 parents 2b9a6a1 + 78a7c97 commit 5de428c

18 files changed

+283
-32
lines changed

runtime/doc/gui_mac.txt

Lines changed: 38 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,19 @@ The MacVim Graphical User Interface *macvim* *gui-macvim*
99
1. MacVim differences |macvim-differences|
1010
2. Starting MacVim |macvim-start|
1111
3. Preferences |macvim-preferences|
12-
4. Special colors |macvim-colors|
13-
5. Menus |macvim-menus|
14-
6. Toolbar |macvim-toolbar|
15-
7. Touch Bar |macvim-touchbar|
16-
8. Dialogs |macvim-dialogs|
17-
9. System services |macvim-services|
18-
10. mvim:// URL handler |macvim-url-handler|
19-
11. Keyboard shortcuts |macvim-shortcuts|
20-
12. Trackpad gestures |macvim-gestures|
21-
13. International |macvim-international|
22-
14. Known bugs/missing features |macvim-todo|
23-
15. Hints |macvim-hints|
12+
4. MacVim appearance |macvim-appearance|
13+
5. Special colors |macvim-colors|
14+
6. Menus |macvim-menus|
15+
7. Toolbar |macvim-toolbar|
16+
8. Touch Bar |macvim-touchbar|
17+
9. Dialogs |macvim-dialogs|
18+
10. System services |macvim-services|
19+
11. mvim:// URL handler |macvim-url-handler|
20+
12. Keyboard shortcuts |macvim-shortcuts|
21+
13. Trackpad gestures |macvim-gestures|
22+
14. International |macvim-international|
23+
15. Known bugs/missing features |macvim-todo|
24+
16. Hints |macvim-hints|
2425

2526
Other relevant documentation:
2627
|gui.txt| For generic items of the GUI.
@@ -259,6 +260,7 @@ KEY VALUE ~
259260
*MMNoFontSubstitution* disable automatic font substitution [bool]
260261
*MMNoTitleBarWindow* hide title bar [bool]
261262
*MMTitlebarAppearsTransparent* enable a transparent titlebar [bool]
263+
*MMAppearanceModeSelection* dark mode selection (|macvim-dark-mode|)[bool]
262264
*MMShareFindPboard* share search text to Find Pasteboard [bool]
263265
*MMShowAddTabButton* enable "add tab" button on tabline [bool]
264266
*MMTabMaxWidth* maximum width of a tab [int]
@@ -301,7 +303,19 @@ shell is used, then "-l" is automatically added as an argument. To override
301303
this behaviour set MMLoginShellArgument to "--".
302304

303305
==============================================================================
304-
4. Special colors *macvim-colors*
306+
4. MacVim appearance *macvim-appearance*
307+
308+
*macvim-appearance-mode* *macvim-dark-mode*
309+
MacVim will by default use the system apperance mode (light or dark). However,
310+
you can manually force MacVim to use either light or dark mode in the
311+
preferences panel. A fourth option allows MacVim to respect the |'background'|
312+
option set by Vim, which is more flexible in situations like loading a dark
313+
color scheme while system preferences are configured to use light mode. It's
314+
also the recommended setting when title bar is configured to be "Transparent"
315+
(see |MMTitlebarAppearsTransparent|).
316+
317+
==============================================================================
318+
5. Special colors *macvim-colors*
305319

306320
The colors in MacVim are defined in two dictionaries inside the "Resources"
307321
folder of the application bundle (MacVim.app/Contents/Resources). It is
@@ -351,7 +365,7 @@ the "Appearance" pane of the System Preferences. It also changes the
351365
highlight color when a window becomes inactive.
352366

353367
==============================================================================
354-
5. Menus *macvim-menus*
368+
6. Menus *macvim-menus*
355369

356370
Menus in macOS behave slightly different from other platforms. For that
357371
reason two new commands have been added to Vim. To understand what these
@@ -474,7 +488,7 @@ _cycleWindows: Select next window (similar to <D-`>)
474488
_cycleWindowsBackwards: Select previous window (similar to <D-S-`>)
475489

476490
==============================================================================
477-
6. Toolbar *macvim-toolbar*
491+
7. Toolbar *macvim-toolbar*
478492

479493
The toolbar in MacVim works just like in the other GUIs (see |gui-toolbar|),
480494
with the addition of two separator items (see |menu-separator|). You can use
@@ -498,7 +512,7 @@ Note: Only a subset of the builtin toolbar items presently have icons. If no
498512
icon can be found a warning triangle is displayed instead.
499513

500514
==============================================================================
501-
7. Touch Bar *macvim-touchbar*
515+
8. Touch Bar *macvim-touchbar*
502516

503517
Touch Bar in MacVim works similar to the toolbar (see |macvim-toolbar|). The
504518
difference is that you use the special menu "TouchBar" instead of "ToolBar": >
@@ -536,7 +550,7 @@ ExitFullScreen |'fullscreen'| mode. To disable the button, add the
536550
let g:macvim_default_touchbar_fullscreen=0
537551
538552
==============================================================================
539-
8. Dialogs *macvim-dialogs*
553+
9. Dialogs *macvim-dialogs*
540554

541555
Dialogs can be controlled with the keyboard in two ways. By default each
542556
button in a dialog is bound to a key. The button that is highlighted by blue
@@ -555,7 +569,7 @@ select the current button. The current button is indicated with a blue
555569
outline.
556570

557571
==============================================================================
558-
9. System services *macvim-services*
572+
10. System services *macvim-services*
559573

560574
MacVim supports two system services. These can be accessed from the MacVim
561575
submenu in the Services menu or by right-clicking a selection. For services
@@ -572,7 +586,7 @@ The services respect the "Open files from applications" setting in the general
572586
preferences.
573587

574588
==============================================================================
575-
10. mvim:// URL handler *mvim://* *macvim-url-handler*
589+
11. mvim:// URL handler *mvim://* *macvim-url-handler*
576590

577591
MacVim supports a custom URL handler for "mvim://" URLs. The handler is
578592
supposed to be compatible to TextMate's URL scheme as documented at >
@@ -593,7 +607,7 @@ will open the file /etc/profile on line 20 when clicked in a web browser.
593607
Note that url has to be a file:// url pointing to an existing local file.
594608

595609
==============================================================================
596-
11. Keyboard shortcuts *macvim-shortcuts*
610+
12. Keyboard shortcuts *macvim-shortcuts*
597611

598612
Most keyboard shortcuts in MacVim are bound to menu items and can be
599613
discovered by looking through the menus (see |macvim-menus| on how to create
@@ -673,7 +687,7 @@ sometimes be slightly involved. Here are all the things you need to consider:
673687
- A few command key mappings are set up by MacVim, see |cmd-movement|.
674688

675689
==============================================================================
676-
12. Trackpad gestures *macvim-gestures*
690+
13. Trackpad gestures *macvim-gestures*
677691

678692
MacVim supports trackpad swipe gestures. By default this can be used to
679693
navigate back/forward in the help (try it!).
@@ -708,7 +722,7 @@ As another example, here is how to switch buffers by swiping left/right: >
708722
See the section on |key-mapping| for more help on how to map keys.
709723

710724
==============================================================================
711-
13. International *macvim-international*
725+
14. International *macvim-international*
712726

713727
When editing non-English text it may be convenient to keep separate keyboard
714728
layouts for normal and insert mode. This is supported via the 'imd' option on
@@ -729,7 +743,7 @@ wrong layout when going back to normal mode, then select the layout you want
729743
to use in normal mode and type ":set imd" followed by ":set noimd".
730744

731745
==============================================================================
732-
14. Known bugs/missing features *macvim-todo*
746+
15. Known bugs/missing features *macvim-todo*
733747

734748
This list is by no means exhaustive, it only enumerates some of the more
735749
prominent bugs/missing features.
@@ -760,7 +774,7 @@ This is also the best place for making feature requests as well as for asking
760774
general questions about MacVim.
761775

762776
==============================================================================
763-
15. Hints *macvim-hints*
777+
16. Hints *macvim-hints*
764778

765779
In this section some general (not necessarily MacVim specific) hints are
766780
given.

runtime/doc/tags

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4957,6 +4957,7 @@ LogiPat-flags pi_logipat.txt /*LogiPat-flags*
49574957
Lua if_lua.txt /*Lua*
49584958
M motion.txt /*M*
49594959
MDI starting.txt /*MDI*
4960+
MMAppearanceModeSelection gui_mac.txt /*MMAppearanceModeSelection*
49604961
MMCellWidthMultiplier gui_mac.txt /*MMCellWidthMultiplier*
49614962
MMDialogsTrackPwd gui_mac.txt /*MMDialogsTrackPwd*
49624963
MMDisableLaunchAnimation gui_mac.txt /*MMDisableLaunchAnimation*
@@ -7728,12 +7729,15 @@ mac-vimfile os_mac.txt /*mac-vimfile*
77287729
macintosh os_mac.txt /*macintosh*
77297730
macro map.txt /*macro*
77307731
macvim gui_mac.txt /*macvim*
7732+
macvim-appearance gui_mac.txt /*macvim-appearance*
7733+
macvim-appearance-mode gui_mac.txt /*macvim-appearance-mode*
77317734
macvim-autocommands gui_mac.txt /*macvim-autocommands*
77327735
macvim-backspace gui_mac.txt /*macvim-backspace*
77337736
macvim-clientserver remote.txt /*macvim-clientserver*
77347737
macvim-colors gui_mac.txt /*macvim-colors*
77357738
macvim-colorscheme gui_mac.txt /*macvim-colorscheme*
77367739
macvim-commands gui_mac.txt /*macvim-commands*
7740+
macvim-dark-mode gui_mac.txt /*macvim-dark-mode*
77377741
macvim-default-menu gui_mac.txt /*macvim-default-menu*
77387742
macvim-delete gui_mac.txt /*macvim-delete*
77397743
macvim-dialogs gui_mac.txt /*macvim-dialogs*

src/MacVim/English.lproj/Preferences.nib/designable.nib

Lines changed: 100 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Binary file not shown.

src/MacVim/MMAppController.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@
4747
- (NSArray *)filterOpenFiles:(NSArray *)filenames;
4848
- (BOOL)openFiles:(NSArray *)filenames withArguments:(NSDictionary *)args;
4949

50+
- (void)refreshAllAppearances;
51+
5052
- (IBAction)newWindow:(id)sender;
5153
- (IBAction)newWindowAndActivate:(id)sender;
5254
- (IBAction)fileOpen:(id)sender;

src/MacVim/MMAppController.m

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,6 +1072,15 @@ - (BOOL)openFiles:(NSArray *)filenames withArguments:(NSDictionary *)args
10721072
return openOk;
10731073
}
10741074

1075+
- (void)refreshAllAppearances
1076+
{
1077+
unsigned count = [vimControllers count];
1078+
for (unsigned i = 0; i < count; ++i) {
1079+
MMVimController *vc = [vimControllers objectAtIndex:i];
1080+
[vc.windowController refreshApperanceMode];
1081+
}
1082+
}
1083+
10751084
- (IBAction)newWindow:(id)sender
10761085
{
10771086
ASLogDebug(@"Open new window");

src/MacVim/MMBackend.m

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1236,6 +1236,14 @@ - (void)setBlurRadius:(int)radius
12361236
[self queueMessage:SetBlurRadiusMsgID data:data];
12371237
}
12381238

1239+
- (void)setBackground:(int)dark
1240+
{
1241+
NSMutableData *data = [NSMutableData data];
1242+
[data appendBytes:&dark length:sizeof(int)];
1243+
1244+
[self queueMessage:SetBackgroundOptionMsgID data:data];
1245+
}
1246+
12391247
- (void)updateModifiedFlag
12401248
{
12411249
int state = [self checkForModifiedBuffers];

0 commit comments

Comments
 (0)