@@ -44,6 +44,11 @@ Supported platforms: Linux, MacOS and Cygwin.
4444 Demonstrates how to read keystrokes with multibyte sequences
4545 (arrow keys).
4646
47+ * [ ` example05.lua ` ] ( ./examples/example05.lua )
48+
49+ Demonstrates how to read keystrokes with multibyte sequences
50+ (arrow keys) using the convenience method [ nocurses.getkey()] ( #nocurses_getkey ) .
51+
4752<!-- ---------------------------------------------------------------------------------------- -->
4853
4954## Documentation
@@ -55,6 +60,9 @@ See also original documentation at https://github.com/LionyxML/nocurses.
5560 * [ nocurses.clrline()] ( #nocurses_clrline )
5661 * [ nocurses.clrscr()] ( #nocurses_clrscr )
5762 * [ nocurses.getch()] ( #nocurses_getch )
63+ * [ nocurses.peekch()] ( #nocurses_peekch )
64+ * [ nocurses.skipch()] ( #nocurses_skipch )
65+ * [ nocurses.getkey()] ( #nocurses_getkey )
5866 * [ nocurses.gettermsize()] ( #nocurses_gettermsize )
5967 * [ nocurses.gotoxy()] ( #nocurses_gotoxy )
6068 * [ nocurses.resetcolors()] ( #nocurses_resetcolors )
@@ -74,32 +82,32 @@ See also original documentation at https://github.com/LionyxML/nocurses.
7482## Module Functions
7583<!-- ---------------------------------------------------------------------------------------- -->
7684
77- * <a id =" nocurses_awake " >** ` nocurses.awake()
85+ * <a id =" nocurses_awake " >** `nocurses.awake()
7886 `** </a >
7987
8088 May be called from any thread to interrupt [ nocurses.getch()] ( #nocurses_getch ) on the main
8189 thread. The main thread is the first thread that loads the * nocurses* module.
8290
8391<!-- ---------------------------------------------------------------------------------------- -->
8492
85- * <a id =" nocurses_clrline " >** ` nocurses.clrline()
93+ * <a id =" nocurses_clrline " >** `nocurses.clrline()
8694 `** </a >
8795
8896 Clears the row contents.
8997
9098<!-- ---------------------------------------------------------------------------------------- -->
9199
92- * <a id =" nocurses_clrscr " >** ` nocurses.clrscr()
100+ * <a id =" nocurses_clrscr " >** `nocurses.clrscr()
93101 `** </a >
94102
95103 Clears the screen.
96104
97105<!-- ---------------------------------------------------------------------------------------- -->
98106
99- * <a id =" nocurses_getch " >** ` nocurses.getch(timeout)
107+ * <a id =" nocurses_getch " >** `nocurses.getch([ timeout] )
100108 `** </a >
101109
102- Gets a character without waiting for enter.
110+ Gets a character byte without waiting for enter.
103111
104112 * * timeout* - optional float, timeout in seconds.
105113
@@ -119,87 +127,143 @@ See also original documentation at https://github.com/LionyxML/nocurses.
119127 see: [ src/notify_capi.h] ( ./src/notify_capi.h ) .
120128
121129 * the terminal size changes.
130+
131+ Otherwise this function returns the obtained character byte as integer value.
132+
133+ <!-- ---------------------------------------------------------------------------------------- -->
134+ * <a id =" nocurses_peekch " >** `nocurses.peekch([ cnt] )
135+ `** </a >
136+
137+ Obtains next character byte from the input queue without consuming the character, i.e.
138+ a subsequent call to [ nocurses.getch()] ( #nocurses_getch ) will deliver this byte again.
139+
140+ * * cnt* - optional integer, number of the byte in the input queue to obtain, first byte
141+ has number 1. If not given, the default value is 1, i.e. the first byte in the
142+ input queue is obtained.
143+
144+ This function does not wait and will return * nil* if the specified input byte is not
145+ available.
146+
147+ The input character byte is returned as integer value.
148+
149+ <!-- ---------------------------------------------------------------------------------------- -->
150+ * <a id =" nocurses_skipch " >** `nocurses.skipch([ cnt] )
151+ `** </a >
152+
153+ Discards bytes in the input queue.
154+
155+ * * cnt* - optional integer, number of bytes in the input queue to discard. If not given,
156+ the default value is 1, i.e. the first byte in the input queue is skipped,
157+ if available..
158+
159+ This function does not wait and will skip only input bytes in the queue that are immediately
160+ available.
161+
162+ This funtion returns the number of bytes skipped in the input queue.
163+
164+ <!-- ---------------------------------------------------------------------------------------- -->
165+ * <a id =" nocurses_getkey " >** `nocurses.getkey([ timeout] )
166+ `** </a >
167+
168+ Returns the name of the pressed key as string.
169+
170+ This function is implemented in Lua (see [ ` getkey.lua ` ] ( ./src/nocurses/getkey.lua ) )
171+ using the low level functions [ getch()] ( #nocurses_getch ) ,
172+ [ peekch()] ( #nocurses_peekch ) and [ skipch()] ( #nocurses_skipch ) and
173+ heuristically determines the pressed key for the current input byte sequence.
174+
175+ * * timeout* - optional float, timeout in seconds.
176+
177+ The timout handling is the same as in the function [ nocurses.getch()] ( #nocurses_getch ) .
178+
179+ If a pressed key could be determined, this functions returns the key name as string
180+ and the consumed raw input bytes as string.
181+
182+ If the pressed key could not be determined from the input byte sequence, this functions
183+ returns the boolean value * false* and the consumed raw input bytes as string.
184+
185+ See also: [ ` example05.lua ` ] ( ./examples/example05.lua )
122186
123187<!-- ---------------------------------------------------------------------------------------- -->
124188
125- * <a id =" nocurses_gettermsize " >** ` nocurses.gettermsize()
189+ * <a id =" nocurses_gettermsize " >** `nocurses.gettermsize()
126190 `** </a >
127191
128192 Gets the columns and rows of the terminal.
129193
130194<!-- ---------------------------------------------------------------------------------------- -->
131195
132- * <a id =" nocurses_gotoxy " >** ` nocurses.gotoxy(x, y)
196+ * <a id =" nocurses_gotoxy " >** `nocurses.gotoxy(x, y)
133197 `** </a >
134198
135199 Sets the cursor do the position x, y. Where x is the row number and y the line number.
136200
137201<!-- ---------------------------------------------------------------------------------------- -->
138202
139- * <a id =" nocurses_resetcolors " >** ` nocurses.resetcolors()
203+ * <a id =" nocurses_resetcolors " >** `nocurses.resetcolors()
140204 `** </a >
141205
142206 Reset terminal to default colors.
143207
144208<!-- ---------------------------------------------------------------------------------------- -->
145209
146- * <a id =" nocurses_setbgrcolor " >** ` nocurses.setbgrcolor(colorName)
210+ * <a id =" nocurses_setbgrcolor " >** `nocurses.setbgrcolor(colorName)
147211 `** </a >
148212
149213 Sets the background color to one of the colors described on the color table below.
150214
151215<!-- ---------------------------------------------------------------------------------------- -->
152216
153- * <a id =" nocurses_setblink " >** ` nocurses.setblink(status)
217+ * <a id =" nocurses_setblink " >** `nocurses.setblink(status)
154218 `** </a >
155219
156220 Sets the blink attribute on or off. * status* can be * true* or * false* .
157221
158222<!-- ---------------------------------------------------------------------------------------- -->
159223
160- * <a id =" nocurses_setcurshape " >** ` nocurses.setcurshape(shapeName)
224+ * <a id =" nocurses_setcurshape " >** `nocurses.setcurshape(shapeName)
161225 `** </a >
162226
163227 Sets the shape of the cursor in the terminal in the shape table below.
164228
165229<!-- ---------------------------------------------------------------------------------------- -->
166230
167- * <a id =" nocurses_setfontbold " >** ` nocurses.setfontbold(status)
231+ * <a id =" nocurses_setfontbold " >** `nocurses.setfontbold(status)
168232 `** </a >
169233
170234 Sets the bold attribute on or off. * status* can be * true* or * false* .
171235
172236<!-- ---------------------------------------------------------------------------------------- -->
173237
174- * <a id =" nocurses_setfontcolor " >** ` nocurses.setfontcolor(colorName)
238+ * <a id =" nocurses_setfontcolor " >** `nocurses.setfontcolor(colorName)
175239 `** </a >
176240
177241 Sets the text color to one of the colors described on the color table below.
178242
179243<!-- ---------------------------------------------------------------------------------------- -->
180244
181- * <a id =" nocurses_setinvert " >** ` nocurses.setinvert(status)
245+ * <a id =" nocurses_setinvert " >** `nocurses.setinvert(status)
182246 `** </a >
183247
184248 Sets the invert attribute on or off. * status* can be * true* or * false* .
185249
186250<!-- ---------------------------------------------------------------------------------------- -->
187251
188- * <a id =" nocurses_settitle " >** ` nocurses.settitle(title)
252+ * <a id =" nocurses_settitle " >** `nocurses.settitle(title)
189253 `** </a >
190254
191255 Sets the title of the terminal.
192256
193257<!-- ---------------------------------------------------------------------------------------- -->
194258
195- * <a id =" nocurses_setunderline " >** ` nocurses.setunderline(status)
259+ * <a id =" nocurses_setunderline " >** `nocurses.setunderline(status)
196260 `** </a >
197261
198262 Sets the underline attribute on or off. * status* can be * true* or * false* .
199263
200264<!-- ---------------------------------------------------------------------------------------- -->
201265
202- * <a id =" nocurses_wait " >** ` nocurses.wait()
266+ * <a id =" nocurses_wait " >** `nocurses.wait()
203267 `** </a >
204268
205269 Waits for the user to hit [ ENTER] .
0 commit comments