aboutsummaryrefslogtreecommitdiff
path: root/src/api/window.c
blob: 655f9ff47f7771b14a5d9f67a593a298034d3881 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>

#include "api/window.h"
#include "api/defs.h"
#include "api/helpers.h"
#include "../vim.h"
#include "screen.h"
#include "misc2.h"


Buffer window_get_buffer(Window window, Error *err)
{
  win_T *win = find_window(window, err);

  if (!win) {
    return 0;
  }

  return win->w_buffer->b_fnum;
}

Position window_get_cursor(Window window, Error *err)
{
  Position rv = {.row = 0, .col = 0};
  win_T *win = find_window(window, err);

  if (win) {
    rv.row = win->w_cursor.lnum;
    rv.col = win->w_cursor.col;
  }

  return rv;
}

void window_set_cursor(Window window, Position pos, Error *err)
{
  win_T *win = find_window(window, err);

  if (!win) {
    return;
  }

  if (pos.row <= 0 || pos.row > win->w_buffer->b_ml.ml_line_count) {
    set_api_error("cursor position outside buffer", err);
    return;
  }

  win->w_cursor.lnum = pos.row;
  win->w_cursor.col = pos.col;
  win->w_cursor.coladd = 0;
  // When column is out of range silently correct it.
  check_cursor_col_win(win);
  update_screen(VALID);
}

int64_t window_get_height(Window window, Error *err)
{
  abort();
}

void window_set_height(Window window, int64_t height, Error *err)
{
  abort();
}

int64_t window_get_width(Window window, Error *err)
{
  abort();
}

Object window_get_var(Window window, String name, Error *err)
{
  abort();
}

void window_set_var(Window window, String name, Object value, Error *err)
{
  abort();
}

String window_get_option(Window window, String name, Error *err)
{
  abort();
}

void window_set_option(Window window, String name, String value, Error *err)
{
  abort();
}

Position window_get_pos(Window window, Error *err)
{
  abort();
}

Tabpage window_get_tabpage(Window window, Error *err)
{
  abort();
}

bool window_is_valid(Window window)
{
  abort();
}