aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Hoelz <rob@hoelz.ro>2024-07-01 21:55:35 -0500
committerGitHub <noreply@github.com>2024-07-01 21:55:35 -0500
commit15fb24d27881324ae400d401dc9afbea960aabd2 (patch)
tree1906c8a2267aab01d98cfbf36bb16785e58087bf
parent9143542451bc7b193d4baf2b816b73f59b12cc4c (diff)
parent4dd0fbac93fcd18a8074f5021ca60be4bb87e979 (diff)
downloadlua-term-15fb24d27881324ae400d401dc9afbea960aabd2.tar.gz
lua-term-15fb24d27881324ae400d401dc9afbea960aabd2.tar.bz2
lua-term-15fb24d27881324ae400d401dc9afbea960aabd2.zip
Merge pull request #27 from Tieske/windowsHEADmaster
enable Windows support
-rw-r--r--README.md6
-rw-r--r--term/init.lua13
2 files changed, 19 insertions, 0 deletions
diff --git a/README.md b/README.md
index 9ea4dd6..faf0194 100644
--- a/README.md
+++ b/README.md
@@ -42,6 +42,12 @@ zypper in lua-luaterm
42 42
43Adjust the repository URL to your version of openSUSE by substituting `openSUSE_Tumbleweed` with your actual version eg `opensSUSE_42.2`. 43Adjust 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
47lua-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
49to enable virtual terminal processing and to switch output to utf-8.
50
45Usage 51Usage
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
21do -- 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
32end
33
21local term = require 'term.core' 34local term = require 'term.core'
22local sformat = string.format 35local sformat = string.format
23local iotype = io.type 36local iotype = io.type