类似C的getchar(),read(io, Char)仍然需要回车,谢谢哈。
找到这两个函数可用。
function getc1()
ret = ccall(:jl_tty_set_mode, Int32, (Ptr{Cvoid},Int32), stdin.handle, true)
ret == 0 || error(“unable to switch to raw mode”)
c = read(stdin, Char)
ccall(:jl_tty_set_mode, Int32, (Ptr{Cvoid},Int32), stdin.handle, false)
return c
end
using REPL
function getc2()
t = REPL.TerminalMenus.terminal
REPL.Terminals.raw!(t, true) || error(“unable to switch to raw mode”)
c = Char(REPL.TerminalMenus.readkey(t.in_stream))
REPL.Terminals.raw!(t, false)
return c
end