mirror of
https://github.com/qvacua/vimr.git
synced 2024-12-25 23:02:35 +03:00
Use API for resizing
This commit is contained in:
parent
10e0877149
commit
006f0a026c
@ -50,7 +50,6 @@ typedef NS_ENUM(NSInteger, NeoVimAgentMsgId) {
|
||||
NeoVimAgentMsgIdInput,
|
||||
NeoVimAgentMsgIdInputMarked,
|
||||
NeoVimAgentMsgIdDelete,
|
||||
NeoVimAgentMsgIdResize,
|
||||
NeoVimAgentMsgIdScroll,
|
||||
|
||||
NeoVimAgentMsgIdGetPwd,
|
||||
|
@ -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 NeoVimAgentMsgIdResize: return data_sync(data, outputCondition, neovim_resize);
|
||||
|
||||
case NeoVimAgentMsgIdInput: return data_sync(data, outputCondition, neovim_vim_input);
|
||||
|
||||
case NeoVimAgentMsgIdInputMarked: return data_sync(data, outputCondition, neovim_vim_input_marked_text);
|
||||
|
@ -15,7 +15,6 @@ extern void start_neovim(NSInteger width, NSInteger height, NSArray<NSString *>
|
||||
|
||||
extern void neovim_scroll(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_marked_text(void **argv);
|
||||
|
@ -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) {
|
||||
work_and_write_data_sync(argv, ^NSData *(NSData *data) {
|
||||
NSString *input = [[[NSString alloc] initWithData:data
|
||||
|
@ -42,8 +42,6 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
- (void)vimInputMarkedText:(NSString *)markedText;
|
||||
- (void)deleteCharacters:(NSInteger)count;
|
||||
|
||||
- (void)resizeToWidth:(int)width height:(int)height;
|
||||
|
||||
- (NSString * _Nullable)escapedFileName:(NSString *)fileName;
|
||||
- (NSArray<NSString *> *)escapedFileNames:(NSArray<NSString *> *)fileNames;
|
||||
|
||||
|
@ -283,12 +283,6 @@ static CFDataRef local_server_callback(CFMessagePortRef local __unused, SInt32 m
|
||||
[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 {
|
||||
NSArray<NSString *> *fileNames = [self escapedFileNames:@[fileName]];
|
||||
if (fileNames.count == 0) {
|
||||
|
@ -50,7 +50,7 @@ extension NeoVimView {
|
||||
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.agent.resize(toWidth: Int32(discreteSize.width), height: Int32(discreteSize.height))
|
||||
self.nvim.uiTryResize(width: discreteSize.width, height: discreteSize.height)
|
||||
}
|
||||
|
||||
fileprivate func launchNeoVim(_ size: Size) {
|
||||
@ -59,6 +59,7 @@ extension NeoVimView {
|
||||
|
||||
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: "title", value: .bool(true))
|
||||
self.nvim.setOption(name: "termguicolors", value: .bool(true))
|
||||
|
Loading…
Reference in New Issue
Block a user