{"id":22562213,"url":"https://github.com/max1220/lua-tmt","last_synced_at":"2025-07-05T23:39:46.261Z","repository":{"id":101936942,"uuid":"141556193","full_name":"max1220/lua-tmt","owner":"max1220","description":"Simple lua binding for libtmt","archived":false,"fork":false,"pushed_at":"2019-06-25T23:02:41.000Z","size":13,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-02T13:16:25.291Z","etag":null,"topics":["lua","lua-bindings","terminal-emulator","terminal-emulators"],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/max1220.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-07-19T09:27:29.000Z","updated_at":"2023-02-21T11:38:08.000Z","dependencies_parsed_at":null,"dependency_job_id":"a5b63a73-f08c-4a5e-a1a5-889c0c3bc5bb","html_url":"https://github.com/max1220/lua-tmt","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/max1220%2Flua-tmt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/max1220%2Flua-tmt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/max1220%2Flua-tmt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/max1220%2Flua-tmt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/max1220","download_url":"https://codeload.github.com/max1220/lua-tmt/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246034266,"owners_count":20712851,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["lua","lua-bindings","terminal-emulator","terminal-emulators"],"created_at":"2024-12-07T22:12:06.704Z","updated_at":"2025-03-28T12:42:34.843Z","avatar_url":"https://github.com/max1220.png","language":"C","readme":"lua-tmt\n-------\n\nSimple lua binding for [libtmt](https://github.com/deadpixi/libtmt), the tiny mock terminal library.\n\nThis is a terminal emulation library, it takes strings with terminal escape sequences, and updates a cell-matrix and a few paramters accordingly.\n\nWith a library like [lpty](http://tset.de/lpty/index.html), one can create terminal multiplexers, or GUI terminal emulators.  \n\n\n\nInstallation\n------------\n\nAfter cloning the repository, or downloading the .zip, modify the makefile if needed. By default, it compiles using the Lua 5.1 headers.\n\nThen build the project by running `make` in this folder.\n\nThe generated `tmt.so` is the Lua library and can be copied to your project path, or(to install systemwide) somewhere in lua's package.cpath.\n\nTo list Lua's default package.cpath from bash: `lua -e \"print((package.cpath:gsub(';', '\\n')))\"`\n\n\n\nUsage\n-----\n\nThe library(`tmt = require(\"tmt\")`) exports one function(`tmt.new(w,h)`) and a lookup table(`tmt.special_keys[KEY_NAME] = terminal_escape_code`):\nA terminal returned by `term = tmt.new` supports the following functions:  \n\n\n* `events = term:write(str)` writes the string `str` to the terminal.\n\n   The string can contain terminal escape sequences supported by libtmt.\n\n   events is a table containing a list of events. Each events has a type.  \n   The following events might be generated:\n\n   * `screen` the screen content has been updated\n   * `bell` the terminal should do whatever bell should do\n   * `answer` the terminal has recived an answer. The answer is in the `answer`-field in the event's table\n   * `cursor` the cursor has moved. The new x,y is stored in the event's table at `x` and `y`.\n\n\n* `screen = term:get_screen()` gets the current screen content as a table.\n\n   The returned table contains 3 fields, `width`(screen width), `height`(screen height), and `lines`.\n\n   lines is a list of line-tables, each a list of cells, so that  \n   `lines[y]` contains a line-table(list of cells), and\n   `lines[y][x]` contains a cell.\n\n   Each line also contains a field `dirty`, which is true if the line was changed since it was last drawn.\n\n   Each cell is a table and has the following fields:\n   `char` (integer) The character number(convert to string using string.char)\n   `fg` (integer) The foreground ANSI terminal color\n   `bg` (integer) The background ANSI terminal color\n   `bold`, `dim`, `underline`, `blink`, `reverse`, `invisible` (boolean) character attributes\n\n\n* `x, y = term:get_cursor()` Gets the current cursor position.\n\n\n* `width, height = term:get_size()` Gets the terminal size(columns, rows)\n\n\n* `term:set_size(width, height)` Sets the terminal size to width, height(columns, rows)\n\n\n\nExample\n-------\n\nFor a more complete example, see example_dump_screen.lua.\n\n\n```\nlocal tmt = require(\"tmt\")\nlocal term = tmt.new(80, 25)\nterm:write(\"Hello World!\")\nlocal screen = term:get_screen()\nfor _, cell in ipairs(screen.lines[1]) do\n\tio.write(string.char(cell.char))\nend\nio.write(\"\\n\")\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmax1220%2Flua-tmt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmax1220%2Flua-tmt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmax1220%2Flua-tmt/lists"}