std:term リファレンス
import term := "std:term" で取得する端末制御モジュール。raw mode の切り替え・キー入力の読み取り・端末サイズの取得を提供する。
peek_key
peek_key()
peek_key: { Effect(Result(Int), Io) }
先読みバッファーの先頭 1 バイトを消費せず返す (無ければ empty)。
効果ハンドラーの操作である。handle の操作スロットに peek_key と書いて横取りできる(language-spec.md §17.9)。
>>> term.peek_key() Err({ kind := "empty", message := "term.peek_key: no buffered input" |})
raw_mode
raw_mode(block)
raw_mode: { EffectConduit({ a }) | Effect(Result(a), Io) }
端末を raw mode にして block を実行し、終了時に必ず元へ復元する (同期)。
効果ハンドラーの操作である。handle の操作スロットに raw_mode と書いて横取りできる(language-spec.md §17.9)。
>>> term.raw_mode({| term.read_key(1000) })
read_key
read_key(timeout_ms)
read_key: { Int | Effect(Future(Result(Int)), Io) }
標準入力から 1 バイト読む (timeout_ms 省略・0 でブロック)。
効果ハンドラーの操作である。handle の操作スロットに read_key と書いて横取りできる(language-spec.md §17.9)。
>>> key := term.read_key(1000) >>> print key
size
size()
size: { Effect(Result({ rows: Int, cols: Int |}), Io) }
端末の行数・列数を返す (同期)。
効果ハンドラーの操作である。handle の操作スロットに size と書いて横取りできる(language-spec.md §17.9)。
>>> dims := term.size()! >>> print dims