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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
//! Port of `src/nvim/grid_defs.h` (`ScreenGrid`) and the compositor query
//! `ui_comp_get_grid_at_coord()` from `src/nvim/ui_compositor.c` (both vendored
//! at `vendor/grid_defs.h` / `vendor/ui_compositor.c`).
//!
//! `screenchar()`/`screenattr()`/`screenchars()`/`screenstring()` read the
//! composed screen through `screenchar_adjust()`, which asks the compositor for
//! the grid on top at a screen coordinate. Only the two symbols the eval tree
//! reaches are ported here: the `ScreenGrid` record and the coordinate lookup.
//!
//! RUST-PORT NOTE: vimlrs has no live UI compositor. The compositor owns a
//! stack of layer grids plus `default_grid`, none of which exist standalone, so
//! `ui_comp_get_grid_at_coord()` has no grids to search and returns `None` (a
//! null grid). `screenchar_adjust()` (eval/funcs.rs) then yields the "no screen"
//! result (-1 / empty) for the `screen*()` builtins. The intrusive
//! `schar_T*`/`sattr_T*`/`size_t*` pointer arrays become owning `Vec`s.
use crate;
/// `typedef uint32_t schar_T` (`Src/types_defs.h:12`) — a composed screen cell.
pub type schar_T = u32;
/// `typedef int32_t sattr_T` (`Src/types_defs.h:13`) — a cell's highlight attr.
pub type sattr_T = i32;
/// Port of `struct ScreenGrid` from `Src/grid_defs.h:45`.
///
/// A rectangular block of the screen (the default grid, a window grid, or a
/// float). `screenchar_adjust()` reads `comp_row`/`comp_col` (grid origin) and
/// `rows`/`cols`; the `screen*()` builtins read `chars`/`attrs`/`line_offset`.
///
/// RUST-PORT NOTE: the C `schar_T *chars` / `sattr_T *attrs` / `colnr_T *vcols`
/// / `size_t *line_offset` / `int *dirty_col` pointer arrays are modelled as
/// owning `Vec`s. Since vimlrs never allocates a grid (see the module note), all
/// arrays stay empty; the fields exist for faithful field-name parity.
/// Port of `ui_comp_get_grid_at_coord()` from `Src/ui_compositor.c:335`.
///
/// Compute which grid is on top at supplied screen coordinates. C walks the
/// compositor layer stack (top-down), then the windows of the current tab, and
/// finally falls back to `&default_grid`.
///
/// RUST-PORT NOTE: vimlrs has no compositor layer stack (`layers`), no window
/// grids, and no `default_grid`, so there is nothing to search — the faithful
/// result is "no grid on top", returned as `None`. This is the deviation that
/// makes `screenchar()`/`screenattr()`/`screenchars()`/`screenstring()` report
/// the off-screen result. The C loop structure is preserved as commentary.