macro_manager.hpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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. /// @brief Retrieves the last recorded macro's key sequences.
  21. [[nodiscard]] const std::vector<std::string>& get_last_macro() const noexcept { return last_macro_; }
  22. private:
  23. EditorCore& core_;
  24. std::vector<std::string> current_macro_;
  25. std::vector<std::string> last_macro_;
  26. bool recording_macro_ = false;
  27. };
  28. } // namespace lumacs