Terminal raw mode and window size for IO.FS.Handle / stdin
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 38/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Ambito
- backend
Direzione di ricerca
Start by reading the existing IO.FS.Handle terminal API, the libuv bindings, and the issue’s references to uv_tty_set_mode, uv_tty_reset_mode, and uv_tty_get_winsize. The proposal identifies the desired operations and return type, but leaves API placement and platform behavior open. Done means Lean can set and reset terminal mode and read window dimensions without spawning shell commands.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Description
Lean can tell whether a handle is a terminal (Handle.isTty), but cannot change the terminal's mode or read its size. Terminal UIs written in Lean (lean-tea's TUI, and the TUI and attach command of Aether, github.com/Verilean/aether) spawn a shell for each change:
IO.Process.output { cmd := "sh", args := #["-c", "stty raw -echo min 0 time 1 < /dev/tty"] }
IO.Process.output { cmd := "sh", args := #["-c", "stty size < /dev/tty"] }
This costs a process per call, needs /bin/sh and stty on PATH, and cannot restore the mode if the program is killed between the two calls. They also use min 0 time 1 to get a read timeout on stdin, because a read on stdin cannot otherwise be bounded.
libuv already has the primitives: uv_tty_set_mode (UV_TTY_MODE_NORMAL, _RAW, _IO), uv_tty_reset_mode (async-signal-safe, for restoring at exit) and uv_tty_get_winsize. Std.Async.Signal.sigwinch already exists for resize notifications.
Proposal:
namespace IO.FS.Handle -- or on the tty `Handle` of RFC #13638
inductive TtyMode | normal | raw | io
opaque setTtyMode (h : @& Handle) (mode : TtyMode) : IO Unit
opaque ttySize (h : @& Handle) : IO (UInt16 × UInt16) -- (rows, columns)
end IO.FS.Handle
opaque IO.resetTtyMode : IO Unit -- uv_tty_reset_mode
A second, larger request, for a separate discussion if preferred: spawning a child on a pseudo-terminal (openpty + posix_spawn, or forkpty), returning the master side as a handle with resize. Running interactive programs (shells, REPLs, coding agents) under a Lean program requires this in C today. libuv has no PTY support, so this would be Lean's own code (POSIX, or ConPTY on Windows).
Steps to Reproduce
There is no API to call. The cost of the workaround on Linux, 50 calls each: sh -c true 5.8 ms, sh -c 'stty size < /dev/tty' 6.6 ms per call.
Expected behavior: raw mode, reset and window size without spawning processes.
Actual behavior: isTty only.
Versions
Lean 4.36.0 (x86_64-unknown-linux-gnu), checked against v4.37.0-rc1.
Impact
Add 👍 to issues you consider important. If others benefit from the changes in this issue, please add 👍 to it.
- Lingua principale
- Lean
- Stelle
- 10.3k
- Fork
- 1.1k
- Merge medio
- 16h 45m
- PR unite (30g)
- 361
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di leanprover/lean4
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
leanprover/lean4#16876 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
leanprover/lean4#16842 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
leanprover/lean4#16841 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 82/100
leanprover/lean4#16840 ·
I maintainer di solito rispondono entro 1 giorno
-
doc: stray "public" in Bool and HEq documentationForse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 72/100
leanprover/lean4#16825 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di leanprover/lean4
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
Thai project names become 'project', 'project-2'… (slug keeps ASCII only)Forse già presa @mastel2 l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
storytold/craft-anything#2538 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
compiler-explorer/compiler-explorer#9738 ·
I maintainer di solito rispondono entro 2 giorni