diff options
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( |
