diff options
Diffstat (limited to 'src/engine/user/cursor.cpp')
-rw-r--r-- | src/engine/user/cursor.cpp | 44 |
1 files changed, 34 insertions, 10 deletions
diff --git a/src/engine/user/cursor.cpp b/src/engine/user/cursor.cpp index 963531f..b38cee0 100644 --- a/src/engine/user/cursor.cpp +++ b/src/engine/user/cursor.cpp @@ -10,7 +10,10 @@ CursorController::CursorController() noexcept { } -void CursorController::move(const Vector2 &direction, const uint32_t &amount) noexcept +void CursorController::move( + const Vector2 &direction, + const uint32_t &amount, + bool flush_cout) noexcept { auto direction_format = direction_format_map.at(direction); @@ -18,12 +21,16 @@ void CursorController::move(const Vector2 &direction, const uint32_t &amount) no fmt::runtime(direction_format.data()), fmt::arg("esc", ESC), fmt::arg("amount", amount)); - std::cout.flush(); + + if (flush_cout) + { + std::cout.flush(); + } _position = _position.to_direction(direction, static_cast<Vector2::Value>(amount)); } -void CursorController::move_to(const Vector2 &position) noexcept +void CursorController::move_to(const Vector2 &position, bool flush_cout) noexcept { const auto inverted_pos = _invert_position_y(position); @@ -32,7 +39,11 @@ void CursorController::move_to(const Vector2 &position) noexcept fmt::arg("esc", ESC), fmt::arg("row", inverted_pos.get_y()), fmt::arg("column", inverted_pos.get_x() + 1)); - std::cout.flush(); + + if (flush_cout) + { + std::cout.flush(); + } _position = position; } @@ -60,26 +71,39 @@ void CursorController::update_position(const Vector2 &position) noexcept _position = position; } -void CursorController::hide() noexcept +void CursorController::hide(bool flush_cout) noexcept { fmt::print(CURSOR_INVISIBLE, fmt::arg("esc", ESC)); - std::cout.flush(); + + if (flush_cout) + { + std::cout.flush(); + } } -void CursorController::show() noexcept +void CursorController::show(bool flush_cout) noexcept { fmt::print(CURSOR_VISIBLE, fmt::arg("esc", ESC)); - std::cout.flush(); + + if (flush_cout) + { + std::cout.flush(); + } } -void CursorController::set_cursor_style(CursorStyle cursor_style) noexcept +void CursorController::set_cursor_style( + CursorStyle cursor_style, + bool flush_cout) noexcept { fmt::print( SET_CURSOR_STYLE, fmt::arg("esc", ESC), fmt::arg("style", static_cast<int>(cursor_style))); - std::cout.flush(); + if (flush_cout) + { + std::cout.flush(); + } } void CursorController::set_bounds(const Bounds &bounds) noexcept |