diff options
-rw-r--r-- | src/api/buffer.c | 6 | ||||
-rw-r--r-- | src/api/buffer.h | 7 | ||||
-rw-r--r-- | src/api/vim.c | 5 | ||||
-rw-r--r-- | src/api/vim.h | 5 |
4 files changed, 23 insertions, 0 deletions
diff --git a/src/api/buffer.c b/src/api/buffer.c index 309d5b5b27..bdd27fe347 100644 --- a/src/api/buffer.c +++ b/src/api/buffer.c @@ -67,6 +67,12 @@ void buffer_set_line(Buffer buffer, int64_t index, String line, Error *err) buffer_set_slice(buffer, index, index, true, true, array, err); } +void buffer_del_line(Buffer buffer, int64_t index, Error *err) +{ + StringArray array = {.size = 0}; + buffer_set_slice(buffer, index, index, true, true, array, err); +} + StringArray buffer_get_slice(Buffer buffer, int64_t start, int64_t end, diff --git a/src/api/buffer.h b/src/api/buffer.h index 17ba9ead94..516df04ae4 100644 --- a/src/api/buffer.h +++ b/src/api/buffer.h @@ -29,6 +29,13 @@ String buffer_get_line(Buffer buffer, int64_t index, Error *err); /// @param[out] err Details of an error that may have occurred void buffer_set_line(Buffer buffer, int64_t index, String line, Error *err); +/// Deletes a buffer line +/// +/// @param buffer The buffer handle +/// @param index The line index +/// @param[out] err Details of an error that may have occurred +void buffer_del_line(Buffer buffer, int64_t index, Error *err); + /// Retrieves a line range from the buffer /// /// @param buffer The buffer handle diff --git a/src/api/vim.c b/src/api/vim.c index 30e2a9a12b..e85d60e104 100644 --- a/src/api/vim.c +++ b/src/api/vim.c @@ -141,6 +141,11 @@ void vim_set_current_line(String line, Error *err) buffer_set_line(curbuf->b_fnum, curwin->w_cursor.lnum - 1, line, err); } +void vim_del_current_line(Error *err) +{ + buffer_del_line(curbuf->b_fnum, curwin->w_cursor.lnum - 1, err); +} + Object vim_get_var(bool special, String name, bool pop, Error *err) { return dict_get_value(special ? &vimvardict : &globvardict, name, diff --git a/src/api/vim.h b/src/api/vim.h index 2205760d8b..86a42b7aae 100644 --- a/src/api/vim.h +++ b/src/api/vim.h @@ -50,6 +50,11 @@ void vim_change_directory(String dir, Error *err); /// @return The current line string String vim_get_current_line(Error *err); +/// Delete the current line +/// +/// @param[out] err Details of an error that may have occurred +void vim_del_current_line(Error *err); + /// Sets the current line /// /// @param line The line contents |