mirror of
https://github.com/macvim-dev/macvim.git
synced 2026-06-11 15:37:29 +02:00
Sync MacVim channel code with Vim
This commit is contained in:
@@ -56,7 +56,6 @@ extern NSTimeInterval MMBalloonEvalInternalDelay;
|
||||
unsigned numWholeLineChanges;
|
||||
unsigned offsetForDrawDataPrune;
|
||||
BOOL imState;
|
||||
NSMutableDictionary *channelDict;
|
||||
int winposX;
|
||||
int winposY;
|
||||
#ifdef FEAT_BEVAL
|
||||
@@ -156,8 +155,8 @@ extern NSTimeInterval MMBalloonEvalInternalDelay;
|
||||
- (BOOL)imState;
|
||||
- (void)setImState:(BOOL)activated;
|
||||
|
||||
- (void)addChannel:(channel_T *)channel;
|
||||
- (void)removeChannel:(channel_T *)channel;
|
||||
- (void *)addChannel:(channel_T *)channel which:(int)which;
|
||||
- (void)removeChannel:(void *)cookie;
|
||||
|
||||
#ifdef FEAT_BEVAL
|
||||
- (void)setLastToolTip:(NSString *)toolTip;
|
||||
|
||||
+25
-16
@@ -164,11 +164,14 @@ extern GuiFont gui_mch_retain_font(GuiFont font);
|
||||
|
||||
|
||||
@interface MMChannel : NSObject {
|
||||
channel_T *channel;
|
||||
int which;
|
||||
CFSocketRef socket;
|
||||
CFRunLoopSourceRef runLoopSource;
|
||||
}
|
||||
|
||||
- (id)initWithChannel:(channel_T *)channel;
|
||||
- (id)initWithChannel:(channel_T *)c which:(int)w;
|
||||
- (void)read;
|
||||
@end
|
||||
|
||||
|
||||
@@ -241,7 +244,6 @@ extern GuiFont gui_mch_retain_font(GuiFont font);
|
||||
connectionNameDict = [[NSMutableDictionary alloc] init];
|
||||
clientProxyDict = [[NSMutableDictionary alloc] init];
|
||||
serverReplyDict = [[NSMutableDictionary alloc] init];
|
||||
channelDict = [[NSMutableDictionary alloc] init];
|
||||
|
||||
NSBundle *mainBundle = [NSBundle mainBundle];
|
||||
NSString *path = [mainBundle pathForResource:@"Colors" ofType:@"plist"];
|
||||
@@ -273,7 +275,6 @@ extern GuiFont gui_mch_retain_font(GuiFont font);
|
||||
gui_mch_free_font(oldWideFont); oldWideFont = NOFONT;
|
||||
[blinkTimer release]; blinkTimer = nil;
|
||||
[alternateServerName release]; alternateServerName = nil;
|
||||
[channelDict release]; channelDict = nil;
|
||||
[serverReplyDict release]; serverReplyDict = nil;
|
||||
[clientProxyDict release]; clientProxyDict = nil;
|
||||
[connectionNameDict release]; connectionNameDict = nil;
|
||||
@@ -1684,18 +1685,17 @@ extern GuiFont gui_mch_retain_font(GuiFont font);
|
||||
[self flushQueue:YES];
|
||||
}
|
||||
|
||||
- (void)addChannel:(channel_T *)channel
|
||||
- (void *)addChannel:(channel_T *)channel which:(int)which
|
||||
{
|
||||
NSValue *key = [NSValue valueWithPointer:channel];
|
||||
MMChannel *mmChannel =
|
||||
[[[MMChannel alloc] initWithChannel:channel] autorelease];
|
||||
[channelDict setObject:mmChannel forKey:key];
|
||||
[[MMChannel alloc] initWithChannel:channel which:which];
|
||||
return (__bridge void *)mmChannel;
|
||||
}
|
||||
|
||||
- (void)removeChannel:(channel_T *)channel
|
||||
- (void)removeChannel:(void *)cookie
|
||||
{
|
||||
NSValue *key = [NSValue valueWithPointer:channel];
|
||||
[channelDict removeObjectForKey:key];
|
||||
MMChannel *mmChannel = (__bridge MMChannel *)cookie;
|
||||
[mmChannel release];
|
||||
}
|
||||
|
||||
#ifdef FEAT_BEVAL
|
||||
@@ -3428,20 +3428,22 @@ static void socketReadCallback(CFSocketRef s,
|
||||
const void *data,
|
||||
void *info)
|
||||
{
|
||||
#ifdef FEAT_CHANNEL
|
||||
channel_read((channel_T *)info, FALSE, "socketReadCallback");
|
||||
#endif
|
||||
MMChannel *mmChannel = (__bridge MMChannel *)info;
|
||||
[mmChannel read];
|
||||
}
|
||||
|
||||
- (id)initWithChannel:(channel_T *)channel
|
||||
- (id)initWithChannel:(channel_T *)c which:(int)w
|
||||
{
|
||||
self = [super init];
|
||||
if (!self) return nil;
|
||||
|
||||
channel = c;
|
||||
which = w;
|
||||
|
||||
// Tell CFRunLoop that we are interested in channel socket input.
|
||||
CFSocketContext ctx = {0, channel, NULL, NULL, NULL};
|
||||
CFSocketContext ctx = {0, (__bridge void *)self, NULL, NULL, NULL};
|
||||
socket = CFSocketCreateWithNative(kCFAllocatorDefault,
|
||||
channel->ch_sock,
|
||||
channel->ch_pfd[which].ch_fd,
|
||||
kCFSocketReadCallBack,
|
||||
&socketReadCallback,
|
||||
&ctx);
|
||||
@@ -3455,4 +3457,11 @@ static void socketReadCallback(CFSocketRef s,
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)read
|
||||
{
|
||||
#ifdef FEAT_CHANNEL
|
||||
channel_read(channel, which, "MMChannel_read");
|
||||
#endif
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -2241,16 +2241,16 @@ static int vimModMaskToEventModifierFlags(int mods)
|
||||
|
||||
// -- Channel Support ------------------------------------------------------
|
||||
|
||||
void
|
||||
gui_macvim_add_channel(channel_T *channel)
|
||||
void *
|
||||
gui_macvim_add_channel(channel_T *channel, int which)
|
||||
{
|
||||
[[MMBackend sharedInstance] addChannel:channel];
|
||||
return [[MMBackend sharedInstance] addChannel:channel which:which];
|
||||
}
|
||||
|
||||
void
|
||||
gui_macvim_remove_channel(channel_T *channel)
|
||||
gui_macvim_remove_channel(void *cookie)
|
||||
{
|
||||
[[MMBackend sharedInstance] removeChannel:channel];
|
||||
[[MMBackend sharedInstance] removeChannel:cookie];
|
||||
}
|
||||
|
||||
|
||||
|
||||
+7
-8
@@ -239,7 +239,7 @@ add_channel(void)
|
||||
channel->ch_pfd[which].ch_inputHandler = -1;
|
||||
#endif
|
||||
#ifdef FEAT_GUI_MACVIM
|
||||
channel->ch_inputHandler = -1;
|
||||
channel->ch_pfd[which].ch_inputHandler = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -359,10 +359,9 @@ channel_gui_register_one(channel_T *channel, int which)
|
||||
# ifdef FEAT_GUI_MACVIM
|
||||
/* Tell Core Foundation we are interested in being called when there
|
||||
* is input on the editor connection socket. */
|
||||
if (channel->ch_pfd[which].ch_inputHandler == -1) {
|
||||
channel->ch_pfd[which].ch_inputHandler = 0;
|
||||
gui_macvim_add_channel(channel);
|
||||
}
|
||||
if (channel->ch_pfd[which].ch_inputHandler == 0)
|
||||
channel->ch_pfd[which].ch_inputHandler = gui_macvim_add_channel(
|
||||
channel, which);
|
||||
# endif
|
||||
# endif
|
||||
# endif
|
||||
@@ -431,10 +430,10 @@ channel_gui_unregister(channel_T *channel)
|
||||
}
|
||||
# else
|
||||
# ifdef FEAT_GUI_MACVIM
|
||||
if (channel->ch_pfd[which].ch_inputHandler == 0)
|
||||
if (channel->ch_pfd[which].ch_inputHandler != 0)
|
||||
{
|
||||
gui_macvim_remove_channel(channel);
|
||||
channel->ch_pfd[which].ch_inputHandler = -1;
|
||||
gui_macvim_remove_channel(channel->ch_pfd[which].ch_inputHandler);
|
||||
channel->ch_pfd[which].ch_inputHandler = 0;
|
||||
}
|
||||
# endif
|
||||
# endif
|
||||
|
||||
@@ -227,10 +227,10 @@ gui_mch_replace_dialog(exarg_T *eap);
|
||||
void
|
||||
im_set_control(int enable);
|
||||
|
||||
void *
|
||||
gui_macvim_add_channel(channel_T *channel, int which);
|
||||
void
|
||||
gui_macvim_add_channel(channel_T *channel);
|
||||
void
|
||||
gui_macvim_remove_channel(channel_T *channel);
|
||||
gui_macvim_remove_channel(void *cookie);
|
||||
|
||||
void
|
||||
gui_mch_drawsign(int row, int col, int typenr);
|
||||
|
||||
+1
-1
@@ -1335,7 +1335,7 @@ typedef struct {
|
||||
int ch_inputHandler; /* ret.value of WSAAsyncSelect() */
|
||||
#endif
|
||||
#ifdef FEAT_GUI_MACVIM
|
||||
int ch_inputHandler; /* Cookie for input */
|
||||
void *ch_inputHandler; /* Cookie for input */
|
||||
#endif
|
||||
} chan_fd_T;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user