1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-12-26 23:36:08 +03:00

Use API for resizing

This commit is contained in:
Tae Won Ha 2017-12-01 17:54:22 +01:00
parent 10e0877149
commit 006f0a026c
No known key found for this signature in database
GPG Key ID: E40743465B5B8B44
7 changed files with 2 additions and 26 deletions

View File

@ -50,7 +50,6 @@ typedef NS_ENUM(NSInteger, NeoVimAgentMsgId) {
NeoVimAgentMsgIdInput, NeoVimAgentMsgIdInput,
NeoVimAgentMsgIdInputMarked, NeoVimAgentMsgIdInputMarked,
NeoVimAgentMsgIdDelete, NeoVimAgentMsgIdDelete,
NeoVimAgentMsgIdResize,
NeoVimAgentMsgIdScroll, NeoVimAgentMsgIdScroll,
NeoVimAgentMsgIdGetPwd, NeoVimAgentMsgIdGetPwd,

View File

@ -70,8 +70,6 @@ static CFDataRef local_server_callback(CFMessagePortRef local, SInt32 msgid, CFD
case NeoVimAgentMsgIdGetEscapeFileNames: return data_sync(data, outputCondition, neovim_escaped_filenames); case NeoVimAgentMsgIdGetEscapeFileNames: return data_sync(data, outputCondition, neovim_escaped_filenames);
case NeoVimAgentMsgIdResize: return data_sync(data, outputCondition, neovim_resize);
case NeoVimAgentMsgIdInput: return data_sync(data, outputCondition, neovim_vim_input); case NeoVimAgentMsgIdInput: return data_sync(data, outputCondition, neovim_vim_input);
case NeoVimAgentMsgIdInputMarked: return data_sync(data, outputCondition, neovim_vim_input_marked_text); case NeoVimAgentMsgIdInputMarked: return data_sync(data, outputCondition, neovim_vim_input_marked_text);

View File

@ -15,7 +15,6 @@ extern void start_neovim(NSInteger width, NSInteger height, NSArray<NSString *>
extern void neovim_scroll(void **argv); extern void neovim_scroll(void **argv);
extern void neovim_escaped_filenames(void **argv); extern void neovim_escaped_filenames(void **argv);
extern void neovim_resize(void **argv);
extern void neovim_vim_input(void **argv); extern void neovim_vim_input(void **argv);
extern void neovim_vim_input_marked_text(void **argv); extern void neovim_vim_input_marked_text(void **argv);

View File

@ -729,19 +729,6 @@ void neovim_escaped_filenames(void **argv) {
}); });
} }
void neovim_resize(void **argv) {
work_and_write_data_sync(argv, ^NSData *(NSData *data) {
const int *values = data.bytes;
int width = values[0];
int height = values[1];
set_ui_size(_server_ui_data->bridge, width, height);
ui_refresh();
return nil;
});
}
void neovim_vim_input(void **argv) { void neovim_vim_input(void **argv) {
work_and_write_data_sync(argv, ^NSData *(NSData *data) { work_and_write_data_sync(argv, ^NSData *(NSData *data) {
NSString *input = [[[NSString alloc] initWithData:data NSString *input = [[[NSString alloc] initWithData:data

View File

@ -42,8 +42,6 @@ NS_ASSUME_NONNULL_BEGIN
- (void)vimInputMarkedText:(NSString *)markedText; - (void)vimInputMarkedText:(NSString *)markedText;
- (void)deleteCharacters:(NSInteger)count; - (void)deleteCharacters:(NSInteger)count;
- (void)resizeToWidth:(int)width height:(int)height;
- (NSString * _Nullable)escapedFileName:(NSString *)fileName; - (NSString * _Nullable)escapedFileName:(NSString *)fileName;
- (NSArray<NSString *> *)escapedFileNames:(NSArray<NSString *> *)fileNames; - (NSArray<NSString *> *)escapedFileNames:(NSArray<NSString *> *)fileNames;

View File

@ -283,12 +283,6 @@ static CFDataRef local_server_callback(CFMessagePortRef local __unused, SInt32 m
[self sendMessageWithId:NeoVimAgentMsgIdDelete data:data expectsReply:NO]; [self sendMessageWithId:NeoVimAgentMsgIdDelete data:data expectsReply:NO];
} }
- (void)resizeToWidth:(int)width height:(int)height {
int values[] = {width, height};
NSData *data = [[NSData alloc] initWithBytes:values length:(2 * sizeof(int))];
[self sendMessageWithId:NeoVimAgentMsgIdResize data:data expectsReply:NO];
}
- (NSString *)escapedFileName:(NSString *)fileName { - (NSString *)escapedFileName:(NSString *)fileName {
NSArray<NSString *> *fileNames = [self escapedFileNames:@[fileName]]; NSArray<NSString *> *fileNames = [self escapedFileNames:@[fileName]];
if (fileNames.count == 0) { if (fileNames.count == 0) {

View File

@ -50,7 +50,7 @@ extension NeoVimView {
self.xOffset = floor((size.width - self.cellSize.width * CGFloat(discreteSize.width)) / 2) self.xOffset = floor((size.width - self.cellSize.width * CGFloat(discreteSize.width)) / 2)
self.yOffset = floor((size.height - self.cellSize.height * CGFloat(discreteSize.height)) / 2) self.yOffset = floor((size.height - self.cellSize.height * CGFloat(discreteSize.height)) / 2)
self.agent.resize(toWidth: Int32(discreteSize.width), height: Int32(discreteSize.height)) self.nvim.uiTryResize(width: discreteSize.width, height: discreteSize.height)
} }
fileprivate func launchNeoVim(_ size: Size) { fileprivate func launchNeoVim(_ size: Size) {
@ -59,6 +59,7 @@ extension NeoVimView {
self.nvim.connect() self.nvim.connect()
// We probably should set the following in a .vim file. Otherwise the start screen doesn't get shown.
self.nvim.setOption(name: "mouse", value: .string("a")) self.nvim.setOption(name: "mouse", value: .string("a"))
self.nvim.setOption(name: "title", value: .bool(true)) self.nvim.setOption(name: "title", value: .bool(true))
self.nvim.setOption(name: "termguicolors", value: .bool(true)) self.nvim.setOption(name: "termguicolors", value: .bool(true))