mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
API: Implement window_{get,set}_{height,width}
This commit is contained in:
parent
b7c5d294c1
commit
a132effd35
@ -6,6 +6,7 @@
|
|||||||
#include "api/defs.h"
|
#include "api/defs.h"
|
||||||
#include "api/helpers.h"
|
#include "api/helpers.h"
|
||||||
#include "../vim.h"
|
#include "../vim.h"
|
||||||
|
#include "../window.h"
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
#include "misc2.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)
|
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)
|
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)
|
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)
|
Object window_get_var(Window window, String name, Error *err)
|
||||||
|
@ -49,6 +49,14 @@ void window_set_height(Window window, int64_t height, Error *err);
|
|||||||
/// @return the width in columns
|
/// @return the width in columns
|
||||||
int64_t window_get_width(Window window, Error *err);
|
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
|
/// Gets a window variable
|
||||||
///
|
///
|
||||||
/// @param window The window handle
|
/// @param window The window handle
|
||||||
|
Loading…
Reference in New Issue
Block a user