| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- #pragma once
- #include <string>
- #include <map>
- #include <memory>
- #include <vector>
- namespace lumacs {
- /// RGB Color representation
- struct Color {
- int r, g, b;
- Color(int r = 0, int g = 0, int b = 0) : r(r), g(g), b(b) {}
-
- /// Convert to ncurses color index (will be assigned dynamically)
- int to_ncurses_color() const;
-
- /// Comparison operator for use in maps
- bool operator<(const Color& other) const;
- };
- /// Theme element types
- enum class ThemeElement {
- // Text elements
- Normal,
- Keyword,
- String,
- Comment,
- Function,
- Type,
- Number,
- Constant,
- Error,
-
- // UI elements
- StatusLine,
- StatusLineInactive,
- MessageLine,
- LineNumber,
- Cursor,
- Selection,
- SearchMatch,
- SearchFail,
-
- // Window elements
- WindowBorder,
- WindowBorderActive,
-
- // Special
- Background
- };
- /// A theme defines colors and attributes for various UI elements
- class Theme {
- public:
- Theme(const std::string& name) : name_(name) {}
-
- /// Set color for a theme element
- void set_color(ThemeElement element, const Color& fg, const Color& bg = Color(-1, -1, -1));
-
- /// Get foreground color for an element
- Color get_fg_color(ThemeElement element) const;
-
- /// Get background color for an element
- Color get_bg_color(ThemeElement element) const;
-
- /// Get ncurses color pair for an element
- int get_color_pair(ThemeElement element) const;
-
- /// Theme name
- const std::string& name() const { return name_; }
-
- /// Initialize all color pairs for ncurses
- void initialize_ncurses_colors();
-
- private:
- std::string name_;
- std::map<ThemeElement, std::pair<Color, Color>> colors_; // fg, bg
- mutable std::map<ThemeElement, int> color_pairs_;
- mutable int next_pair_id_ = 1;
- };
- /// Theme manager - handles multiple themes and switching between them
- class ThemeManager {
- public:
- /// Register a new theme
- void register_theme(std::shared_ptr<Theme> theme);
-
- /// Set the active theme
- void set_active_theme(const std::string& name);
-
- /// Get the active theme
- std::shared_ptr<Theme> active_theme() const { return active_theme_; }
-
- /// Get available theme names
- std::vector<std::string> theme_names() const;
-
- /// Create default themes
- void create_default_themes();
-
- /// Create Everforest dark theme
- std::shared_ptr<Theme> create_everforest_theme();
-
- /// Create default light theme
- std::shared_ptr<Theme> create_default_theme();
-
- private:
- std::map<std::string, std::shared_ptr<Theme>> themes_;
- std::shared_ptr<Theme> active_theme_;
- };
- } // namespace lumacs
|