The NCLua library adds event handling and 2D graphics to Lua scripts.
Programs written in C can use libnclua to run embedded NCLua scripts, i.e.,
Lua scripts that use the APIs exported by libnclua; Lua scripts can also use
libnclua, either through the C API or by requiring the appropriated modules
-- e.g., canvas for 2D graphics, event for general event handling,
event.stopwatch for stopwatch timers, event.tcp_socket for asynchronous
TCP sockets, event.http_soup for asynchronous HTTP requests, etc. The
NCLua library comes with a standalone interpreter, called nclua
(cf. src/nclua.c), which can be used to run NCLua scripts.
For stable releases and binaries, cf. http://www.telemidia.puc-rio.br/~gflima/nclua.
For the latest sources, cf. https://github.com/telemidia/nclua.
NCLua is the Lua dialect used by the Brazilian digital TV middleware, called Ginga (cf. http://www.ginga.org.br). The reference implementation of Ginga (>= 0.14) uses libnclua to run NCLua scripts.
Required:
- Lua >= 5.2, http://www.lua.org
- Cairo >= 1.10, http://cairographics.org
- GLib >= 2.32, https://developer.gnome.org/glib
- Pango >= 1.30, http://www.pango.org
Optional:
- GIO >= 2.32, https://developer.gnome.org/gio
- Libsoup >= 2.42, https://developer.gnome.org/libsoup
- GTK+ >= 3.4.2, http://www.gtk.org
GIO is used by the tcp event class, Libsoup is used by the http event
class, and GTK+ is used by the nclua binary. These libraries are
optional, if they are not present the corresponding modules are not built.
On Ubuntu-based distros, to install the dependencies run:
$ sudo apt-get install -y git gcc g++ autotools-dev dh-autoreconf \
liblua5.2-dev libglib2.0-dev libpango1.0-dev \
librsvg2-dev libgtk-3-dev libsoup2.4-dev -qq
To build with autotools run:
$ ./bootstrap
$ ./configure --prefix=/usr/
$ make
For a complete reference, cf. nclua/canvas.c.
Functions:
canvas.newcreates a new canvascanvas:attrAntiAliasgets or sets the anti-alias attributecanvas:attrClipgets or sets the clip regioncanvas:attrColorgets or sets the color attributecanvas:attrCropgets or sets the crop regioncanvas:attrFiltergets or sets the filter attributecanvas:attrFlipgets or sets the flip attributecanvas:attrFontgets or sets the font attributecanvas:attrLineWidthgets or sets the line width attributecanvas:attrOpacitygets or sets the opacity attributecanvas:attrRotationgets or sets the rotation attributecanvas:attrScalegets or sets the scale attributecanvas:attrSizegets the dimensions in pixelscanvas:clearclears canvascanvas:composecomposes two canvascanvas:drawEllipsedraws an ellipsecanvas:drawLinedraws a linecanvas:drawPolygondraws a polygoncanvas:drawRectdraws a rectanglecanvas:drawRoundRectdraws a rectangle with rounded cornerscanvas:drawTextdraws textcanvas:flushcommits the pending operationscanvas:measureTextmeasures textcanvas:pixelgets or sets pixel
Internal functions (for debugging):
canvas:_dump_to_filedumps canvas content to PNG filecanvas:_dump_to_memorydumps canvas content to memory addresscanvas:_resizeresizes canvas contentcanvas:_surfacereturns a pointer to canvas content
For a complete reference, cf. nclua/dir.c.
Functions:
dir.dirgets an iterator for pathdir.testtests whether path satisfies a given query
For a complete reference, cf. User API section in nclua/event/init.lua.
Event classes:
nclNCL (Nested Context Language) eventskeykeyboard inputpointermouse inputhttpHTTP requeststcpTCP/IP messagesuseruser defined
Functions:
event.postposts event into input or output queuesevent.registerregisters event handlerevent.timersets up timer that calls a function when expiredevent.unregisterunregisters event handlerevent.uptimereturns the up-time since script started
The libnclua API is used by C programs to run NCLua scripts.
Core functions (cf. lib/nclua.c):
nclua_openopens the librarynclua_closecloses the librarynclua_cycleprocesses pending eventsnclua_receivereceives an eventnclua_sendsends an eventnclua_paintpaints top-level canvas onto memorynclua_resizeresizes top-level canvas
Wrapper functions (cf. lib/ncluaw.c, Lua-free interface):
ncluaw_event_key_initinitializes key eventncluaw_event_ncl_initinitializes NCL eventncluaw_event_pointer_initinitializes pointer eventncluaw_event_cloneclones eventncluaw_event_freefrees eventncluaw_event_equalscompares eventsncluaw_openopens the wrapper libraryncluaw_closecloses the wrapper libraryncluaw_at_panicinstalls panic functionncluaw_cycleprocesses pending eventsncluaw_receivereceives eventncluaw_sendsends eventncluaw_send_key_eventsends key eventncluaw_send_ncl_eventsends NCL eventncluaw_send_pointer_eventsends pointer eventncluaw_paintpaints top-level canvas onto memoryncluaw_resizeresizes top-level canvas
Copyright (C) 2013-2018 PUC-Rio/Laboratorio TeleMidia
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. A copy of the license is included in the "GNU Free Documentation License" file as part of this distribution.