macro_manager.hpp 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. #pragma once
  2. #include <string>
  3. #include <vector>
  4. #include <memory>
  5. namespace lumacs {
  6. class EditorCore; // Forward declaration
  7. /// @brief Manages the recording and playback of keyboard macros.
  8. class MacroManager {
  9. public:
  10. explicit MacroManager(EditorCore& core);
  11. /// @brief Starts recording a new keyboard macro. Clears any existing macro.
  12. void start_kbd_macro();
  13. /// @brief Stops recording the current macro or executes the last recorded macro.
  14. void end_kbd_macro_or_call();
  15. /// @brief Records a key sequence if macro recording is currently active.
  16. /// @param key_sequence The key sequence to record.
  17. void record_key_sequence(const std::string& key_sequence);
  18. /// @brief Checks if macro recording is currently active.
  19. [[nodiscard]] bool is_recording_macro() const noexcept { return recording_macro_; }
  20. private:
  21. EditorCore& core_;
  22. std::vector<std::string> current_macro_;
  23. std::vector<std::string> last_macro_;
  24. bool recording_macro_ = false;
  25. };
  26. } // namespace lumacs