mirror of
https://github.com/qvacua/vimr.git
synced 2024-12-29 16:56:40 +03:00
GH-442 Push (again) dirty status to ui
This commit is contained in:
parent
f547e71776
commit
b09970e818
@ -69,6 +69,8 @@ static int _put_column = -1;
|
||||
|
||||
static NSString *_backspace = nil;
|
||||
|
||||
static bool _dirty = false;
|
||||
|
||||
#pragma mark Helper functions
|
||||
static inline int screen_cursor_row() {
|
||||
return curwin->w_winrow + curwin->w_wrow;
|
||||
@ -96,6 +98,20 @@ static bool has_dirty_docs() {
|
||||
return false;
|
||||
}
|
||||
|
||||
static void send_dirty_status() {
|
||||
bool new_dirty_status = has_dirty_docs();
|
||||
DLOG("dirty status: %d vs. %d", _dirty, new_dirty_status);
|
||||
if (_dirty == new_dirty_status) {
|
||||
return;
|
||||
}
|
||||
|
||||
_dirty = new_dirty_status;
|
||||
DLOG("sending dirty status: %d", _dirty);
|
||||
NSData *data = [[NSData alloc] initWithBytes:&_dirty length:sizeof(bool)];
|
||||
[_neovim_server sendMessageWithId:NeoVimServerMsgIdDirtyStatusChanged data:data];
|
||||
[data release];
|
||||
}
|
||||
|
||||
static void insert_marked_text(NSString *markedText) {
|
||||
_marked_text = [markedText retain]; // release when the final text is input in -vimInput
|
||||
|
||||
@ -442,13 +458,13 @@ void custom_ui_autocmds_groups(
|
||||
@autoreleasepool {
|
||||
DLOG("got event %d for file %s in group %d.", event, fname, group);
|
||||
|
||||
// if (event == EVENT_TEXTCHANGED
|
||||
// || event == EVENT_TEXTCHANGEDI
|
||||
// || event == EVENT_BUFWRITEPOST
|
||||
// || event == EVENT_BUFLEAVE)
|
||||
// {
|
||||
// send_dirty_status();
|
||||
// }
|
||||
if (event == EVENT_TEXTCHANGED
|
||||
|| event == EVENT_TEXTCHANGEDI
|
||||
|| event == EVENT_BUFWRITEPOST
|
||||
|| event == EVENT_BUFLEAVE)
|
||||
{
|
||||
send_dirty_status();
|
||||
}
|
||||
|
||||
NSUInteger eventCode = event;
|
||||
|
||||
|
@ -1495,9 +1495,9 @@ extension NeoVimView {
|
||||
DispatchQueue.main.async {
|
||||
// NSLog("\(event.rawValue) with buffer \(bufferHandle)")
|
||||
|
||||
if (event == .TEXTCHANGED || event == .TEXTCHANGEDI || event == .BUFWRITEPOST || event == .BUFLEAVE) {
|
||||
self.delegate?.set(dirtyStatus: self.hasDirtyDocs())
|
||||
}
|
||||
// if (event == .TEXTCHANGED || event == .TEXTCHANGEDI || event == .BUFWRITEPOST || event == .BUFLEAVE) {
|
||||
// self.delegate?.set(dirtyStatus: self.hasDirtyDocs())
|
||||
// }
|
||||
|
||||
if event == .BUFWINENTER || event == .BUFWINLEAVE {
|
||||
self.bufferListChanged()
|
||||
|
Loading…
Reference in New Issue
Block a user