From 912e7b10facdd3b2565423206ae25b1d6e4f7dd9 Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Sat, 20 Jun 2026 11:54:06 +0200 Subject: lib: add xterm policy --- ttwhy/routers/echo.cppm | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'ttwhy/routers') diff --git a/ttwhy/routers/echo.cppm b/ttwhy/routers/echo.cppm index 40e68d6..7f2550e 100644 --- a/ttwhy/routers/echo.cppm +++ b/ttwhy/routers/echo.cppm @@ -22,6 +22,8 @@ namespace ttwhy::routers export template struct echo { + using terminal_policy = scanners::xterm_policy; + explicit echo(StreamType & stream) : m_output_stream{stream} {} @@ -42,7 +44,7 @@ namespace ttwhy::routers } else if constexpr (std::same_as) { - co_await process_navigation_key(event.key); + co_await process_navigation_key(event); } }, event); @@ -77,16 +79,23 @@ namespace ttwhy::routers }; } - auto process_navigation_key(scanners::navigation_key key) -> asio::awaitable + auto process_navigation_key(scanners::navigation_event event) -> asio::awaitable { - switch (key) + auto modifiers = std::to_underlying(event.modifiers); + + switch (event.key) { case scanners::navigation_key::delete_key: - co_await asio::async_write(m_output_stream, asio::buffer("{DEL}"), asio::as_tuple(asio::use_awaitable)); + { + auto message = std::format("{{DEL, MODS:{}}}", static_cast(modifiers)); + co_await asio::async_write(m_output_stream, asio::buffer(message), asio::as_tuple(asio::use_awaitable)); break; + } default: - co_await asio::async_write(m_output_stream, asio::buffer(std::format("{{NAV:{}}}", std::to_underlying(key))), - asio::as_tuple(asio::use_awaitable)); + { + auto message = std::format("{{NAV:{}, MODS:{}}}", static_cast(event.key), static_cast(modifiers)); + co_await asio::async_write(m_output_stream, asio::buffer(message), asio::as_tuple(asio::use_awaitable)); + } } } -- cgit v1.2.3