mirror of
https://github.com/qvacua/vimr.git
synced 2024-12-28 08:13:17 +03:00
Do not send unnec' screen cursor position to UI
This commit is contained in:
parent
5d3aca696d
commit
c415df78e1
@ -223,13 +223,12 @@ static void server_ui_cursor_goto(UI *ui __unused, Integer row, Integer col) {
|
||||
|
||||
NSInteger values[] = {
|
||||
row, col,
|
||||
screen_cursor_row(), screen_cursor_column(),
|
||||
(NSInteger) curwin->w_cursor.lnum, curwin->w_cursor.col + 1
|
||||
};
|
||||
|
||||
DLOG("%d:%d - %d:%d - %d:%d", values[0], values[1], values[2], values[3], values[4], values[5]);
|
||||
DLOG("%d:%d - %d:%d - %d:%d", values[0], values[1], values[2], values[3]);
|
||||
|
||||
NSData *data = [[NSData alloc] initWithBytes:values length:(6 * sizeof(NSInteger))];
|
||||
NSData *data = [[NSData alloc] initWithBytes:values length:(4 * sizeof(NSInteger))];
|
||||
[_neovim_server sendMessageWithId:NeoVimServerMsgIdSetPosition data:data];
|
||||
[data release];
|
||||
}
|
||||
@ -309,28 +308,40 @@ static void server_ui_highlight_set(UI *ui __unused, HlAttrs attrs) {
|
||||
}
|
||||
|
||||
static void server_ui_put(UI *ui __unused, String str) {
|
||||
NSString *string = [[NSString alloc] initWithBytes:str.data length:str.size encoding:NSUTF8StringEncoding];
|
||||
NSInteger cursor[] = {screen_cursor_row(), screen_cursor_column()};
|
||||
NSString *string = [[NSString alloc] initWithBytes:str.data
|
||||
length:str.size
|
||||
encoding:NSUTF8StringEncoding];
|
||||
NSData *data = [string dataUsingEncoding:NSUTF8StringEncoding];
|
||||
|
||||
NSMutableData *data = [[NSMutableData alloc]
|
||||
initWithCapacity:2 * sizeof(NSInteger) + [string lengthOfBytesUsingEncoding:NSUTF8StringEncoding]];
|
||||
[data appendBytes:cursor length:2 * sizeof(NSInteger)];
|
||||
[data appendData:[string dataUsingEncoding:NSUTF8StringEncoding]];
|
||||
// NSInteger cursor[] = {screen_cursor_row(), screen_cursor_column()};
|
||||
|
||||
// NSMutableData *data = [[NSMutableData alloc]
|
||||
// initWithCapacity:2 * sizeof(NSInteger) + [string lengthOfBytesUsingEncoding:NSUTF8StringEncoding]];
|
||||
// [data appendBytes:cursor length:2 * sizeof(NSInteger)];
|
||||
// [data appendData:[string dataUsingEncoding:NSUTF8StringEncoding]];
|
||||
|
||||
if (_marked_text != nil && _marked_row == _put_row && _marked_column == _put_column) {
|
||||
|
||||
DLOG("putting marked text: '%s'", string.cstr);
|
||||
[_neovim_server sendMessageWithId:NeoVimServerMsgIdPutMarked data:data];
|
||||
} else if (_marked_text != nil && str.size == 0 && _marked_row == _put_row && _marked_column == _put_column - 1) {
|
||||
|
||||
} else if (_marked_text != nil
|
||||
&& str.size == 0
|
||||
&& _marked_row == _put_row
|
||||
&& _marked_column == _put_column - 1) {
|
||||
|
||||
DLOG("putting marked text cuz zero");
|
||||
[_neovim_server sendMessageWithId:NeoVimServerMsgIdPutMarked data:data];
|
||||
|
||||
} else {
|
||||
|
||||
DLOG("putting non-marked text: '%s'", string.cstr);
|
||||
[_neovim_server sendMessageWithId:NeoVimServerMsgIdPut data:data];
|
||||
|
||||
}
|
||||
|
||||
_put_column += 1;
|
||||
|
||||
[data release];
|
||||
[string release];
|
||||
}
|
||||
|
||||
|
@ -482,10 +482,9 @@ static CFDataRef local_server_callback(CFMessagePortRef local, SInt32 msgid, CFD
|
||||
return;
|
||||
|
||||
case NeoVimServerMsgIdSetPosition: {
|
||||
NSInteger *values = data_to_NSInteger_array(data, 6);
|
||||
NSInteger *values = data_to_NSInteger_array(data, 4);
|
||||
[_bridge gotoPosition:(Position) { .row = values[0], .column = values[1] }
|
||||
screenCursor:(Position) { .row = values[2], .column = values[3] }
|
||||
currentPosition:(Position) { .row = values[4], .column = values[5] }];
|
||||
textPosition:(Position) { .row = values[2], .column = values[3] }];
|
||||
return;
|
||||
}
|
||||
|
||||
@ -535,18 +534,12 @@ static CFDataRef local_server_callback(CFMessagePortRef local, SInt32 msgid, CFD
|
||||
|
||||
case NeoVimServerMsgIdPut:
|
||||
case NeoVimServerMsgIdPutMarked: {
|
||||
NSInteger *values = (NSInteger *) data.bytes;
|
||||
NSInteger row = values[0];
|
||||
NSInteger column = values[1];
|
||||
|
||||
NSString *string = [[NSString alloc] initWithBytes:(values + 2)
|
||||
length:data.length - 2 * sizeof(NSInteger)
|
||||
encoding:NSUTF8StringEncoding];
|
||||
NSString *string = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
|
||||
|
||||
if (msgid == NeoVimServerMsgIdPut) {
|
||||
[_bridge put:string screenCursor:(Position) { .row=row, .column=column }];
|
||||
[_bridge put:string];
|
||||
} else {
|
||||
[_bridge putMarkedText:string screenCursor:(Position) { .row=row, .column=column }];
|
||||
[_bridge putMarkedText:string];
|
||||
}
|
||||
|
||||
return;
|
||||
@ -566,9 +559,10 @@ static CFDataRef local_server_callback(CFMessagePortRef local, SInt32 msgid, CFD
|
||||
[_bridge visualBell];
|
||||
return;
|
||||
|
||||
case NeoVimServerMsgIdFlush:
|
||||
case NeoVimServerMsgIdFlush: {
|
||||
[_bridge flush];
|
||||
return;
|
||||
}
|
||||
|
||||
case NeoVimServerMsgIdSetForeground: {
|
||||
NSInteger *values = data_to_NSInteger_array(data, 1);
|
||||
|
@ -54,10 +54,6 @@ typedef struct {
|
||||
NSInteger column;
|
||||
} Position;
|
||||
|
||||
#define qDefaultForeground 0xFF000000
|
||||
#define qDefaultBackground 0xFFFFFFFF
|
||||
#define qDefaultSpecial 0xFFFF0000
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@protocol NeoVimUiBridgeProtocol <NSObject>
|
||||
@ -84,7 +80,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
* 2. NeoVim wants to put the cursor at (row, column).
|
||||
* In case of 1. NeoVim will put in subsequent call. In case of 2. NeoVim seems to flush twice in a row.
|
||||
*/
|
||||
- (void)gotoPosition:(Position)position screenCursor:(Position)screenCursor currentPosition:(Position)currentPosition;
|
||||
- (void)gotoPosition:(Position)position textPosition:(Position)textPosition;
|
||||
|
||||
- (void)updateMenu;
|
||||
- (void)busyStart;
|
||||
@ -104,9 +100,9 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
/**
|
||||
* Draw string at the current cursor which was set by a previous cursorGotoRow:column callback.
|
||||
*/
|
||||
- (void)put:(NSString *)string screenCursor:(Position)screenCursor;
|
||||
- (void)put:(NSString *)string;
|
||||
|
||||
- (void)putMarkedText:(NSString *)markedText screenCursor:(Position)screenCursor;
|
||||
- (void)putMarkedText:(NSString *)markedText;
|
||||
- (void)unmarkRow:(NSInteger)row column:(NSInteger)column;
|
||||
|
||||
- (void)bell;
|
||||
|
@ -40,19 +40,14 @@ extension NeoVimView {
|
||||
}
|
||||
}
|
||||
|
||||
public func gotoPosition(_ position: Position,
|
||||
screenCursor: Position,
|
||||
currentPosition: Position) {
|
||||
|
||||
public func gotoPosition(_ position: Position, textPosition: Position) {
|
||||
gui.async {
|
||||
self.bridgeLogger.debug("pos: \(position), screen: \(screenCursor), " +
|
||||
"current-pos: \(currentPosition)")
|
||||
self.bridgeLogger.debug(position)
|
||||
|
||||
self.markForRender(cellPosition: self.grid.position)
|
||||
self.grid.goto(position)
|
||||
}
|
||||
gui.async {
|
||||
self.delegate?.cursor(to: currentPosition)
|
||||
|
||||
self.delegate?.cursor(to: textPosition)
|
||||
}
|
||||
}
|
||||
|
||||
@ -92,10 +87,10 @@ extension NeoVimView {
|
||||
}
|
||||
}
|
||||
|
||||
public func put(_ string: String, screenCursor: Position) {
|
||||
public func put(_ string: String) {
|
||||
gui.async {
|
||||
let curPos = self.grid.position
|
||||
self.bridgeLogger.debug("\(curPos) -> \(string) <- screen: \(screenCursor)")
|
||||
// self.bridgeLogger.debug("\(curPos) -> \(string)")
|
||||
|
||||
self.grid.put(string)
|
||||
|
||||
@ -111,11 +106,11 @@ extension NeoVimView {
|
||||
}
|
||||
}
|
||||
|
||||
public func putMarkedText(_ markedText: String, screenCursor: Position) {
|
||||
public func putMarkedText(_ markedText: String) {
|
||||
gui.async {
|
||||
self.bridgeLogger.debug("'\(markedText)' <- screen: \(screenCursor)")
|
||||
|
||||
let curPos = self.grid.position
|
||||
// self.bridgeLogger.debug("\(curPos) -> '\(markedText)'")
|
||||
|
||||
self.grid.putMarkedText(markedText)
|
||||
|
||||
self.markForRender(position: curPos)
|
||||
@ -196,7 +191,7 @@ extension NeoVimView {
|
||||
|
||||
public func autoCommandEvent(_ event: NeoVimAutoCommandEvent, bufferHandle: Int) {
|
||||
gui.async {
|
||||
self.bridgeLogger.debug("\(neoVimAutoCommandEventName(event)) -> \(bufferHandle)")
|
||||
// self.bridgeLogger.debug("\(neoVimAutoCommandEventName(event)) -> \(bufferHandle)")
|
||||
|
||||
if event == .BUFWINENTER || event == .BUFWINLEAVE {
|
||||
self.bufferListChanged()
|
||||
@ -365,4 +360,4 @@ extension NeoVimView {
|
||||
}
|
||||
}
|
||||
|
||||
fileprivate let gui = DispatchQueue.main
|
||||
fileprivate let gui = DispatchQueue.main
|
||||
|
Loading…
Reference in New Issue
Block a user