-
-
Notifications
You must be signed in to change notification settings - Fork 686
MBP Touchbar Support #568
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
MBP Touchbar Support #568
Conversation
Thanks for this! Apart from some minor style nitpicks (I'll go through and leave comments on the specific lines), this mostly looks reasonable. I don't have the hardware to test it. When you say "this needs some work," what sort of work are you thinking of? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I said in the PR comment, most of my notes here are really minor nitpicky stuff about indenting consistency. I'm mostly concerned about the discussion in menu.vim
and the else
structure in enableMenuItemWithDescriptor
... plus having some idea of what other "work" you think remains here.
@@ -1266,4 +1266,21 @@ if has("gui_macvim") | |||
macm Help.MacVim\ Website action=openWebsite: | |||
endif | |||
|
|||
if has("touchbar") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a better place to do this setup? I'm specifically thinking that customizing the Touch Bar items will likely be something people will want to do quite a lot, and that having to first go through and delete these menu items is somewhat tedious. It might be better if the initial setup of the Touch Bar menu could be deferred somewhere so users could set a global variable in their vimrc to suppress default menu generation and instead generate the items themselves.
@@ -28,6 +28,11 @@ | |||
// TODO: Move all toolbar code to window controller? | |||
NSToolbar *toolbar; | |||
NSMutableDictionary *toolbarItemDict; | |||
#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_12 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The indenting on this preprocessor line (and the corresponding #endif
) is off.
@@ -129,7 +129,11 @@ - (id)initWithBackend:(id)backend pid:(int)processIdentifier | |||
[[MMWindowController alloc] initWithVimController:self]; | |||
backendProxy = [backend retain]; | |||
popupMenuItems = [[NSMutableArray alloc] init]; | |||
#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_12 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The indent on this #if
/#endif
pair is off.
@@ -178,6 +182,11 @@ - (void)dealloc | |||
|
|||
[toolbarItemDict release]; toolbarItemDict = nil; | |||
[toolbar release]; toolbar = nil; | |||
#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_12 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The indent on this #if
/#endif
pair is off.
#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_12 | ||
- (NSTouchBar *)makeTouchBar | ||
{ | ||
touchbar = [[NSTouchBar alloc] init]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lines 503 - 506 have mixed tab/space indenting and are too far in.
@@ -1081,7 +1108,10 @@ - (void)addMenuWithDescriptor:(NSArray *)desc atIndex:(int)idx | |||
|
|||
return; | |||
} | |||
|
|||
#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_12 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The indent of this #if
/#endif
block is off.
@@ -1132,7 +1162,13 @@ - (void)addMenuItemWithDescriptor:(NSArray *)desc | |||
[self addToolbarItemWithLabel:title tip:tip icon:icon atIndex:idx]; | |||
return; | |||
} | |||
|
|||
#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_12 | |||
if ([rootName isEqual:@"TouchBar"]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At this point it might be worth writing isTouchBarMenuName
or similar, or at least making the name a constant.
@@ -1228,7 +1273,11 @@ - (void)enableMenuItemWithDescriptor:(NSArray *)desc state:(BOOL)on | |||
NSString *title = [desc lastObject]; | |||
[[toolbar itemWithItemIdentifier:title] setEnabled:on]; | |||
} | |||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For clarity, this should be written in a way that doesn't inject the preprocessor check between the else
and the if
; this kind of construct is error-prone and can be difficult to follow (I realize it might be elsewhere in MacVim's codebase, but I'd rather we don't propagate it). I'd rather see something more like:
} else {
#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_12
if ([rootName isEqual:@"TouchBar")) { return; }
#endif
// Use tag to set...
} else { | ||
label = NSTouchBarItemIdentifierFixedSpaceLarge; | ||
} | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This whole else
block has mixed tab/space indenting and seemingly overly deep indents.
#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_12 | ||
- (NSTouchBar *)makeTouchBar | ||
{ | ||
return [vimController makeTouchBar]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A tab is used to indent here instead of spaces.
Awesome idea! Is it possible to further user-customize the touch bar shortcuts to specific macros? |
I have the same question on updates. I'm quite interested in having TouchBar support as right now it doesn't do anything when I have MacVim up :(. (macOS allows you to force it to only show function keys when MacVim is up but if you do that it's hard to adjust volume, etc) I don't mind taking this over and help push this through if the original author is no longer interested. I think this at least needs some documentation in Played around with it a little bit, and some additional potential improvements below. These are really just random ideas. Could be future pull requests after this is in:
|
Given the amount of time this PR has sat here I think it would be fine for you to do so. As I noted in my initial review, most of what I'd want to see fixed before merging are just style issues to try and keep the code consistent. If you can build a PR that incorporates this original change and fixes those, it would probably get merged pretty quickly. I don't have hardware to test it on, and I'm not personally that interested in the feature, but I would like to see more contributors since I don't have much time to devote myself. So by all means, if you want to pick this up and run with it, please do so! |
I just submitted a new PR (#715) which takes this current patch and fixed up misc issues and added features. |
Cool; I will take a look at it today. |
Proof of Concept
This needs some work