diff options
| author | Felix Morgner <felix.morgner@gmail.com> | 2026-09-24 07:59:43 +0200 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@gmail.com> | 2026-09-24 07:59:43 +0200 |
| commit | 79a35574ce6d472f7a7cc4a200a1ed7befe34066 (patch) | |
| tree | 1fb3c1c33645692bc041af8d285bb99754887149 /ttwhy/terminal/echo.cppm | |
| parent | d05b9343f69a0841043963088e0003368e205bd9 (diff) | |
| download | ttwhy-79a35574ce6d472f7a7cc4a200a1ed7befe34066.tar.xz ttwhy-79a35574ce6d472f7a7cc4a200a1ed7befe34066.zip | |
doc: add API documentation
Diffstat (limited to 'ttwhy/terminal/echo.cppm')
| -rw-r--r-- | ttwhy/terminal/echo.cppm | 16 |
1 files changed, 16 insertions, 0 deletions
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<typename StreamType> 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<void> { co_await std::visit( |
