TermColor.Terminal.Basic: terminal control and IO #
The sequence builders are pure values. The IO helpers write to stdout and flush explicitly. Cursor
controls are disabled for redirected output and TERM=dumb/TERM=unknown; live objects fall back
to newline-separated snapshots in that mode. Live-region width follows the terminal on each
default-width update; callers can pin it with updateTextAtWidth. Size detection is best effort:
it queries /dev/tty for the current TTY size, then falls back to COLUMNS/LINES.
Move to a one-based terminal column.
Equations
- TermColor.Terminal.cursorToColumnSequence column = TermColor.Terminal.csi✝ ++ toString (column + 1) ++ "G"
Instances For
Erase the current line and return to its first column.
Equations
Instances For
Clear the visible screen and move the cursor to its home position.
Equations
Instances For
Save the current cursor position.
Equations
Instances For
Restore the previously saved cursor position.
Instances For
Enter the terminal's alternate screen buffer.
Equations
Instances For
Leave the terminal's alternate screen buffer.
Equations
Instances For
Hide the terminal cursor.
Equations
Instances For
Show the terminal cursor.
Equations
Instances For
Whether a TTY and terminal declaration allow cursor-control sequences.
Equations
- TermColor.Terminal.terminalControlAllowed isTty (some "dumb") = if (!isTty) = true then false else false
- TermColor.Terminal.terminalControlAllowed isTty (some "unknown") = if (!isTty) = true then false else false
- TermColor.Terminal.terminalControlAllowed isTty term = if (!isTty) = true then false else true
Instances For
Write text to stdout without flushing.
Equations
- TermColor.Terminal.write text = IO.print text
Instances For
Flush stdout.
Equations
- TermColor.Terminal.flush = do let __do_lift ← liftM IO.getStdout __do_lift.flush
Instances For
Render styled text using terminal detection and write it without a newline.
Equations
- TermColor.Terminal.writeText text choice = do let __do_lift ← TermColor.render text choice TermColor.Terminal.write __do_lift
Instances For
Render styled text using terminal detection and write it with a newline.
Equations
- TermColor.Terminal.writeTextLine text choice = do let __do_lift ← TermColor.render (text ++ TermColor.Text.plain "\n") choice TermColor.Terminal.write __do_lift
Instances For
Erase the current line and return to its first column.
Equations
Instances For
Clear the visible screen and flush stdout.
Equations
Instances For
Save the cursor position and flush stdout.
Equations
Instances For
Restore the cursor position and flush stdout.
Equations
Instances For
Enter the alternate screen buffer and flush stdout.
Equations
Instances For
Leave the alternate screen buffer and flush stdout.
Equations
Instances For
Move the cursor up and flush stdout.
Equations
Instances For
Move the cursor down and flush stdout.
Equations
Instances For
Move to a one-based terminal column and flush stdout.
Equations
Instances For
Hide the terminal cursor and flush stdout.
Equations
Instances For
Show the terminal cursor and flush stdout.
Equations
Instances For
Whether stdout is attached to a terminal.
Equations
- TermColor.Terminal.stdoutIsTty = do let __do_lift ← liftM IO.getStdout liftM __do_lift.isTty
Instances For
Whether stdout is a TTY suitable for cursor-control sequences.
Instances For
Whether stdin is attached to a terminal.
Equations
- TermColor.Terminal.stdinIsTty = do let __do_lift ← liftM IO.getStdin liftM __do_lift.isTty
Instances For
A terminal's usable character dimensions.
Instances For
Equations
Equations
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Equations
Query terminal dimensions, returning none when no size can be determined.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Query terminal width, falling back to the layout library's default width.
Equations
- TermColor.Terminal.terminalWidth = do let __do_lift ← TermColor.Terminal.terminalSize match __do_lift with | some size => pure size.columns | none => pure TermColor.Layout.defaultWidth
Instances For
Equations
- One or more equations did not get rendered due to their size.
- TermColor.Terminal.instBEqHitRegion.beq x✝¹ x✝ = false
Instances For
Equations
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Whether a one-based terminal coordinate lies inside a hit region.
Equations
Instances For
Equations
Equations
- One or more equations did not get rendered due to their size.
- TermColor.Terminal.instBEqFrame.beq x✝¹ x✝ = false
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Equations
- One or more equations did not get rendered due to their size.
Instances For
Retained line-oriented screen state for small full-screen applications.
- size : Option TermColor.Terminal.Size
- frame : Frame
Instances For
Start a screen and capture the current terminal size.
Equations
- TermColor.Terminal.Screen.start = do let __do_lift ← TermColor.Terminal.terminalSize pure { size := __do_lift }
Instances For
Render a frame, atomically retaining its hit regions after the write succeeds.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Render a screen, rewriting only lines whose visible text changed.
Equations
- screen.render text choice = screen.renderFrame { text := text } choice
Instances For
Finish a screen and leave the cursor below its last rendered line.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Enable SGR mouse events, optionally including drag reporting.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Enable mouse reporting when stdout is a capable terminal.
Equations
Instances For
Disable mouse reporting.
Equations
Instances For
Scope mouse reporting and restore the terminal mode even when the action fails.
Equations
- TermColor.Terminal.withMouseCapture action drag = do TermColor.Terminal.enableMouse drag tryFinally action (TermColor.Terminal.disableMouse drag)
Instances For
Start an inactive live region.
Equations
Instances For
Use a supplied width for subsequent text updates.
Instances For
Pure output and next state for a multi-line redraw.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Pure output and next state for finishing a live region.
Instances For
Redraw a multi-line region and flush stdout.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Render styled text at a supplied width, redraw a multi-line region, and flush stdout.
Equations
- state.updateTextAtWidth width text choice = do let __do_lift ← TermColor.Terminal.LiveRegion.renderTextAtWidth✝ width text choice (state.setWidth width).update __do_lift
Instances For
Render styled text at the current terminal width, redraw the region, and flush stdout.
When the region has no explicit width, the terminal is queried for every update so live output can reflow after a window resize.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Leave the live region in place and move to the next line.
Equations
- state.finish = match state.finishSequence with | (output, next) => do TermColor.Terminal.write output TermColor.Terminal.flush pure next
Instances For
Hide the cursor for an action and restore it even when the action fails.
Equations
Instances For
Run an action in the alternate screen buffer and restore the normal screen afterward.