aboutsummaryrefslogtreecommitdiff
path: root/src/engine/user
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2022-06-08 18:31:58 +0200
committerHampusM <hampus@hampusmat.com>2022-06-13 17:57:01 +0200
commit6d66d5675d0fb78827bc47c49f9d4a1852c7255d (patch)
treee8cbf56d895c6d4acc496fffb076938e822dba40 /src/engine/user
parent7e84d664079d9c407bdf94861825bb05ccf1b0f7 (diff)
feat: implement command mode
Diffstat (limited to 'src/engine/user')
-rw-r--r--src/engine/user/cursor.cpp15
-rw-r--r--src/engine/user/cursor.hpp6
2 files changed, 21 insertions, 0 deletions
diff --git a/src/engine/user/cursor.cpp b/src/engine/user/cursor.cpp
index d348d9e..963531f 100644
--- a/src/engine/user/cursor.cpp
+++ b/src/engine/user/cursor.cpp
@@ -55,6 +55,11 @@ void CursorController::ensure_position() noexcept
_position = _invert_position_y(Vector2(vector2_options));
}
+void CursorController::update_position(const Vector2 &position) noexcept
+{
+ _position = position;
+}
+
void CursorController::hide() noexcept
{
fmt::print(CURSOR_INVISIBLE, fmt::arg("esc", ESC));
@@ -67,6 +72,16 @@ void CursorController::show() noexcept
std::cout.flush();
}
+void CursorController::set_cursor_style(CursorStyle cursor_style) noexcept
+{
+ fmt::print(
+ SET_CURSOR_STYLE,
+ fmt::arg("esc", ESC),
+ fmt::arg("style", static_cast<int>(cursor_style)));
+
+ std::cout.flush();
+}
+
void CursorController::set_bounds(const Bounds &bounds) noexcept
{
_bounds = bounds;
diff --git a/src/engine/user/cursor.hpp b/src/engine/user/cursor.hpp
index 199c86b..ace47ee 100644
--- a/src/engine/user/cursor.hpp
+++ b/src/engine/user/cursor.hpp
@@ -25,6 +25,8 @@ constexpr fmt::string_view REQUEST_CURSOR_POSITION = "{esc}[6n";
constexpr fmt::string_view CURSOR_VISIBLE = "{esc}[?25h";
constexpr fmt::string_view CURSOR_INVISIBLE = "{esc}[?25l";
+constexpr fmt::string_view SET_CURSOR_STYLE = "{esc}[{style} q";
+
const std::unordered_map<Vector2, std::string_view, Vector2Hasher> direction_format_map =
{{Vector2::up(), MOVE_CURSOR_UP},
{Vector2::down(), MOVE_CURSOR_DOWN},
@@ -45,10 +47,14 @@ public:
void ensure_position() noexcept override;
+ void update_position(const Vector2 &position) noexcept override;
+
void hide() noexcept override;
void show() noexcept override;
+ void set_cursor_style(CursorStyle cursor_style) noexcept override;
+
void set_bounds(const Bounds &bounds) noexcept override;
private: