about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2021-11-06 19:21:01 -0700
committerKartik K. Agaram <vc@akkartik.com>2021-11-06 19:21:01 -0700
commit5619f0117a15e67dfc0b12f21d58be41450d738f (patch)
treec61f963db2febcead995a52c66aff7c56bdf4be2
parent8d5d27af0c206b827e379c67c7073b71251bb275 (diff)
downloadteliva-5619f0117a15e67dfc0b12f21d58be41450d738f.tar.gz
window:nodelay() for non-blocking input
-rw-r--r--src/lcurseslib.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/lcurseslib.c b/src/lcurseslib.c
index 5a5b8b0..000a1ea 100644
--- a/src/lcurseslib.c
+++ b/src/lcurseslib.c
@@ -74,6 +74,12 @@ argtypeerror(lua_State *L, int narg, const char *expected)
 }
 
 
+static void checktype (lua_State *L, int narg, int t, const char *expected) {
+  if (lua_type(L, narg) != t)
+    argtypeerror(L, narg, expected);
+}
+
+
 static lua_Integer checkinteger (lua_State *L, int narg, const char *expected) {
   lua_Integer d = lua_tointeger(L, narg);
   if (d == 0 && !lua_isnumber(L, narg))
@@ -270,6 +276,15 @@ static int Wmvaddstr (lua_State *L) {
 }
 
 
+static int Wnodelay (lua_State *L) {
+  WINDOW *w = checkwin(L, 1);
+  checktype(L, 2, LUA_TBOOLEAN, "boolean or nil");
+  int bf = (int)lua_toboolean(L, 2);
+  lua_pushboolean(L, nodelay(w, bf));
+  return 1;
+}
+
+
 static const luaL_Reg curses_window_methods[] =
 {
   {"__tostring", W__tostring},
@@ -281,6 +296,7 @@ static const luaL_Reg curses_window_methods[] =
   {"getyx", Wgetyx},
   {"mvaddch", Wmvaddch},
   {"mvaddstr", Wmvaddstr},
+  {"nodelay", Wnodelay},
   {NULL, NULL}
 };
 
m> 2015-05-25 22:27:19 -0700 1459' href='/akkartik/mu/commit/html/023jump.cc.html?h=hlt&id=c5ffb6e1cc9c5ff880d037c53b8ebc8562be0008'>c5ffb6e1 ^
65361948 ^
c5ffb6e1 ^
672e3e50 ^


c5ffb6e1 ^


672e3e50 ^



c5ffb6e1 ^
672e3e50 ^


c5ffb6e1 ^


672e3e50 ^






65361948 ^
c5ffb6e1 ^

65361948 ^
c5ffb6e1 ^
672e3e50 ^

c5ffb6e1 ^
65361948 ^
c5ffb6e1 ^
672e3e50 ^




65361948 ^
c5ffb6e1 ^
672e3e50 ^
c5ffb6e1 ^
672e3e50 ^
c5ffb6e1 ^

672e3e50 ^


65361948 ^

672e3e50 ^
c5ffb6e1 ^
672e3e50 ^
c5ffb6e1 ^
672e3e50 ^







65361948 ^
c5ffb6e1 ^

65361948 ^
c5ffb6e1 ^
672e3e50 ^

c5ffb6e1 ^
65361948 ^
c5ffb6e1 ^
672e3e50 ^




65361948 ^
c5ffb6e1 ^
672e3e50 ^
c5ffb6e1 ^
672e3e50 ^
c5ffb6e1 ^

672e3e50 ^


65361948 ^

672e3e50 ^
c5ffb6e1 ^
672e3e50 ^
c5ffb6e1 ^
672e3e50 ^




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