Skip to content

Commit e0d1117

Browse files
authored
Merge pull request #1084 from ychin/touchbar_subfolders_title_emoji
Touch Bar add submenu/title/emoji picker support
2 parents a9f6bac + e13d237 commit e0d1117

7 files changed

Lines changed: 298 additions & 80 deletions

File tree

runtime/doc/gui_mac.txt

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -514,10 +514,17 @@ icon can be found a warning triangle is displayed instead.
514514
==============================================================================
515515
8. Touch Bar *macvim-touchbar*
516516

517-
Touch Bar in MacVim works similar to the toolbar (see |macvim-toolbar|). The
518-
difference is that you use the special menu "TouchBar" instead of "ToolBar": >
517+
Touch Bar in MacVim is configurable, and works similar to the toolbar (see
518+
|macvim-toolbar|). The difference is that you use the special menu "TouchBar"
519+
instead of "ToolBar": >
519520
:an TouchBar.Hello :echo "Hello"<CR>
520-
521+
<
522+
You can also create submenus. Due to macOS restrictions, submenus can only be
523+
one level deep: >
524+
:an TouchBar.Navigate.Next :next<CR>
525+
:an TouchBar.Navigate.Prev :prev<CR>
526+
<
527+
*macvim-touchbar-separator*
521528
The separators work similar to how toolbars work: >
522529
:an TouchBar.-Sep- <Nop>
523530
:an TouchBar.-space1- <Nop>
@@ -530,24 +537,45 @@ separator and are specified by names that begin with "-space" and ends with
530537
that items after it will be right-aligned, and is specified by names that
531538
begin with "-flexspace" and ends with "-".
532539

540+
*macvim-touchbar-icon*
533541
You can specify icons for Touch Bar buttons the same way for toolbar icons.
534542
Touch Bar icons should ideally be 36x36 pixels, and no larger than 44x44
535543
pixels. You can also use default template icons provided by Apple by using
536544
their template names. An example: >
537-
:an icon=NSTouchBarListViewTemplate TouchBar.ShowList <Nop>
545+
:an icon=NSTouchBarListViewTemplate TouchBar.ShowList :ls<CR>
546+
<
547+
*macvim-touchbar-title*
548+
By default, the TouchBar buttons will use the menu names as the title. If an
549+
icon is specified, the title will not be shown. You can override this by using
550+
|tmenu| to set a tooltip. The tooltip will be displayed as the title of the
551+
button. If an icon is specified, the tooltip override will be shown alongside
552+
the icion. Example: >
553+
:an icon=NSTouchBarAddTemplate TouchBar.AddItem <Nop>
554+
:tmenu TouchBar.AddItem Add an Item
555+
<
556+
*macvim-touchbar-characterpicker* *macvim-touchbar-emoji*
557+
You can also insert emojis by adding a character picker button (specified by
558+
using a name that begin wtih "-characterpicker" and ends with "-"): >
559+
:inoremenu TouchBar.-characterpicker- <Nop>
538560
539561
This feature only works on Mac devices that come with Touch Bars. On the ones
540562
that don't, nothing will show up.
541563

542-
*macvim-touchbar-defaults*
564+
*macvim-touchbar-defaults*
543565
Here is a list of default Touch Bar buttons that MacVim sets up:
544566

545-
*macvim-touchbar-fullscreen*
567+
*macvim-touchbar-fullscreen*
546568
*g:macvim_default_touchbar_fullscreen*
547569
EnterFullScreen Touch Bar buttons that allow you to toggle
548-
ExitFullScreen |'fullscreen'| mode. To disable the button, add the
549-
following to your vimrc file: >
570+
ExitFullScreen |'fullscreen'| mode. To disable, add the following to
571+
your vimrc file: >
550572
let g:macvim_default_touchbar_fullscreen=0
573+
<
574+
*g:macvim_default_touchbar_characterpicker*
575+
-characterpicker- Character picker that lets you add special characters
576+
and emojis in insert and terminal modes. To disable,
577+
add the following to your vimrc file: >
578+
let g:macvim_default_touchbar_characterpicker=0
551579
552580
==============================================================================
553581
9. Dialogs *macvim-dialogs*

