From a4ce7ffbd0b74afbd7e06cb553b7cddafee96d01 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Fri, 5 Nov 2021 12:25:31 -0700 Subject: window:getmaxyx() --- src/hanoi.lua | 3 +-- src/lcurseslib.c | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/hanoi.lua b/src/hanoi.lua index 6a2311d..f3d08fa 100644 --- a/src/hanoi.lua +++ b/src/hanoi.lua @@ -36,8 +36,7 @@ end local function render(screen) screen:clear() - local lines = curses.lines() - local cols = curses.cols() + local lines, cols = screen:getmaxyx() local line = math.floor(lines/2) local col = math.floor(cols/4) for i,t in ipairs(tower) do diff --git a/src/lcurseslib.c b/src/lcurseslib.c index 3aeba75..baafbf5 100644 --- a/src/lcurseslib.c +++ b/src/lcurseslib.c @@ -109,11 +109,33 @@ static int Wclear (lua_State *L) { } +static int Wgetyx (lua_State *L) { + WINDOW *w = checkwin(L, 1); + int y, x; + getyx(w, y, x); + lua_pushinteger(L, y); + lua_pushinteger(L, x); + return 2; +} + + +static int Wgetmaxyx (lua_State *L) { + WINDOW *w = checkwin(L, 1); + int y, x; + getmaxyx(w, y, x); + lua_pushinteger(L, y); + lua_pushinteger(L, x); + return 2; +} + + static const luaL_Reg curses_window_methods[] = { {"__tostring", W__tostring}, {"addstr", Waddstr}, {"clear", Wclear}, + {"getmaxyx", Wgetmaxyx}, + {"getyx", Wgetyx}, {NULL, NULL} }; -- cgit 1.4.1-2-gfad0 eliva/tree/sandboxing/system_includes?id=504573a0de604bfeb04d4fe938fca8f42da55eca'>tree commit diff stats
path: root/sandboxing/system_includes
blob: c9ecf4065c062049117e47721d1921b21dda2f24 (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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
kilo.c:#include <assert.h>
kilo.c:#include <ncurses.h>
kilo.c:#include <stdlib.h>
kilo.c:#include <stdio.h>
kilo.c:#include <stdint.h>
kilo.c:#include <errno.h>
kilo.c:#include <string.h>
kilo.c:#include <ctype.h>
kilo.c:#include <time.h>
kilo.c:#include <sys/types.h>
kilo.c:#include <sys/time.h>
kilo.c:#include <unistd.h>
kilo.c:#include <fcntl.h>
lapi.c:#include <assert.h>
lapi.c:#include <math.h>
lapi.c:#include <stdarg.h>
lapi.c:#include <string.h>
lauxlib.c:#include <ctype.h>
lauxlib.c:#include <errno.h>
lauxlib.c:#include <stdarg.h>
lauxlib.c:#include <stdio.h>
lauxlib.c:#include <stdlib.h>
lauxlib.c:#include <string.h>
lauxlib.h:#include <stddef.h>
lauxlib.h:#include <stdio.h>
lbaselib.c:#include <ctype.h>
lbaselib.c:#include <ncurses.h>
lbaselib.c:#include <stdio.h>
lbaselib.c:#include <stdlib.h>
lbaselib.c:#include <string.h>
lcode.c:#include <stdlib.h>
ldblib.c:#include <stdio.h>
ldblib.c:#include <stdlib.h>
ldblib.c:#include <string.h>
ldebug.c:#include <stdarg.h>
ldebug.c:#include <stddef.h>
ldebug.c:#include <string.h>
ldo.c:#include <setjmp.h>
ldo.c:#include <stdio.h>
ldo.c:#include <stdlib.h>
ldo.c:#include <string.h>
ldump.c:#include <stddef.h>
lfunc.c:#include <stddef.h>
lgc.c:#include <string.h>
liolib.c:#include <errno.h>
liolib.c:#include <stdio.h>
liolib.c:#include <stdlib.h>
liolib.c:#include <string.h>
llex.c:#include <ctype.h>
llex.c:#include <locale.h>
llex.c:#include <string.h>
llimits.h:#include <limits.h>
llimits.h:#include <stddef.h>
lmathlib.c:#include <stdlib.h>
lmathlib.c:#include <math.h>
lmem.c:#include <stddef.h>
lmem.h:#include <stddef.h>
loadlib.c:#include <stdlib.h>
loadlib.c:#include <string.h>
loadlib.c:#include <dlfcn.h>
loadlib.c:#include <windows.h>
loadlib.c:#include <mach-o/dyld.h>
lobject.c:#include <ctype.h>
lobject.c:#include <stdarg.h>
lobject.c:#include <stdio.h>
lobject.c:#include <stdlib.h>
lobject.c:#include <string.h>
lobject.h:#include <stdarg.h>
loslib.c:#include <errno.h>
loslib.c:#include <locale.h>
loslib.c:#include <stdlib.h>
loslib.c:#include <string.h>
loslib.c:#include <time.h>
lparser.c:#include <string.h>
lstate.c:#include <stddef.h>
lstring.c:#include <string.h>
lstrlib.c:#include <ctype.h>
lstrlib.c:#include <stddef.h>
lstrlib.c:#include <stdio.h>
lstrlib.c:#include <stdlib.h>
lstrlib.c:#include <string.h>
ltable.c:#include <math.h>
ltable.c:#include <string.h>
ltablib.c:#include <stddef.h>
ltm.c:#include <string.h>
lua.c:#include <assert.h>
lua.c:#include <ctype.h>
lua.c:#include <fcntl.h>
lua.c:#include <locale.h>
lua.c:#include <ncurses.h>
lua.c:#include <signal.h>
lua.c:#include <stdio.h>
lua.c:#include <stdlib.h>
lua.c:#include <string.h>
lua.c:#include <time.h>
lua.c:#include <unistd.h>
lua.h:#include <stdarg.h>
lua.h:#include <stddef.h>
luaconf.h:#include <limits.h>
luaconf.h:#include <stddef.h>
luaconf.h:#include <assert.h>
luaconf.h:#include <math.h>
luaconf.h:#include <unistd.h>
luaconf.h:#include <stdio.h>
lundump.c:#include <string.h>
lvm.c:#include <stdio.h>
lvm.c:#include <stdlib.h>
lvm.c:#include <string.h>
lzio.c:#include <string.h>
menu.c:#include <ncurses.h>
menu.c:#include <string.h>
tlv.c:#include <assert.h>
tlv.c:#include <ncurses.h>
tlv.c:#include <stdio.h>
tlv.c:#include <stdlib.h>
tlv.c:#include <string.h>
tlv.c:#include <strings.h>
lcurses/_helpers.c:#include <errno.h>
lcurses/_helpers.c:#include <grp.h>
lcurses/_helpers.c:#include <pwd.h>
lcurses/_helpers.c:#include <stdlib.h>
lcurses/_helpers.c:#include <string.h>
lcurses/_helpers.c:#include <sys/stat.h>
lcurses/_helpers.c:#include <unistd.h>
lcurses/_helpers.c:#include <ncurses.h>
lcurses/_helpers.c:#include <term.h>
lcurses/compat-5.2.c:#include <errno.h>
lcurses/compat-5.2.c:#include <string.h>
lcurses/compat-5.2.c:#include <limits.h>
lcurses/compat-5.2.c:#include <math.h>
lcurses/compat-5.2.h:#include <stddef.h>
lcurses/compat-5.2.h:#include <string.h>
lcurses/compat-5.2.h:#include <stdio.h>
lcurses/compat-5.2.h:#include <limits.h>
lcurses/strlcpy.c:#include <sys/types.h>
lcurses/strlcpy.c:#include <string.h>
luasec/compat.h:#include <openssl/ssl.h>
luasec/context.c:#include <string.h>
luasec/context.c:#include <windows.h>
luasec/context.c:#include <openssl/ssl.h>
luasec/context.c:#include <openssl/err.h>
luasec/context.c:#include <openssl/x509.h>
luasec/context.c:#include <openssl/x509v3.h>
luasec/context.c:#include <openssl/dh.h>
luasec/context.c:#include <openssl/ec.h>
luasec/context.h:#include <openssl/ssl.h>
luasec/ec.c:#include <openssl/objects.h>
luasec/ec.h:#include <openssl/ec.h>
luasec/options.c:#include <openssl/ssl.h>
luasec/options.lua:#include <openssl/ssl.h>
luasec/ssl.c:#include <errno.h>
luasec/ssl.c:#include <string.h>
luasec/ssl.c:#include <winsock2.h>
luasec/ssl.c:#include <openssl/ssl.h>
luasec/ssl.c:#include <openssl/x509v3.h>
luasec/ssl.c:#include <openssl/x509_vfy.h>
luasec/ssl.c:#include <openssl/err.h>
luasec/ssl.c:#include <openssl/dh.h>
luasec/ssl.h:#include <openssl/ssl.h>
luasec/x509.c:#include <stdio.h>
luasec/x509.c:#include <string.h>
luasec/x509.c:#include <ws2tcpip.h>
luasec/x509.c:#include <windows.h>
luasec/x509.c:#include <sys/types.h>
luasec/x509.c:#include <sys/socket.h>
luasec/x509.c:#include <netinet/in.h>
luasec/x509.c:#include <arpa/inet.h>
luasec/x509.c:#include <openssl/ssl.h>
luasec/x509.c:#include <openssl/x509v3.h>
luasec/x509.c:#include <openssl/evp.h>
luasec/x509.c:#include <openssl/err.h>
luasec/x509.c:#include <openssl/asn1.h>
luasec/x509.c:#include <openssl/bio.h>
luasec/x509.c:#include <openssl/bn.h>
luasec/x509.h:#include <openssl/x509v3.h>
luasocket/auxiliar.c:#include <string.h>
luasocket/auxiliar.c:#include <stdio.h>
luasocket/except.c:#include <stdio.h>
luasocket/inet.c:#include <stdio.h>
luasocket/inet.c:#include <stdlib.h>
luasocket/inet.c:#include <string.h>
luasocket/mime.c:#include <string.h>
luasocket/mime.c:#include <ctype.h>
luasocket/options.c:#include <string.h>
luasocket/select.c:#include <string.h>
luasocket/serial.c:#include <string.h>
luasocket/serial.c:#include <sys/un.h>
luasocket/tcp.c:#include <string.h>
luasocket/timeout.c:#include <stdio.h>
luasocket/timeout.c:#include <limits.h>
luasocket/timeout.c:#include <float.h>
luasocket/timeout.c:#include <windows.h>
luasocket/timeout.c:#include <time.h>
luasocket/timeout.c:#include <sys/time.h>
luasocket/udp.c:#include <string.h>
luasocket/udp.c:#include <stdlib.h>
luasocket/unixdgram.c:#include <string.h>
luasocket/unixdgram.c:#include <stdlib.h>
luasocket/unixdgram.c:#include <sys/un.h>
luasocket/unixstream.c:#include <string.h>
luasocket/unixstream.c:#include <sys/un.h>
luasocket/usocket.c:#include <string.h>
luasocket/usocket.c:#include <signal.h>
luasocket/usocket.c:#include <sys/poll.h>
luasocket/usocket.h:#include <errno.h>
luasocket/usocket.h:#include <unistd.h>
luasocket/usocket.h:#include <fcntl.h>
luasocket/usocket.h:#include <sys/types.h>
luasocket/usocket.h:#include <sys/socket.h>
luasocket/usocket.h:#include <sys/time.h>
luasocket/usocket.h:#include <netdb.h>
luasocket/usocket.h:#include <signal.h>
luasocket/usocket.h:#include <netinet/in.h>
luasocket/usocket.h:#include <arpa/inet.h>
luasocket/usocket.h:#include <netinet/tcp.h>
luasocket/usocket.h:#include <net/if.h>
luasocket/usocket.h:#include <sys/poll.h>
luasocket/wsocket.c:#include <string.h>
luasocket/wsocket.h:#include <winsock2.h>
luasocket/wsocket.h:#include <ws2tcpip.h>