diff options
| author | Thijs Schreijer <thijs@thijsschreijer.nl> | 2025-06-09 22:31:00 +0200 |
|---|---|---|
| committer | Thijs Schreijer <thijs@thijsschreijer.nl> | 2025-06-09 23:04:57 +0200 |
| commit | c157641a4e68e4b292a2149232dc75c6171c9310 (patch) | |
| tree | 7289a03c1b2f8b7dbeefd7e3fdd2a46f79a36f02 /spec/04-term_spec.lua | |
| parent | e62b0b470eb87b1cb7ed511ba7b14845a1958134 (diff) | |
| download | luasystem-fix/control.tar.gz luasystem-fix/control.tar.bz2 luasystem-fix/control.zip | |
fix(term): report only printables as charactersfix/control
readkey would return "char" as type for control characters, yet
they are not printable.
Diffstat (limited to '')
| -rw-r--r-- | spec/04-term_spec.lua | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/spec/04-term_spec.lua b/spec/04-term_spec.lua index 0ce0033..5dea046 100644 --- a/spec/04-term_spec.lua +++ b/spec/04-term_spec.lua | |||
| @@ -902,6 +902,14 @@ describe("Terminal:", function() | |||
| 902 | end) | 902 | end) |
| 903 | 903 | ||
| 904 | 904 | ||
| 905 | it("reads a control byte for single-byte control characters", function() | ||
| 906 | setbuffer("\000\031\127") | ||
| 907 | assert.are.same({"\000", "ctrl"}, {system.readansi(0)}) | ||
| 908 | assert.are.same({"\031", "ctrl"}, {system.readansi(0)}) | ||
| 909 | assert.are.same({"\127", "ctrl"}, {system.readansi(0)}) | ||
| 910 | end) | ||
| 911 | |||
| 912 | |||
| 905 | it("reads a multi-byte characters one at a time", function() | 913 | it("reads a multi-byte characters one at a time", function() |
| 906 | setbuffer(string.char(226, 130, 172) .. -- "€" single | 914 | setbuffer(string.char(226, 130, 172) .. -- "€" single |
| 907 | string.char(240, 159, 154, 128)) -- "🚀" double | 915 | string.char(240, 159, 154, 128)) -- "🚀" double |
| @@ -952,7 +960,7 @@ describe("Terminal:", function() | |||
| 952 | 960 | ||
| 953 | it("returns a single <esc> character if no sequence is found", function() | 961 | it("returns a single <esc> character if no sequence is found", function() |
| 954 | setbuffer("\27") | 962 | setbuffer("\27") |
| 955 | assert.are.same({"\27", "char"}, {system.readansi(0)}) | 963 | assert.are.same({"\27", "ctrl"}, {system.readansi(0)}) |
| 956 | end) | 964 | end) |
| 957 | 965 | ||
| 958 | 966 | ||
