mirror of
https://github.com/neovim/neovim.git
synced 2025-09-08 12:28:18 +00:00
API: Implement buffer updates
Originally written by @phodge in https://github.com/neovim/neovim/pull/5269.
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
#include "nvim/window.h"
|
||||
#include "nvim/undo.h"
|
||||
#include "nvim/ex_docmd.h"
|
||||
#include "nvim/liveupdate.h"
|
||||
|
||||
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
||||
# include "api/buffer.c.generated.h"
|
||||
@@ -75,6 +76,34 @@ String buffer_get_line(Buffer buffer, Integer index, Error *err)
|
||||
return rv;
|
||||
}
|
||||
|
||||
/// Activate live updates from this buffer to the current channel.
|
||||
///
|
||||
///
|
||||
/// @param buffer The buffer handle
|
||||
/// @param enabled True turns on live updates, False turns them off.
|
||||
/// @param[out] err Details of an error that may have occurred
|
||||
/// @return False when live updates couldn't be enabled because the buffer isn't
|
||||
/// loaded; otherwise True.
|
||||
Boolean nvim_buf_live_updates(uint64_t channel_id,
|
||||
Buffer buffer,
|
||||
Boolean enabled,
|
||||
Error *err)
|
||||
FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY
|
||||
{
|
||||
buf_T *buf = find_buffer_by_handle(buffer, err);
|
||||
|
||||
if (!buf) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (enabled) {
|
||||
return liveupdate_register(buf, channel_id);
|
||||
}
|
||||
|
||||
liveupdate_unregister(buf, channel_id);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// Sets a buffer line
|
||||
///
|
||||
/// @deprecated use nvim_buf_set_lines instead.
|
||||
@@ -407,7 +436,7 @@ void nvim_buf_set_lines(uint64_t channel_id,
|
||||
false);
|
||||
}
|
||||
|
||||
changed_lines((linenr_T)start, 0, (linenr_T)end, (long)extra);
|
||||
changed_lines((linenr_T)start, 0, (linenr_T)end, (long)extra, true);
|
||||
|
||||
if (save_curbuf.br_buf == NULL) {
|
||||
fix_cursor((linenr_T)start, (linenr_T)end, (linenr_T)extra);
|
||||
|
Reference in New Issue
Block a user