diff options
author | Thiago de Arruda <tpadilha84@gmail.com> | 2014-05-11 10:11:45 -0300 |
---|---|---|
committer | Thiago de Arruda <tpadilha84@gmail.com> | 2014-05-13 14:11:32 -0300 |
commit | a132effd35801ea60b178f6dc6707159c21fcbf4 (patch) | |
tree | 5f3a5153f51593d7ed611c99ae940df6906a5ce6 | |
parent | b7c5d294c11dafe698ad7a05c14b1be781916a4e (diff) | |
download | rneovim-a132effd35801ea60b178f6dc6707159c21fcbf4.tar.gz rneovim-a132effd35801ea60b178f6dc6707159c21fcbf4.tar.bz2 rneovim-a132effd35801ea60b178f6dc6707159c21fcbf4.zip |
API: Implement window_{get,set}_{height,width}
-rw-r--r-- | src/api/window.c | 46 | ||||
-rw-r--r-- | src/api/window.h | 8 |
2 files changed, 51 insertions, 3 deletions
diff --git a/src/api/window.c b/src/api/window.c index 655f9ff47f..019e63aec3 100644 --- a/src/api/window.c +++ b/src/api/window.c @@ -6,6 +6,7 @@ #include "api/defs.h" #include "api/helpers.h" #include "../vim.h" +#include "../window.h" #include "screen.h" #include "misc2.h" @@ -57,17 +58,56 @@ void window_set_cursor(Window window, Position pos, Error *err) int64_t window_get_height(Window window, Error *err) { - abort(); + win_T *win = find_window(window, err); + + if (!win) { + return 0; + } + + return win->w_height; } void window_set_height(Window window, int64_t height, Error *err) { - abort(); + win_T *win = find_window(window, err); + + if (!win) { + return; + } + + win_T *savewin = curwin; + curwin = win; + try_start(); + win_setheight(height); + curwin = savewin; + try_end(err); } int64_t window_get_width(Window window, Error *err) { - abort(); + win_T *win = find_window(window, err); + + if (!win) { + return 0; + } + + return win->w_width; +} + +void window_set_width(Window window, int64_t width, Error *err) +{ + win_T *win = find_window(window, err); + + if (!win) { + return; + } + + win_T *savewin = curwin; + curwin = win; + try_start(); + win_setwidth(width); + curwin = savewin; + try_end(err); } Object window_get_var(Window window, String name, Error *err) diff --git a/src/api/window.h b/src/api/window.h index 1874cfae82..96ff619d88 100644 --- a/src/api/window.h +++ b/src/api/window.h @@ -49,6 +49,14 @@ void window_set_height(Window window, int64_t height, Error *err); /// @return the width in columns int64_t window_get_width(Window window, Error *err); +/// 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, int64_t width, Error *err); + /// Gets a window variable /// /// @param window The window handle |