diff options
| author | Thiago de Arruda <tpadilha84@gmail.com> | 2014-06-02 11:24:02 -0300 | 
|---|---|---|
| committer | Thiago de Arruda <tpadilha84@gmail.com> | 2014-06-02 11:24:02 -0300 | 
| commit | cab8cf970c09ea465d30e11eb356e2e5d37dc544 (patch) | |
| tree | 5d274c892e4d53f5e976ae8f6f58aba030785e02 /src/nvim/api/window.c | |
| parent | 52a9a5b0b0c53a1481d901f39ed0d1e7e86c3853 (diff) | |
| parent | 4aecb71b0e819aa84a430dacdab2146229c410a5 (diff) | |
| download | rneovim-cab8cf970c09ea465d30e11eb356e2e5d37dc544.tar.gz rneovim-cab8cf970c09ea465d30e11eb356e2e5d37dc544.tar.bz2 rneovim-cab8cf970c09ea465d30e11eb356e2e5d37dc544.zip | |
Merge pull request #710 'Automatically generate declarations'
Diffstat (limited to 'src/nvim/api/window.c')
| -rw-r--r-- | src/nvim/api/window.c | 77 | 
1 files changed, 77 insertions, 0 deletions
| diff --git a/src/nvim/api/window.c b/src/nvim/api/window.c index fd13557e3b..2b81afdb0c 100644 --- a/src/nvim/api/window.c +++ b/src/nvim/api/window.c @@ -12,6 +12,11 @@  #include "nvim/misc2.h" +/// Gets the current buffer in a window +/// +/// @param window The window handle +/// @param[out] err Details of an error that may have occurred +/// @return The buffer handle  Buffer window_get_buffer(Window window, Error *err)  {    win_T *win = find_window(window, err); @@ -23,6 +28,11 @@ Buffer window_get_buffer(Window window, Error *err)    return win->w_buffer->handle;  } +/// Gets the cursor position in the window +/// +/// @param window The window handle +/// @param[out] err Details of an error that may have occurred +/// @return the (row, col) tuple  Position window_get_cursor(Window window, Error *err)  {    Position rv = {.row = 0, .col = 0}; @@ -36,6 +46,11 @@ Position window_get_cursor(Window window, Error *err)    return rv;  } +/// Sets the cursor position in the window +/// +/// @param window The window handle +/// @param pos the (row, col) tuple representing the new position +/// @param[out] err Details of an error that may have occurred  void window_set_cursor(Window window, Position pos, Error *err)  {    win_T *win = find_window(window, err); @@ -67,6 +82,11 @@ void window_set_cursor(Window window, Position pos, Error *err)    update_screen(VALID);  } +/// Gets the window height +/// +/// @param window The window handle +/// @param[out] err Details of an error that may have occurred +/// @return the height in rows  Integer window_get_height(Window window, Error *err)  {    win_T *win = find_window(window, err); @@ -78,6 +98,12 @@ Integer window_get_height(Window window, Error *err)    return win->w_height;  } +/// Sets the window height. This will only succeed if the screen is split +/// horizontally. +/// +/// @param window The window handle +/// @param height the new height in rows +/// @param[out] err Details of an error that may have occurred  void window_set_height(Window window, Integer height, Error *err)  {    win_T *win = find_window(window, err); @@ -99,6 +125,11 @@ void window_set_height(Window window, Integer height, Error *err)    try_end(err);  } +/// Gets the window width +/// +/// @param window The window handle +/// @param[out] err Details of an error that may have occurred +/// @return the width in columns  Integer window_get_width(Window window, Error *err)  {    win_T *win = find_window(window, err); @@ -110,6 +141,12 @@ Integer window_get_width(Window window, Error *err)    return win->w_width;  } +/// Sets the window width. This will only succeed if the screen is split +/// vertically. +/// +/// @param window The window handle +/// @param width the new width in columns +/// @param[out] err Details of an error that may have occurred  void window_set_width(Window window, Integer width, Error *err)  {    win_T *win = find_window(window, err); @@ -131,6 +168,12 @@ void window_set_width(Window window, Integer width, Error *err)    try_end(err);  } +/// Gets a window variable +/// +/// @param window The window handle +/// @param name The variable name +/// @param[out] err Details of an error that may have occurred +/// @return The variable value  Object window_get_var(Window window, String name, Error *err)  {    win_T *win = find_window(window, err); @@ -142,6 +185,13 @@ Object window_get_var(Window window, String name, Error *err)    return dict_get_value(win->w_vars, name, err);  } +/// Sets a window variable. Passing 'nil' as value deletes the variable. +/// +/// @param window The window handle +/// @param name The variable name +/// @param value The variable value +/// @param[out] err Details of an error that may have occurred +/// @return The old value  Object window_set_var(Window window, String name, Object value, Error *err)  {    win_T *win = find_window(window, err); @@ -153,6 +203,12 @@ Object window_set_var(Window window, String name, Object value, Error *err)    return dict_set_value(win->w_vars, name, value, err);  } +/// Gets a window option value +/// +/// @param window The window handle +/// @param name The option name +/// @param[out] err Details of an error that may have occurred +/// @return The option value  Object window_get_option(Window window, String name, Error *err)  {    win_T *win = find_window(window, err); @@ -164,6 +220,13 @@ Object window_get_option(Window window, String name, Error *err)    return get_option_from(win, SREQ_WIN, name, err);  } +/// Sets a window option value. Passing 'nil' as value deletes the option(only +/// works if there's a global fallback) +/// +/// @param window The window handle +/// @param name The option name +/// @param value The option value +/// @param[out] err Details of an error that may have occurred  void window_set_option(Window window, String name, Object value, Error *err)  {    win_T *win = find_window(window, err); @@ -175,6 +238,11 @@ void window_set_option(Window window, String name, Object value, Error *err)    set_option_to(win, SREQ_WIN, name, value, err);  } +/// Gets the window position in display cells. First position is zero. +/// +/// @param window The window handle +/// @param[out] err Details of an error that may have occurred +/// @return The (row, col) tuple with the window position  Position window_get_position(Window window, Error *err)  {    Position rv; @@ -188,6 +256,11 @@ Position window_get_position(Window window, Error *err)    return rv;  } +/// Gets the window tab page +/// +/// @param window The window handle +/// @param[out] err Details of an error that may have occurred +/// @return The tab page that contains the window  Tabpage window_get_tabpage(Window window, Error *err)  {    Tabpage rv = 0; @@ -200,6 +273,10 @@ Tabpage window_get_tabpage(Window window, Error *err)    return rv;  } +/// Checks if a window is valid +/// +/// @param window The window handle +/// @return true if the window is valid, false otherwise  Boolean window_is_valid(Window window)  {    Error stub = {.set = false}; | 
