mirror of
https://github.com/macvim-dev/macvim.git
synced 2026-06-07 15:37:14 +02:00
Merge pull request #1064 from ichizok/fix/balloon-gui
Fix balloon API on GUI
This commit is contained in:
@@ -13,13 +13,6 @@
|
||||
#import "vim.h"
|
||||
|
||||
|
||||
#ifdef FEAT_BEVAL
|
||||
// Seconds to delay balloon evaluation after mouse event (subtracted from
|
||||
// p_bdlay).
|
||||
extern NSTimeInterval MMBalloonEvalInternalDelay;
|
||||
#endif
|
||||
|
||||
|
||||
@interface MMBackend : NSObject <MMBackendProtocol, MMVimServerProtocol,
|
||||
MMVimClientProtocol> {
|
||||
NSMutableArray *outputQueue;
|
||||
|
||||
+4
-10
@@ -46,12 +46,6 @@
|
||||
|
||||
static unsigned MMServerMax = 1000;
|
||||
|
||||
#ifdef FEAT_BEVAL
|
||||
// Seconds to delay balloon evaluation after mouse event (subtracted from
|
||||
// p_bdlay so that this effectively becomes the smallest possible delay).
|
||||
NSTimeInterval MMBalloonEvalInternalDelay = 0.1;
|
||||
#endif
|
||||
|
||||
// TODO: Move to separate file.
|
||||
static int eventModifierFlagsToVimModMask(int modifierFlags);
|
||||
static int eventModifierFlagsToVimMouseModMask(int modifierFlags);
|
||||
@@ -1919,7 +1913,7 @@ extern GuiFont gui_mch_retain_font(GuiFont font);
|
||||
object:nil];
|
||||
[self performSelector:@selector(bevalCallback:)
|
||||
withObject:nil
|
||||
afterDelay:MMBalloonEvalInternalDelay];
|
||||
afterDelay:p_bdlay/1000.0];
|
||||
}
|
||||
#endif
|
||||
} else if (MouseDownMsgID == msgid) {
|
||||
@@ -1978,7 +1972,7 @@ extern GuiFont gui_mch_retain_font(GuiFont font);
|
||||
object:nil];
|
||||
[self performSelector:@selector(bevalCallback:)
|
||||
withObject:nil
|
||||
afterDelay:MMBalloonEvalInternalDelay];
|
||||
afterDelay:p_bdlay/1000.0];
|
||||
}
|
||||
#endif
|
||||
} else if (AddInputMsgID == msgid) {
|
||||
@@ -3359,14 +3353,14 @@ extern GuiFont gui_mch_retain_font(GuiFont font);
|
||||
// variable. (The reason we need to know is due to how the Cocoa tool
|
||||
// tips work: if there is no tool tip we must set it to nil explicitly
|
||||
// or it might never go away.)
|
||||
[self setLastToolTip:nil];
|
||||
|
||||
(*balloonEval->msgCB)(balloonEval, 0);
|
||||
|
||||
[self queueMessage:SetTooltipMsgID properties:
|
||||
[NSDictionary dictionaryWithObject:(lastToolTip ? lastToolTip : @"")
|
||||
forKey:@"toolTip"]];
|
||||
[self flushQueue:YES];
|
||||
|
||||
[self setLastToolTip:nil];
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -161,7 +161,7 @@ static BOOL isUnsafeMessage(int msgid);
|
||||
- (void)handleBrowseForFile:(NSDictionary *)attr;
|
||||
- (void)handleShowDialog:(NSDictionary *)attr;
|
||||
- (void)handleDeleteSign:(NSDictionary *)attr;
|
||||
- (void)setToolTipDelay:(NSTimeInterval)seconds;
|
||||
- (void)setToolTipDelay;
|
||||
@end
|
||||
|
||||
|
||||
@@ -219,6 +219,8 @@ static BOOL isUnsafeMessage(int msgid);
|
||||
|
||||
[mainMenu addItem:appMenuItem];
|
||||
|
||||
[self setToolTipDelay];
|
||||
|
||||
isInitialized = YES;
|
||||
|
||||
// After MMVimController's initialization is completed,
|
||||
@@ -1006,11 +1008,6 @@ static BOOL isUnsafeMessage(int msgid);
|
||||
[textView setToolTipAtMousePoint:toolTip];
|
||||
else
|
||||
[textView setToolTipAtMousePoint:nil];
|
||||
} else if (SetTooltipDelayMsgID == msgid) {
|
||||
NSDictionary *dict = [NSDictionary dictionaryWithData:data];
|
||||
NSNumber *delay = dict ? [dict objectForKey:@"delay"] : nil;
|
||||
if (delay)
|
||||
[self setToolTipDelay:[delay floatValue]];
|
||||
} else if (AddToMRUMsgID == msgid) {
|
||||
NSDictionary *dict = [NSDictionary dictionaryWithData:data];
|
||||
NSArray *filenames = dict ? [dict objectForKey:@"filenames"] : nil;
|
||||
@@ -1906,18 +1903,15 @@ static BOOL isUnsafeMessage(int msgid);
|
||||
[view deleteSign:[attr objectForKey:@"imgName"]];
|
||||
}
|
||||
|
||||
- (void)setToolTipDelay:(NSTimeInterval)seconds
|
||||
- (void)setToolTipDelay
|
||||
{
|
||||
// HACK! NSToolTipManager is an AppKit private class.
|
||||
static Class TTM = nil;
|
||||
if (!TTM)
|
||||
TTM = NSClassFromString(@"NSToolTipManager");
|
||||
|
||||
if (seconds < 0)
|
||||
seconds = 0;
|
||||
|
||||
if (TTM) {
|
||||
[[TTM sharedToolTipManager] setInitialToolTipDelay:seconds];
|
||||
[[TTM sharedToolTipManager] setInitialToolTipDelay:1e-6];
|
||||
} else {
|
||||
ASLogNotice(@"Failed to get NSToolTipManager");
|
||||
}
|
||||
|
||||
@@ -261,7 +261,6 @@ extern const char * const MMVimMsgIDStrings[];
|
||||
MSG(SetWindowPositionMsgID) \
|
||||
MSG(DeleteSignMsgID) \
|
||||
MSG(SetTooltipMsgID) \
|
||||
MSG(SetTooltipDelayMsgID) \
|
||||
MSG(GestureMsgID) \
|
||||
MSG(AddToMRUMsgID) \
|
||||
MSG(BackingPropertiesChangedMsgID) \
|
||||
|
||||
@@ -2494,12 +2494,7 @@ gui_mch_create_beval_area(
|
||||
void
|
||||
gui_mch_enable_beval_area(BalloonEval *beval UNUSED)
|
||||
{
|
||||
// Set the balloon delay when enabling balloon eval.
|
||||
float delay = p_bdlay/1000.0f - MMBalloonEvalInternalDelay;
|
||||
if (delay < 0) delay = 0;
|
||||
[[MMBackend sharedInstance] queueMessage:SetTooltipDelayMsgID properties:
|
||||
[NSDictionary dictionaryWithObject:[NSNumber numberWithFloat:delay]
|
||||
forKey:@"delay"]];
|
||||
// NOP
|
||||
}
|
||||
|
||||
void
|
||||
@@ -2514,8 +2509,11 @@ gui_mch_disable_beval_area(BalloonEval *beval UNUSED)
|
||||
* Show a balloon with "mesg".
|
||||
*/
|
||||
void
|
||||
gui_mch_post_balloon(BalloonEval *beval UNUSED, char_u *mesg)
|
||||
gui_mch_post_balloon(BalloonEval *beval, char_u *mesg)
|
||||
{
|
||||
vim_free(beval->msg);
|
||||
beval->msg = mesg == NULL ? NULL : vim_strsave(mesg);
|
||||
|
||||
NSString *toolTip = [NSString stringWithVimString:mesg];
|
||||
[[MMBackend sharedInstance] setLastToolTip:toolTip];
|
||||
}
|
||||
|
||||
@@ -4,8 +4,6 @@ source check.vim
|
||||
CheckGui
|
||||
CheckFeature balloon_eval
|
||||
|
||||
if !has('gui_macvim') " See https://github.com/macvim-dev/macvim/issues/902
|
||||
|
||||
func Test_balloon_show_gui()
|
||||
let msg = 'this this this this'
|
||||
call balloon_show(msg)
|
||||
@@ -20,5 +18,4 @@ func Test_balloon_show_gui()
|
||||
call balloon_show('')
|
||||
endfunc
|
||||
|
||||
endif " !has('gui_macvim')
|
||||
" vim: shiftwidth=2 sts=2 expandtab
|
||||
|
||||
Reference in New Issue
Block a user