runtime/doc/tags

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6801,6 +6801,7 @@ g:html_use_encoding syntax.txt /*g:html_use_encoding*
68016801
g:html_use_input_for_pc syntax.txt /*g:html_use_input_for_pc*
68026802
g:html_use_xhtml syntax.txt /*g:html_use_xhtml*
68036803
g:html_whole_filler syntax.txt /*g:html_whole_filler*
6804+
g:macvim_default_touchbar_characterpicker gui_mac.txt /*g:macvim_default_touchbar_characterpicker*
68046805
g:macvim_default_touchbar_fullscreen gui_mac.txt /*g:macvim_default_touchbar_fullscreen*
68056806
g:netrw_altfile pi_netrw.txt /*g:netrw_altfile*
68066807
g:netrw_alto pi_netrw.txt /*g:netrw_alto*
@@ -7803,8 +7804,13 @@ macvim-tablabel gui_mac.txt /*macvim-tablabel*
78037804
macvim-todo gui_mac.txt /*macvim-todo*
78047805
macvim-toolbar gui_mac.txt /*macvim-toolbar*
78057806
macvim-touchbar gui_mac.txt /*macvim-touchbar*
7807+
macvim-touchbar-characterpicker gui_mac.txt /*macvim-touchbar-characterpicker*
78067808
macvim-touchbar-defaults gui_mac.txt /*macvim-touchbar-defaults*
7809+
macvim-touchbar-emoji gui_mac.txt /*macvim-touchbar-emoji*
78077810
macvim-touchbar-fullscreen gui_mac.txt /*macvim-touchbar-fullscreen*
7811+
macvim-touchbar-icon gui_mac.txt /*macvim-touchbar-icon*
7812+
macvim-touchbar-separator gui_mac.txt /*macvim-touchbar-separator*
7813+
macvim-touchbar-title gui_mac.txt /*macvim-touchbar-title*
78087814
macvim-url-handler gui_mac.txt /*macvim-url-handler*
78097815
macvim-user-defaults gui_mac.txt /*macvim-user-defaults*
78107816
macvim-window-title gui_mac.txt /*macvim-window-title*
@@ -8618,6 +8624,7 @@ progname-variable eval.txt /*progname-variable*
86188624
progpath-variable eval.txt /*progpath-variable*
86198625
progress.vim syntax.txt /*progress.vim*
86208626
prompt-buffer channel.txt /*prompt-buffer*
8627+
prompt_getprompt() eval.txt /*prompt_getprompt()*
86218628
prompt_setcallback() eval.txt /*prompt_setcallback()*
86228629
prompt_setinterrupt() eval.txt /*prompt_setinterrupt()*
86238630
prompt_setprompt() eval.txt /*prompt_setprompt()*

runtime/menu.vim

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1332,8 +1332,8 @@ if has("touchbar")
13321332
" 1. Smart fullscreen icon that toggles between going full screen or not.
13331333

13341334
if !exists("g:macvim_default_touchbar_fullscreen") || g:macvim_default_touchbar_fullscreen
1335-
an icon=NSTouchBarEnterFullScreenTemplate 1.10 TouchBar.EnterFullScreen :set fullscreen<CR>
1336-
tln icon=NSTouchBarEnterFullScreenTemplate 1.10 TouchBar.EnterFullScreen <C-W>:set fullscreen<CR>
1335+
an icon=NSTouchBarEnterFullScreenTemplate 1.20 TouchBar.EnterFullScreen :set fullscreen<CR>
1336+
tln icon=NSTouchBarEnterFullScreenTemplate 1.20 TouchBar.EnterFullScreen <C-W>:set fullscreen<CR>
13371337
endif
13381338

13391339
let s:touchbar_fullscreen=0
@@ -1342,16 +1342,16 @@ if has("touchbar")
13421342
silent! aun TouchBar.EnterFullScreen
13431343
silent! tlun TouchBar.EnterFullScreen
13441344
if !exists("g:macvim_default_touchbar_fullscreen") || g:macvim_default_touchbar_fullscreen
1345-
an icon=NSTouchBarExitFullScreenTemplate 1.10 TouchBar.ExitFullScreen :set nofullscreen<CR>
1346-
tln icon=NSTouchBarExitFullScreenTemplate 1.10 TouchBar.ExitFullScreen <C-W>:set nofullscreen<CR>
1345+
an icon=NSTouchBarExitFullScreenTemplate 1.20 TouchBar.ExitFullScreen :set nofullscreen<CR>
1346+
tln icon=NSTouchBarExitFullScreenTemplate 1.20 TouchBar.ExitFullScreen <C-W>:set nofullscreen<CR>
13471347
endif
13481348
let s:touchbar_fullscreen = 1
13491349
elseif !&fullscreen && s:touchbar_fullscreen != 0
13501350
silent! aun TouchBar.ExitFullScreen
13511351
silent! tlun TouchBar.ExitFullScreen
13521352
if !exists("g:macvim_default_touchbar_fullscreen") || g:macvim_default_touchbar_fullscreen
1353-
an icon=NSTouchBarEnterFullScreenTemplate 1.10 TouchBar.EnterFullScreen :set fullscreen<CR>
1354-
tln icon=NSTouchBarEnterFullScreenTemplate 1.10 TouchBar.EnterFullScreen <C-W>:set fullscreen<CR>
1353+
an icon=NSTouchBarEnterFullScreenTemplate 1.20 TouchBar.EnterFullScreen :set fullscreen<CR>
1354+
tln icon=NSTouchBarEnterFullScreenTemplate 1.20 TouchBar.EnterFullScreen <C-W>:set fullscreen<CR>
13551355
endif
13561356
let s:touchbar_fullscreen = 0
13571357
endif
@@ -1360,6 +1360,14 @@ if has("touchbar")
13601360
au!
13611361
au VimEnter,VimResized * call <SID>SetupFullScreenTouchBar()
13621362
aug END
1363+
1364+
" 2. Character (i.e. emojis) picker. Only in modes where user is actively
1365+
" entering text.
1366+
if !exists("g:macvim_default_touchbar_characterpicker") || g:macvim_default_touchbar_characterpicker
1367+
inoremenu 1.40 TouchBar.-characterpicker- <Nop>
1368+
cnoremenu 1.40 TouchBar.-characterpicker- <Nop>
1369+
tlnoremenu 1.40 TouchBar.-characterpicker- <Nop>
1370+
endif
13631371
endif
13641372

13651373
" vim: set sw=2 :

src/MacVim/MMVimController.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313

1414
@class MMWindowController;
15+
@class MMTouchBarInfo;
1516

1617

1718

@@ -34,10 +35,7 @@
3435
NSToolbar *toolbar;
3536
NSMutableDictionary *toolbarItemDict;
3637
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_12_2
37-
NSTouchBar *touchbar;
38-
NSMutableDictionary *touchbarItemDict;
39-
NSMutableArray *touchbarItemOrder;
40-
NSMutableSet *touchbarDisabledItems;
38+
MMTouchBarInfo *touchbarInfo;
4139
#endif
4240

4341
int pid;

0 commit comments

Comments
 (0)