theme2.rs

  1mod registry;
  2mod settings;
  3mod themes;
  4
  5pub use registry::*;
  6pub use settings::*;
  7
  8use gpui2::{HighlightStyle, Hsla, SharedString};
  9use std::sync::Arc;
 10
 11pub struct Theme {
 12    pub metadata: ThemeMetadata,
 13
 14    pub transparent: Hsla,
 15    pub mac_os_traffic_light_red: Hsla,
 16    pub mac_os_traffic_light_yellow: Hsla,
 17    pub mac_os_traffic_light_green: Hsla,
 18    pub border: Hsla,
 19    pub border_variant: Hsla,
 20    pub border_focused: Hsla,
 21    pub border_transparent: Hsla,
 22    /// The background color of an elevated surface, like a modal, tooltip or toast.
 23    pub elevated_surface: Hsla,
 24    pub surface: Hsla,
 25    /// Window background color of the base app
 26    pub background: Hsla,
 27    /// Default background for elements like filled buttons,
 28    /// text fields, checkboxes, radio buttons, etc.
 29    /// - TODO: Map to step 3.
 30    pub filled_element: Hsla,
 31    /// The background color of a hovered element, like a button being hovered
 32    /// with a mouse, or hovered on a touch screen.
 33    /// - TODO: Map to step 4.
 34    pub filled_element_hover: Hsla,
 35    /// The background color of an active element, like a button being pressed,
 36    /// or tapped on a touch screen.
 37    /// - TODO: Map to step 5.
 38    pub filled_element_active: Hsla,
 39    /// The background color of a selected element, like a selected tab,
 40    /// a button toggled on, or a checkbox that is checked.
 41    pub filled_element_selected: Hsla,
 42    pub filled_element_disabled: Hsla,
 43    pub ghost_element: Hsla,
 44    /// The background color of a hovered element with no default background,
 45    /// like a ghost-style button or an interactable list item.
 46    /// - TODO: Map to step 3.
 47    pub ghost_element_hover: Hsla,
 48    /// - TODO: Map to step 4.
 49    pub ghost_element_active: Hsla,
 50    pub ghost_element_selected: Hsla,
 51    pub ghost_element_disabled: Hsla,
 52    pub text: Hsla,
 53    pub text_muted: Hsla,
 54    pub text_placeholder: Hsla,
 55    pub text_disabled: Hsla,
 56    pub text_accent: Hsla,
 57    pub icon_muted: Hsla,
 58    pub syntax: SyntaxTheme,
 59
 60    pub status_bar: Hsla,
 61    pub title_bar: Hsla,
 62    pub toolbar: Hsla,
 63    pub tab_bar: Hsla,
 64    /// The background of the editor
 65    pub editor: Hsla,
 66    pub editor_subheader: Hsla,
 67    pub editor_active_line: Hsla,
 68    pub terminal: Hsla,
 69    pub image_fallback_background: Hsla,
 70
 71    pub git_created: Hsla,
 72    pub git_modified: Hsla,
 73    pub git_deleted: Hsla,
 74    pub git_conflict: Hsla,
 75    pub git_ignored: Hsla,
 76    pub git_renamed: Hsla,
 77
 78    pub players: [PlayerTheme; 8],
 79}
 80
 81#[derive(Clone)]
 82pub struct SyntaxTheme {
 83    pub comment: Hsla,
 84    pub string: Hsla,
 85    pub function: Hsla,
 86    pub keyword: Hsla,
 87    pub highlights: Vec<(String, HighlightStyle)>,
 88}
 89
 90#[derive(Clone, Copy)]
 91pub struct PlayerTheme {
 92    pub cursor: Hsla,
 93    pub selection: Hsla,
 94}
 95
 96#[derive(Clone)]
 97pub struct ThemeMetadata {
 98    pub name: SharedString,
 99    pub is_light: bool,
100}
101
102pub struct Editor {
103    pub syntax: Arc<SyntaxTheme>,
104}
105
106// #[derive(Default)]
107// pub struct SyntaxTheme {
108//     pub highlights: Vec<(String, HighlightStyle)>,
109// }
110
111// impl SyntaxTheme {
112//     pub fn new(highlights: Vec<(String, HighlightStyle)>) -> Self {
113//         Self { highlights }
114//     }
115// }