Remove 2 suffix for theme

Co-authored-by: Mikayla <mikayla@zed.dev>
This commit is contained in:
Max Brunsfeld 2024-01-03 12:41:01 -08:00
parent 4305c5fdbe
commit dfcb17fe74
79 changed files with 319 additions and 2648 deletions

88
Cargo.lock generated
View File

@ -15,7 +15,7 @@ dependencies = [
"project", "project",
"settings", "settings",
"smallvec", "smallvec",
"theme2", "theme",
"ui", "ui",
"util", "util",
"workspace", "workspace",
@ -331,7 +331,7 @@ dependencies = [
"serde_json", "serde_json",
"settings", "settings",
"smol", "smol",
"theme2", "theme",
"tiktoken-rs", "tiktoken-rs",
"ui", "ui",
"util", "util",
@ -688,7 +688,7 @@ dependencies = [
"settings", "settings",
"smol", "smol",
"tempdir", "tempdir",
"theme2", "theme",
"util", "util",
"workspace", "workspace",
] ]
@ -1017,7 +1017,7 @@ dependencies = [
"project", "project",
"search", "search",
"settings", "settings",
"theme2", "theme",
"ui", "ui",
"workspace", "workspace",
] ]
@ -1501,7 +1501,7 @@ dependencies = [
"smallvec", "smallvec",
"sqlx", "sqlx",
"text", "text",
"theme2", "theme",
"time", "time",
"tokio", "tokio",
"tokio-tungstenite", "tokio-tungstenite",
@ -1552,7 +1552,7 @@ dependencies = [
"serde_derive", "serde_derive",
"settings", "settings",
"smallvec", "smallvec",
"theme2", "theme",
"theme_selector", "theme_selector",
"time", "time",
"tree-sitter-markdown", "tree-sitter-markdown",
@ -1611,7 +1611,7 @@ dependencies = [
"serde", "serde",
"serde_json", "serde_json",
"settings", "settings",
"theme2", "theme",
"ui", "ui",
"util", "util",
"workspace", "workspace",
@ -1713,7 +1713,7 @@ dependencies = [
"serde_derive", "serde_derive",
"settings", "settings",
"smol", "smol",
"theme2", "theme",
"ui", "ui",
"util", "util",
] ]
@ -1731,7 +1731,7 @@ dependencies = [
"language", "language",
"settings", "settings",
"smol", "smol",
"theme2", "theme",
"util", "util",
"workspace", "workspace",
"zed_actions", "zed_actions",
@ -2241,7 +2241,7 @@ dependencies = [
"serde_json", "serde_json",
"settings", "settings",
"smallvec", "smallvec",
"theme2", "theme",
"ui", "ui",
"unindent", "unindent",
"util", "util",
@ -2423,7 +2423,7 @@ dependencies = [
"sqlez", "sqlez",
"sum_tree", "sum_tree",
"text", "text",
"theme2", "theme",
"tree-sitter", "tree-sitter",
"tree-sitter-html", "tree-sitter-html",
"tree-sitter-rust", "tree-sitter-rust",
@ -2636,7 +2636,7 @@ dependencies = [
"smallvec", "smallvec",
"smol", "smol",
"sysinfo", "sysinfo",
"theme2", "theme",
"tree-sitter-markdown", "tree-sitter-markdown",
"ui", "ui",
"urlencoding", "urlencoding",
@ -2663,7 +2663,7 @@ dependencies = [
"serde_json", "serde_json",
"settings", "settings",
"text", "text",
"theme2", "theme",
"ui", "ui",
"util", "util",
"workspace", "workspace",
@ -3155,7 +3155,7 @@ dependencies = [
"serde", "serde",
"settings", "settings",
"text", "text",
"theme2", "theme",
"ui", "ui",
"util", "util",
"workspace", "workspace",
@ -3961,7 +3961,7 @@ dependencies = [
"smol", "smol",
"sum_tree", "sum_tree",
"text", "text",
"theme2", "theme",
"tree-sitter", "tree-sitter",
"tree-sitter-elixir", "tree-sitter-elixir",
"tree-sitter-embedded-template", "tree-sitter-embedded-template",
@ -3990,7 +3990,7 @@ dependencies = [
"picker", "picker",
"project", "project",
"settings", "settings",
"theme2", "theme",
"ui", "ui",
"util", "util",
"workspace", "workspace",
@ -4012,7 +4012,7 @@ dependencies = [
"project", "project",
"serde", "serde",
"settings", "settings",
"theme2", "theme",
"tree-sitter", "tree-sitter",
"ui", "ui",
"unindent", "unindent",
@ -4625,7 +4625,7 @@ dependencies = [
"snippet", "snippet",
"sum_tree", "sum_tree",
"text", "text",
"theme2", "theme",
"tree-sitter", "tree-sitter",
"tree-sitter-html", "tree-sitter-html",
"tree-sitter-rust", "tree-sitter-rust",
@ -5203,7 +5203,7 @@ dependencies = [
"settings", "settings",
"smol", "smol",
"text", "text",
"theme2", "theme",
"ui", "ui",
"util", "util",
"workspace", "workspace",
@ -5424,7 +5424,7 @@ dependencies = [
"parking_lot 0.11.2", "parking_lot 0.11.2",
"serde_json", "serde_json",
"settings", "settings",
"theme2", "theme",
"ui", "ui",
"util", "util",
"workspace", "workspace",
@ -5776,7 +5776,7 @@ dependencies = [
"serde_json", "serde_json",
"settings", "settings",
"smallvec", "smallvec",
"theme2", "theme",
"ui", "ui",
"unicase", "unicase",
"util", "util",
@ -5801,7 +5801,7 @@ dependencies = [
"settings", "settings",
"smol", "smol",
"text", "text",
"theme2", "theme",
"util", "util",
"workspace", "workspace",
] ]
@ -6150,7 +6150,7 @@ dependencies = [
"settings", "settings",
"smol", "smol",
"text", "text",
"theme2", "theme",
"ui", "ui",
"util", "util",
"workspace", "workspace",
@ -6346,7 +6346,7 @@ dependencies = [
"smallvec", "smallvec",
"smol", "smol",
"sum_tree", "sum_tree",
"theme2", "theme",
"util", "util",
] ]
@ -6933,7 +6933,7 @@ dependencies = [
"settings", "settings",
"smallvec", "smallvec",
"smol", "smol",
"theme2", "theme",
"ui", "ui",
"unindent", "unindent",
"util", "util",
@ -7777,7 +7777,7 @@ dependencies = [
"smallvec", "smallvec",
"story", "story",
"strum", "strum",
"theme2", "theme",
"ui", "ui",
"util", "util",
] ]
@ -8081,7 +8081,7 @@ dependencies = [
"shellexpand", "shellexpand",
"smallvec", "smallvec",
"smol", "smol",
"theme2", "theme",
"thiserror", "thiserror",
"util", "util",
] ]
@ -8113,7 +8113,7 @@ dependencies = [
"smallvec", "smallvec",
"smol", "smol",
"terminal", "terminal",
"theme2", "theme",
"thiserror", "thiserror",
"ui", "ui",
"util", "util",
@ -8152,24 +8152,6 @@ checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d"
[[package]] [[package]]
name = "theme" name = "theme"
version = "0.1.0" version = "0.1.0"
dependencies = [
"anyhow",
"fs",
"gpui",
"indexmap 1.9.3",
"parking_lot 0.11.2",
"schemars",
"serde",
"serde_derive",
"serde_json",
"settings",
"toml 0.5.11",
"util",
]
[[package]]
name = "theme2"
version = "0.1.0"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"fs", "fs",
@ -8207,7 +8189,7 @@ dependencies = [
"serde", "serde",
"simplelog", "simplelog",
"strum", "strum",
"theme2", "theme",
"uuid 1.4.1", "uuid 1.4.1",
] ]
@ -8227,7 +8209,7 @@ dependencies = [
"postage", "postage",
"settings", "settings",
"smol", "smol",
"theme2", "theme",
"ui", "ui",
"util", "util",
"workspace", "workspace",
@ -9046,7 +9028,7 @@ dependencies = [
"smallvec", "smallvec",
"story", "story",
"strum", "strum",
"theme2", "theme",
] ]
[[package]] [[package]]
@ -9329,7 +9311,7 @@ dependencies = [
"serde_derive", "serde_derive",
"serde_json", "serde_json",
"settings", "settings",
"theme2", "theme",
"tokio", "tokio",
"ui", "ui",
"util", "util",
@ -9742,7 +9724,7 @@ dependencies = [
"schemars", "schemars",
"serde", "serde",
"settings", "settings",
"theme2", "theme",
"theme_selector", "theme_selector",
"ui", "ui",
"util", "util",
@ -10021,7 +10003,7 @@ dependencies = [
"settings", "settings",
"smallvec", "smallvec",
"terminal", "terminal",
"theme2", "theme",
"ui", "ui",
"util", "util",
"uuid 1.4.1", "uuid 1.4.1",
@ -10190,7 +10172,7 @@ dependencies = [
"tempdir", "tempdir",
"terminal_view", "terminal_view",
"text", "text",
"theme2", "theme",
"theme_selector", "theme_selector",
"thiserror", "thiserror",
"tiny_http", "tiny_http",

View File

@ -76,7 +76,6 @@ members = [
"crates/terminal_view", "crates/terminal_view",
"crates/text", "crates/text",
"crates/theme", "crates/theme",
"crates/theme2",
"crates/theme_importer", "crates/theme_importer",
"crates/theme_selector", "crates/theme_selector",
"crates/ui", "crates/ui",

View File

@ -17,7 +17,7 @@ project = { path = "../project" }
settings = { path = "../settings" } settings = { path = "../settings" }
ui = { path = "../ui" } ui = { path = "../ui" }
util = { path = "../util" } util = { path = "../util" }
theme = { path = "../theme2", package = "theme2" } theme = { path = "../theme" }
workspace = { path = "../workspace", package = "workspace" } workspace = { path = "../workspace", package = "workspace" }
anyhow.workspace = true anyhow.workspace = true

View File

@ -22,7 +22,7 @@ project = { path = "../project" }
search = { path = "../search" } search = { path = "../search" }
semantic_index = { path = "../semantic_index" } semantic_index = { path = "../semantic_index" }
settings = { path = "../settings" } settings = { path = "../settings" }
theme = { package = "theme2", path = "../theme2" } theme = { path = "../theme" }
ui = { path = "../ui" } ui = { path = "../ui" }
util = { path = "../util" } util = { path = "../util" }
workspace = { path = "../workspace" } workspace = { path = "../workspace" }

View File

@ -15,7 +15,7 @@ gpui = { package = "gpui2", path = "../gpui2" }
menu = { path = "../menu" } menu = { path = "../menu" }
project = { path = "../project" } project = { path = "../project" }
settings = { path = "../settings" } settings = { path = "../settings" }
theme = { package = "theme2", path = "../theme2" } theme = { path = "../theme" }
workspace = { path = "../workspace" } workspace = { path = "../workspace" }
util = { path = "../util" } util = { path = "../util" }
anyhow.workspace = true anyhow.workspace = true

View File

@ -17,7 +17,7 @@ language = { path = "../language" }
project = { path = "../project" } project = { path = "../project" }
search = { path = "../search" } search = { path = "../search" }
settings = { path = "../settings" } settings = { path = "../settings" }
theme = { package = "theme2", path = "../theme2" } theme = { path = "../theme" }
workspace = { path = "../workspace" } workspace = { path = "../workspace" }
outline = { path = "../outline" } outline = { path = "../outline" }
itertools = "0.10" itertools = "0.10"

View File

@ -78,7 +78,7 @@ notifications = { path = "../notifications", features = ["test-support"] }
project = { path = "../project", features = ["test-support"] } project = { path = "../project", features = ["test-support"] }
rpc = { path = "../rpc", features = ["test-support"] } rpc = { path = "../rpc", features = ["test-support"] }
settings = { path = "../settings", features = ["test-support"] } settings = { path = "../settings", features = ["test-support"] }
theme = { package = "theme2", path = "../theme2" } theme = { path = "../theme" }
workspace = { path = "../workspace", features = ["test-support"] } workspace = { path = "../workspace", features = ["test-support"] }
collab_ui = { path = "../collab_ui", features = ["test-support"] } collab_ui = { path = "../collab_ui", features = ["test-support"] }

99
crates/collab2/Cargo.toml Normal file
View File

@ -0,0 +1,99 @@
[package]
authors = ["Nathan Sobo <nathan@zed.dev>"]
default-run = "collab"
edition = "2021"
name = "collab"
version = "0.28.0"
publish = false
[[bin]]
name = "collab"
[[bin]]
name = "seed"
required-features = ["seed-support"]
[dependencies]
clock = { path = "../clock" }
collections = { path = "../collections" }
live_kit_server = { path = "../live_kit_server" }
text = { path = "../text" }
rpc = { path = "../rpc" }
util = { path = "../util" }
anyhow.workspace = true
async-tungstenite = "0.16"
axum = { version = "0.5", features = ["json", "headers", "ws"] }
axum-extra = { version = "0.3", features = ["erased-json"] }
base64 = "0.13"
clap = { version = "3.1", features = ["derive"], optional = true }
dashmap = "5.4"
envy = "0.4.2"
futures.workspace = true
hyper = "0.14"
lazy_static.workspace = true
lipsum = { version = "0.8", optional = true }
log.workspace = true
nanoid = "0.4"
parking_lot.workspace = true
prometheus = "0.13"
prost.workspace = true
rand.workspace = true
reqwest = { version = "0.11", features = ["json"], optional = true }
scrypt = "0.7"
smallvec.workspace = true
sea-orm = { version = "0.12.x", features = ["sqlx-postgres", "postgres-array", "runtime-tokio-rustls", "with-uuid"] }
serde.workspace = true
serde_derive.workspace = true
serde_json.workspace = true
sha-1 = "0.9"
sqlx = { version = "0.7", features = ["runtime-tokio-rustls", "postgres", "json", "time", "uuid", "any"] }
time.workspace = true
tokio = { version = "1", features = ["full"] }
tokio-tungstenite = "0.17"
tonic = "0.6"
tower = "0.4"
toml.workspace = true
tracing = "0.1.34"
tracing-log = "0.1.3"
tracing-subscriber = { version = "0.3.11", features = ["env-filter", "json"] }
uuid.workspace = true
[dev-dependencies]
audio = { path = "../audio" }
collections = { path = "../collections", features = ["test-support"] }
gpui = { package = "gpui2", path = "../gpui2", features = ["test-support"] }
call = { path = "../call", features = ["test-support"] }
client = { path = "../client", features = ["test-support"] }
channel = { path = "../channel" }
editor = { path = "../editor", features = ["test-support"] }
language = { path = "../language", features = ["test-support"] }
fs = { path = "../fs", features = ["test-support"] }
git = { path = "../git", features = ["test-support"] }
live_kit_client = { package = "live_kit_client2", path = "../live_kit_client2", features = ["test-support"] }
lsp = { path = "../lsp", features = ["test-support"] }
node_runtime = { path = "../node_runtime" }
notifications = { path = "../notifications", features = ["test-support"] }
project = { path = "../project", features = ["test-support"] }
rpc = { path = "../rpc", features = ["test-support"] }
settings = { path = "../settings", features = ["test-support"] }
theme = { path = "../theme" }
workspace = { path = "../workspace", features = ["test-support"] }
collab_ui = { path = "../collab_ui", features = ["test-support"] }
async-trait.workspace = true
pretty_assertions.workspace = true
ctor.workspace = true
env_logger.workspace = true
indoc.workspace = true
util = { path = "../util" }
lazy_static.workspace = true
sea-orm = { version = "0.12.x", features = ["sqlx-sqlite"] }
serde_json.workspace = true
sqlx = { version = "0.7", features = ["sqlite"] }
unindent.workspace = true
[features]
seed-support = ["clap", "lipsum", "reqwest"]

View File

@ -45,7 +45,7 @@ recent_projects = { path = "../recent_projects" }
rpc = { path = "../rpc" } rpc = { path = "../rpc" }
settings = { path = "../settings" } settings = { path = "../settings" }
feature_flags = { path = "../feature_flags"} feature_flags = { path = "../feature_flags"}
theme = { package = "theme2", path = "../theme2" } theme = { path = "../theme" }
theme_selector = { path = "../theme_selector" } theme_selector = { path = "../theme_selector" }
vcs_menu = { path = "../vcs_menu" } vcs_menu = { path = "../vcs_menu" }
ui = { path = "../ui" } ui = { path = "../ui" }

View File

@ -18,7 +18,7 @@ project = { path = "../project" }
settings = { path = "../settings" } settings = { path = "../settings" }
ui = { path = "../ui" } ui = { path = "../ui" }
util = { path = "../util" } util = { path = "../util" }
theme = { package = "theme2", path = "../theme2" } theme = { path = "../theme" }
workspace = { path = "../workspace" } workspace = { path = "../workspace" }
zed_actions = { path = "../zed_actions" } zed_actions = { path = "../zed_actions" }
anyhow.workspace = true anyhow.workspace = true

View File

@ -24,7 +24,7 @@ collections = { path = "../collections" }
gpui = { package = "gpui2", path = "../gpui2" } gpui = { package = "gpui2", path = "../gpui2" }
language = { path = "../language" } language = { path = "../language" }
settings = { path = "../settings" } settings = { path = "../settings" }
theme = { package = "theme2", path = "../theme2" } theme = { path = "../theme" }
lsp = { path = "../lsp" } lsp = { path = "../lsp" }
node_runtime = { path = "../node_runtime"} node_runtime = { path = "../node_runtime"}
util = { path = "../util" } util = { path = "../util" }

View File

@ -16,7 +16,7 @@ zed_actions = { path = "../zed_actions"}
gpui = { package = "gpui2", path = "../gpui2" } gpui = { package = "gpui2", path = "../gpui2" }
language = { path = "../language" } language = { path = "../language" }
settings = { path = "../settings" } settings = { path = "../settings" }
theme = { package = "theme2", path = "../theme2" } theme = { path = "../theme" }
util = { path = "../util" } util = { path = "../util" }
workspace = {path = "../workspace" } workspace = {path = "../workspace" }
anyhow.workspace = true anyhow.workspace = true

View File

@ -17,7 +17,7 @@ language = { path = "../language" }
lsp = { path = "../lsp" } lsp = { path = "../lsp" }
project = { path = "../project" } project = { path = "../project" }
settings = { path = "../settings" } settings = { path = "../settings" }
theme = { package = "theme2", path = "../theme2" } theme = { path = "../theme" }
util = { path = "../util" } util = { path = "../util" }
workspace = {path = "../workspace" } workspace = {path = "../workspace" }
@ -37,7 +37,7 @@ language = { path = "../language", features = ["test-support"] }
lsp = { path = "../lsp", features = ["test-support"] } lsp = { path = "../lsp", features = ["test-support"] }
gpui = { package = "gpui2", path = "../gpui2", features = ["test-support"] } gpui = { package = "gpui2", path = "../gpui2", features = ["test-support"] }
workspace = {path = "../workspace", features = ["test-support"] } workspace = {path = "../workspace", features = ["test-support"] }
theme = { package = "theme2", path = "../theme2", features = ["test-support"] } theme = { path = "../theme", features = ["test-support"] }
serde_json.workspace = true serde_json.workspace = true
unindent.workspace = true unindent.workspace = true

View File

@ -42,7 +42,7 @@ settings = { path = "../settings" }
snippet = { path = "../snippet" } snippet = { path = "../snippet" }
sum_tree = { path = "../sum_tree" } sum_tree = { path = "../sum_tree" }
text = { path = "../text" } text = { path = "../text" }
theme = { package="theme2", path = "../theme2" } theme = { path = "../theme" }
ui = { path = "../ui" } ui = { path = "../ui" }
util = { path = "../util" } util = { path = "../util" }
sqlez = { path = "../sqlez" } sqlez = { path = "../sqlez" }

View File

@ -20,7 +20,7 @@ menu = { path = "../menu" }
project = { path = "../project" } project = { path = "../project" }
search = { path = "../search" } search = { path = "../search" }
settings = { path = "../settings" } settings = { path = "../settings" }
theme = { package = "theme2", path = "../theme2" } theme = { path = "../theme" }
ui = { path = "../ui" } ui = { path = "../ui" }
util = { path = "../util" } util = { path = "../util" }
workspace = { path = "../workspace"} workspace = { path = "../workspace"}

View File

@ -19,7 +19,7 @@ project = { path = "../project" }
settings = { path = "../settings" } settings = { path = "../settings" }
text = { path = "../text" } text = { path = "../text" }
util = { path = "../util" } util = { path = "../util" }
theme = { package = "theme2", path = "../theme2" } theme = { path = "../theme" }
ui = { path = "../ui" } ui = { path = "../ui" }
workspace = { path = "../workspace" } workspace = { path = "../workspace" }
postage.workspace = true postage.workspace = true
@ -30,7 +30,7 @@ editor = { path = "../editor", features = ["test-support"] }
gpui = { package = "gpui2", path = "../gpui2", features = ["test-support"] } gpui = { package = "gpui2", path = "../gpui2", features = ["test-support"] }
language = { path = "../language", features = ["test-support"] } language = { path = "../language", features = ["test-support"] }
workspace = { path = "../workspace", features = ["test-support"] } workspace = { path = "../workspace", features = ["test-support"] }
theme = { package = "theme2", path = "../theme2", features = ["test-support"] } theme = { path = "../theme", features = ["test-support"] }
serde_json.workspace = true serde_json.workspace = true
ctor.workspace = true ctor.workspace = true

View File

@ -17,7 +17,7 @@ settings = { path = "../settings" }
text = { path = "../text" } text = { path = "../text" }
workspace = { path = "../workspace" } workspace = { path = "../workspace" }
postage.workspace = true postage.workspace = true
theme = { package = "theme2", path = "../theme2" } theme = { path = "../theme" }
ui = { path = "../ui" } ui = { path = "../ui" }
util = { path = "../util" } util = { path = "../util" }

View File

@ -32,7 +32,7 @@ rpc = { path = "../rpc" }
settings = { path = "../settings" } settings = { path = "../settings" }
sum_tree = { path = "../sum_tree" } sum_tree = { path = "../sum_tree" }
text = { path = "../text" } text = { path = "../text" }
theme = { package = "theme2", path = "../theme2" } theme = { path = "../theme" }
util = { path = "../util" } util = { path = "../util" }
anyhow.workspace = true anyhow.workspace = true

View File

@ -15,7 +15,7 @@ language = { path = "../language" }
gpui = { package = "gpui2", path = "../gpui2" } gpui = { package = "gpui2", path = "../gpui2" }
picker = { path = "../picker" } picker = { path = "../picker" }
project = { path = "../project" } project = { path = "../project" }
theme = { package = "theme2", path = "../theme2" } theme = { path = "../theme" }
ui = { path = "../ui" } ui = { path = "../ui" }
settings = { path = "../settings" } settings = { path = "../settings" }
util = { path = "../util" } util = { path = "../util" }

View File

@ -12,7 +12,7 @@ doctest = false
collections = { path = "../collections" } collections = { path = "../collections" }
editor = { path = "../editor" } editor = { path = "../editor" }
settings = { path = "../settings" } settings = { path = "../settings" }
theme = { package = "theme2", path = "../theme2" } theme = { path = "../theme" }
language = { path = "../language" } language = { path = "../language" }
project = { path = "../project" } project = { path = "../project" }
workspace = { path = "../workspace" } workspace = { path = "../workspace" }

View File

@ -32,7 +32,7 @@ settings = { path = "../settings" }
snippet = { path = "../snippet" } snippet = { path = "../snippet" }
sum_tree = { path = "../sum_tree" } sum_tree = { path = "../sum_tree" }
text = { path = "../text" } text = { path = "../text" }
theme = { package = "theme2", path = "../theme2" } theme = { path = "../theme" }
util = { path = "../util" } util = { path = "../util" }
aho-corasick = "1.1" aho-corasick = "1.1"

View File

@ -17,7 +17,7 @@ language = { path = "../language" }
picker = { path = "../picker" } picker = { path = "../picker" }
settings = { path = "../settings" } settings = { path = "../settings" }
text = { path = "../text" } text = { path = "../text" }
theme = { package = "theme2", path = "../theme2" } theme = { path = "../theme" }
workspace = { path = "../workspace" } workspace = { path = "../workspace" }
util = { path = "../util" } util = { path = "../util" }

View File

@ -15,7 +15,7 @@ gpui = { package = "gpui2", path = "../gpui2" }
menu = { path = "../menu" } menu = { path = "../menu" }
settings = { path = "../settings" } settings = { path = "../settings" }
util = { path = "../util" } util = { path = "../util" }
theme = { package = "theme2", path = "../theme2" } theme = { path = "../theme" }
workspace = { path = "../workspace"} workspace = { path = "../workspace"}
parking_lot.workspace = true parking_lot.workspace = true

View File

@ -17,7 +17,7 @@ menu = { path = "../menu" }
project = { path = "../project" } project = { path = "../project" }
search = { path = "../search" } search = { path = "../search" }
settings = { path = "../settings" } settings = { path = "../settings" }
theme = { path = "../theme2", package = "theme2" } theme = { path = "../theme" }
ui = { path = "../ui" } ui = { path = "../ui" }
util = { path = "../util" } util = { path = "../util" }
workspace = { path = "../workspace", package = "workspace" } workspace = { path = "../workspace", package = "workspace" }

View File

@ -17,7 +17,7 @@ project = { path = "../project" }
text = { path = "../text" } text = { path = "../text" }
settings = { path = "../settings" } settings = { path = "../settings" }
workspace = { path = "../workspace" } workspace = { path = "../workspace" }
theme = { package = "theme2", path = "../theme2" } theme = { path = "../theme" }
util = { path = "../util" } util = { path = "../util" }
anyhow.workspace = true anyhow.workspace = true
@ -33,5 +33,5 @@ gpui = { package = "gpui2", path = "../gpui2", features = ["test-support"] }
language = { path = "../language", features = ["test-support"] } language = { path = "../language", features = ["test-support"] }
lsp = { path = "../lsp", features = ["test-support"] } lsp = { path = "../lsp", features = ["test-support"] }
project = { path = "../project", features = ["test-support"] } project = { path = "../project", features = ["test-support"] }
theme = { package = "theme2", path = "../theme2", features = ["test-support"] } theme = { path = "../theme", features = ["test-support"] }
workspace = { path = "../workspace", features = ["test-support"] } workspace = { path = "../workspace", features = ["test-support"] }

View File

@ -17,7 +17,7 @@ picker = { path = "../picker" }
settings = { path = "../settings" } settings = { path = "../settings" }
text = { path = "../text" } text = { path = "../text" }
util = { path = "../util"} util = { path = "../util"}
theme = { package = "theme2", path = "../theme2" } theme = { path = "../theme" }
ui = { path = "../ui" } ui = { path = "../ui" }
workspace = { path = "../workspace" } workspace = { path = "../workspace" }

View File

@ -18,7 +18,7 @@ test-support = [
collections = { path = "../collections" } collections = { path = "../collections" }
gpui = { package = "gpui2", path = "../gpui2" } gpui = { package = "gpui2", path = "../gpui2" }
sum_tree = { path = "../sum_tree" } sum_tree = { path = "../sum_tree" }
theme = { package = "theme2", path = "../theme2" } theme = { path = "../theme" }
language = { path = "../language" } language = { path = "../language" }
util = { path = "../util" } util = { path = "../util" }
anyhow.workspace = true anyhow.workspace = true

View File

@ -17,7 +17,7 @@ language = { path = "../language" }
menu = { path = "../menu" } menu = { path = "../menu" }
project = { path = "../project" } project = { path = "../project" }
settings = { path = "../settings" } settings = { path = "../settings" }
theme = { package = "theme2", path = "../theme2" } theme = { path = "../theme" }
util = { path = "../util" } util = { path = "../util" }
ui = {path = "../ui"} ui = {path = "../ui"}
workspace = { path = "../workspace" } workspace = { path = "../workspace" }

View File

@ -29,7 +29,7 @@ simplelog = "0.9"
smallvec.workspace = true smallvec.workspace = true
story = { path = "../story" } story = { path = "../story" }
strum = { version = "0.25.0", features = ["derive"] } strum = { version = "0.25.0", features = ["derive"] }
theme2 = { path = "../theme2" } theme = { path = "../theme" }
menu = { path = "../menu" } menu = { path = "../menu" }
ui = { path = "../ui", features = ["stories"] } ui = { path = "../ui", features = ["stories"] }
util = { path = "../util" } util = { path = "../util" }

View File

@ -14,7 +14,7 @@ use log::LevelFilter;
use settings::{default_settings, Settings, SettingsStore}; use settings::{default_settings, Settings, SettingsStore};
use simplelog::SimpleLogger; use simplelog::SimpleLogger;
use strum::IntoEnumIterator; use strum::IntoEnumIterator;
use theme2::{ThemeRegistry, ThemeSettings}; use theme::{ThemeRegistry, ThemeSettings};
use ui::prelude::*; use ui::prelude::*;
use crate::assets::Assets; use crate::assets::Assets;
@ -69,7 +69,7 @@ fn main() {
.unwrap(); .unwrap();
cx.set_global(store); cx.set_global(store);
theme2::init(theme2::LoadThemes::All, cx); theme::init(theme::LoadThemes::All, cx);
let selector = story_selector; let selector = story_selector;

View File

@ -13,7 +13,7 @@ doctest = false
gpui = { package = "gpui2", path = "../gpui2" } gpui = { package = "gpui2", path = "../gpui2" }
settings = { path = "../settings" } settings = { path = "../settings" }
db = { path = "../db" } db = { path = "../db" }
theme = { package = "theme2", path = "../theme2" } theme = { path = "../theme" }
util = { path = "../util" } util = { path = "../util" }
alacritty_terminal = { git = "https://github.com/zed-industries/alacritty", rev = "33306142195b354ef3485ca2b1d8a85dfc6605ca" } alacritty_terminal = { git = "https://github.com/zed-industries/alacritty", rev = "33306142195b354ef3485ca2b1d8a85dfc6605ca" }

View File

@ -15,7 +15,7 @@ gpui = { package = "gpui2", path = "../gpui2" }
project = { path = "../project" } project = { path = "../project" }
# search = { path = "../search" } # search = { path = "../search" }
settings = { path = "../settings" } settings = { path = "../settings" }
theme = { package = "theme2", path = "../theme2" } theme = { path = "../theme" }
util = { path = "../util" } util = { path = "../util" }
workspace = { path = "../workspace" } workspace = { path = "../workspace" }
db = { path = "../db" } db = { path = "../db" }

View File

@ -5,6 +5,9 @@ edition = "2021"
publish = false publish = false
[features] [features]
default = []
importing-themes = []
stories = ["dep:itertools", "dep:story"]
test-support = [ test-support = [
"gpui/test-support", "gpui/test-support",
"fs/test-support", "fs/test-support",
@ -16,21 +19,24 @@ path = "src/theme.rs"
doctest = false doctest = false
[dependencies] [dependencies]
gpui = { path = "../gpui" }
fs = { path = "../fs" }
settings = { path = "../settings" }
util = { path = "../util" }
anyhow.workspace = true anyhow.workspace = true
fs = { path = "../fs" }
gpui = { package = "gpui2", path = "../gpui2" }
indexmap = "1.6.2" indexmap = "1.6.2"
parking_lot.workspace = true parking_lot.workspace = true
refineable.workspace = true
schemars.workspace = true schemars.workspace = true
serde.workspace = true serde.workspace = true
serde_derive.workspace = true serde_derive.workspace = true
serde_json.workspace = true serde_json.workspace = true
settings = { path = "../settings" }
story = { path = "../story", optional = true }
toml.workspace = true toml.workspace = true
uuid.workspace = true
util = { path = "../util" }
itertools = { version = "0.11.0", optional = true }
[dev-dependencies] [dev-dependencies]
gpui = { path = "../gpui", features = ["test-support"] } gpui = { package = "gpui2", path = "../gpui2", features = ["test-support"] }
fs = { path = "../fs", features = ["test-support"] } fs = { path = "../fs", features = ["test-support"] }
settings = { path = "../settings", features = ["test-support"] } settings = { path = "../settings", features = ["test-support"] }

View File

@ -1,480 +0,0 @@
use gpui::{elements::SafeStylable, Action};
use crate::{Interactive, Toggleable};
use self::{action_button::ButtonStyle, disclosure::Disclosable, svg::SvgStyle, toggle::Toggle};
pub type IconButtonStyle = Interactive<ButtonStyle<SvgStyle>>;
pub type ToggleIconButtonStyle = Toggleable<IconButtonStyle>;
pub trait ComponentExt<C: SafeStylable> {
fn toggleable(self, active: bool) -> Toggle<C, ()>;
fn disclosable(self, disclosed: Option<bool>, action: Box<dyn Action>) -> Disclosable<C, ()>;
}
impl<C: SafeStylable> ComponentExt<C> for C {
fn toggleable(self, active: bool) -> Toggle<C, ()> {
Toggle::new(self, active)
}
/// Some(True) => disclosed => content is visible
/// Some(false) => closed => content is hidden
/// None => No disclosure button, but reserve disclosure spacing
fn disclosable(self, disclosed: Option<bool>, action: Box<dyn Action>) -> Disclosable<C, ()> {
Disclosable::new(disclosed, self, action)
}
}
pub mod disclosure {
use gpui::{
elements::{Component, ContainerStyle, Empty, Flex, ParentElement, SafeStylable},
Action, Element,
};
use schemars::JsonSchema;
use serde_derive::Deserialize;
use super::{action_button::Button, svg::Svg, IconButtonStyle};
#[derive(Clone, Default, Deserialize, JsonSchema)]
pub struct DisclosureStyle<S> {
pub button: IconButtonStyle,
#[serde(flatten)]
pub container: ContainerStyle,
pub spacing: f32,
#[serde(flatten)]
content: S,
}
impl<S> DisclosureStyle<S> {
pub fn button_space(&self) -> f32 {
self.spacing + self.button.button_width.unwrap()
}
}
pub struct Disclosable<C, S> {
disclosed: Option<bool>,
action: Box<dyn Action>,
id: usize,
content: C,
style: S,
}
impl Disclosable<(), ()> {
pub fn new<C>(
disclosed: Option<bool>,
content: C,
action: Box<dyn Action>,
) -> Disclosable<C, ()> {
Disclosable {
disclosed,
content,
action,
id: 0,
style: (),
}
}
}
impl<C> Disclosable<C, ()> {
pub fn with_id(mut self, id: usize) -> Disclosable<C, ()> {
self.id = id;
self
}
}
impl<C: SafeStylable> SafeStylable for Disclosable<C, ()> {
type Style = DisclosureStyle<C::Style>;
type Output = Disclosable<C, Self::Style>;
fn with_style(self, style: Self::Style) -> Self::Output {
Disclosable {
disclosed: self.disclosed,
action: self.action,
content: self.content,
id: self.id,
style,
}
}
}
impl<C: SafeStylable> Component for Disclosable<C, DisclosureStyle<C::Style>> {
fn render<V: 'static>(self, cx: &mut gpui::ViewContext<V>) -> gpui::AnyElement<V> {
Flex::row()
.with_spacing(self.style.spacing)
.with_child(if let Some(disclosed) = self.disclosed {
Button::dynamic_action(self.action)
.with_id(self.id)
.with_contents(Svg::new(if disclosed {
"icons/file_icons/chevron_down.svg"
} else {
"icons/file_icons/chevron_right.svg"
}))
.with_style(self.style.button)
.element()
.into_any()
} else {
Empty::new()
.into_any()
.constrained()
// TODO: Why is this optional at all?
.with_width(self.style.button.button_width.unwrap())
.into_any()
})
.with_child(
self.content
.with_style(self.style.content)
.render(cx)
.flex(1., true),
)
.align_children_center()
.contained()
.with_style(self.style.container)
.into_any()
}
}
}
pub mod toggle {
use gpui::elements::{Component, SafeStylable};
use crate::Toggleable;
pub struct Toggle<C, S> {
style: S,
active: bool,
component: C,
}
impl<C: SafeStylable> Toggle<C, ()> {
pub fn new(component: C, active: bool) -> Self {
Toggle {
active,
component,
style: (),
}
}
}
impl<C: SafeStylable> SafeStylable for Toggle<C, ()> {
type Style = Toggleable<C::Style>;
type Output = Toggle<C, Self::Style>;
fn with_style(self, style: Self::Style) -> Self::Output {
Toggle {
active: self.active,
component: self.component,
style,
}
}
}
impl<C: SafeStylable> Component for Toggle<C, Toggleable<C::Style>> {
fn render<V: 'static>(self, cx: &mut gpui::ViewContext<V>) -> gpui::AnyElement<V> {
self.component
.with_style(self.style.in_state(self.active).clone())
.render(cx)
}
}
}
pub mod action_button {
use std::borrow::Cow;
use gpui::{
elements::{Component, ContainerStyle, MouseEventHandler, SafeStylable, TooltipStyle},
platform::{CursorStyle, MouseButton},
Action, Element, TypeTag,
};
use schemars::JsonSchema;
use serde_derive::Deserialize;
use crate::Interactive;
#[derive(Clone, Deserialize, Default, JsonSchema)]
pub struct ButtonStyle<C> {
#[serde(flatten)]
pub container: ContainerStyle,
// TODO: These are incorrect for the intended usage of the buttons.
// The size should be constant, but putting them here duplicates them
// across the states the buttons can be in
pub button_width: Option<f32>,
pub button_height: Option<f32>,
#[serde(flatten)]
contents: C,
}
pub struct Button<C, S> {
action: Box<dyn Action>,
tooltip: Option<(Cow<'static, str>, TooltipStyle)>,
tag: TypeTag,
id: usize,
contents: C,
style: Interactive<S>,
}
impl Button<(), ()> {
pub fn dynamic_action(action: Box<dyn Action>) -> Button<(), ()> {
Self {
contents: (),
tag: action.type_tag(),
action,
style: Interactive::new_blank(),
tooltip: None,
id: 0,
}
}
pub fn action<A: Action + Clone>(action: A) -> Self {
Self::dynamic_action(Box::new(action))
}
pub fn with_tooltip(
mut self,
tooltip: impl Into<Cow<'static, str>>,
tooltip_style: TooltipStyle,
) -> Self {
self.tooltip = Some((tooltip.into(), tooltip_style));
self
}
pub fn with_id(mut self, id: usize) -> Self {
self.id = id;
self
}
pub fn with_contents<C: SafeStylable>(self, contents: C) -> Button<C, ()> {
Button {
action: self.action,
tag: self.tag,
style: self.style,
tooltip: self.tooltip,
id: self.id,
contents,
}
}
}
impl<C: SafeStylable> SafeStylable for Button<C, ()> {
type Style = Interactive<ButtonStyle<C::Style>>;
type Output = Button<C, ButtonStyle<C::Style>>;
fn with_style(self, style: Self::Style) -> Self::Output {
Button {
action: self.action,
tag: self.tag,
contents: self.contents,
tooltip: self.tooltip,
id: self.id,
style,
}
}
}
impl<C: SafeStylable> Component for Button<C, ButtonStyle<C::Style>> {
fn render<V: 'static>(self, cx: &mut gpui::ViewContext<V>) -> gpui::AnyElement<V> {
let mut button = MouseEventHandler::new_dynamic(self.tag, self.id, cx, |state, cx| {
let style = self.style.style_for(state);
let mut contents = self
.contents
.with_style(style.contents.to_owned())
.render(cx)
.contained()
.with_style(style.container)
.constrained();
if let Some(height) = style.button_height {
contents = contents.with_height(height);
}
if let Some(width) = style.button_width {
contents = contents.with_width(width);
}
contents.into_any()
})
.on_click(MouseButton::Left, {
let action = self.action.boxed_clone();
move |_, _, cx| {
let window = cx.window();
let view = cx.view_id();
let action = action.boxed_clone();
cx.spawn(|_, mut cx| async move {
window.dispatch_action(view, action.as_ref(), &mut cx)
})
.detach();
}
})
.with_cursor_style(CursorStyle::PointingHand)
.into_any();
if let Some((tooltip, style)) = self.tooltip {
button = button
.with_dynamic_tooltip(self.tag, 0, tooltip, Some(self.action), style, cx)
.into_any()
}
button
}
}
}
pub mod svg {
use std::borrow::Cow;
use gpui::{
elements::{Component, Empty, SafeStylable},
Element,
};
use schemars::JsonSchema;
use serde::Deserialize;
#[derive(Clone, Default, JsonSchema)]
pub struct SvgStyle {
icon_width: f32,
icon_height: f32,
color: gpui::color::Color,
}
impl<'de> Deserialize<'de> for SvgStyle {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
#[derive(Deserialize)]
#[serde(untagged)]
pub enum IconSize {
IconSize { icon_size: f32 },
Dimensions { width: f32, height: f32 },
IconDimensions { icon_width: f32, icon_height: f32 },
}
#[derive(Deserialize)]
struct SvgStyleHelper {
#[serde(flatten)]
size: IconSize,
color: gpui::color::Color,
}
let json = SvgStyleHelper::deserialize(deserializer)?;
let color = json.color;
let result = match json.size {
IconSize::IconSize { icon_size } => SvgStyle {
icon_width: icon_size,
icon_height: icon_size,
color,
},
IconSize::Dimensions { width, height } => SvgStyle {
icon_width: width,
icon_height: height,
color,
},
IconSize::IconDimensions {
icon_width,
icon_height,
} => SvgStyle {
icon_width,
icon_height,
color,
},
};
Ok(result)
}
}
pub struct Svg<S> {
path: Option<Cow<'static, str>>,
style: S,
}
impl Svg<()> {
pub fn new(path: impl Into<Cow<'static, str>>) -> Self {
Self {
path: Some(path.into()),
style: (),
}
}
pub fn optional(path: Option<impl Into<Cow<'static, str>>>) -> Self {
Self {
path: path.map(Into::into),
style: (),
}
}
}
impl SafeStylable for Svg<()> {
type Style = SvgStyle;
type Output = Svg<SvgStyle>;
fn with_style(self, style: Self::Style) -> Self::Output {
Svg {
path: self.path,
style,
}
}
}
impl Component for Svg<SvgStyle> {
fn render<V: 'static>(self, _: &mut gpui::ViewContext<V>) -> gpui::AnyElement<V> {
if let Some(path) = self.path {
gpui::elements::Svg::new(path)
.with_color(self.style.color)
.constrained()
} else {
Empty::new().constrained()
}
.constrained()
.with_width(self.style.icon_width)
.with_height(self.style.icon_height)
.into_any()
}
}
}
pub mod label {
use std::borrow::Cow;
use gpui::{
elements::{Component, LabelStyle, SafeStylable},
fonts::TextStyle,
Element,
};
pub struct Label<S> {
text: Cow<'static, str>,
style: S,
}
impl Label<()> {
pub fn new(text: impl Into<Cow<'static, str>>) -> Self {
Self {
text: text.into(),
style: (),
}
}
}
impl SafeStylable for Label<()> {
type Style = TextStyle;
type Output = Label<LabelStyle>;
fn with_style(self, style: Self::Style) -> Self::Output {
Label {
text: self.text,
style: style.into(),
}
}
}
impl Component for Label<LabelStyle> {
fn render<V: 'static>(self, _: &mut gpui::ViewContext<V>) -> gpui::AnyElement<V> {
gpui::elements::Label::new(self.text, self.style).into_any()
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,106 +0,0 @@
use crate::{Theme, ThemeMeta};
use anyhow::{Context, Result};
use gpui::{fonts, AssetSource, FontCache};
use parking_lot::Mutex;
use serde::Deserialize;
use serde_json::Value;
use std::{
borrow::Cow,
collections::HashMap,
sync::{
atomic::{AtomicUsize, Ordering::SeqCst},
Arc,
},
};
pub struct ThemeRegistry {
assets: Box<dyn AssetSource>,
themes: Mutex<HashMap<String, Arc<Theme>>>,
theme_data: Mutex<HashMap<String, Arc<Value>>>,
font_cache: Arc<FontCache>,
next_theme_id: AtomicUsize,
}
impl ThemeRegistry {
pub fn new(source: impl AssetSource, font_cache: Arc<FontCache>) -> Arc<Self> {
let this = Arc::new(Self {
assets: Box::new(source),
themes: Default::default(),
theme_data: Default::default(),
next_theme_id: Default::default(),
font_cache,
});
this.themes.lock().insert(
settings::EMPTY_THEME_NAME.to_string(),
gpui::fonts::with_font_cache(this.font_cache.clone(), || {
let mut theme = Theme::default();
theme.meta.id = this.next_theme_id.fetch_add(1, SeqCst);
theme.meta.name = settings::EMPTY_THEME_NAME.into();
Arc::new(theme)
}),
);
this
}
pub fn list_names(&self, staff: bool) -> impl Iterator<Item = Cow<str>> + '_ {
let mut dirs = self.assets.list("themes/");
if !staff {
dirs = dirs
.into_iter()
.filter(|path| !path.starts_with("themes/staff"))
.collect()
}
fn get_name(path: &str) -> Option<&str> {
path.strip_prefix("themes/")?.strip_suffix(".json")
}
dirs.into_iter().filter_map(|path| match path {
Cow::Borrowed(path) => Some(Cow::Borrowed(get_name(path)?)),
Cow::Owned(path) => Some(Cow::Owned(get_name(&path)?.to_string())),
})
}
pub fn list(&self, staff: bool) -> impl Iterator<Item = ThemeMeta> + '_ {
self.list_names(staff).filter_map(|theme_name| {
self.get(theme_name.as_ref())
.ok()
.map(|theme| theme.meta.clone())
})
}
pub fn clear(&self) {
self.theme_data.lock().clear();
self.themes.lock().clear();
}
pub fn get(&self, name: &str) -> Result<Arc<Theme>> {
if let Some(theme) = self.themes.lock().get(name) {
return Ok(theme.clone());
}
let asset_path = format!("themes/{}.json", name);
let theme_json = self
.assets
.load(&asset_path)
.with_context(|| format!("failed to load theme file {}", asset_path))?;
// Allocate into the heap directly, the Theme struct is too large to fit in the stack.
let mut theme = fonts::with_font_cache(self.font_cache.clone(), || {
let mut theme = Box::new(Theme::default());
let mut deserializer = serde_json::Deserializer::from_slice(&theme_json);
let result = Theme::deserialize_in_place(&mut deserializer, &mut theme);
result.map(|_| theme)
})?;
// Reset name to be the file path, so that we can use it to access the stored themes
theme.meta.name = name.into();
theme.meta.id = self.next_theme_id.fetch_add(1, SeqCst);
let theme: Arc<Theme> = theme.into();
self.themes.lock().insert(name.to_string(), theme.clone());
Ok(theme)
}
}

View File

@ -1,214 +0,0 @@
use crate::{Theme, ThemeRegistry};
use anyhow::Result;
use gpui::{font_cache::FamilyId, fonts, AppContext};
use schemars::{
gen::SchemaGenerator,
schema::{InstanceType, Schema, SchemaObject},
JsonSchema,
};
use serde::{Deserialize, Serialize};
use serde_json::Value;
use settings::SettingsJsonSchemaParams;
use std::sync::Arc;
use util::ResultExt as _;
const MIN_FONT_SIZE: f32 = 6.0;
const MIN_LINE_HEIGHT: f32 = 1.0;
#[derive(Clone, JsonSchema)]
pub struct ThemeSettings {
pub buffer_font_family_name: String,
pub buffer_font_features: fonts::Features,
pub buffer_font_family: FamilyId,
pub(crate) buffer_font_size: f32,
pub(crate) buffer_line_height: BufferLineHeight,
#[serde(skip)]
pub theme: Arc<Theme>,
}
pub struct AdjustedBufferFontSize(pub f32);
#[derive(Clone, Debug, Default, Serialize, Deserialize, JsonSchema)]
pub struct ThemeSettingsContent {
#[serde(default)]
pub buffer_font_family: Option<String>,
#[serde(default)]
pub buffer_font_size: Option<f32>,
#[serde(default)]
pub buffer_line_height: Option<BufferLineHeight>,
#[serde(default)]
pub buffer_font_features: Option<fonts::Features>,
#[serde(default)]
pub theme: Option<String>,
}
#[derive(Clone, Copy, Debug, Serialize, Deserialize, PartialEq, JsonSchema, Default)]
#[serde(rename_all = "snake_case")]
pub enum BufferLineHeight {
#[default]
Comfortable,
Standard,
Custom(f32),
}
impl BufferLineHeight {
pub fn value(&self) -> f32 {
match self {
BufferLineHeight::Comfortable => 1.618,
BufferLineHeight::Standard => 1.3,
BufferLineHeight::Custom(line_height) => *line_height,
}
}
}
impl ThemeSettings {
pub fn buffer_font_size(&self, cx: &AppContext) -> f32 {
if cx.has_global::<AdjustedBufferFontSize>() {
cx.global::<AdjustedBufferFontSize>().0
} else {
self.buffer_font_size
}
.max(MIN_FONT_SIZE)
}
pub fn line_height(&self) -> f32 {
f32::max(self.buffer_line_height.value(), MIN_LINE_HEIGHT)
}
}
pub fn adjusted_font_size(size: f32, cx: &AppContext) -> f32 {
if cx.has_global::<AdjustedBufferFontSize>() {
let buffer_font_size = settings::get::<ThemeSettings>(cx).buffer_font_size;
let delta = cx.global::<AdjustedBufferFontSize>().0 - buffer_font_size;
size + delta
} else {
size
}
.max(MIN_FONT_SIZE)
}
pub fn adjust_font_size(cx: &mut AppContext, f: fn(&mut f32)) {
if !cx.has_global::<AdjustedBufferFontSize>() {
let buffer_font_size = settings::get::<ThemeSettings>(cx).buffer_font_size;
cx.set_global(AdjustedBufferFontSize(buffer_font_size));
}
cx.update_global::<AdjustedBufferFontSize, _, _>(|delta, cx| {
f(&mut delta.0);
delta.0 = delta
.0
.max(MIN_FONT_SIZE - settings::get::<ThemeSettings>(cx).buffer_font_size);
});
cx.refresh_windows();
}
pub fn reset_font_size(cx: &mut AppContext) {
if cx.has_global::<AdjustedBufferFontSize>() {
cx.remove_global::<AdjustedBufferFontSize>();
cx.refresh_windows();
}
}
impl settings::Setting for ThemeSettings {
const KEY: Option<&'static str> = None;
type FileContent = ThemeSettingsContent;
fn load(
defaults: &Self::FileContent,
user_values: &[&Self::FileContent],
cx: &AppContext,
) -> Result<Self> {
let buffer_font_features = defaults.buffer_font_features.clone().unwrap();
let themes = cx.global::<Arc<ThemeRegistry>>();
let mut this = Self {
buffer_font_family: cx
.font_cache()
.load_family(
&[defaults.buffer_font_family.as_ref().unwrap()],
&buffer_font_features,
)
.unwrap(),
buffer_font_family_name: defaults.buffer_font_family.clone().unwrap(),
buffer_font_features,
buffer_font_size: defaults.buffer_font_size.unwrap(),
buffer_line_height: defaults.buffer_line_height.unwrap(),
theme: themes.get(defaults.theme.as_ref().unwrap()).unwrap(),
};
for value in user_values.into_iter().copied().cloned() {
let font_cache = cx.font_cache();
let mut family_changed = false;
if let Some(value) = value.buffer_font_family {
this.buffer_font_family_name = value;
family_changed = true;
}
if let Some(value) = value.buffer_font_features {
this.buffer_font_features = value;
family_changed = true;
}
if family_changed {
if let Some(id) = font_cache
.load_family(&[&this.buffer_font_family_name], &this.buffer_font_features)
.log_err()
{
this.buffer_font_family = id;
}
}
if let Some(value) = &value.theme {
if let Some(theme) = themes.get(value).log_err() {
this.theme = theme;
}
}
merge(&mut this.buffer_font_size, value.buffer_font_size);
merge(&mut this.buffer_line_height, value.buffer_line_height);
}
Ok(this)
}
fn json_schema(
generator: &mut SchemaGenerator,
params: &SettingsJsonSchemaParams,
cx: &AppContext,
) -> schemars::schema::RootSchema {
let mut root_schema = generator.root_schema_for::<ThemeSettingsContent>();
let theme_names = cx
.global::<Arc<ThemeRegistry>>()
.list_names(params.staff_mode)
.map(|theme_name| Value::String(theme_name.to_string()))
.collect();
let theme_name_schema = SchemaObject {
instance_type: Some(InstanceType::String.into()),
enum_values: Some(theme_names),
..Default::default()
};
root_schema
.definitions
.extend([("ThemeName".into(), theme_name_schema.into())]);
root_schema
.schema
.object
.as_mut()
.unwrap()
.properties
.extend([(
"theme".to_owned(),
Schema::new_ref("#/definitions/ThemeName".into()),
)]);
root_schema
}
}
fn merge<T: Copy>(target: &mut T, value: Option<T>) {
if let Some(value) = value {
*target = value;
}
}

View File

@ -1,244 +0,0 @@
use std::borrow::Cow;
use gpui::{
elements::{
ConstrainedBox, Container, ContainerStyle, Dimensions, Empty, Flex, KeystrokeLabel, Label,
MouseEventHandler, ParentElement, Stack, Svg, SvgStyle,
},
fonts::TextStyle,
geometry::vector::Vector2F,
platform,
platform::MouseButton,
scene::MouseClick,
Action, Element, EventContext, MouseState, ViewContext,
};
use schemars::JsonSchema;
use serde::Deserialize;
use crate::{ContainedText, Interactive};
#[derive(Clone, Deserialize, Default, JsonSchema)]
pub struct CheckboxStyle {
pub icon: SvgStyle,
pub label: ContainedText,
pub default: ContainerStyle,
pub checked: ContainerStyle,
pub hovered: ContainerStyle,
pub hovered_and_checked: ContainerStyle,
}
pub fn checkbox<Tag, V, F>(
label: &'static str,
style: &CheckboxStyle,
checked: bool,
id: usize,
cx: &mut ViewContext<V>,
change: F,
) -> MouseEventHandler<V>
where
Tag: 'static,
V: 'static,
F: 'static + Fn(&mut V, bool, &mut EventContext<V>),
{
let label = Label::new(label, style.label.text.clone())
.contained()
.with_style(style.label.container);
checkbox_with_label::<Tag, _, _, _>(label, style, checked, id, cx, change)
}
pub fn checkbox_with_label<Tag, D, V, F>(
label: D,
style: &CheckboxStyle,
checked: bool,
id: usize,
cx: &mut ViewContext<V>,
change: F,
) -> MouseEventHandler<V>
where
Tag: 'static,
D: Element<V>,
V: 'static,
F: 'static + Fn(&mut V, bool, &mut EventContext<V>),
{
MouseEventHandler::new::<Tag, _>(id, cx, |state, _| {
let indicator = if checked {
svg(&style.icon)
} else {
Empty::new()
.constrained()
.with_width(style.icon.dimensions.width)
.with_height(style.icon.dimensions.height)
};
Flex::row()
.with_child(indicator.contained().with_style(if checked {
if state.hovered() {
style.hovered_and_checked
} else {
style.checked
}
} else {
if state.hovered() {
style.hovered
} else {
style.default
}
}))
.with_child(label)
.align_children_center()
})
.on_click(platform::MouseButton::Left, move |_, view, cx| {
change(view, !checked, cx)
})
.with_cursor_style(platform::CursorStyle::PointingHand)
}
pub fn svg<V: 'static>(style: &SvgStyle) -> ConstrainedBox<V> {
Svg::new(style.asset.clone())
.with_color(style.color)
.constrained()
.with_width(style.dimensions.width)
.with_height(style.dimensions.height)
}
#[derive(Clone, Deserialize, Default, JsonSchema)]
pub struct IconStyle {
pub icon: SvgStyle,
pub container: ContainerStyle,
}
impl IconStyle {
pub fn width(&self) -> f32 {
self.icon.dimensions.width
+ self.container.padding.left
+ self.container.padding.right
+ self.container.margin.left
+ self.container.margin.right
}
}
pub fn icon<V: 'static>(style: &IconStyle) -> Container<V> {
svg(&style.icon).contained().with_style(style.container)
}
pub fn keystroke_label<V: 'static>(
label_text: &'static str,
label_style: &ContainedText,
keystroke_style: &ContainedText,
action: Box<dyn Action>,
cx: &mut ViewContext<V>,
) -> Container<V> {
// FIXME: Put the theme in it's own global so we can
// query the keystroke style on our own
Flex::row()
.with_child(Label::new(label_text, label_style.text.clone()).contained())
.with_child(
KeystrokeLabel::new(
cx.view_id(),
action,
keystroke_style.container,
keystroke_style.text.clone(),
)
.flex_float(),
)
.contained()
.with_style(label_style.container)
}
pub type CopilotCTAButton = Interactive<ContainedText>;
pub fn cta_button<Tag, L, V, F>(
label: L,
max_width: f32,
style: &CopilotCTAButton,
cx: &mut ViewContext<V>,
f: F,
) -> MouseEventHandler<V>
where
Tag: 'static,
L: Into<Cow<'static, str>>,
V: 'static,
F: Fn(MouseClick, &mut V, &mut EventContext<V>) + 'static,
{
MouseEventHandler::new::<Tag, _>(0, cx, |state, _| {
let style = style.style_for(state);
Label::new(label, style.text.to_owned())
.aligned()
.contained()
.with_style(style.container)
.constrained()
.with_max_width(max_width)
})
.on_click(MouseButton::Left, f)
.with_cursor_style(platform::CursorStyle::PointingHand)
}
#[derive(Clone, Deserialize, Default, JsonSchema)]
pub struct ModalStyle {
close_icon: Interactive<IconStyle>,
container: ContainerStyle,
titlebar: ContainerStyle,
title_text: Interactive<TextStyle>,
dimensions: Dimensions,
}
impl ModalStyle {
pub fn dimensions(&self) -> Vector2F {
self.dimensions.to_vec()
}
}
pub fn modal<Tag, V, I, D, F>(
title: I,
style: &ModalStyle,
cx: &mut ViewContext<V>,
build_modal: F,
) -> impl Element<V>
where
Tag: 'static,
I: Into<Cow<'static, str>>,
D: Element<V>,
V: 'static,
F: FnOnce(&mut gpui::ViewContext<V>) -> D,
{
const TITLEBAR_HEIGHT: f32 = 28.;
Flex::column()
.with_child(
Stack::new()
.with_child(Label::new(
title,
style
.title_text
.style_for(&mut MouseState::default())
.clone(),
))
.with_child(
// FIXME: Get a better tag type
MouseEventHandler::new::<Tag, _>(999999, cx, |state, _cx| {
let style = style.close_icon.style_for(state);
icon(style)
})
.on_click(platform::MouseButton::Left, move |_, _, cx| {
cx.remove_window();
})
.with_cursor_style(platform::CursorStyle::PointingHand)
.aligned()
.right(),
)
.contained()
.with_style(style.titlebar)
.constrained()
.with_height(TITLEBAR_HEIGHT),
)
.with_child(
build_modal(cx)
.contained()
.with_style(style.container)
.constrained()
.with_width(style.dimensions().x())
.with_height(style.dimensions().y() - TITLEBAR_HEIGHT),
)
.constrained()
.with_height(style.dimensions().y())
}

View File

@ -1,42 +0,0 @@
[package]
name = "theme2"
version = "0.1.0"
edition = "2021"
publish = false
[features]
default = []
importing-themes = []
stories = ["dep:itertools", "dep:story"]
test-support = [
"gpui/test-support",
"fs/test-support",
"settings/test-support"
]
[lib]
path = "src/theme2.rs"
doctest = false
[dependencies]
anyhow.workspace = true
fs = { path = "../fs" }
gpui = { package = "gpui2", path = "../gpui2" }
indexmap = "1.6.2"
parking_lot.workspace = true
refineable.workspace = true
schemars.workspace = true
serde.workspace = true
serde_derive.workspace = true
serde_json.workspace = true
settings = { path = "../settings" }
story = { path = "../story", optional = true }
toml.workspace = true
uuid.workspace = true
util = { path = "../util" }
itertools = { version = "0.11.0", optional = true }
[dev-dependencies]
gpui = { package = "gpui2", path = "../gpui2", features = ["test-support"] }
fs = { path = "../fs", features = ["test-support"] }
settings = { path = "../settings", features = ["test-support"] }

View File

@ -1,148 +0,0 @@
mod default_colors;
mod default_theme;
mod one_themes;
pub mod prelude;
mod registry;
mod scale;
mod settings;
mod styles;
#[cfg(not(feature = "importing-themes"))]
mod themes;
mod user_theme;
use std::sync::Arc;
use ::settings::Settings;
pub use default_colors::*;
pub use default_theme::*;
pub use registry::*;
pub use scale::*;
pub use settings::*;
pub use styles::*;
#[cfg(not(feature = "importing-themes"))]
pub use themes::*;
pub use user_theme::*;
use gpui::{AppContext, Hsla, SharedString};
use serde::Deserialize;
#[derive(Debug, PartialEq, Clone, Copy, Deserialize)]
pub enum Appearance {
Light,
Dark,
}
impl Appearance {
pub fn is_light(&self) -> bool {
match self {
Self::Light => true,
Self::Dark => false,
}
}
}
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
pub enum LoadThemes {
/// Only load the base theme.
///
/// No user themes will be loaded.
JustBase,
/// Load all of the built-in themes.
All,
}
pub fn init(themes_to_load: LoadThemes, cx: &mut AppContext) {
cx.set_global(ThemeRegistry::default());
match themes_to_load {
LoadThemes::JustBase => (),
LoadThemes::All => cx.global_mut::<ThemeRegistry>().load_user_themes(),
}
ThemeSettings::register(cx);
}
pub trait ActiveTheme {
fn theme(&self) -> &Arc<Theme>;
}
impl ActiveTheme for AppContext {
fn theme(&self) -> &Arc<Theme> {
&ThemeSettings::get_global(self).active_theme
}
}
// todo!()
// impl<'a> ActiveTheme for WindowContext<'a> {
// fn theme(&self) -> &Arc<Theme> {
// &ThemeSettings::get_global(self.app()).active_theme
// }
// }
pub struct ThemeFamily {
pub id: String,
pub name: SharedString,
pub author: SharedString,
pub themes: Vec<Theme>,
pub scales: ColorScales,
}
impl ThemeFamily {}
pub struct Theme {
pub id: String,
pub name: SharedString,
pub appearance: Appearance,
pub styles: ThemeStyles,
}
impl Theme {
/// Returns the [`SystemColors`] for the theme.
#[inline(always)]
pub fn system(&self) -> &SystemColors {
&self.styles.system
}
/// Returns the [`PlayerColors`] for the theme.
#[inline(always)]
pub fn players(&self) -> &PlayerColors {
&self.styles.player
}
/// Returns the [`ThemeColors`] for the theme.
#[inline(always)]
pub fn colors(&self) -> &ThemeColors {
&self.styles.colors
}
/// Returns the [`SyntaxTheme`] for the theme.
#[inline(always)]
pub fn syntax(&self) -> &Arc<SyntaxTheme> {
&self.styles.syntax
}
/// Returns the [`StatusColors`] for the theme.
#[inline(always)]
pub fn status(&self) -> &StatusColors {
&self.styles.status
}
/// Returns the color for the syntax node with the given name.
#[inline(always)]
pub fn syntax_color(&self, name: &str) -> Hsla {
self.syntax().color(name)
}
/// Returns the [`Appearance`] for the theme.
#[inline(always)]
pub fn appearance(&self) -> Appearance {
self.appearance
}
}
pub fn color_alpha(color: Hsla, alpha: f32) -> Hsla {
let mut color = color;
color.a = alpha;
color
}

View File

@ -19,5 +19,5 @@ rust-embed.workspace = true
serde.workspace = true serde.workspace = true
simplelog = "0.9" simplelog = "0.9"
strum = { version = "0.25.0", features = ["derive"] } strum = { version = "0.25.0", features = ["derive"] }
theme = { package = "theme2", path = "../theme2", features = ["importing-themes"] } theme = { path = "../theme", features = ["importing-themes"] }
uuid.workspace = true uuid.workspace = true

View File

@ -78,7 +78,7 @@ struct Args {
fn main() -> Result<()> { fn main() -> Result<()> {
const SOURCE_PATH: &str = "assets/themes/src/vscode"; const SOURCE_PATH: &str = "assets/themes/src/vscode";
const OUT_PATH: &str = "crates/theme2/src/themes"; const OUT_PATH: &str = "crates/theme/src/themes";
let args = Args::parse(); let args = Args::parse();
@ -376,6 +376,6 @@ fn main() -> Result<()> {
fn format_themes_crate() -> std::io::Result<std::process::Output> { fn format_themes_crate() -> std::io::Result<std::process::Output> {
Command::new("cargo") Command::new("cargo")
.args(["fmt", "--package", "theme2"]) .args(["fmt", "--package", "theme"])
.output() .output()
} }

View File

@ -17,7 +17,7 @@ fuzzy = { path = "../fuzzy" }
gpui = { package = "gpui2", path = "../gpui2" } gpui = { package = "gpui2", path = "../gpui2" }
picker = { path = "../picker" } picker = { path = "../picker" }
settings = { path = "../settings" } settings = { path = "../settings" }
theme = { package = "theme2", path = "../theme2" } theme = { path = "../theme" }
ui = { path = "../ui" } ui = { path = "../ui" }
util = { path = "../util" } util = { path = "../util" }
workspace = { path = "../workspace" } workspace = { path = "../workspace" }

View File

@ -19,7 +19,7 @@ settings = { path = "../settings" }
smallvec.workspace = true smallvec.workspace = true
story = { path = "../story", optional = true } story = { path = "../story", optional = true }
strum = { version = "0.25.0", features = ["derive"] } strum = { version = "0.25.0", features = ["derive"] }
theme = { package = "theme2", path = "../theme2" } theme = { path = "../theme" }
rand = "0.8" rand = "0.8"
[features] [features]

View File

@ -80,7 +80,7 @@ This may change in the future, but this is a little trick that let's you use fam
## Building out the container ## Building out the container
Let's grab our [theme2::colors::ThemeColors] from the theme and start building out a basic container. Let's grab our [theme::colors::ThemeColors] from the theme and start building out a basic container.
We can access the current theme's colors like this: We can access the current theme's colors like this:

View File

@ -32,7 +32,7 @@ language = { path = "../language" }
search = { path = "../search" } search = { path = "../search" }
settings = { path = "../settings" } settings = { path = "../settings" }
workspace = { path = "../workspace" } workspace = { path = "../workspace" }
theme = { package = "theme2", path = "../theme2" } theme = { path = "../theme" }
ui = { path = "../ui"} ui = { path = "../ui"}
diagnostics = { path = "../diagnostics" } diagnostics = { path = "../diagnostics" }
zed_actions = { path = "../zed_actions" } zed_actions = { path = "../zed_actions" }
@ -49,5 +49,5 @@ project = { path = "../project", features = ["test-support"] }
util = { path = "../util", features = ["test-support"] } util = { path = "../util", features = ["test-support"] }
settings = { path = "../settings" } settings = { path = "../settings" }
workspace = { path = "../workspace", features = ["test-support"] } workspace = { path = "../workspace", features = ["test-support"] }
theme = { package = "theme2", path = "../theme2", features = ["test-support"] } theme = { path = "../theme", features = ["test-support"] }
lsp = { path = "../lsp", features = ["test-support"] } lsp = { path = "../lsp", features = ["test-support"] }

View File

@ -21,7 +21,7 @@ db = { path = "../db" }
install_cli = { path = "../install_cli" } install_cli = { path = "../install_cli" }
project = { path = "../project" } project = { path = "../project" }
settings = { path = "../settings" } settings = { path = "../settings" }
theme = { package = "theme2", path = "../theme2" } theme = { path = "../theme" }
theme_selector = { path = "../theme_selector" } theme_selector = { path = "../theme_selector" }
util = { path = "../util" } util = { path = "../util" }
picker = { path = "../picker" } picker = { path = "../picker" }

View File

@ -33,7 +33,7 @@ node_runtime = { path = "../node_runtime" }
project = { path = "../project" } project = { path = "../project" }
settings = { path = "../settings" } settings = { path = "../settings" }
terminal = { path = "../terminal" } terminal = { path = "../terminal" }
theme = { path = "../theme2", package = "theme2" } theme = { path = "../theme" }
util = { path = "../util" } util = { path = "../util" }
ui = { path = "../ui" } ui = { path = "../ui" }

View File

@ -254,7 +254,7 @@ pub mod simple_message_notification {
// } // }
// fn render(&mut self, cx: &mut gpui::ViewContext<Self>) -> gpui::AnyElement<Self> { // fn render(&mut self, cx: &mut gpui::ViewContext<Self>) -> gpui::AnyElement<Self> {
// let theme = theme2::current(cx).clone(); // let theme = theme::current(cx).clone();
// let theme = &theme.simple_message_notification; // let theme = &theme.simple_message_notification;
// enum MessageNotificationTag {} // enum MessageNotificationTag {}

View File

@ -272,7 +272,7 @@ pub struct DraggedTab {
// #[allow(clippy::too_many_arguments)] // #[allow(clippy::too_many_arguments)]
// fn nav_button<A: Action, F: 'static + Fn(&mut Pane, &mut ViewContext<Pane>)>( // fn nav_button<A: Action, F: 'static + Fn(&mut Pane, &mut ViewContext<Pane>)>(
// svg_path: &'static str, // svg_path: &'static str,
// style: theme2::Interactive<theme2::IconButton>, // style: theme::Interactive<theme2::IconButton>,
// nav_button_height: f32, // nav_button_height: f32,
// tooltip_style: TooltipStyle, // tooltip_style: TooltipStyle,
// enabled: bool, // enabled: bool,

View File

@ -66,7 +66,7 @@ sum_tree = { path = "../sum_tree" }
shellexpand = "2.1.0" shellexpand = "2.1.0"
text = { path = "../text" } text = { path = "../text" }
terminal_view = { path = "../terminal_view" } terminal_view = { path = "../terminal_view" }
theme = { package = "theme2", path = "../theme2" } theme = { path = "../theme" }
theme_selector = { path = "../theme_selector" } theme_selector = { path = "../theme_selector" }
util = { path = "../util" } util = { path = "../util" }
semantic_index = { path = "../semantic_index" } semantic_index = { path = "../semantic_index" }