#pragma once

#include <string>
#include <vector>
#include <memory>

namespace lumacs {

class EditorCore; // Forward declaration

/// @brief Manages the recording and playback of keyboard macros.
class MacroManager {
public:
    explicit MacroManager(EditorCore& core);

    /// @brief Starts recording a new keyboard macro. Clears any existing macro.
    void start_kbd_macro();

    /// @brief Stops recording the current macro or executes the last recorded macro.
    void end_kbd_macro_or_call();

    /// @brief Records a key sequence if macro recording is currently active.
    /// @param key_sequence The key sequence to record.
    void record_key_sequence(const std::string& key_sequence);

    /// @brief Checks if macro recording is currently active.
    [[nodiscard]] bool is_recording_macro() const noexcept { return recording_macro_; }

    /// @brief Retrieves the last recorded macro's key sequences.
    [[nodiscard]] const std::vector<std::string>& get_last_macro() const noexcept { return last_macro_; }

private:
    EditorCore& core_;

    std::vector<std::string> current_macro_;
    std::vector<std::string> last_macro_;
    bool recording_macro_ = false;
};

} // namespace lumacs
