aboutsummaryrefslogtreecommitdiff
path: root/ttwhy/routers/echo.cppm
diff options
context:
space:
mode:
Diffstat (limited to 'ttwhy/routers/echo.cppm')
-rw-r--r--ttwhy/routers/echo.cppm21
1 files changed, 15 insertions, 6 deletions
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<typename StreamType>
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<scanners::navigation_event, event_type>)
{
- 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<void>
+ auto process_navigation_key(scanners::navigation_event event) -> asio::awaitable<void>
{
- 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<int>(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<int>(event.key), static_cast<int>(modifiers));
+ co_await asio::async_write(m_output_stream, asio::buffer(message), asio::as_tuple(asio::use_awaitable));
+ }
}
}