Skip to content

Commit

Permalink
feat: introduce -it option for colored and bigger interactive terminal
Browse files Browse the repository at this point in the history
  • Loading branch information
edubart committed Oct 7, 2023
1 parent 8aedc6f commit 93f8a23
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/cartesi-machine.lua
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,12 @@ where options are:
-i or --htif-console-getchar
run in interactive mode.
-it
run in interactive mode like -i,
but also sets terminal features and size in the guest to match with the host.
This option will copy TERM, LANG, LC_ALL environment variables from the host to the guest,
allowing the use of true colors and special characters when the host terminal supports.
--htif-yield-manual
honor yield requests with manual reset by target.
Expand Down Expand Up @@ -643,6 +649,26 @@ local options = {
return true
end,
},
{
"^%-it$",
function(all)
if not all then return false end
htif_console_getchar = true
local term, lang, lc_all = os.getenv("TERM"), os.getenv("LANG"), os.getenv("LC_ALL")
if term then append_init = append_init .. "export TERM=" .. term .. "\n" end
if lang then append_init = append_init .. "export LANG=" .. lang .. "\n" end
if lc_all then append_init = append_init .. "export LC_ALL=" .. lc_all .. "\n" end
local stty <close> = assert(io.popen("stty size"))
local line = assert(stty:read(), "command failed: stty size")
if line then
local rows, cols = line:match("^([0-9]+) ([0-9]+)$")
if rows and cols then
append_init = append_init .. "busybox stty rows " .. rows .. " cols " .. cols .. "\n"
end
end
return true
end,
},
{
"^%-%-htif%-yield%-manual$",
function(all)
Expand Down

0 comments on commit 93f8a23

Please sign in to comment.