2021-09-15 18:56:20 +00:00
|
|
|
mod resolution;
|
2021-08-24 23:33:56 +00:00
|
|
|
mod theme_registry;
|
|
|
|
|
2021-08-04 00:51:06 +00:00
|
|
|
use gpui::{
|
|
|
|
color::Color,
|
2021-09-14 22:59:38 +00:00
|
|
|
elements::{ContainerStyle, ImageStyle, LabelStyle},
|
2021-10-05 17:21:13 +00:00
|
|
|
fonts::{HighlightStyle, TextStyle},
|
2021-09-07 22:04:29 +00:00
|
|
|
Border,
|
2021-08-04 00:51:06 +00:00
|
|
|
};
|
2021-09-02 18:20:30 +00:00
|
|
|
use serde::Deserialize;
|
2021-10-05 17:21:13 +00:00
|
|
|
use std::{collections::HashMap, sync::Arc};
|
2021-08-04 01:42:39 +00:00
|
|
|
|
2021-08-24 23:33:56 +00:00
|
|
|
pub use theme_registry::*;
|
2021-08-04 01:42:39 +00:00
|
|
|
|
2021-09-07 22:42:31 +00:00
|
|
|
pub const DEFAULT_THEME_NAME: &'static str = "black";
|
2021-08-04 01:42:39 +00:00
|
|
|
|
2021-10-05 11:45:19 +00:00
|
|
|
#[derive(Deserialize, Default)]
|
2021-08-03 20:36:58 +00:00
|
|
|
pub struct Theme {
|
2021-08-04 21:16:28 +00:00
|
|
|
#[serde(default)]
|
|
|
|
pub name: String,
|
2021-08-20 16:44:34 +00:00
|
|
|
pub workspace: Workspace,
|
2021-08-24 23:46:23 +00:00
|
|
|
pub chat_panel: ChatPanel,
|
2021-11-26 18:13:05 +00:00
|
|
|
pub contacts_panel: ContactsPanel,
|
2021-09-24 01:14:15 +00:00
|
|
|
pub project_panel: ProjectPanel,
|
2021-08-20 16:44:34 +00:00
|
|
|
pub selector: Selector,
|
2021-09-02 00:13:48 +00:00
|
|
|
pub editor: EditorStyle,
|
2022-01-05 16:25:03 +00:00
|
|
|
pub project_diagnostics: ProjectDiagnostics,
|
2021-08-03 20:36:58 +00:00
|
|
|
}
|
|
|
|
|
2021-10-05 11:45:19 +00:00
|
|
|
#[derive(Deserialize, Default)]
|
2021-08-20 16:44:34 +00:00
|
|
|
pub struct Workspace {
|
2021-08-03 20:36:58 +00:00
|
|
|
pub background: Color,
|
2021-09-14 16:53:41 +00:00
|
|
|
pub titlebar: Titlebar,
|
2021-08-24 23:38:26 +00:00
|
|
|
pub tab: Tab,
|
|
|
|
pub active_tab: Tab,
|
2021-09-07 22:04:29 +00:00
|
|
|
pub pane_divider: Border,
|
2021-09-07 19:02:43 +00:00
|
|
|
pub left_sidebar: Sidebar,
|
|
|
|
pub right_sidebar: Sidebar,
|
2021-11-03 16:27:51 +00:00
|
|
|
pub status_bar: StatusBar,
|
2021-08-03 20:36:58 +00:00
|
|
|
}
|
|
|
|
|
2021-10-05 11:45:19 +00:00
|
|
|
#[derive(Clone, Deserialize, Default)]
|
2021-09-14 16:53:41 +00:00
|
|
|
pub struct Titlebar {
|
|
|
|
#[serde(flatten)]
|
|
|
|
pub container: ContainerStyle,
|
2021-11-28 19:41:46 +00:00
|
|
|
pub height: f32,
|
2021-09-14 16:53:41 +00:00
|
|
|
pub title: TextStyle,
|
2021-09-14 22:59:38 +00:00
|
|
|
pub avatar_width: f32,
|
2021-11-28 20:25:05 +00:00
|
|
|
pub avatar_ribbon: AvatarRibbon,
|
2021-09-14 23:47:43 +00:00
|
|
|
pub offline_icon: OfflineIcon,
|
|
|
|
pub icon_color: Color,
|
2021-09-14 22:59:38 +00:00
|
|
|
pub avatar: ImageStyle,
|
2021-11-25 09:34:03 +00:00
|
|
|
pub sign_in_prompt: ContainedText,
|
|
|
|
pub hovered_sign_in_prompt: ContainedText,
|
2021-09-23 13:36:32 +00:00
|
|
|
pub outdated_warning: ContainedText,
|
2021-09-14 16:53:41 +00:00
|
|
|
}
|
|
|
|
|
2021-11-28 20:25:05 +00:00
|
|
|
#[derive(Clone, Deserialize, Default)]
|
|
|
|
pub struct AvatarRibbon {
|
|
|
|
#[serde(flatten)]
|
|
|
|
pub container: ContainerStyle,
|
|
|
|
pub width: f32,
|
|
|
|
pub height: f32,
|
|
|
|
}
|
|
|
|
|
2021-10-05 11:45:19 +00:00
|
|
|
#[derive(Clone, Deserialize, Default)]
|
2021-09-14 23:47:43 +00:00
|
|
|
pub struct OfflineIcon {
|
|
|
|
#[serde(flatten)]
|
|
|
|
pub container: ContainerStyle,
|
|
|
|
pub width: f32,
|
|
|
|
}
|
|
|
|
|
2021-10-05 11:45:19 +00:00
|
|
|
#[derive(Clone, Deserialize, Default)]
|
2021-08-03 20:36:58 +00:00
|
|
|
pub struct Tab {
|
2021-09-30 20:30:24 +00:00
|
|
|
pub height: f32,
|
2021-08-03 20:36:58 +00:00
|
|
|
#[serde(flatten)]
|
|
|
|
pub container: ContainerStyle,
|
|
|
|
#[serde(flatten)]
|
|
|
|
pub label: LabelStyle,
|
2021-09-07 21:28:14 +00:00
|
|
|
pub spacing: f32,
|
|
|
|
pub icon_width: f32,
|
2021-08-03 20:36:58 +00:00
|
|
|
pub icon_close: Color,
|
2021-09-07 21:28:14 +00:00
|
|
|
pub icon_close_active: Color,
|
2021-08-03 20:36:58 +00:00
|
|
|
pub icon_dirty: Color,
|
|
|
|
pub icon_conflict: Color,
|
|
|
|
}
|
|
|
|
|
2021-10-05 11:45:19 +00:00
|
|
|
#[derive(Deserialize, Default)]
|
2021-08-27 12:57:47 +00:00
|
|
|
pub struct Sidebar {
|
2021-09-07 19:02:43 +00:00
|
|
|
#[serde(flatten)]
|
|
|
|
pub container: ContainerStyle,
|
2021-09-14 16:53:41 +00:00
|
|
|
pub width: f32,
|
2021-09-30 20:30:24 +00:00
|
|
|
pub item: SidebarItem,
|
|
|
|
pub active_item: SidebarItem,
|
2021-08-27 12:57:47 +00:00
|
|
|
pub resize_handle: ContainerStyle,
|
|
|
|
}
|
|
|
|
|
2021-10-05 11:45:19 +00:00
|
|
|
#[derive(Deserialize, Default)]
|
2021-09-30 20:30:24 +00:00
|
|
|
pub struct SidebarItem {
|
|
|
|
pub icon_color: Color,
|
|
|
|
pub icon_size: f32,
|
2021-09-07 18:44:31 +00:00
|
|
|
pub height: f32,
|
2021-08-20 20:51:52 +00:00
|
|
|
}
|
|
|
|
|
2021-11-03 16:27:51 +00:00
|
|
|
#[derive(Deserialize, Default)]
|
|
|
|
pub struct StatusBar {
|
|
|
|
#[serde(flatten)]
|
|
|
|
pub container: ContainerStyle,
|
|
|
|
pub height: f32,
|
|
|
|
pub cursor_position: TextStyle,
|
2021-11-03 21:15:22 +00:00
|
|
|
pub diagnostic_icon_size: f32,
|
|
|
|
pub diagnostic_icon_spacing: f32,
|
|
|
|
pub diagnostic_icon_color: Color,
|
|
|
|
pub diagnostic_message: TextStyle,
|
2021-11-03 16:27:51 +00:00
|
|
|
}
|
|
|
|
|
2021-10-05 11:45:19 +00:00
|
|
|
#[derive(Deserialize, Default)]
|
2021-08-24 23:46:23 +00:00
|
|
|
pub struct ChatPanel {
|
2021-08-25 22:22:14 +00:00
|
|
|
#[serde(flatten)]
|
|
|
|
pub container: ContainerStyle,
|
2021-08-24 23:46:23 +00:00
|
|
|
pub message: ChatMessage,
|
2021-09-15 13:12:16 +00:00
|
|
|
pub pending_message: ChatMessage,
|
2021-08-31 00:59:13 +00:00
|
|
|
pub channel_select: ChannelSelect,
|
2021-09-02 18:20:30 +00:00
|
|
|
pub input_editor: InputEditorStyle,
|
2021-09-07 10:27:43 +00:00
|
|
|
pub sign_in_prompt: TextStyle,
|
|
|
|
pub hovered_sign_in_prompt: TextStyle,
|
2021-08-24 23:46:23 +00:00
|
|
|
}
|
|
|
|
|
2021-10-05 11:45:19 +00:00
|
|
|
#[derive(Debug, Deserialize, Default)]
|
2021-09-24 01:14:15 +00:00
|
|
|
pub struct ProjectPanel {
|
|
|
|
#[serde(flatten)]
|
|
|
|
pub container: ContainerStyle,
|
2021-09-30 17:24:47 +00:00
|
|
|
pub entry: ProjectPanelEntry,
|
|
|
|
pub hovered_entry: ProjectPanelEntry,
|
|
|
|
pub selected_entry: ProjectPanelEntry,
|
2021-09-30 21:16:28 +00:00
|
|
|
pub hovered_selected_entry: ProjectPanelEntry,
|
2021-09-30 17:24:47 +00:00
|
|
|
}
|
|
|
|
|
2021-10-05 11:45:19 +00:00
|
|
|
#[derive(Debug, Deserialize, Default)]
|
2021-09-30 17:24:47 +00:00
|
|
|
pub struct ProjectPanelEntry {
|
2021-09-30 20:30:24 +00:00
|
|
|
pub height: f32,
|
2021-09-30 17:24:47 +00:00
|
|
|
#[serde(flatten)]
|
|
|
|
pub container: ContainerStyle,
|
|
|
|
pub text: TextStyle,
|
|
|
|
pub icon_color: Color,
|
|
|
|
pub icon_size: f32,
|
|
|
|
pub icon_spacing: f32,
|
2021-09-24 01:14:15 +00:00
|
|
|
}
|
|
|
|
|
2021-10-05 11:45:19 +00:00
|
|
|
#[derive(Deserialize, Default)]
|
2021-11-26 18:13:05 +00:00
|
|
|
pub struct ContactsPanel {
|
2021-09-20 18:04:48 +00:00
|
|
|
#[serde(flatten)]
|
|
|
|
pub container: ContainerStyle,
|
2021-09-22 15:02:50 +00:00
|
|
|
pub host_row_height: f32,
|
2021-09-21 19:21:03 +00:00
|
|
|
pub host_avatar: ImageStyle,
|
2021-09-21 16:13:02 +00:00
|
|
|
pub host_username: ContainedText,
|
2021-09-22 15:02:50 +00:00
|
|
|
pub tree_branch_width: f32,
|
|
|
|
pub tree_branch_color: Color,
|
2021-12-20 19:36:59 +00:00
|
|
|
pub shared_project: WorktreeRow,
|
|
|
|
pub hovered_shared_project: WorktreeRow,
|
|
|
|
pub unshared_project: WorktreeRow,
|
|
|
|
pub hovered_unshared_project: WorktreeRow,
|
2021-09-21 16:13:02 +00:00
|
|
|
}
|
|
|
|
|
2021-10-05 11:45:19 +00:00
|
|
|
#[derive(Deserialize, Default)]
|
2021-09-22 15:02:50 +00:00
|
|
|
pub struct WorktreeRow {
|
|
|
|
#[serde(flatten)]
|
|
|
|
pub container: ContainerStyle,
|
|
|
|
pub height: f32,
|
|
|
|
pub name: ContainedText,
|
|
|
|
pub guest_avatar: ImageStyle,
|
|
|
|
pub guest_avatar_spacing: f32,
|
2021-09-20 18:04:48 +00:00
|
|
|
}
|
|
|
|
|
2021-10-05 11:45:19 +00:00
|
|
|
#[derive(Deserialize, Default)]
|
2021-08-24 23:46:23 +00:00
|
|
|
pub struct ChatMessage {
|
2021-09-01 23:14:51 +00:00
|
|
|
#[serde(flatten)]
|
|
|
|
pub container: ContainerStyle,
|
2021-08-25 14:42:35 +00:00
|
|
|
pub body: TextStyle,
|
2021-08-31 00:59:13 +00:00
|
|
|
pub sender: ContainedText,
|
|
|
|
pub timestamp: ContainedText,
|
|
|
|
}
|
|
|
|
|
2021-10-05 11:45:19 +00:00
|
|
|
#[derive(Deserialize, Default)]
|
2021-08-31 00:59:13 +00:00
|
|
|
pub struct ChannelSelect {
|
|
|
|
#[serde(flatten)]
|
|
|
|
pub container: ContainerStyle,
|
|
|
|
pub header: ChannelName,
|
|
|
|
pub item: ChannelName,
|
|
|
|
pub active_item: ChannelName,
|
|
|
|
pub hovered_item: ChannelName,
|
|
|
|
pub hovered_active_item: ChannelName,
|
|
|
|
pub menu: ContainerStyle,
|
|
|
|
}
|
|
|
|
|
2021-10-05 11:45:19 +00:00
|
|
|
#[derive(Deserialize, Default)]
|
2021-08-31 00:59:13 +00:00
|
|
|
pub struct ChannelName {
|
|
|
|
#[serde(flatten)]
|
|
|
|
pub container: ContainerStyle,
|
|
|
|
pub hash: ContainedText,
|
|
|
|
pub name: TextStyle,
|
2021-08-24 23:46:23 +00:00
|
|
|
}
|
|
|
|
|
2021-10-05 11:45:19 +00:00
|
|
|
#[derive(Deserialize, Default)]
|
2021-08-03 20:36:58 +00:00
|
|
|
pub struct Selector {
|
|
|
|
#[serde(flatten)]
|
|
|
|
pub container: ContainerStyle,
|
2021-09-07 21:42:19 +00:00
|
|
|
pub empty: ContainedLabel,
|
2021-09-02 18:20:30 +00:00
|
|
|
pub input_editor: InputEditorStyle,
|
2021-08-25 22:22:14 +00:00
|
|
|
pub item: ContainedLabel,
|
|
|
|
pub active_item: ContainedLabel,
|
2021-08-03 20:36:58 +00:00
|
|
|
}
|
|
|
|
|
2021-10-05 11:45:19 +00:00
|
|
|
#[derive(Clone, Debug, Deserialize, Default)]
|
2021-08-31 00:59:13 +00:00
|
|
|
pub struct ContainedText {
|
|
|
|
#[serde(flatten)]
|
|
|
|
pub container: ContainerStyle,
|
|
|
|
#[serde(flatten)]
|
|
|
|
pub text: TextStyle,
|
|
|
|
}
|
|
|
|
|
2021-10-05 11:45:19 +00:00
|
|
|
#[derive(Deserialize, Default)]
|
2021-08-25 22:22:14 +00:00
|
|
|
pub struct ContainedLabel {
|
2021-08-03 20:36:58 +00:00
|
|
|
#[serde(flatten)]
|
|
|
|
pub container: ContainerStyle,
|
|
|
|
#[serde(flatten)]
|
|
|
|
pub label: LabelStyle,
|
|
|
|
}
|
|
|
|
|
2022-01-05 16:25:03 +00:00
|
|
|
#[derive(Clone, Deserialize, Default)]
|
|
|
|
pub struct ProjectDiagnostics {
|
|
|
|
#[serde(flatten)]
|
|
|
|
pub container: ContainerStyle,
|
|
|
|
pub empty_message: TextStyle,
|
|
|
|
}
|
|
|
|
|
2021-10-05 17:21:13 +00:00
|
|
|
#[derive(Clone, Deserialize, Default)]
|
|
|
|
pub struct EditorStyle {
|
|
|
|
pub text: TextStyle,
|
|
|
|
#[serde(default)]
|
|
|
|
pub placeholder_text: Option<TextStyle>,
|
|
|
|
pub background: Color,
|
|
|
|
pub selection: SelectionStyle,
|
|
|
|
pub gutter_background: Color,
|
|
|
|
pub active_line_background: Color,
|
2021-11-24 22:23:45 +00:00
|
|
|
pub highlighted_line_background: Color,
|
2021-10-05 17:21:13 +00:00
|
|
|
pub line_number: Color,
|
|
|
|
pub line_number_active: Color,
|
|
|
|
pub guest_selections: Vec<SelectionStyle>,
|
|
|
|
pub syntax: Arc<SyntaxTheme>,
|
2021-11-19 13:35:00 +00:00
|
|
|
pub error_diagnostic: DiagnosticStyle,
|
|
|
|
pub invalid_error_diagnostic: DiagnosticStyle,
|
|
|
|
pub warning_diagnostic: DiagnosticStyle,
|
|
|
|
pub invalid_warning_diagnostic: DiagnosticStyle,
|
|
|
|
pub information_diagnostic: DiagnosticStyle,
|
|
|
|
pub invalid_information_diagnostic: DiagnosticStyle,
|
|
|
|
pub hint_diagnostic: DiagnosticStyle,
|
|
|
|
pub invalid_hint_diagnostic: DiagnosticStyle,
|
2021-11-19 02:16:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Copy, Clone, Deserialize, Default)]
|
|
|
|
pub struct DiagnosticStyle {
|
|
|
|
pub text: Color,
|
2022-01-07 01:55:56 +00:00
|
|
|
#[serde(default)]
|
|
|
|
pub header: ContainerStyle,
|
2021-10-05 17:21:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Clone, Copy, Default, Deserialize)]
|
|
|
|
pub struct SelectionStyle {
|
|
|
|
pub cursor: Color,
|
|
|
|
pub selection: Color,
|
|
|
|
}
|
|
|
|
|
2021-10-05 11:45:19 +00:00
|
|
|
#[derive(Clone, Deserialize, Default)]
|
2021-09-02 18:20:30 +00:00
|
|
|
pub struct InputEditorStyle {
|
2021-09-07 21:42:19 +00:00
|
|
|
#[serde(flatten)]
|
|
|
|
pub container: ContainerStyle,
|
2021-09-16 20:12:38 +00:00
|
|
|
pub text: TextStyle,
|
2021-09-16 19:23:42 +00:00
|
|
|
#[serde(default)]
|
2021-09-16 20:12:38 +00:00
|
|
|
pub placeholder_text: Option<TextStyle>,
|
2021-09-02 18:20:30 +00:00
|
|
|
pub selection: SelectionStyle,
|
2021-08-24 23:39:56 +00:00
|
|
|
}
|
|
|
|
|
2021-10-05 17:21:13 +00:00
|
|
|
impl EditorStyle {
|
|
|
|
pub fn placeholder_text(&self) -> &TextStyle {
|
|
|
|
self.placeholder_text.as_ref().unwrap_or(&self.text)
|
|
|
|
}
|
2021-11-28 20:25:05 +00:00
|
|
|
|
|
|
|
pub fn replica_selection_style(&self, replica_id: u16) -> &SelectionStyle {
|
|
|
|
let style_ix = replica_id as usize % (self.guest_selections.len() + 1);
|
|
|
|
if style_ix == 0 {
|
|
|
|
&self.selection
|
|
|
|
} else {
|
|
|
|
&self.guest_selections[style_ix - 1]
|
|
|
|
}
|
|
|
|
}
|
2021-10-05 17:21:13 +00:00
|
|
|
}
|
|
|
|
|
2021-09-02 18:20:30 +00:00
|
|
|
impl InputEditorStyle {
|
|
|
|
pub fn as_editor(&self) -> EditorStyle {
|
|
|
|
EditorStyle {
|
|
|
|
text: self.text.clone(),
|
2021-09-03 00:36:56 +00:00
|
|
|
placeholder_text: self.placeholder_text.clone(),
|
2021-09-07 21:42:19 +00:00
|
|
|
background: self
|
|
|
|
.container
|
|
|
|
.background_color
|
|
|
|
.unwrap_or(Color::transparent_black()),
|
2021-09-02 18:20:30 +00:00
|
|
|
selection: self.selection,
|
2021-09-16 20:12:38 +00:00
|
|
|
gutter_background: Default::default(),
|
|
|
|
active_line_background: Default::default(),
|
2021-11-24 22:23:45 +00:00
|
|
|
highlighted_line_background: Default::default(),
|
2021-09-16 20:12:38 +00:00
|
|
|
line_number: Default::default(),
|
|
|
|
line_number_active: Default::default(),
|
|
|
|
guest_selections: Default::default(),
|
2021-10-04 22:06:12 +00:00
|
|
|
syntax: Default::default(),
|
2021-11-19 13:35:00 +00:00
|
|
|
error_diagnostic: Default::default(),
|
|
|
|
invalid_error_diagnostic: Default::default(),
|
|
|
|
warning_diagnostic: Default::default(),
|
|
|
|
invalid_warning_diagnostic: Default::default(),
|
|
|
|
information_diagnostic: Default::default(),
|
|
|
|
invalid_information_diagnostic: Default::default(),
|
|
|
|
hint_diagnostic: Default::default(),
|
|
|
|
invalid_hint_diagnostic: Default::default(),
|
2021-09-02 00:13:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-10-05 17:21:13 +00:00
|
|
|
|
|
|
|
#[derive(Default)]
|
|
|
|
pub struct SyntaxTheme {
|
|
|
|
pub highlights: Vec<(String, HighlightStyle)>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl SyntaxTheme {
|
|
|
|
pub fn new(highlights: Vec<(String, HighlightStyle)>) -> Self {
|
|
|
|
Self { highlights }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'de> Deserialize<'de> for SyntaxTheme {
|
|
|
|
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
|
|
|
where
|
|
|
|
D: serde::Deserializer<'de>,
|
|
|
|
{
|
|
|
|
let syntax_data: HashMap<String, HighlightStyle> = Deserialize::deserialize(deserializer)?;
|
|
|
|
|
|
|
|
let mut result = Self::new(Vec::new());
|
|
|
|
for (key, style) in syntax_data {
|
|
|
|
match result
|
|
|
|
.highlights
|
|
|
|
.binary_search_by(|(needle, _)| needle.cmp(&key))
|
|
|
|
{
|
|
|
|
Ok(i) | Err(i) => {
|
|
|
|
result.highlights.insert(i, (key, style));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Ok(result)
|
|
|
|
}
|
|
|
|
}
|