descriptionnone
ownersgilles@umd.edu
last changeTue, 25 Feb 2020 16:42:03 +0000 (25 11:42 -0500)
content tags
add:
README
This is lua-unibilium, lua bindings to unibilium.

Unibilium may be found at https://github.com/mauke/unibilium/

Assume you have

        local unibi = require("unibilium")

in a lua script. Here is the translation to unibilium.h

 - u = unibi.from_mem(mem)   -- unibi_from_mem
   u = unibi.from_term(term) -- unibi_from_term
   u = unibi.from_env()      -- unibi_from_env

   These return (garbage-collected) unibi_term* objects. (unibi_from_fd
   and unibi_from_fp are not directly wrapped -- use lua io mechanisms
   and call unibi.from_mem for the same effect).

 - z = u[X]

   This pulls out a property from u, using one of the unibi_get_XYZ
   family. X should be a string based on uninames.c in the unibilium
   project. It can be a long-form property name, like "can_change", or a
   short name, like "ccc". X may be an extended property, like "Tc".

   If u does not have the property referred to by X, then z will be nil.

   If X refers to a boolean property (like "ccc"), then z will be a
   boolean. If X refers to a numeric property (like "cols"), then z will
   be an integer. If X refers to a string property, like "sgr", then z
   is an object wrapping that string (see below).

   While unibilium allows setting (extended) properties, this binding
   does not expose that feature.


 - z(p1, p2, ...)

   If z is is a (non-nil) string property from u, such as u["sgr"], then
   z may be called. This invokes unibi_run, using the z itself as the
   format parameter and p1, p2, ... as the arguments. The resulting
   string is returned.

   So the following should write "hello", then move the cursor to
   (y=2,x=3), then write "world":

        local unibi = require("unibilium")
        u = unibi.from_env()
        move = u["cursor_address"]
        if move then
                io.write("hello" .. move(2, 3) .. "world")
        end

   If z takes more parameters than are provided, zeroes are silently
   added. If z takes less parameters than are provided, the remainder
   are silently discarded.
shortlog
2020-02-25 S. Gillesinitialmasterv2.0.0
tags
4 years ago v2.0.0
heads
4 years ago master