{"id":15633637,"url":"https://github.com/hoelzro/lua-term","last_synced_at":"2025-04-07T17:12:07.245Z","repository":{"id":3715349,"uuid":"4787404","full_name":"hoelzro/lua-term","owner":"hoelzro","description":"Terminal operations for Lua","archived":false,"fork":false,"pushed_at":"2023-12-29T17:58:44.000Z","size":28,"stargazers_count":150,"open_issues_count":3,"forks_count":23,"subscribers_count":13,"default_branch":"master","last_synced_at":"2024-04-13T09:06:08.613Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hoelzro.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES","contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2012-06-25T21:04:17.000Z","updated_at":"2024-04-08T03:40:49.000Z","dependencies_parsed_at":"2024-01-08T20:19:18.402Z","dependency_job_id":null,"html_url":"https://github.com/hoelzro/lua-term","commit_stats":{"total_commits":45,"total_committers":7,"mean_commits":6.428571428571429,"dds":0.1777777777777778,"last_synced_commit":"375fa065efc9a95b289371cf0eb7bf8b3be0bc9c"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hoelzro%2Flua-term","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hoelzro%2Flua-term/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hoelzro%2Flua-term/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hoelzro%2Flua-term/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hoelzro","download_url":"https://codeload.github.com/hoelzro/lua-term/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247694877,"owners_count":20980733,"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":[],"created_at":"2024-10-03T10:49:46.994Z","updated_at":"2025-04-07T17:12:07.213Z","avatar_url":"https://github.com/hoelzro.png","language":"Lua","funding_links":[],"categories":["资源","Lua","Resources","Lua 🌙"],"sub_categories":["Command-line Utilities"],"readme":"Overview\n--------\n\nlua-term is a Lua module for manipulating a terminal.\n\nInstallation\n------------\n\nlua-term is available on Luarocks.\n\n\n## OpenBSD\n\nlua-term is available as an OpenBSD package. Use the proper Lua flavour to\nget the package for your Lua version:\n\n```\n# For Lua 5.1\n$ doas pkg_add -r lua-term\n# For Lua 5.2\n$ doas pkg_add -r lua52-term\n# For Lua 5.3\n$ doas pkg_add -r lua53-term\n```\n\nOr install from ports:\n\n```\n$ cd /usr/ports/devel/lua-term\n$ env FLAVOR=lua51 doas make install\n```\n\n## openSUSE\nlua-term is available in the `devel:languages:lua` devel project on [OBS](https://build.opensuse.org/package/show/devel:languages:lua/lua-luaterm).\n\nAdd the repository and install lua-term via:\n```\nzypper addrepo http://download.opensuse.org/repositories/devel:/languages:/lua/openSUSE_Tumbleweed/devel:languages:lua.repo\nzypper refresh\nzypper in lua-luaterm\n```\n\nAdjust the repository URL to your version of openSUSE by substituting `openSUSE_Tumbleweed` with your actual version eg `opensSUSE_42.2`.\n\n## Windows\n\nlua-term works on Windows as well when virtual terminal processing is enabled. To have this enabled automatically ensure that\n[LuaSystem](https://github.com/lunarmodules/luasystem) is installed (version 0.4.0 or newer). If found, that module will be used\nto enable virtual terminal processing and to switch output to utf-8.\n\nUsage\n-----\n\n```lua\n    local term   = require 'term'\n    local colors = term.colors -- or require 'term.colors'\n\n    print(term.isatty(io.stdout)) -- true if standard output goes to the terminal\n\n    print(colors.red 'hello')\n    print(colors.red .. 'hello' .. colors.reset)\n    print(colors.red, 'hello', colors.reset)\n\n    -- The following functions take an optional IO handle (like io.stdout);\n    -- io.stdout is the default if you don't specify one\n    term.clear()    -- clears the screen\n    term.cleareol() -- clears from the cursor to the end of the line\n    --term.cursor.goto(1, 1) -- It will fail in Lua \u003e= 5.2 because goto is a reserved word.\n    term.cursor['goto'](1, 1) -- This will work on Lua \u003e= 5.2, please use jump instead\n    term.cursor.jump(1, 1) -- jump is just an alias for goto\n    term.cursor.jump(io.stdout, 1, 1)\n    term.cursor.goup(1)\n    term.cursor.godown(1)\n    term.cursor.goright(1)\n    term.cursor.goleft(1)\n    term.cursor.save()    -- save position\n    term.cursor.restore() -- restore position\n```\n\n`term` Functions\n--------------\n\nSome functions in lua-term take an optional file handle argument; if this is\nnot provided, `io.stdout` is used.\n\n### `term.clear([opt_file])`\n\nClear the terminal's contents.\n\n### `term.cleareol([opt_file])`\n\nClear from the current cursor position to the end of the current line.\n\n### `term.isatty(file)`\n\nReturns `true` if `file` is a TTY; `false` otherwise.\n\n*NOTE*: This function has been deprecated in favor of luasystem's implementation\n(or luaposix if you don't need Windows support).\nIf you would like this functionality in the future, please use luasystem.\n\n`term.colors` Values\n------------------\n\nThe following values are available in `term.colors`:\n\n### Terminal Attributes\n\n  * reset\n  * clear (a synonym for reset)\n  * default (a synonym for reset)\n  * bright\n  * dim\n  * underscore\n  * blink\n  * reverse\n  * hidden\n\n### Foreground Colors\n\n  * black\n  * red\n  * green\n  * yellow\n  * blue\n  * magenta\n  * cyan\n  * white\n\n### Background Colors\n\n  * onblack\n  * onred\n  * ongreen\n  * onyellow\n  * onblue\n  * onmagenta\n  * oncyan\n  * onwhite\n\nEvery value in `term.colors` may be used in several ways:\n\n### As a Function\n\n```lua\nprint(colors.red 'hello')\n```\n\n### As a String\n\n```lua\nprint(colors.red .. 'hello' .. colors.reset)\nprint(colors.red, 'hello', colors.reset)\n```\n\n`term.cursor` Functions\n---------------------\n\n### `term.cursor.goto([opt_file], x, y)`\n\nPlace the cursor at (`x`, `y`).\n\n### `term.cursor.jump([opt_file], x, y)`\n\nAn alias for `term.cursor.goto`.\n\n### `term.cursor.goup([opt_file], nlines)`\n\nMoves the cursor up `nlines` lines.\n\n### `term.cursor.godown([opt_file], nlines)`\n\nMoves the cursor down `nlines` lines.\n\n### `term.cursor.goright([opt_file], ncols)`\n\nMoves the cursor right `ncols` columns.\n\n### `term.cursor.goleft([opt_file], ncols)`\n\nMoves the cursor left `ncols` columns.\n\n### `term.cursor.save([opt_file])`\n\nSaves the cursor position.\n\n### `term.cursor.restore([opt_file])`\n\nRestores the cursor position.\n\nAlternatives\n------------\n\nIf you are looking to simply provide coloration to a terminal application and would\nlike to use a more \"tag-like\" API (ex. `colors '%{red}hello%{reset}'`), there is a Lua rock\nnamed ansicolors: https://github.com/kikito/ansicolors.lua\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhoelzro%2Flua-term","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhoelzro%2Flua-term","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhoelzro%2Flua-term/lists"}