From 44d7fec2624dd5a59fc93e229c0e3221f8311278 Mon Sep 17 00:00:00 2001
From: HampusM <hampus@hampusmat.com>
Date: Sun, 12 Jun 2022 14:46:38 +0200
Subject: refactor: improve configuring cursor style

---
 src/game/game.cpp | 8 ++++++--
 src/game/game.hpp | 3 +++
 2 files changed, 9 insertions(+), 2 deletions(-)

(limited to 'src/game')

diff --git a/src/game/game.cpp b/src/game/game.cpp
index 3f76b05..95bedb9 100644
--- a/src/game/game.cpp
+++ b/src/game/game.cpp
@@ -36,6 +36,8 @@ Game::Game(
 	  _cell_helper(std::move(cell_helper)),
 	  _rle_reader(std::move(rle_reader)),
 	  _current_mode(Mode::NORMAL),
+	  _normal_mode_cursor_style(CursorStyle::BlinkingBlock),
+	  _command_mode_cursor_style(CursorStyle::SteadyBar),
 	  _minimum_cursor_pos_y(0)
 {
 }
@@ -87,6 +89,8 @@ void Game::on_start() noexcept
 		StatusLineSection::G,
 		fmt::format("{}x{}", scene_size.get_width(), scene_size.get_height()));
 
+	_cursor_controller->set_cursor_style(_normal_mode_cursor_style);
+
 	_commands["open"] = CommandInfo(
 		{.option_cnt = 1U,
 		 .function = [this](CommandInfo::Options options)
@@ -237,7 +241,7 @@ void Game::_on_normal_mode_update() noexcept
 		_cursor_controller->update_position(
 			_cursor_controller->where() + Vector2::right());
 
-		_cursor_controller->set_cursor_style(CursorStyle::BlinkingBar);
+		_cursor_controller->set_cursor_style(_command_mode_cursor_style);
 
 		_command_mode_input = "";
 
@@ -496,7 +500,7 @@ void Game::_return_to_normal_mode() noexcept
 	_cursor_controller->move_to(_last_pos_before_command_mode.value_or(
 		Vector2({.x = CURSOR_FALLBACK_POS_X, .y = CURSOR_FALLBACK_POS_Y})));
 
-	_cursor_controller->set_cursor_style(CursorStyle::BlinkingBlock);
+	_cursor_controller->set_cursor_style(_normal_mode_cursor_style);
 
 	_current_mode = Mode::NORMAL;
 }
diff --git a/src/game/game.hpp b/src/game/game.hpp
index 09a9ee0..e69ce46 100644
--- a/src/game/game.hpp
+++ b/src/game/game.hpp
@@ -83,6 +83,9 @@ private:
 
 	Mode _current_mode;
 
+	CursorStyle _normal_mode_cursor_style;
+	CursorStyle _command_mode_cursor_style;
+
 	int32_t _minimum_cursor_pos_y;
 
 	std::optional<Vector2> _last_pos_before_command_mode;
-- 
cgit v1.2.3-18-g5258