gsh/input/display

The display module renders the REPL prompt and active input buffer to the terminal output stream.

It provides real-time, syntax-highlighted visual feedback during typing using the contour library, while applying defensive rendering heuristics to prevent ANSI escaping artifacts during incomplete string inputs.

Values

pub fn render(prompt: String, buffer: String) -> Nil

Clears the current line buffer and redraws the prompt along with the user’s input.

Rendering Heuristics:

  • Line Reset: Invokes terminal.clear_line() to erase the previous cursor line.
  • Quote Balancing: Counts quotation marks (") across input graphemes. If the count is odd (indicating an unclosed string literal), syntax highlighting is temporarily bypassed to prevent broken ANSI color code rendering.
  • ANSI Highlighting: When quote counts are balanced, passes the buffer string to contour.to_ansi() for real-time Gleam syntax coloring before output.
Search Document