| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- #pragma once
- #include <string>
- #include <vector>
- #include <memory>
- #include <functional>
- namespace lumacs {
- class Window; // Forward declaration
- /// @brief Represents a chunk of text in the modeline with a specific face.
- struct ModelineChunk {
- std::string text; ///< The text content to display.
- std::string face_name; ///< The face name for styling (e.g., "mode-line", "mode-line-inactive").
- };
- /// @brief Interface for a modeline segment (e.g., buffer name, line number).
- class ModelineSegment {
- public:
- virtual ~ModelineSegment() = default;
-
- /// @brief Generate the text chunks for this segment.
- /// @param window The window context.
- /// @param active Whether the window is currently focused.
- /// @return A vector of styled text chunks.
- virtual std::vector<ModelineChunk> generate(const std::shared_ptr<Window>& window, bool active) = 0;
-
- /// @brief Get the unique name of the segment (for debugging/config).
- virtual std::string name() const = 0;
- };
- /// @brief Manages the composition of the modeline from various segments.
- class ModelineManager {
- public:
- ModelineManager();
- /// @brief Initialize the default set of segments.
- void create_default_segments();
- /// @brief Register a new segment to be displayed.
- void add_segment(std::shared_ptr<ModelineSegment> segment);
- /// @brief Remove all registered segments.
- void clear_segments();
- /// @brief Generate the complete modeline content for a specific window.
- /// @param window The window to generate modeline for.
- /// @param active Whether the window is active (focused).
- /// @return Full list of styled chunks.
- std::vector<ModelineChunk> generate_content(const std::shared_ptr<Window>& window, bool active);
- private:
- std::vector<std::shared_ptr<ModelineSegment>> segments_;
- };
- } // namespace lumacs
|