Detailed changes
@@ -5259,6 +5259,21 @@ dependencies = [
"unicode-width",
]
+[[package]]
+name = "theme"
+version = "0.1.0"
+dependencies = [
+ "anyhow",
+ "editor",
+ "gpui",
+ "indexmap",
+ "parking_lot",
+ "serde 1.0.125",
+ "serde_json 1.0.64",
+ "serde_path_to_error",
+ "toml 0.5.8",
+]
+
[[package]]
name = "thiserror"
version = "1.0.29"
@@ -6097,6 +6112,7 @@ dependencies = [
"sum_tree",
"surf",
"tempdir",
+ "theme",
"thiserror",
"time 0.3.2",
"tiny_http",
@@ -0,0 +1,15 @@
+[package]
+name = "theme"
+version = "0.1.0"
+edition = "2018"
+
+[dependencies]
+editor = { path = "../editor" }
+gpui = { path = "../gpui" }
+anyhow = "1.0.38"
+indexmap = "1.6.2"
+parking_lot = "0.11.1"
+serde = { version = "1", features = ["derive"] }
+serde_json = { version = "1.0.64", features = ["preserve_order"] }
+serde_path_to_error = "0.1.4"
+toml = "0.5"
@@ -1,12 +1,10 @@
-use super::resolution::resolve_references;
+use crate::{resolution::resolve_references, Theme};
use anyhow::{Context, Result};
use gpui::{fonts, AssetSource, FontCache};
use parking_lot::Mutex;
use serde_json::{Map, Value};
use std::{collections::HashMap, sync::Arc};
-use super::Theme;
-
pub struct ThemeRegistry {
assets: Box<dyn AssetSource>,
themes: Mutex<HashMap<String, Arc<Theme>>>,
@@ -122,24 +120,9 @@ fn deep_merge_json(base: &mut Map<String, Value>, extension: Map<String, Value>)
#[cfg(test)]
mod tests {
use super::*;
- use crate::{test::test_app_state, theme::DEFAULT_THEME_NAME};
use anyhow::anyhow;
use gpui::MutableAppContext;
- #[gpui::test]
- fn test_bundled_themes(cx: &mut MutableAppContext) {
- let app_state = test_app_state(cx);
- let mut has_default_theme = false;
- for theme_name in app_state.themes.list() {
- let theme = app_state.themes.get(&theme_name).unwrap();
- if theme.name == DEFAULT_THEME_NAME {
- has_default_theme = true;
- }
- assert_eq!(theme.name, theme_name);
- }
- assert!(has_default_theme);
- }
-
#[gpui::test]
fn test_theme_extension(cx: &mut MutableAppContext) {
let assets = TestAssets(&[
@@ -34,8 +34,8 @@ gpui = { path = "../gpui" }
project = { path = "../project" }
rpc = { path = "../rpc" }
sum_tree = { path = "../sum_tree" }
+theme = { path = "../theme" }
util = { path = "../util" }
-
anyhow = "1.0.38"
async-recursion = "0.3"
async-trait = "0.1"
@@ -83,7 +83,6 @@ project = { path = "../project", features = ["test-support"] }
rpc = { path = "../rpc", features = ["test-support"] }
client = { path = "../client", features = ["test-support"] }
util = { path = "../util", features = ["test-support"] }
-
cargo-bundle = "0.5.0"
env_logger = "0.8"
serde_json = { version = "1.0.64", features = ["preserve_order"] }
@@ -1,4 +1,4 @@
-use crate::{theme, Settings};
+use crate::Settings;
use client::{
channel::{Channel, ChannelEvent, ChannelList, ChannelMessage},
Client,
@@ -8,7 +8,6 @@ pub mod project_panel;
pub mod settings;
#[cfg(any(test, feature = "test-support"))]
pub mod test;
-pub mod theme;
pub mod theme_selector;
pub mod workspace;
@@ -31,6 +30,7 @@ pub use project::{self, fs};
use project_panel::ProjectPanel;
pub use settings::Settings;
use std::{path::PathBuf, sync::Arc};
+use theme::ThemeRegistry;
use util::TryFutureExt;
use crate::workspace::Workspace;
@@ -48,7 +48,7 @@ pub struct AppState {
pub settings_tx: Arc<Mutex<watch::Sender<Settings>>>,
pub settings: watch::Receiver<Settings>,
pub languages: Arc<LanguageRegistry>,
- pub themes: Arc<settings::ThemeRegistry>,
+ pub themes: Arc<ThemeRegistry>,
pub client: Arc<client::Client>,
pub user_store: ModelHandle<client::UserStore>,
pub fs: Arc<dyn fs::Fs>,
@@ -198,6 +198,7 @@ mod tests {
use super::*;
use crate::{test::test_app_state, workspace::ItemView};
use serde_json::json;
+ use theme::DEFAULT_THEME_NAME;
use util::test::temp_tree;
#[gpui::test]
@@ -299,4 +300,18 @@ mod tests {
assert!(!editor.is_dirty(cx));
});
}
+
+ #[gpui::test]
+ fn test_bundled_themes(cx: &mut MutableAppContext) {
+ let app_state = test_app_state(cx);
+ let mut has_default_theme = false;
+ for theme_name in app_state.themes.list() {
+ let theme = app_state.themes.get(&theme_name).unwrap();
+ if theme.name == DEFAULT_THEME_NAME {
+ has_default_theme = true;
+ }
+ assert_eq!(theme.name, theme_name);
+ }
+ assert!(has_default_theme);
+ }
}
@@ -7,6 +7,7 @@ use log::LevelFilter;
use parking_lot::Mutex;
use simplelog::SimpleLogger;
use std::{fs, path::PathBuf, sync::Arc};
+use theme::ThemeRegistry;
use zed::{
self,
assets::Assets,
@@ -30,7 +31,7 @@ fn main() {
.collect::<Vec<_>>();
app.platform().fonts().add_fonts(&embedded_fonts).unwrap();
- let themes = settings::ThemeRegistry::new(Assets, app.font_cache());
+ let themes = ThemeRegistry::new(Assets, app.font_cache());
let (settings_tx, settings) =
settings::channel("Inconsolata", &app.font_cache(), &themes).unwrap();
let languages = Arc::new(language::build_language_registry());
@@ -1,4 +1,4 @@
-use crate::{theme::Theme, workspace::Workspace, Settings};
+use crate::{workspace::Workspace, Settings};
use client::{Collaborator, UserStore};
use gpui::{
action,
@@ -9,6 +9,7 @@ use gpui::{
Subscription, View, ViewContext,
};
use postage::watch;
+use theme::Theme;
action!(JoinWorktree, u64);
action!(LeaveWorktree, u64);
@@ -1,6 +1,5 @@
use crate::{
project::{self, Project, ProjectEntry, ProjectPath},
- theme,
workspace::Workspace,
Settings,
};
@@ -1,9 +1,8 @@
-use crate::theme::{self, DEFAULT_THEME_NAME};
use anyhow::Result;
use gpui::font_cache::{FamilyId, FontCache};
use postage::watch;
use std::sync::Arc;
-pub use theme::{Theme, ThemeRegistry};
+use theme::{Theme, ThemeRegistry, DEFAULT_THEME_NAME};
#[derive(Clone)]
pub struct Settings {
@@ -1,10 +1,4 @@
-use crate::{
- assets::Assets,
- language,
- settings::Settings,
- theme::{Theme, ThemeRegistry, DEFAULT_THEME_NAME},
- AppState,
-};
+use crate::{assets::Assets, language, settings::Settings, AppState};
use buffer::LanguageRegistry;
use client::{http::ServerResponse, test::FakeHttpClient, ChannelList, Client, UserStore};
use gpui::{AssetSource, MutableAppContext};
@@ -12,6 +6,7 @@ use parking_lot::Mutex;
use postage::watch;
use project::fs::FakeFs;
use std::sync::Arc;
+use theme::{Theme, ThemeRegistry, DEFAULT_THEME_NAME};
#[cfg(test)]
#[ctor::ctor]
@@ -1,4 +1,4 @@
-use crate::{settings::ThemeRegistry, workspace::Workspace, AppState, Settings};
+use crate::{workspace::Workspace, AppState, Settings};
use editor::{Editor, EditorSettings};
use fuzzy::{match_strings, StringMatch, StringMatchCandidate};
use gpui::{
@@ -11,6 +11,7 @@ use gpui::{
use parking_lot::Mutex;
use postage::watch;
use std::{cmp, sync::Arc};
+use theme::ThemeRegistry;
pub struct ThemeSelector {
settings_tx: Arc<Mutex<watch::Sender<Settings>>>,
@@ -1,6 +1,6 @@
-use crate::theme::Theme;
use anyhow::{anyhow, Result};
use gpui::{elements::*, Axis};
+use theme::Theme;
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct PaneGroup {
@@ -1,5 +1,5 @@
use super::Workspace;
-use crate::{theme, Settings};
+use crate::Settings;
use gpui::{
action, elements::*, platform::CursorStyle, AnyViewHandle, MutableAppContext, RenderContext,
};