#pragma once #include #include #include namespace lumacs { /// Emacs-style kill ring for cut/copy/paste operations /// Maintains a circular buffer of killed/copied text class KillRing { public: /// Constructor with optional maximum size /// @param max_size Maximum number of entries to keep (default: 60) explicit KillRing(size_t max_size = 60); /// Push new text to the kill ring /// @param text Text to add to the ring void push(std::string text); /// Get the current entry in the kill ring /// @return Current text, or empty string if ring is empty std::string current() const; /// Move to previous entry and return it /// @return Previous text in the ring std::string previous(); /// Move to next entry and return it /// @return Next text in the ring std::string next(); /// Check if the kill ring is empty /// @return true if the ring contains no entries bool empty() const noexcept; /// Get the number of entries in the ring /// @return Number of entries currently stored size_t size() const noexcept; /// Clear all entries from the ring void clear(); /// Enable append mode for the next push operation /// When append mode is active, the next push will append to the current entry /// instead of creating a new one void set_append_next(bool append = true) { append_next_ = append; } private: std::deque ring_; ///< The circular buffer of text entries size_t max_size_; ///< Maximum number of entries to keep size_t current_index_ = 0; ///< Current position in the ring bool append_next_ = false; ///< Whether to append to current entry on next push }; } // namespace lumacs