|
| 1 | +import type { Denops } from "../mod.ts"; |
| 2 | + |
| 3 | +export interface WinInfo { |
| 4 | + /** |
| 5 | + * last complete displayed buffer line |
| 6 | + */ |
| 7 | + botline: number; |
| 8 | + /** |
| 9 | + * number of buffer in the window |
| 10 | + */ |
| 11 | + bufnr: number; |
| 12 | + /** |
| 13 | + * window height (excluding winbar) |
| 14 | + */ |
| 15 | + height: number; |
| 16 | + /** |
| 17 | + * 1 if showing a location list |
| 18 | + */ |
| 19 | + loclist: number; |
| 20 | + /** |
| 21 | + * 1 if quickfix or location list window |
| 22 | + */ |
| 23 | + quickfix: number; |
| 24 | + /** |
| 25 | + * 1 if a terminal window |
| 26 | + */ |
| 27 | + terminal: number; |
| 28 | + /** |
| 29 | + * tab page number |
| 30 | + */ |
| 31 | + tabnr: number; |
| 32 | + /** |
| 33 | + * first displayed buffer line |
| 34 | + */ |
| 35 | + topline: number; |
| 36 | + /** |
| 37 | + * a reference to the dictionary with window-local variables |
| 38 | + */ |
| 39 | + variables: Record<string, unknown>; |
| 40 | + /** |
| 41 | + * window width |
| 42 | + */ |
| 43 | + width: number; |
| 44 | + /** |
| 45 | + * 1 if the window has a toolbar, 0 otherwise |
| 46 | + */ |
| 47 | + winbar: number; |
| 48 | + /** |
| 49 | + * leftmost screen column of the window; "col" from `win_screenpos()` |
| 50 | + */ |
| 51 | + wincol: number; |
| 52 | + /** |
| 53 | + * number of columns occupied by any 'foldcolumn', 'signcolumn' and line number in front of the text |
| 54 | + */ |
| 55 | + textoff: number; |
| 56 | + /** |
| 57 | + * `window-ID` |
| 58 | + */ |
| 59 | + winid: number; |
| 60 | + /** |
| 61 | + * window number |
| 62 | + */ |
| 63 | + winnr: number; |
| 64 | + /** |
| 65 | + * topmost screen line of the window; "row" from `win_screenpos()` |
| 66 | + */ |
| 67 | + winrow: number; |
| 68 | +} |
| 69 | + |
| 70 | +/** |
| 71 | + * Returns information about windows as a `List` with Dictionaries. |
| 72 | + * |
| 73 | + * If **{winid}** is given Information about the window with that ID |
| 74 | + * is returned, as a `List` with one item. If the window does not |
| 75 | + * exist the result is an empty list. |
| 76 | + * |
| 77 | + * Without **{winid}** information about all the windows in all the |
| 78 | + * tab pages is returned. |
| 79 | + * |
| 80 | + * Each List item is a `Dictionary` with the following entries: |
| 81 | + * botline last complete displayed buffer line |
| 82 | + * bufnr number of buffer in the window |
| 83 | + * height window height (excluding winbar) |
| 84 | + * loclist 1 if showing a location list |
| 85 | + * *only with the +quickfix feature* |
| 86 | + * quickfix 1 if quickfix or location list window |
| 87 | + * *only with the +quickfix feature* |
| 88 | + * terminal 1 if a terminal window |
| 89 | + * *only with the +terminal feature* |
| 90 | + * tabnr tab page number |
| 91 | + * topline first displayed buffer line |
| 92 | + * variables a reference to the dictionary with |
| 93 | + * window-local variables |
| 94 | + * width window width |
| 95 | + * winbar 1 if the window has a toolbar, 0 |
| 96 | + * otherwise |
| 97 | + * wincol leftmost screen column of the window; |
| 98 | + * "col" from `win_screenpos()` |
| 99 | + * textoff number of columns occupied by any |
| 100 | + * 'foldcolumn', 'signcolumn' and line |
| 101 | + * number in front of the text |
| 102 | + * winid `window-ID` |
| 103 | + * winnr window number |
| 104 | + * winrow topmost screen line of the window; |
| 105 | + * "row" from `win_screenpos()` |
| 106 | + * |
| 107 | + * Can also be used as a `method`: |
| 108 | + * |
| 109 | + * GetWinnr()->getwininfo() |
| 110 | + */ |
| 111 | +export function getwininfo(denops: Denops, winid?: number): Promise<WinInfo[]>; |
| 112 | +export function getwininfo( |
| 113 | + denops: Denops, |
| 114 | + ...args: unknown[] |
| 115 | +): Promise<unknown> { |
| 116 | + return denops.call("getwininfo", ...args); |
| 117 | +} |
| 118 | + |
| 119 | +/** |
| 120 | + * The result is a `List` with two numbers, the result of |
| 121 | + * `getwinposx()` and `getwinposy()` combined: |
| 122 | + * [x-pos, y-pos] |
| 123 | + * **{timeout}** can be used to specify how long to wait in msec for |
| 124 | + * a response from the terminal. When omitted 100 msec is used. |
| 125 | + * Use a longer time for a remote terminal. |
| 126 | + * When using a value less than 10 and no response is received |
| 127 | + * within that time, a previously reported position is returned, |
| 128 | + * if available. This can be used to poll for the position and |
| 129 | + * do some work in the meantime: |
| 130 | + * |
| 131 | + * while 1 |
| 132 | + * let res = getwinpos(1) |
| 133 | + * if res[0] >= 0 |
| 134 | + * break |
| 135 | + * endif |
| 136 | + * " Do some work here |
| 137 | + * endwhile |
| 138 | + * |
| 139 | + * Can also be used as a `method`: |
| 140 | + * |
| 141 | + * GetTimeout()->getwinpos() |
| 142 | + */ |
| 143 | +export function getwinpos( |
| 144 | + denops: Denops, |
| 145 | + timeout?: number, |
| 146 | +): Promise<[x: number, y: number]>; |
| 147 | +export function getwinpos( |
| 148 | + denops: Denops, |
| 149 | + ...args: unknown[] |
| 150 | +): Promise<unknown> { |
| 151 | + return denops.call("getwinpos", ...args); |
| 152 | +} |
0 commit comments