From 79a35574ce6d472f7a7cc4a200a1ed7befe34066 Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Thu, 24 Sep 2026 07:59:43 +0200 Subject: doc: add API documentation --- ttwhy/terminal/echo.cppm | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'ttwhy/terminal/echo.cppm') diff --git a/ttwhy/terminal/echo.cppm b/ttwhy/terminal/echo.cppm index 660cf42..6f1ac2e 100644 --- a/ttwhy/terminal/echo.cppm +++ b/ttwhy/terminal/echo.cppm @@ -27,23 +27,39 @@ namespace ttwhy::terminal constexpr auto vte_cursor_left_sequence_format = "\x1b[{}D"sv; constexpr auto vte_cursor_right_sequence_format = "\x1b[{}C"sv; + //! An asynchronous router that echoes characters and handles terminal navigation. + //! + //! @tparam StreamType The output stream descriptor type. export template struct echo { + //! Construct an echo router writing to an output stream. + //! + //! @param stream The output stream to write echoed text and escape sequences to. explicit echo(StreamType & stream) : m_output_stream{stream} {} + //! Get the current cursor position within the printed line. + //! + //! @return The zero-based cursor position. [[nodiscard]] auto cursor_position() const noexcept -> std::size_t { return m_cursor_position; } + //! Get the maximum cursor position reached on the current line. + //! + //! @return The maximum position reached. [[nodiscard]] auto max_position() const noexcept -> std::size_t { return m_max_position; } + //! Asynchronously process an incoming terminal input event. + //! + //! @param event The input event to handle. + //! @return An awaitable task that completes when processing finishes. auto process(input_event event) -> asio::awaitable { co_await std::visit( -- cgit v1.2.3