diff options
| author | Thijs <thijs@thijsschreijer.nl> | 2024-06-24 23:18:10 +0200 |
|---|---|---|
| committer | Thijs <thijs@thijsschreijer.nl> | 2024-06-24 23:18:10 +0200 |
| commit | 4dd0fbac93fcd18a8074f5021ca60be4bb87e979 (patch) | |
| tree | 1906c8a2267aab01d98cfbf36bb16785e58087bf | |
| parent | 9143542451bc7b193d4baf2b816b73f59b12cc4c (diff) | |
| download | lua-term-4dd0fbac93fcd18a8074f5021ca60be4bb87e979.tar.gz lua-term-4dd0fbac93fcd18a8074f5021ca60be4bb87e979.tar.bz2 lua-term-4dd0fbac93fcd18a8074f5021ca60be4bb87e979.zip | |
enable Windows support
requires LuaSystem to be installed
| -rw-r--r-- | README.md | 6 | ||||
| -rw-r--r-- | term/init.lua | 13 |
2 files changed, 19 insertions, 0 deletions
| @@ -42,6 +42,12 @@ zypper in lua-luaterm | |||
| 42 | 42 | ||
| 43 | Adjust the repository URL to your version of openSUSE by substituting `openSUSE_Tumbleweed` with your actual version eg `opensSUSE_42.2`. | 43 | Adjust the repository URL to your version of openSUSE by substituting `openSUSE_Tumbleweed` with your actual version eg `opensSUSE_42.2`. |
| 44 | 44 | ||
| 45 | ## Windows | ||
| 46 | |||
| 47 | lua-term works on Windows as well when virtual terminal processing is enabled. To have this enabled automatically ensure that | ||
| 48 | [LuaSystem](https://github.com/lunarmodules/luasystem) is installed (version 0.4.0 or newer). If found, that module will be used | ||
| 49 | to enable virtual terminal processing and to switch output to utf-8. | ||
| 50 | |||
| 45 | Usage | 51 | Usage |
| 46 | ----- | 52 | ----- |
| 47 | 53 | ||
diff --git a/term/init.lua b/term/init.lua index bd2024b..b0387a6 100644 --- a/term/init.lua +++ b/term/init.lua | |||
| @@ -18,6 +18,19 @@ | |||
| 18 | -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | 18 | -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 19 | -- THE SOFTWARE. | 19 | -- THE SOFTWARE. |
| 20 | 20 | ||
| 21 | do -- set console to utf-8 and enable ANSI escape sequences on Windows | ||
| 22 | local ok, sys = pcall(require, "system") | ||
| 23 | if ok and sys.setconsoleflags and sys.windows then | ||
| 24 | sys.setconsoleoutputcp(sys.CODEPAGE_UTF8) | ||
| 25 | if sys.isatty(io.stdout) then | ||
| 26 | sys.setconsoleflags(io.stdout, sys.getconsoleflags(io.stdout) + sys.COF_VIRTUAL_TERMINAL_PROCESSING) | ||
| 27 | end | ||
| 28 | if sys.isatty(io.stderr) then | ||
| 29 | sys.setconsoleflags(io.stderr, sys.getconsoleflags(io.stderr) + sys.COF_VIRTUAL_TERMINAL_PROCESSING) | ||
| 30 | end | ||
| 31 | end | ||
| 32 | end | ||
| 33 | |||
| 21 | local term = require 'term.core' | 34 | local term = require 'term.core' |
| 22 | local sformat = string.format | 35 | local sformat = string.format |
| 23 | local iotype = io.type | 36 | local iotype = io.type |
