Terminal rendering for normal-terminal writes.
This deliberately uses direct terminal operations, not a fullscreen diff. Scrollback content is appended once as ordinary terminal output; only the volatile fat-prompt region is cleared and repainted around those appends.
Vars
terminalLock: Lock
Procs
proc acquireTerminalWrite() {....raises: [], tags: [], forbids: [].}
- Enter the single terminal-writer critical section. Reentrant so editor redraw callbacks can hold the frame while minline performs nested writes.
proc beginEditorRedraw(ed: var minline.LineEditor; ready: bool; footerBarBytes: string; footerRowsAboveEditor = 1) {. ...raises: [IOError], tags: [ReadEnvEffect, WriteIOEffect], forbids: [].}
- Start an atomic live-editor redraw frame. The caller must finish with finishEditorRedraw after minline has emitted the editor bytes.
proc enterPromptInput(hasBar: bool; barFooterBytes, promptOnlyBytes: string) {. ...raises: [IOError], tags: [WriteIOEffect], forbids: [].}
- Prepare the cursor for the line editor. In bar mode, the caller has already cleared the reserved prompt region and supplies the repaint bytes.
proc eraseRowsAbove(rows: int) {....raises: [IOError], tags: [WriteIOEffect], forbids: [].}
- Erase rows immediately above the current cursor.
proc finishEditorRedraw(showCaret = true) {....raises: [IOError], tags: [WriteIOEffect], forbids: [].}
- Finish the live-editor redraw frame opened by beginEditorRedraw.
proc hideCaret() {....raises: [IOError], tags: [WriteIOEffect], forbids: [].}
- Hide the physical terminal caret while the prompt is in turn-running mode.
proc releaseTerminalWrite() {....raises: [], tags: [], forbids: [].}
- Leave the terminal-writer critical section acquired by acquireTerminalWrite.
proc resetPromptInputAfterEmpty(hasBar: bool; rows: int; promptOnlyBytes, repaintBytes: string) {. ...raises: [IOError], tags: [WriteIOEffect], forbids: [].}
- Empty submission should keep the prompt/footer on the same floor.
proc restoreCursorStyle() {.noconv, ...raises: [], tags: [WriteIOEffect], forbids: [].}
proc setSteadyCursor() {....raises: [IOError], tags: [WriteIOEffect], forbids: [].}
- Use a steady block cursor while 3code is active.
proc syncWrite(bytes: string) {....raises: [IOError], tags: [WriteIOEffect], forbids: [].}
- Write one synchronized terminal update.
proc writeRaw(bytes: string) {....raises: [IOError], tags: [WriteIOEffect], forbids: [].}
- Direct terminal write owned by the terminal renderer.
Templates
template withTerminalWriteLock(body: untyped)
- Serialize all terminal writes. Reentrant for helpers that compose other terminal operations within one render tick.