Scripting with Lua
From Yzis Wiki
This page is about using lua from within yzis. If you are interested in lua integration from a developer point of view, see Integrating Lua into Yzis
Contents |
Scripting with Lua
The scripting language of Yzis is lua, a small yet powerful scripting language.
Yzis uses lua 5.1 . Because versions of lua are not compatible between themselves, we will only support one version at a given time. Support for lua 5.0 has been dropped.
Most of the lua information can be found on the lua wiki: [Lua Wiki]
There is an excellent tutorial about lua: [Lua Tutorial].
All you need to know about lua is contained in one short manual (but the tutorial is strongly recommended): [Lua 5.1 Manual]
Main functions available in lua
This list is not exhaustive, the reference is the API documentation.
Buffer Control
- line(line_number) : return the text of line line_number
- insert(x,y,text) : insert text at position x,y
- insertline(y, text) : insert a new line with text after line y
- appendline(text) : append a new line containing text at end of file
- replace(x,y,text) : goto x,y and insert text in replace mode
- setline (y, text) : set line y to value text
- remove (x,y,len) : remove len characters at position x,y
- deleteline (y) : delete line y
- linecount() : return the number of lines of the buffer
- filename() : return current buffer file name
View Control
- color(x,y) : return syntax highlighting color for character at position x,y
- highlight(text) : uses the same syntax than the :highlight command (used to tune syntax highlight colors and parameters)
Cursor Control
- wincol() : return the current column
- winline() : return the current line
- winpos() : return the current column,line
- goto(x,y) : move cursor to position x,y
- scrcol() : return the current column on screen
- scrline() : return the current line on screen
- scrgoto(x,y) : move cursor to position x,y on screen
Misc
- version() : return Yzis version
- sendkeys(text) : send raw keys from text to the current view
- connect(event, functionname) : connect Lua function 'functionname' to Yzis event 'event'
- source(filename) : source a Lua file (search this file in standard Yzis directories)
- yzdebug(string) : sends string to the debug output of Yzis
- set(string) : sets global options
- setlocal(string) : sets local options
- newoption(string optionname, string optiongroup, string defaultvalue, string currentvalue, int visibility, int kind)
- map (string key, string mapping)
- imap (string key, string mapping)
