Merge remote-tracking branch 'origin/main' into editor2-paint

This commit is contained in:
Antonio Scandurra 2023-11-07 13:09:48 +01:00
commit bdf6e8bcc7
204 changed files with 48828 additions and 1648 deletions

View file

@ -0,0 +1,54 @@
[package]
name = "channel2"
version = "0.1.0"
edition = "2021"
publish = false
[lib]
path = "src/channel2.rs"
doctest = false
[features]
test-support = ["collections/test-support", "gpui/test-support", "rpc/test-support"]
[dependencies]
client = { package = "client2", path = "../client2" }
collections = { path = "../collections" }
db = { package = "db2", path = "../db2" }
gpui = { package = "gpui2", path = "../gpui2" }
util = { path = "../util" }
rpc = { package = "rpc2", path = "../rpc2" }
text = { path = "../text" }
language = { package = "language2", path = "../language2" }
settings = { package = "settings2", path = "../settings2" }
feature_flags = { package = "feature_flags2", path = "../feature_flags2" }
sum_tree = { path = "../sum_tree" }
clock = { path = "../clock" }
anyhow.workspace = true
futures.workspace = true
image = "0.23"
lazy_static.workspace = true
smallvec.workspace = true
log.workspace = true
parking_lot.workspace = true
postage.workspace = true
rand.workspace = true
schemars.workspace = true
smol.workspace = true
thiserror.workspace = true
time.workspace = true
tiny_http = "0.8"
uuid.workspace = true
url = "2.2"
serde.workspace = true
serde_derive.workspace = true
tempfile = "3"
[dev-dependencies]
collections = { path = "../collections", features = ["test-support"] }
gpui = { package = "gpui2", path = "../gpui2", features = ["test-support"] }
rpc = { package = "rpc2", path = "../rpc2", features = ["test-support"] }
client = { package = "client2", path = "../client2", features = ["test-support"] }
settings = { package = "settings2", path = "../settings2", features = ["test-support"] }
util = { path = "../util", features = ["test-support"] }

View file

@ -0,0 +1,23 @@
mod channel_buffer;
mod channel_chat;
mod channel_store;
use client::{Client, UserStore};
use gpui::{AppContext, Model};
use std::sync::Arc;
pub use channel_buffer::{ChannelBuffer, ChannelBufferEvent, ACKNOWLEDGE_DEBOUNCE_INTERVAL};
pub use channel_chat::{
mentions_to_proto, ChannelChat, ChannelChatEvent, ChannelMessage, ChannelMessageId,
MessageParams,
};
pub use channel_store::{Channel, ChannelEvent, ChannelId, ChannelMembership, ChannelStore};
#[cfg(test)]
mod channel_store_tests;
pub fn init(client: &Arc<Client>, user_store: Model<UserStore>, cx: &mut AppContext) {
channel_store::init(client, user_store, cx);
channel_buffer::init(client);
channel_chat::init(client);
}

View file

@ -0,0 +1,259 @@
use crate::{Channel, ChannelId, ChannelStore};
use anyhow::Result;
use client::{Client, Collaborator, UserStore};
use collections::HashMap;
use gpui::{AppContext, AsyncAppContext, Context, EventEmitter, Model, ModelContext, Task};
use language::proto::serialize_version;
use rpc::{
proto::{self, PeerId},
TypedEnvelope,
};
use std::{sync::Arc, time::Duration};
use util::ResultExt;
pub const ACKNOWLEDGE_DEBOUNCE_INTERVAL: Duration = Duration::from_millis(250);
pub(crate) fn init(client: &Arc<Client>) {
client.add_model_message_handler(ChannelBuffer::handle_update_channel_buffer);
client.add_model_message_handler(ChannelBuffer::handle_update_channel_buffer_collaborators);
}
pub struct ChannelBuffer {
pub channel_id: ChannelId,
connected: bool,
collaborators: HashMap<PeerId, Collaborator>,
user_store: Model<UserStore>,
channel_store: Model<ChannelStore>,
buffer: Model<language::Buffer>,
buffer_epoch: u64,
client: Arc<Client>,
subscription: Option<client::Subscription>,
acknowledge_task: Option<Task<Result<()>>>,
}
pub enum ChannelBufferEvent {
CollaboratorsChanged,
Disconnected,
BufferEdited,
ChannelChanged,
}
impl EventEmitter for ChannelBuffer {
type Event = ChannelBufferEvent;
}
impl ChannelBuffer {
pub(crate) async fn new(
channel: Arc<Channel>,
client: Arc<Client>,
user_store: Model<UserStore>,
channel_store: Model<ChannelStore>,
mut cx: AsyncAppContext,
) -> Result<Model<Self>> {
let response = client
.request(proto::JoinChannelBuffer {
channel_id: channel.id,
})
.await?;
let base_text = response.base_text;
let operations = response
.operations
.into_iter()
.map(language::proto::deserialize_operation)
.collect::<Result<Vec<_>, _>>()?;
let buffer = cx.build_model(|_| {
language::Buffer::remote(response.buffer_id, response.replica_id as u16, base_text)
})?;
buffer.update(&mut cx, |buffer, cx| buffer.apply_ops(operations, cx))??;
let subscription = client.subscribe_to_entity(channel.id)?;
anyhow::Ok(cx.build_model(|cx| {
cx.subscribe(&buffer, Self::on_buffer_update).detach();
cx.on_release(Self::release).detach();
let mut this = Self {
buffer,
buffer_epoch: response.epoch,
client,
connected: true,
collaborators: Default::default(),
acknowledge_task: None,
channel_id: channel.id,
subscription: Some(subscription.set_model(&cx.handle(), &mut cx.to_async())),
user_store,
channel_store,
};
this.replace_collaborators(response.collaborators, cx);
this
})?)
}
fn release(&mut self, _: &mut AppContext) {
if self.connected {
if let Some(task) = self.acknowledge_task.take() {
task.detach();
}
self.client
.send(proto::LeaveChannelBuffer {
channel_id: self.channel_id,
})
.log_err();
}
}
pub fn remote_id(&self, cx: &AppContext) -> u64 {
self.buffer.read(cx).remote_id()
}
pub fn user_store(&self) -> &Model<UserStore> {
&self.user_store
}
pub(crate) fn replace_collaborators(
&mut self,
collaborators: Vec<proto::Collaborator>,
cx: &mut ModelContext<Self>,
) {
let mut new_collaborators = HashMap::default();
for collaborator in collaborators {
if let Ok(collaborator) = Collaborator::from_proto(collaborator) {
new_collaborators.insert(collaborator.peer_id, collaborator);
}
}
for (_, old_collaborator) in &self.collaborators {
if !new_collaborators.contains_key(&old_collaborator.peer_id) {
self.buffer.update(cx, |buffer, cx| {
buffer.remove_peer(old_collaborator.replica_id as u16, cx)
});
}
}
self.collaborators = new_collaborators;
cx.emit(ChannelBufferEvent::CollaboratorsChanged);
cx.notify();
}
async fn handle_update_channel_buffer(
this: Model<Self>,
update_channel_buffer: TypedEnvelope<proto::UpdateChannelBuffer>,
_: Arc<Client>,
mut cx: AsyncAppContext,
) -> Result<()> {
let ops = update_channel_buffer
.payload
.operations
.into_iter()
.map(language::proto::deserialize_operation)
.collect::<Result<Vec<_>, _>>()?;
this.update(&mut cx, |this, cx| {
cx.notify();
this.buffer
.update(cx, |buffer, cx| buffer.apply_ops(ops, cx))
})??;
Ok(())
}
async fn handle_update_channel_buffer_collaborators(
this: Model<Self>,
message: TypedEnvelope<proto::UpdateChannelBufferCollaborators>,
_: Arc<Client>,
mut cx: AsyncAppContext,
) -> Result<()> {
this.update(&mut cx, |this, cx| {
this.replace_collaborators(message.payload.collaborators, cx);
cx.emit(ChannelBufferEvent::CollaboratorsChanged);
cx.notify();
})
}
fn on_buffer_update(
&mut self,
_: Model<language::Buffer>,
event: &language::Event,
cx: &mut ModelContext<Self>,
) {
match event {
language::Event::Operation(operation) => {
let operation = language::proto::serialize_operation(operation);
self.client
.send(proto::UpdateChannelBuffer {
channel_id: self.channel_id,
operations: vec![operation],
})
.log_err();
}
language::Event::Edited => {
cx.emit(ChannelBufferEvent::BufferEdited);
}
_ => {}
}
}
pub fn acknowledge_buffer_version(&mut self, cx: &mut ModelContext<'_, ChannelBuffer>) {
let buffer = self.buffer.read(cx);
let version = buffer.version();
let buffer_id = buffer.remote_id();
let client = self.client.clone();
let epoch = self.epoch();
self.acknowledge_task = Some(cx.spawn(move |_, cx| async move {
cx.background_executor()
.timer(ACKNOWLEDGE_DEBOUNCE_INTERVAL)
.await;
client
.send(proto::AckBufferOperation {
buffer_id,
epoch,
version: serialize_version(&version),
})
.ok();
Ok(())
}));
}
pub fn epoch(&self) -> u64 {
self.buffer_epoch
}
pub fn buffer(&self) -> Model<language::Buffer> {
self.buffer.clone()
}
pub fn collaborators(&self) -> &HashMap<PeerId, Collaborator> {
&self.collaborators
}
pub fn channel(&self, cx: &AppContext) -> Option<Arc<Channel>> {
self.channel_store
.read(cx)
.channel_for_id(self.channel_id)
.cloned()
}
pub(crate) fn disconnect(&mut self, cx: &mut ModelContext<Self>) {
log::info!("channel buffer {} disconnected", self.channel_id);
if self.connected {
self.connected = false;
self.subscription.take();
cx.emit(ChannelBufferEvent::Disconnected);
cx.notify()
}
}
pub(crate) fn channel_changed(&mut self, cx: &mut ModelContext<Self>) {
cx.emit(ChannelBufferEvent::ChannelChanged);
cx.notify()
}
pub fn is_connected(&self) -> bool {
self.connected
}
pub fn replica_id(&self, cx: &AppContext) -> u16 {
self.buffer.read(cx).replica_id()
}
}

View file

@ -0,0 +1,647 @@
use crate::{Channel, ChannelId, ChannelStore};
use anyhow::{anyhow, Result};
use client::{
proto,
user::{User, UserStore},
Client, Subscription, TypedEnvelope, UserId,
};
use futures::lock::Mutex;
use gpui::{AppContext, AsyncAppContext, Context, EventEmitter, Model, ModelContext, Task};
use rand::prelude::*;
use std::{
collections::HashSet,
mem,
ops::{ControlFlow, Range},
sync::Arc,
};
use sum_tree::{Bias, SumTree};
use time::OffsetDateTime;
use util::{post_inc, ResultExt as _, TryFutureExt};
pub struct ChannelChat {
pub channel_id: ChannelId,
messages: SumTree<ChannelMessage>,
acknowledged_message_ids: HashSet<u64>,
channel_store: Model<ChannelStore>,
loaded_all_messages: bool,
last_acknowledged_id: Option<u64>,
next_pending_message_id: usize,
user_store: Model<UserStore>,
rpc: Arc<Client>,
outgoing_messages_lock: Arc<Mutex<()>>,
rng: StdRng,
_subscription: Subscription,
}
#[derive(Debug, PartialEq, Eq)]
pub struct MessageParams {
pub text: String,
pub mentions: Vec<(Range<usize>, UserId)>,
}
#[derive(Clone, Debug)]
pub struct ChannelMessage {
pub id: ChannelMessageId,
pub body: String,
pub timestamp: OffsetDateTime,
pub sender: Arc<User>,
pub nonce: u128,
pub mentions: Vec<(Range<usize>, UserId)>,
}
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub enum ChannelMessageId {
Saved(u64),
Pending(usize),
}
#[derive(Clone, Debug, Default)]
pub struct ChannelMessageSummary {
max_id: ChannelMessageId,
count: usize,
}
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord)]
struct Count(usize);
#[derive(Clone, Debug, PartialEq)]
pub enum ChannelChatEvent {
MessagesUpdated {
old_range: Range<usize>,
new_count: usize,
},
NewMessage {
channel_id: ChannelId,
message_id: u64,
},
}
impl EventEmitter for ChannelChat {
type Event = ChannelChatEvent;
}
pub fn init(client: &Arc<Client>) {
client.add_model_message_handler(ChannelChat::handle_message_sent);
client.add_model_message_handler(ChannelChat::handle_message_removed);
}
impl ChannelChat {
pub async fn new(
channel: Arc<Channel>,
channel_store: Model<ChannelStore>,
user_store: Model<UserStore>,
client: Arc<Client>,
mut cx: AsyncAppContext,
) -> Result<Model<Self>> {
let channel_id = channel.id;
let subscription = client.subscribe_to_entity(channel_id).unwrap();
let response = client
.request(proto::JoinChannelChat { channel_id })
.await?;
let messages = messages_from_proto(response.messages, &user_store, &mut cx).await?;
let loaded_all_messages = response.done;
Ok(cx.build_model(|cx| {
cx.on_release(Self::release).detach();
let mut this = Self {
channel_id: channel.id,
user_store,
channel_store,
rpc: client,
outgoing_messages_lock: Default::default(),
messages: Default::default(),
acknowledged_message_ids: Default::default(),
loaded_all_messages,
next_pending_message_id: 0,
last_acknowledged_id: None,
rng: StdRng::from_entropy(),
_subscription: subscription.set_model(&cx.handle(), &mut cx.to_async()),
};
this.insert_messages(messages, cx);
this
})?)
}
fn release(&mut self, _: &mut AppContext) {
self.rpc
.send(proto::LeaveChannelChat {
channel_id: self.channel_id,
})
.log_err();
}
pub fn channel(&self, cx: &AppContext) -> Option<Arc<Channel>> {
self.channel_store
.read(cx)
.channel_for_id(self.channel_id)
.cloned()
}
pub fn client(&self) -> &Arc<Client> {
&self.rpc
}
pub fn send_message(
&mut self,
message: MessageParams,
cx: &mut ModelContext<Self>,
) -> Result<Task<Result<u64>>> {
if message.text.is_empty() {
Err(anyhow!("message body can't be empty"))?;
}
let current_user = self
.user_store
.read(cx)
.current_user()
.ok_or_else(|| anyhow!("current_user is not present"))?;
let channel_id = self.channel_id;
let pending_id = ChannelMessageId::Pending(post_inc(&mut self.next_pending_message_id));
let nonce = self.rng.gen();
self.insert_messages(
SumTree::from_item(
ChannelMessage {
id: pending_id,
body: message.text.clone(),
sender: current_user,
timestamp: OffsetDateTime::now_utc(),
mentions: message.mentions.clone(),
nonce,
},
&(),
),
cx,
);
let user_store = self.user_store.clone();
let rpc = self.rpc.clone();
let outgoing_messages_lock = self.outgoing_messages_lock.clone();
Ok(cx.spawn(move |this, mut cx| async move {
let outgoing_message_guard = outgoing_messages_lock.lock().await;
let request = rpc.request(proto::SendChannelMessage {
channel_id,
body: message.text,
nonce: Some(nonce.into()),
mentions: mentions_to_proto(&message.mentions),
});
let response = request.await?;
drop(outgoing_message_guard);
let response = response.message.ok_or_else(|| anyhow!("invalid message"))?;
let id = response.id;
let message = ChannelMessage::from_proto(response, &user_store, &mut cx).await?;
this.update(&mut cx, |this, cx| {
this.insert_messages(SumTree::from_item(message, &()), cx);
})?;
Ok(id)
}))
}
pub fn remove_message(&mut self, id: u64, cx: &mut ModelContext<Self>) -> Task<Result<()>> {
let response = self.rpc.request(proto::RemoveChannelMessage {
channel_id: self.channel_id,
message_id: id,
});
cx.spawn(move |this, mut cx| async move {
response.await?;
this.update(&mut cx, |this, cx| {
this.message_removed(id, cx);
})?;
Ok(())
})
}
pub fn load_more_messages(&mut self, cx: &mut ModelContext<Self>) -> Option<Task<Option<()>>> {
if self.loaded_all_messages {
return None;
}
let rpc = self.rpc.clone();
let user_store = self.user_store.clone();
let channel_id = self.channel_id;
let before_message_id = self.first_loaded_message_id()?;
Some(cx.spawn(move |this, mut cx| {
async move {
let response = rpc
.request(proto::GetChannelMessages {
channel_id,
before_message_id,
})
.await?;
let loaded_all_messages = response.done;
let messages = messages_from_proto(response.messages, &user_store, &mut cx).await?;
this.update(&mut cx, |this, cx| {
this.loaded_all_messages = loaded_all_messages;
this.insert_messages(messages, cx);
})?;
anyhow::Ok(())
}
.log_err()
}))
}
pub fn first_loaded_message_id(&mut self) -> Option<u64> {
self.messages.first().and_then(|message| match message.id {
ChannelMessageId::Saved(id) => Some(id),
ChannelMessageId::Pending(_) => None,
})
}
/// Load all of the chat messages since a certain message id.
///
/// For now, we always maintain a suffix of the channel's messages.
pub async fn load_history_since_message(
chat: Model<Self>,
message_id: u64,
mut cx: AsyncAppContext,
) -> Option<usize> {
loop {
let step = chat
.update(&mut cx, |chat, cx| {
if let Some(first_id) = chat.first_loaded_message_id() {
if first_id <= message_id {
let mut cursor = chat.messages.cursor::<(ChannelMessageId, Count)>();
let message_id = ChannelMessageId::Saved(message_id);
cursor.seek(&message_id, Bias::Left, &());
return ControlFlow::Break(
if cursor
.item()
.map_or(false, |message| message.id == message_id)
{
Some(cursor.start().1 .0)
} else {
None
},
);
}
}
ControlFlow::Continue(chat.load_more_messages(cx))
})
.log_err()?;
match step {
ControlFlow::Break(ix) => return ix,
ControlFlow::Continue(task) => task?.await?,
}
}
}
pub fn acknowledge_last_message(&mut self, cx: &mut ModelContext<Self>) {
if let ChannelMessageId::Saved(latest_message_id) = self.messages.summary().max_id {
if self
.last_acknowledged_id
.map_or(true, |acknowledged_id| acknowledged_id < latest_message_id)
{
self.rpc
.send(proto::AckChannelMessage {
channel_id: self.channel_id,
message_id: latest_message_id,
})
.ok();
self.last_acknowledged_id = Some(latest_message_id);
self.channel_store.update(cx, |store, cx| {
store.acknowledge_message_id(self.channel_id, latest_message_id, cx);
});
}
}
}
pub fn rejoin(&mut self, cx: &mut ModelContext<Self>) {
let user_store = self.user_store.clone();
let rpc = self.rpc.clone();
let channel_id = self.channel_id;
cx.spawn(move |this, mut cx| {
async move {
let response = rpc.request(proto::JoinChannelChat { channel_id }).await?;
let messages = messages_from_proto(response.messages, &user_store, &mut cx).await?;
let loaded_all_messages = response.done;
let pending_messages = this.update(&mut cx, |this, cx| {
if let Some((first_new_message, last_old_message)) =
messages.first().zip(this.messages.last())
{
if first_new_message.id > last_old_message.id {
let old_messages = mem::take(&mut this.messages);
cx.emit(ChannelChatEvent::MessagesUpdated {
old_range: 0..old_messages.summary().count,
new_count: 0,
});
this.loaded_all_messages = loaded_all_messages;
}
}
this.insert_messages(messages, cx);
if loaded_all_messages {
this.loaded_all_messages = loaded_all_messages;
}
this.pending_messages().cloned().collect::<Vec<_>>()
})?;
for pending_message in pending_messages {
let request = rpc.request(proto::SendChannelMessage {
channel_id,
body: pending_message.body,
mentions: mentions_to_proto(&pending_message.mentions),
nonce: Some(pending_message.nonce.into()),
});
let response = request.await?;
let message = ChannelMessage::from_proto(
response.message.ok_or_else(|| anyhow!("invalid message"))?,
&user_store,
&mut cx,
)
.await?;
this.update(&mut cx, |this, cx| {
this.insert_messages(SumTree::from_item(message, &()), cx);
})?;
}
anyhow::Ok(())
}
.log_err()
})
.detach();
}
pub fn message_count(&self) -> usize {
self.messages.summary().count
}
pub fn messages(&self) -> &SumTree<ChannelMessage> {
&self.messages
}
pub fn message(&self, ix: usize) -> &ChannelMessage {
let mut cursor = self.messages.cursor::<Count>();
cursor.seek(&Count(ix), Bias::Right, &());
cursor.item().unwrap()
}
pub fn acknowledge_message(&mut self, id: u64) {
if self.acknowledged_message_ids.insert(id) {
self.rpc
.send(proto::AckChannelMessage {
channel_id: self.channel_id,
message_id: id,
})
.ok();
}
}
pub fn messages_in_range(&self, range: Range<usize>) -> impl Iterator<Item = &ChannelMessage> {
let mut cursor = self.messages.cursor::<Count>();
cursor.seek(&Count(range.start), Bias::Right, &());
cursor.take(range.len())
}
pub fn pending_messages(&self) -> impl Iterator<Item = &ChannelMessage> {
let mut cursor = self.messages.cursor::<ChannelMessageId>();
cursor.seek(&ChannelMessageId::Pending(0), Bias::Left, &());
cursor
}
async fn handle_message_sent(
this: Model<Self>,
message: TypedEnvelope<proto::ChannelMessageSent>,
_: Arc<Client>,
mut cx: AsyncAppContext,
) -> Result<()> {
let user_store = this.update(&mut cx, |this, _| this.user_store.clone())?;
let message = message
.payload
.message
.ok_or_else(|| anyhow!("empty message"))?;
let message_id = message.id;
let message = ChannelMessage::from_proto(message, &user_store, &mut cx).await?;
this.update(&mut cx, |this, cx| {
this.insert_messages(SumTree::from_item(message, &()), cx);
cx.emit(ChannelChatEvent::NewMessage {
channel_id: this.channel_id,
message_id,
})
})?;
Ok(())
}
async fn handle_message_removed(
this: Model<Self>,
message: TypedEnvelope<proto::RemoveChannelMessage>,
_: Arc<Client>,
mut cx: AsyncAppContext,
) -> Result<()> {
this.update(&mut cx, |this, cx| {
this.message_removed(message.payload.message_id, cx)
})?;
Ok(())
}
fn insert_messages(&mut self, messages: SumTree<ChannelMessage>, cx: &mut ModelContext<Self>) {
if let Some((first_message, last_message)) = messages.first().zip(messages.last()) {
let nonces = messages
.cursor::<()>()
.map(|m| m.nonce)
.collect::<HashSet<_>>();
let mut old_cursor = self.messages.cursor::<(ChannelMessageId, Count)>();
let mut new_messages = old_cursor.slice(&first_message.id, Bias::Left, &());
let start_ix = old_cursor.start().1 .0;
let removed_messages = old_cursor.slice(&last_message.id, Bias::Right, &());
let removed_count = removed_messages.summary().count;
let new_count = messages.summary().count;
let end_ix = start_ix + removed_count;
new_messages.append(messages, &());
let mut ranges = Vec::<Range<usize>>::new();
if new_messages.last().unwrap().is_pending() {
new_messages.append(old_cursor.suffix(&()), &());
} else {
new_messages.append(
old_cursor.slice(&ChannelMessageId::Pending(0), Bias::Left, &()),
&(),
);
while let Some(message) = old_cursor.item() {
let message_ix = old_cursor.start().1 .0;
if nonces.contains(&message.nonce) {
if ranges.last().map_or(false, |r| r.end == message_ix) {
ranges.last_mut().unwrap().end += 1;
} else {
ranges.push(message_ix..message_ix + 1);
}
} else {
new_messages.push(message.clone(), &());
}
old_cursor.next(&());
}
}
drop(old_cursor);
self.messages = new_messages;
for range in ranges.into_iter().rev() {
cx.emit(ChannelChatEvent::MessagesUpdated {
old_range: range,
new_count: 0,
});
}
cx.emit(ChannelChatEvent::MessagesUpdated {
old_range: start_ix..end_ix,
new_count,
});
cx.notify();
}
}
fn message_removed(&mut self, id: u64, cx: &mut ModelContext<Self>) {
let mut cursor = self.messages.cursor::<ChannelMessageId>();
let mut messages = cursor.slice(&ChannelMessageId::Saved(id), Bias::Left, &());
if let Some(item) = cursor.item() {
if item.id == ChannelMessageId::Saved(id) {
let ix = messages.summary().count;
cursor.next(&());
messages.append(cursor.suffix(&()), &());
drop(cursor);
self.messages = messages;
cx.emit(ChannelChatEvent::MessagesUpdated {
old_range: ix..ix + 1,
new_count: 0,
});
}
}
}
}
async fn messages_from_proto(
proto_messages: Vec<proto::ChannelMessage>,
user_store: &Model<UserStore>,
cx: &mut AsyncAppContext,
) -> Result<SumTree<ChannelMessage>> {
let messages = ChannelMessage::from_proto_vec(proto_messages, user_store, cx).await?;
let mut result = SumTree::new();
result.extend(messages, &());
Ok(result)
}
impl ChannelMessage {
pub async fn from_proto(
message: proto::ChannelMessage,
user_store: &Model<UserStore>,
cx: &mut AsyncAppContext,
) -> Result<Self> {
let sender = user_store
.update(cx, |user_store, cx| {
user_store.get_user(message.sender_id, cx)
})?
.await?;
Ok(ChannelMessage {
id: ChannelMessageId::Saved(message.id),
body: message.body,
mentions: message
.mentions
.into_iter()
.filter_map(|mention| {
let range = mention.range?;
Some((range.start as usize..range.end as usize, mention.user_id))
})
.collect(),
timestamp: OffsetDateTime::from_unix_timestamp(message.timestamp as i64)?,
sender,
nonce: message
.nonce
.ok_or_else(|| anyhow!("nonce is required"))?
.into(),
})
}
pub fn is_pending(&self) -> bool {
matches!(self.id, ChannelMessageId::Pending(_))
}
pub async fn from_proto_vec(
proto_messages: Vec<proto::ChannelMessage>,
user_store: &Model<UserStore>,
cx: &mut AsyncAppContext,
) -> Result<Vec<Self>> {
let unique_user_ids = proto_messages
.iter()
.map(|m| m.sender_id)
.collect::<HashSet<_>>()
.into_iter()
.collect();
user_store
.update(cx, |user_store, cx| {
user_store.get_users(unique_user_ids, cx)
})?
.await?;
let mut messages = Vec::with_capacity(proto_messages.len());
for message in proto_messages {
messages.push(ChannelMessage::from_proto(message, user_store, cx).await?);
}
Ok(messages)
}
}
pub fn mentions_to_proto(mentions: &[(Range<usize>, UserId)]) -> Vec<proto::ChatMention> {
mentions
.iter()
.map(|(range, user_id)| proto::ChatMention {
range: Some(proto::Range {
start: range.start as u64,
end: range.end as u64,
}),
user_id: *user_id as u64,
})
.collect()
}
impl sum_tree::Item for ChannelMessage {
type Summary = ChannelMessageSummary;
fn summary(&self) -> Self::Summary {
ChannelMessageSummary {
max_id: self.id,
count: 1,
}
}
}
impl Default for ChannelMessageId {
fn default() -> Self {
Self::Saved(0)
}
}
impl sum_tree::Summary for ChannelMessageSummary {
type Context = ();
fn add_summary(&mut self, summary: &Self, _: &()) {
self.max_id = summary.max_id;
self.count += summary.count;
}
}
impl<'a> sum_tree::Dimension<'a, ChannelMessageSummary> for ChannelMessageId {
fn add_summary(&mut self, summary: &'a ChannelMessageSummary, _: &()) {
debug_assert!(summary.max_id > *self);
*self = summary.max_id;
}
}
impl<'a> sum_tree::Dimension<'a, ChannelMessageSummary> for Count {
fn add_summary(&mut self, summary: &'a ChannelMessageSummary, _: &()) {
self.0 += summary.count;
}
}
impl<'a> From<&'a str> for MessageParams {
fn from(value: &'a str) -> Self {
Self {
text: value.into(),
mentions: Vec::new(),
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,184 @@
use crate::{Channel, ChannelId};
use collections::BTreeMap;
use rpc::proto;
use std::sync::Arc;
#[derive(Default, Debug)]
pub struct ChannelIndex {
channels_ordered: Vec<ChannelId>,
channels_by_id: BTreeMap<ChannelId, Arc<Channel>>,
}
impl ChannelIndex {
pub fn by_id(&self) -> &BTreeMap<ChannelId, Arc<Channel>> {
&self.channels_by_id
}
pub fn ordered_channels(&self) -> &[ChannelId] {
&self.channels_ordered
}
pub fn clear(&mut self) {
self.channels_ordered.clear();
self.channels_by_id.clear();
}
/// Delete the given channels from this index.
pub fn delete_channels(&mut self, channels: &[ChannelId]) {
self.channels_by_id
.retain(|channel_id, _| !channels.contains(channel_id));
self.channels_ordered
.retain(|channel_id| !channels.contains(channel_id));
}
pub fn bulk_insert(&mut self) -> ChannelPathsInsertGuard {
ChannelPathsInsertGuard {
channels_ordered: &mut self.channels_ordered,
channels_by_id: &mut self.channels_by_id,
}
}
pub fn acknowledge_note_version(
&mut self,
channel_id: ChannelId,
epoch: u64,
version: &clock::Global,
) {
if let Some(channel) = self.channels_by_id.get_mut(&channel_id) {
let channel = Arc::make_mut(channel);
if let Some((unseen_epoch, unseen_version)) = &channel.unseen_note_version {
if epoch > *unseen_epoch
|| epoch == *unseen_epoch && version.observed_all(unseen_version)
{
channel.unseen_note_version = None;
}
}
}
}
pub fn acknowledge_message_id(&mut self, channel_id: ChannelId, message_id: u64) {
if let Some(channel) = self.channels_by_id.get_mut(&channel_id) {
let channel = Arc::make_mut(channel);
if let Some(unseen_message_id) = channel.unseen_message_id {
if message_id >= unseen_message_id {
channel.unseen_message_id = None;
}
}
}
}
pub fn note_changed(&mut self, channel_id: ChannelId, epoch: u64, version: &clock::Global) {
insert_note_changed(&mut self.channels_by_id, channel_id, epoch, version);
}
pub fn new_message(&mut self, channel_id: ChannelId, message_id: u64) {
insert_new_message(&mut self.channels_by_id, channel_id, message_id)
}
}
/// A guard for ensuring that the paths index maintains its sort and uniqueness
/// invariants after a series of insertions
#[derive(Debug)]
pub struct ChannelPathsInsertGuard<'a> {
channels_ordered: &'a mut Vec<ChannelId>,
channels_by_id: &'a mut BTreeMap<ChannelId, Arc<Channel>>,
}
impl<'a> ChannelPathsInsertGuard<'a> {
pub fn note_changed(&mut self, channel_id: ChannelId, epoch: u64, version: &clock::Global) {
insert_note_changed(&mut self.channels_by_id, channel_id, epoch, &version);
}
pub fn new_messages(&mut self, channel_id: ChannelId, message_id: u64) {
insert_new_message(&mut self.channels_by_id, channel_id, message_id)
}
pub fn insert(&mut self, channel_proto: proto::Channel) -> bool {
let mut ret = false;
if let Some(existing_channel) = self.channels_by_id.get_mut(&channel_proto.id) {
let existing_channel = Arc::make_mut(existing_channel);
ret = existing_channel.visibility != channel_proto.visibility()
|| existing_channel.role != channel_proto.role()
|| existing_channel.name != channel_proto.name;
existing_channel.visibility = channel_proto.visibility();
existing_channel.role = channel_proto.role();
existing_channel.name = channel_proto.name;
} else {
self.channels_by_id.insert(
channel_proto.id,
Arc::new(Channel {
id: channel_proto.id,
visibility: channel_proto.visibility(),
role: channel_proto.role(),
name: channel_proto.name,
unseen_note_version: None,
unseen_message_id: None,
parent_path: channel_proto.parent_path,
}),
);
self.insert_root(channel_proto.id);
}
ret
}
fn insert_root(&mut self, channel_id: ChannelId) {
self.channels_ordered.push(channel_id);
}
}
impl<'a> Drop for ChannelPathsInsertGuard<'a> {
fn drop(&mut self) {
self.channels_ordered.sort_by(|a, b| {
let a = channel_path_sorting_key(*a, &self.channels_by_id);
let b = channel_path_sorting_key(*b, &self.channels_by_id);
a.cmp(b)
});
self.channels_ordered.dedup();
}
}
fn channel_path_sorting_key<'a>(
id: ChannelId,
channels_by_id: &'a BTreeMap<ChannelId, Arc<Channel>>,
) -> impl Iterator<Item = &str> {
let (parent_path, name) = channels_by_id
.get(&id)
.map_or((&[] as &[_], None), |channel| {
(channel.parent_path.as_slice(), Some(channel.name.as_str()))
});
parent_path
.iter()
.filter_map(|id| Some(channels_by_id.get(id)?.name.as_str()))
.chain(name)
}
fn insert_note_changed(
channels_by_id: &mut BTreeMap<ChannelId, Arc<Channel>>,
channel_id: u64,
epoch: u64,
version: &clock::Global,
) {
if let Some(channel) = channels_by_id.get_mut(&channel_id) {
let unseen_version = Arc::make_mut(channel)
.unseen_note_version
.get_or_insert((0, clock::Global::new()));
if epoch > unseen_version.0 {
*unseen_version = (epoch, version.clone());
} else {
unseen_version.1.join(&version);
}
}
}
fn insert_new_message(
channels_by_id: &mut BTreeMap<ChannelId, Arc<Channel>>,
channel_id: u64,
message_id: u64,
) {
if let Some(channel) = channels_by_id.get_mut(&channel_id) {
let unseen_message_id = Arc::make_mut(channel).unseen_message_id.get_or_insert(0);
*unseen_message_id = message_id.max(*unseen_message_id);
}
}

View file

@ -0,0 +1,380 @@
use crate::channel_chat::ChannelChatEvent;
use super::*;
use client::{test::FakeServer, Client, UserStore};
use gpui::{AppContext, Context, Model, TestAppContext};
use rpc::proto::{self};
use settings::SettingsStore;
use util::http::FakeHttpClient;
#[gpui::test]
fn test_update_channels(cx: &mut AppContext) {
let channel_store = init_test(cx);
update_channels(
&channel_store,
proto::UpdateChannels {
channels: vec![
proto::Channel {
id: 1,
name: "b".to_string(),
visibility: proto::ChannelVisibility::Members as i32,
role: proto::ChannelRole::Admin.into(),
parent_path: Vec::new(),
},
proto::Channel {
id: 2,
name: "a".to_string(),
visibility: proto::ChannelVisibility::Members as i32,
role: proto::ChannelRole::Member.into(),
parent_path: Vec::new(),
},
],
..Default::default()
},
cx,
);
assert_channels(
&channel_store,
&[
//
(0, "a".to_string(), proto::ChannelRole::Member),
(0, "b".to_string(), proto::ChannelRole::Admin),
],
cx,
);
update_channels(
&channel_store,
proto::UpdateChannels {
channels: vec![
proto::Channel {
id: 3,
name: "x".to_string(),
visibility: proto::ChannelVisibility::Members as i32,
role: proto::ChannelRole::Admin.into(),
parent_path: vec![1],
},
proto::Channel {
id: 4,
name: "y".to_string(),
visibility: proto::ChannelVisibility::Members as i32,
role: proto::ChannelRole::Member.into(),
parent_path: vec![2],
},
],
..Default::default()
},
cx,
);
assert_channels(
&channel_store,
&[
(0, "a".to_string(), proto::ChannelRole::Member),
(1, "y".to_string(), proto::ChannelRole::Member),
(0, "b".to_string(), proto::ChannelRole::Admin),
(1, "x".to_string(), proto::ChannelRole::Admin),
],
cx,
);
}
#[gpui::test]
fn test_dangling_channel_paths(cx: &mut AppContext) {
let channel_store = init_test(cx);
update_channels(
&channel_store,
proto::UpdateChannels {
channels: vec![
proto::Channel {
id: 0,
name: "a".to_string(),
visibility: proto::ChannelVisibility::Members as i32,
role: proto::ChannelRole::Admin.into(),
parent_path: vec![],
},
proto::Channel {
id: 1,
name: "b".to_string(),
visibility: proto::ChannelVisibility::Members as i32,
role: proto::ChannelRole::Admin.into(),
parent_path: vec![0],
},
proto::Channel {
id: 2,
name: "c".to_string(),
visibility: proto::ChannelVisibility::Members as i32,
role: proto::ChannelRole::Admin.into(),
parent_path: vec![0, 1],
},
],
..Default::default()
},
cx,
);
// Sanity check
assert_channels(
&channel_store,
&[
//
(0, "a".to_string(), proto::ChannelRole::Admin),
(1, "b".to_string(), proto::ChannelRole::Admin),
(2, "c".to_string(), proto::ChannelRole::Admin),
],
cx,
);
update_channels(
&channel_store,
proto::UpdateChannels {
delete_channels: vec![1, 2],
..Default::default()
},
cx,
);
// Make sure that the 1/2/3 path is gone
assert_channels(
&channel_store,
&[(0, "a".to_string(), proto::ChannelRole::Admin)],
cx,
);
}
#[gpui::test]
async fn test_channel_messages(cx: &mut TestAppContext) {
let user_id = 5;
let channel_id = 5;
let channel_store = cx.update(init_test);
let client = channel_store.update(cx, |s, _| s.client());
let server = FakeServer::for_client(user_id, &client, cx).await;
// Get the available channels.
server.send(proto::UpdateChannels {
channels: vec![proto::Channel {
id: channel_id,
name: "the-channel".to_string(),
visibility: proto::ChannelVisibility::Members as i32,
role: proto::ChannelRole::Member.into(),
parent_path: vec![],
}],
..Default::default()
});
cx.executor().run_until_parked();
cx.update(|cx| {
assert_channels(
&channel_store,
&[(0, "the-channel".to_string(), proto::ChannelRole::Member)],
cx,
);
});
let get_users = server.receive::<proto::GetUsers>().await.unwrap();
assert_eq!(get_users.payload.user_ids, vec![5]);
server.respond(
get_users.receipt(),
proto::UsersResponse {
users: vec![proto::User {
id: 5,
github_login: "nathansobo".into(),
avatar_url: "http://avatar.com/nathansobo".into(),
}],
},
);
// Join a channel and populate its existing messages.
let channel = channel_store.update(cx, |store, cx| {
let channel_id = store.ordered_channels().next().unwrap().1.id;
store.open_channel_chat(channel_id, cx)
});
let join_channel = server.receive::<proto::JoinChannelChat>().await.unwrap();
server.respond(
join_channel.receipt(),
proto::JoinChannelChatResponse {
messages: vec![
proto::ChannelMessage {
id: 10,
body: "a".into(),
timestamp: 1000,
sender_id: 5,
mentions: vec![],
nonce: Some(1.into()),
},
proto::ChannelMessage {
id: 11,
body: "b".into(),
timestamp: 1001,
sender_id: 6,
mentions: vec![],
nonce: Some(2.into()),
},
],
done: false,
},
);
cx.executor().start_waiting();
// Client requests all users for the received messages
let mut get_users = server.receive::<proto::GetUsers>().await.unwrap();
get_users.payload.user_ids.sort();
assert_eq!(get_users.payload.user_ids, vec![6]);
server.respond(
get_users.receipt(),
proto::UsersResponse {
users: vec![proto::User {
id: 6,
github_login: "maxbrunsfeld".into(),
avatar_url: "http://avatar.com/maxbrunsfeld".into(),
}],
},
);
let channel = channel.await.unwrap();
channel.update(cx, |channel, _| {
assert_eq!(
channel
.messages_in_range(0..2)
.map(|message| (message.sender.github_login.clone(), message.body.clone()))
.collect::<Vec<_>>(),
&[
("nathansobo".into(), "a".into()),
("maxbrunsfeld".into(), "b".into())
]
);
});
// Receive a new message.
server.send(proto::ChannelMessageSent {
channel_id,
message: Some(proto::ChannelMessage {
id: 12,
body: "c".into(),
timestamp: 1002,
sender_id: 7,
mentions: vec![],
nonce: Some(3.into()),
}),
});
// Client requests user for message since they haven't seen them yet
let get_users = server.receive::<proto::GetUsers>().await.unwrap();
assert_eq!(get_users.payload.user_ids, vec![7]);
server.respond(
get_users.receipt(),
proto::UsersResponse {
users: vec![proto::User {
id: 7,
github_login: "as-cii".into(),
avatar_url: "http://avatar.com/as-cii".into(),
}],
},
);
assert_eq!(
channel.next_event(cx),
ChannelChatEvent::MessagesUpdated {
old_range: 2..2,
new_count: 1,
}
);
channel.update(cx, |channel, _| {
assert_eq!(
channel
.messages_in_range(2..3)
.map(|message| (message.sender.github_login.clone(), message.body.clone()))
.collect::<Vec<_>>(),
&[("as-cii".into(), "c".into())]
)
});
// Scroll up to view older messages.
channel.update(cx, |channel, cx| {
channel.load_more_messages(cx).unwrap().detach();
});
let get_messages = server.receive::<proto::GetChannelMessages>().await.unwrap();
assert_eq!(get_messages.payload.channel_id, 5);
assert_eq!(get_messages.payload.before_message_id, 10);
server.respond(
get_messages.receipt(),
proto::GetChannelMessagesResponse {
done: true,
messages: vec![
proto::ChannelMessage {
id: 8,
body: "y".into(),
timestamp: 998,
sender_id: 5,
nonce: Some(4.into()),
mentions: vec![],
},
proto::ChannelMessage {
id: 9,
body: "z".into(),
timestamp: 999,
sender_id: 6,
nonce: Some(5.into()),
mentions: vec![],
},
],
},
);
assert_eq!(
channel.next_event(cx),
ChannelChatEvent::MessagesUpdated {
old_range: 0..0,
new_count: 2,
}
);
channel.update(cx, |channel, _| {
assert_eq!(
channel
.messages_in_range(0..2)
.map(|message| (message.sender.github_login.clone(), message.body.clone()))
.collect::<Vec<_>>(),
&[
("nathansobo".into(), "y".into()),
("maxbrunsfeld".into(), "z".into())
]
);
});
}
fn init_test(cx: &mut AppContext) -> Model<ChannelStore> {
let http = FakeHttpClient::with_404_response();
let client = Client::new(http.clone(), cx);
let user_store = cx.build_model(|cx| UserStore::new(client.clone(), http, cx));
let settings_store = SettingsStore::test(cx);
cx.set_global(settings_store);
client::init(&client, cx);
crate::init(&client, user_store, cx);
ChannelStore::global(cx)
}
fn update_channels(
channel_store: &Model<ChannelStore>,
message: proto::UpdateChannels,
cx: &mut AppContext,
) {
let task = channel_store.update(cx, |store, cx| store.update_channels(message, cx));
assert!(task.is_none());
}
#[track_caller]
fn assert_channels(
channel_store: &Model<ChannelStore>,
expected_channels: &[(usize, String, proto::ChannelRole)],
cx: &mut AppContext,
) {
let actual = channel_store.update(cx, |store, _| {
store
.ordered_channels()
.map(|(depth, channel)| (depth, channel.name.to_string(), channel.role))
.collect::<Vec<_>>()
});
assert_eq!(actual, expected_channels);
}

View file

@ -292,22 +292,18 @@ impl UserStore {
.upgrade()
.ok_or_else(|| anyhow!("can't upgrade user store handle"))?;
for contact in message.contacts {
let should_notify = contact.should_notify;
updated_contacts.push((
Arc::new(Contact::from_proto(contact, &this, &mut cx).await?),
should_notify,
updated_contacts.push(Arc::new(
Contact::from_proto(contact, &this, &mut cx).await?,
));
}
let mut incoming_requests = Vec::new();
for request in message.incoming_requests {
incoming_requests.push({
let user = this
.update(&mut cx, |this, cx| {
this.get_user(request.requester_id, cx)
})?
.await?;
(user, request.should_notify)
this.update(&mut cx, |this, cx| {
this.get_user(request.requester_id, cx)
})?
.await?
});
}
@ -331,13 +327,7 @@ impl UserStore {
this.contacts
.retain(|contact| !removed_contacts.contains(&contact.user.id));
// Update existing contacts and insert new ones
for (updated_contact, should_notify) in updated_contacts {
if should_notify {
cx.emit(Event::Contact {
user: updated_contact.user.clone(),
kind: ContactEventKind::Accepted,
});
}
for updated_contact in updated_contacts {
match this.contacts.binary_search_by_key(
&&updated_contact.user.github_login,
|contact| &contact.user.github_login,
@ -360,14 +350,7 @@ impl UserStore {
}
});
// Update existing incoming requests and insert new ones
for (user, should_notify) in incoming_requests {
if should_notify {
cx.emit(Event::Contact {
user: user.clone(),
kind: ContactEventKind::Requested,
});
}
for user in incoming_requests {
match this
.incoming_contact_requests
.binary_search_by_key(&&user.github_login, |contact| {

View file

@ -75,23 +75,23 @@ impl ChannelView {
let workspace = workspace.read(cx);
let project = workspace.project().to_owned();
let channel_store = ChannelStore::global(cx);
let markdown = workspace
.app_state()
.languages
.language_for_name("Markdown");
let language_registry = workspace.app_state().languages.clone();
let markdown = language_registry.language_for_name("Markdown");
let channel_buffer =
channel_store.update(cx, |store, cx| store.open_channel_buffer(channel_id, cx));
cx.spawn(|mut cx| async move {
let channel_buffer = channel_buffer.await?;
let markdown = markdown.await.log_err();
if let Some(markdown) = markdown.await.log_err() {
channel_buffer.update(&mut cx, |buffer, cx| {
buffer.buffer().update(cx, |buffer, cx| {
channel_buffer.update(&mut cx, |buffer, cx| {
buffer.buffer().update(cx, |buffer, cx| {
buffer.set_language_registry(language_registry);
if let Some(markdown) = markdown {
buffer.set_language(Some(markdown), cx);
})
});
}
}
})
});
pane.update(&mut cx, |pane, cx| {
let buffer_id = channel_buffer.read(cx).remote_id(cx);

View file

@ -20,7 +20,9 @@ theme = { path = "../theme" }
util = { path = "../util" }
workspace = { path = "../workspace" }
log.workspace = true
anyhow.workspace = true
futures.workspace = true
schemars.workspace = true
serde.workspace = true
serde_derive.workspace = true

View file

@ -2,8 +2,8 @@ pub mod items;
mod project_diagnostics_settings;
mod toolbar_controls;
use anyhow::Result;
use collections::{BTreeSet, HashSet};
use anyhow::{Context, Result};
use collections::{HashMap, HashSet};
use editor::{
diagnostic_block_renderer,
display_map::{BlockDisposition, BlockId, BlockProperties, BlockStyle, RenderBlock},
@ -11,9 +11,10 @@ use editor::{
scroll::autoscroll::Autoscroll,
Editor, ExcerptId, ExcerptRange, MultiBuffer, ToOffset,
};
use futures::future::try_join_all;
use gpui::{
actions, elements::*, fonts::TextStyle, serde_json, AnyViewHandle, AppContext, Entity,
ModelHandle, Task, View, ViewContext, ViewHandle, WeakViewHandle,
ModelHandle, Subscription, Task, View, ViewContext, ViewHandle, WeakViewHandle,
};
use language::{
Anchor, Bias, Buffer, Diagnostic, DiagnosticEntry, DiagnosticSeverity, Point, Selection,
@ -28,6 +29,7 @@ use std::{
any::{Any, TypeId},
borrow::Cow,
cmp::Ordering,
mem,
ops::Range,
path::PathBuf,
sync::Arc,
@ -60,8 +62,10 @@ struct ProjectDiagnosticsEditor {
summary: DiagnosticSummary,
excerpts: ModelHandle<MultiBuffer>,
path_states: Vec<PathState>,
paths_to_update: BTreeSet<(ProjectPath, LanguageServerId)>,
paths_to_update: HashMap<LanguageServerId, HashSet<ProjectPath>>,
current_diagnostics: HashMap<LanguageServerId, HashSet<ProjectPath>>,
include_warnings: bool,
_subscriptions: Vec<Subscription>,
}
struct PathState {
@ -125,9 +129,12 @@ impl View for ProjectDiagnosticsEditor {
"summary": project.diagnostic_summary(cx),
}),
"summary": self.summary,
"paths_to_update": self.paths_to_update.iter().map(|(path, server_id)|
(path.path.to_string_lossy(), server_id.0)
).collect::<Vec<_>>(),
"paths_to_update": self.paths_to_update.iter().map(|(server_id, paths)|
(server_id.0, paths.into_iter().map(|path| path.path.to_string_lossy()).collect::<Vec<_>>())
).collect::<HashMap<_, _>>(),
"current_diagnostics": self.current_diagnostics.iter().map(|(server_id, paths)|
(server_id.0, paths.into_iter().map(|path| path.path.to_string_lossy()).collect::<Vec<_>>())
).collect::<HashMap<_, _>>(),
"paths_states": self.path_states.iter().map(|state|
json!({
"path": state.path.path.to_string_lossy(),
@ -149,21 +156,30 @@ impl ProjectDiagnosticsEditor {
workspace: WeakViewHandle<Workspace>,
cx: &mut ViewContext<Self>,
) -> Self {
cx.subscribe(&project_handle, |this, _, event, cx| match event {
project::Event::DiskBasedDiagnosticsFinished { language_server_id } => {
this.update_excerpts(Some(*language_server_id), cx);
this.update_title(cx);
}
project::Event::DiagnosticsUpdated {
language_server_id,
path,
} => {
this.paths_to_update
.insert((path.clone(), *language_server_id));
}
_ => {}
})
.detach();
let project_event_subscription =
cx.subscribe(&project_handle, |this, _, event, cx| match event {
project::Event::DiskBasedDiagnosticsFinished { language_server_id } => {
log::debug!("Disk based diagnostics finished for server {language_server_id}");
this.update_excerpts(Some(*language_server_id), cx);
}
project::Event::DiagnosticsUpdated {
language_server_id,
path,
} => {
log::debug!("Adding path {path:?} to update for server {language_server_id}");
this.paths_to_update
.entry(*language_server_id)
.or_default()
.insert(path.clone());
let no_multiselections = this.editor.update(cx, |editor, cx| {
editor.selections.all::<usize>(cx).len() <= 1
});
if no_multiselections && !this.is_dirty(cx) {
this.update_excerpts(Some(*language_server_id), cx);
}
}
_ => {}
});
let excerpts = cx.add_model(|cx| MultiBuffer::new(project_handle.read(cx).replica_id()));
let editor = cx.add_view(|cx| {
@ -172,19 +188,14 @@ impl ProjectDiagnosticsEditor {
editor.set_vertical_scroll_margin(5, cx);
editor
});
cx.subscribe(&editor, |this, _, event, cx| {
let editor_event_subscription = cx.subscribe(&editor, |this, _, event, cx| {
cx.emit(event.clone());
if event == &editor::Event::Focused && this.path_states.is_empty() {
cx.focus_self()
}
})
.detach();
});
let project = project_handle.read(cx);
let paths_to_update = project
.diagnostic_summaries(cx)
.map(|(path, server_id, _)| (path, server_id))
.collect();
let summary = project.diagnostic_summary(cx);
let mut this = Self {
project: project_handle,
@ -193,8 +204,10 @@ impl ProjectDiagnosticsEditor {
excerpts,
editor,
path_states: Default::default(),
paths_to_update,
paths_to_update: HashMap::default(),
include_warnings: settings::get::<ProjectDiagnosticsSettings>(cx).include_warnings,
current_diagnostics: HashMap::default(),
_subscriptions: vec![project_event_subscription, editor_event_subscription],
};
this.update_excerpts(None, cx);
this
@ -214,12 +227,7 @@ impl ProjectDiagnosticsEditor {
fn toggle_warnings(&mut self, _: &ToggleWarnings, cx: &mut ViewContext<Self>) {
self.include_warnings = !self.include_warnings;
self.paths_to_update = self
.project
.read(cx)
.diagnostic_summaries(cx)
.map(|(path, server_id, _)| (path, server_id))
.collect();
self.paths_to_update = self.current_diagnostics.clone();
self.update_excerpts(None, cx);
cx.notify();
}
@ -229,29 +237,94 @@ impl ProjectDiagnosticsEditor {
language_server_id: Option<LanguageServerId>,
cx: &mut ViewContext<Self>,
) {
let mut paths = Vec::new();
self.paths_to_update.retain(|(path, server_id)| {
if language_server_id
.map_or(true, |language_server_id| language_server_id == *server_id)
{
paths.push(path.clone());
false
log::debug!("Updating excerpts for server {language_server_id:?}");
let mut paths_to_recheck = HashSet::default();
let mut new_summaries: HashMap<LanguageServerId, HashSet<ProjectPath>> = self
.project
.read(cx)
.diagnostic_summaries(cx)
.fold(HashMap::default(), |mut summaries, (path, server_id, _)| {
summaries.entry(server_id).or_default().insert(path);
summaries
});
let mut old_diagnostics = if let Some(language_server_id) = language_server_id {
new_summaries.retain(|server_id, _| server_id == &language_server_id);
self.paths_to_update.retain(|server_id, paths| {
if server_id == &language_server_id {
paths_to_recheck.extend(paths.drain());
false
} else {
true
}
});
let mut old_diagnostics = HashMap::default();
if let Some(new_paths) = new_summaries.get(&language_server_id) {
if let Some(old_paths) = self
.current_diagnostics
.insert(language_server_id, new_paths.clone())
{
old_diagnostics.insert(language_server_id, old_paths);
}
} else {
true
if let Some(old_paths) = self.current_diagnostics.remove(&language_server_id) {
old_diagnostics.insert(language_server_id, old_paths);
}
}
});
old_diagnostics
} else {
paths_to_recheck.extend(self.paths_to_update.drain().flat_map(|(_, paths)| paths));
mem::replace(&mut self.current_diagnostics, new_summaries.clone())
};
for (server_id, new_paths) in new_summaries {
match old_diagnostics.remove(&server_id) {
Some(mut old_paths) => {
paths_to_recheck.extend(
new_paths
.into_iter()
.filter(|new_path| !old_paths.remove(new_path)),
);
paths_to_recheck.extend(old_paths);
}
None => paths_to_recheck.extend(new_paths),
}
}
paths_to_recheck.extend(old_diagnostics.into_iter().flat_map(|(_, paths)| paths));
if paths_to_recheck.is_empty() {
log::debug!("No paths to recheck for language server {language_server_id:?}");
return;
}
log::debug!(
"Rechecking {} paths for language server {:?}",
paths_to_recheck.len(),
language_server_id
);
let project = self.project.clone();
cx.spawn(|this, mut cx| {
async move {
for path in paths {
let buffer = project
.update(&mut cx, |project, cx| project.open_buffer(path.clone(), cx))
.await?;
this.update(&mut cx, |this, cx| {
this.populate_excerpts(path, language_server_id, buffer, cx)
})?;
}
Result::<_, anyhow::Error>::Ok(())
let _: Vec<()> = try_join_all(paths_to_recheck.into_iter().map(|path| {
let mut cx = cx.clone();
let project = project.clone();
async move {
let buffer = project
.update(&mut cx, |project, cx| project.open_buffer(path.clone(), cx))
.await
.with_context(|| format!("opening buffer for path {path:?}"))?;
this.update(&mut cx, |this, cx| {
this.populate_excerpts(path, language_server_id, buffer, cx);
})
.context("missing project")?;
anyhow::Ok(())
}
}))
.await
.context("rechecking diagnostics for paths")?;
this.update(&mut cx, |this, cx| {
this.summary = this.project.read(cx).diagnostic_summary(cx);
cx.emit(Event::TitleChanged);
})?;
anyhow::Ok(())
}
.log_err()
})
@ -554,11 +627,6 @@ impl ProjectDiagnosticsEditor {
}
cx.notify();
}
fn update_title(&mut self, cx: &mut ViewContext<Self>) {
self.summary = self.project.read(cx).diagnostic_summary(cx);
cx.emit(Event::TitleChanged);
}
}
impl Item for ProjectDiagnosticsEditor {
@ -1301,25 +1369,6 @@ mod tests {
cx,
)
.unwrap();
project
.update_diagnostic_entries(
server_id_2,
PathBuf::from("/test/main.js"),
None,
vec![DiagnosticEntry {
range: Unclipped(PointUtf16::new(1, 0))..Unclipped(PointUtf16::new(1, 1)),
diagnostic: Diagnostic {
message: "warning 1".to_string(),
severity: DiagnosticSeverity::ERROR,
is_primary: true,
is_disk_based: true,
group_id: 2,
..Default::default()
},
}],
cx,
)
.unwrap();
});
// The first language server finishes
@ -1353,6 +1402,25 @@ mod tests {
// The second language server finishes
project.update(cx, |project, cx| {
project
.update_diagnostic_entries(
server_id_2,
PathBuf::from("/test/main.js"),
None,
vec![DiagnosticEntry {
range: Unclipped(PointUtf16::new(1, 0))..Unclipped(PointUtf16::new(1, 1)),
diagnostic: Diagnostic {
message: "warning 1".to_string(),
severity: DiagnosticSeverity::ERROR,
is_primary: true,
is_disk_based: true,
group_id: 2,
..Default::default()
},
}],
cx,
)
.unwrap();
project.disk_based_diagnostics_finished(server_id_2, cx);
});

View file

@ -33,9 +33,9 @@ use util::{
paths::{PathExt, FILE_ROW_COLUMN_DELIMITER},
ResultExt, TryFutureExt,
};
use workspace::item::{BreadcrumbText, FollowableItemHandle};
use workspace::item::{BreadcrumbText, FollowableItemHandle, ItemHandle};
use workspace::{
item::{FollowableItem, Item, ItemEvent, ItemHandle, ProjectItem},
item::{FollowableItem, Item, ItemEvent, ProjectItem},
searchable::{Direction, SearchEvent, SearchableItem, SearchableItemHandle},
ItemId, ItemNavHistory, Pane, StatusItemView, ToolbarItemLocation, ViewId, Workspace,
WorkspaceId,

View file

@ -510,8 +510,8 @@ impl DisplaySnapshot {
self.chunks(
display_rows,
language_aware,
Some(theme.styles.inlay_highlight_style),
Some(theme.styles.suggestion_highlight_style),
None, // todo!("add inlay highlight style")
None, // todo!("add suggestion highlight style")
)
.map(|chunk| {
let mut highlight_style = chunk

View file

@ -9335,7 +9335,7 @@ impl Render for Editor {
underline: None,
};
EditorElement::new(EditorStyle {
background: cx.theme().colors().editor,
background: cx.theme().colors().editor_background,
local_player: cx.theme().players().local(),
text: text_style,
line_height_scalar: settings.buffer_line_height.value(),

View file

@ -508,7 +508,7 @@ impl EditorElement {
let bounds = gutter_bounds.union(&text_bounds);
let scroll_top =
layout.position_map.snapshot.scroll_position().y * layout.position_map.line_height;
let gutter_bg = cx.theme().colors().editor_gutter;
let gutter_bg = cx.theme().colors().editor_gutter_background;
cx.paint_quad(
gutter_bounds,
Corners::default(),
@ -545,7 +545,7 @@ impl EditorElement {
bounds.size.width,
layout.position_map.line_height * (end_row - start_row + 1) as f32,
);
let active_line_bg = cx.theme().colors().editor_active_line;
let active_line_bg = cx.theme().colors().editor_active_line_background;
cx.paint_quad(
Bounds { origin, size },
Corners::default(),
@ -567,7 +567,7 @@ impl EditorElement {
bounds.size.width,
layout.position_map.line_height * highlighted_rows.len() as f32,
);
let highlighted_line_bg = cx.theme().colors().editor_highlighted_line;
let highlighted_line_bg = cx.theme().colors().editor_highlighted_line_background;
cx.paint_quad(
Bounds { origin, size },
Corners::default(),

View file

@ -20,6 +20,7 @@ fn generate_dispatch_bindings() {
.header("src/platform/mac/dispatch.h")
.allowlist_var("_dispatch_main_q")
.allowlist_var("DISPATCH_QUEUE_PRIORITY_DEFAULT")
.allowlist_var("DISPATCH_TIME_NOW")
.allowlist_function("dispatch_get_global_queue")
.allowlist_function("dispatch_async_f")
.allowlist_function("dispatch_after_f")

View file

@ -46,13 +46,17 @@ pub struct AppCell {
}
impl AppCell {
#[track_caller]
pub fn borrow(&self) -> AppRef {
let thread_id = std::thread::current().id();
eprintln!("borrowed {thread_id:?}");
AppRef(self.app.borrow())
}
#[track_caller]
pub fn borrow_mut(&self) -> AppRefMut {
// let thread_id = std::thread::current().id();
// dbg!("borrowed {thread_id:?}");
let thread_id = std::thread::current().id();
eprintln!("borrowed {thread_id:?}");
AppRefMut(self.app.borrow_mut())
}
}
@ -157,6 +161,7 @@ pub struct AppContext {
flushing_effects: bool,
pending_updates: usize,
pub(crate) active_drag: Option<AnyDrag>,
pub(crate) active_tooltip: Option<AnyTooltip>,
pub(crate) next_frame_callbacks: HashMap<DisplayId, Vec<FrameCallback>>,
pub(crate) frame_consumers: HashMap<DisplayId, Task<()>>,
pub(crate) background_executor: BackgroundExecutor,
@ -215,6 +220,7 @@ impl AppContext {
flushing_effects: false,
pending_updates: 0,
active_drag: None,
active_tooltip: None,
next_frame_callbacks: HashMap::default(),
frame_consumers: HashMap::default(),
background_executor: executor,
@ -896,3 +902,9 @@ pub(crate) struct AnyDrag {
pub view: AnyView,
pub cursor_offset: Point<Pixels>,
}
#[derive(Clone)]
pub(crate) struct AnyTooltip {
pub view: AnyView,
pub cursor_offset: Point<Pixels>,
}

View file

@ -189,3 +189,22 @@ impl TestAppContext {
.unwrap();
}
}
impl<T: Send + EventEmitter> Model<T> {
pub fn next_event(&self, cx: &mut TestAppContext) -> T::Event
where
T::Event: Send + Clone,
{
let (tx, mut rx) = futures::channel::mpsc::unbounded();
let _subscription = self.update(cx, |_, cx| {
cx.subscribe(self, move |_, _, event, _| {
tx.unbounded_send(event.clone()).ok();
})
});
cx.executor().run_until_parked();
rx.try_next()
.expect("no event received")
.expect("model was dropped")
}
}

View file

@ -212,6 +212,19 @@ pub trait Component<V> {
{
self.map(|this| if condition { then(this) } else { this })
}
fn when_some<T>(self, option: Option<T>, then: impl FnOnce(Self, T) -> Self) -> Self
where
Self: Sized,
{
self.map(|this| {
if let Some(value) = option {
then(this, value)
} else {
this
}
})
}
}
impl<V> Component<V> for AnyElement<V> {

View file

@ -3,7 +3,7 @@ use crate::{
ElementInteraction, FocusDisabled, FocusEnabled, FocusHandle, FocusListeners, Focusable,
GlobalElementId, GroupBounds, InteractiveElementState, LayoutId, Overflow, ParentElement,
Pixels, Point, SharedString, StatefulInteraction, StatefulInteractive, StatelessInteraction,
StatelessInteractive, Style, StyleRefinement, Styled, ViewContext,
StatelessInteractive, Style, StyleRefinement, Styled, ViewContext, Visibility,
};
use refineable::Refineable;
use smallvec::SmallVec;
@ -249,11 +249,22 @@ where
cx: &mut ViewContext<V>,
) {
self.with_element_id(cx, |this, _global_id, cx| {
let style = this.compute_style(bounds, element_state, cx);
if style.visibility == Visibility::Hidden {
return;
}
if let Some(mouse_cursor) = style.mouse_cursor {
let hovered = bounds.contains_point(&cx.mouse_position());
if hovered {
cx.set_cursor_style(mouse_cursor);
}
}
if let Some(group) = this.group.clone() {
GroupBounds::push(group, bounds, cx);
}
let style = this.compute_style(bounds, element_state, cx);
let z_index = style.z_index.unwrap_or(0);
let mut child_min = point(Pixels::MAX, Pixels::MAX);

View file

@ -21,7 +21,7 @@ pub fn point<T: Clone + Debug + Default>(x: T, y: T) -> Point<T> {
}
impl<T: Clone + Debug + Default> Point<T> {
pub fn new(x: T, y: T) -> Self {
pub const fn new(x: T, y: T) -> Self {
Self { x, y }
}

View file

@ -1,8 +1,8 @@
use crate::{
div, point, px, Action, AnyDrag, AnyView, AppContext, BorrowWindow, Bounds, Component,
DispatchContext, DispatchPhase, Div, Element, ElementId, FocusHandle, KeyMatch, Keystroke,
Modifiers, Overflow, Pixels, Point, Render, SharedString, Size, Style, StyleRefinement, View,
ViewContext,
div, point, px, Action, AnyDrag, AnyTooltip, AnyView, AppContext, BorrowWindow, Bounds,
Component, DispatchContext, DispatchPhase, Div, Element, ElementId, FocusHandle, KeyMatch,
Keystroke, Modifiers, Overflow, Pixels, Point, Render, SharedString, Size, Style,
StyleRefinement, Task, View, ViewContext,
};
use collections::HashMap;
use derive_more::{Deref, DerefMut};
@ -17,9 +17,12 @@ use std::{
ops::Deref,
path::PathBuf,
sync::Arc,
time::Duration,
};
const DRAG_THRESHOLD: f64 = 2.;
const TOOLTIP_DELAY: Duration = Duration::from_millis(500);
const TOOLTIP_OFFSET: Point<Pixels> = Point::new(px(10.0), px(8.0));
pub trait StatelessInteractive<V: 'static>: Element<V> {
fn stateless_interaction(&mut self) -> &mut StatelessInteraction<V>;
@ -333,6 +336,37 @@ pub trait StatefulInteractive<V: 'static>: StatelessInteractive<V> {
}));
self
}
fn on_hover(mut self, listener: impl 'static + Fn(&mut V, bool, &mut ViewContext<V>)) -> Self
where
Self: Sized,
{
debug_assert!(
self.stateful_interaction().hover_listener.is_none(),
"calling on_hover more than once on the same element is not supported"
);
self.stateful_interaction().hover_listener = Some(Box::new(listener));
self
}
fn tooltip<W>(
mut self,
build_tooltip: impl Fn(&mut V, &mut ViewContext<V>) -> View<W> + 'static,
) -> Self
where
Self: Sized,
W: 'static + Render,
{
debug_assert!(
self.stateful_interaction().tooltip_builder.is_none(),
"calling tooltip more than once on the same element is not supported"
);
self.stateful_interaction().tooltip_builder = Some(Arc::new(move |view_state, cx| {
build_tooltip(view_state, cx).into()
}));
self
}
}
pub trait ElementInteraction<V: 'static>: 'static {
@ -568,6 +602,77 @@ pub trait ElementInteraction<V: 'static>: 'static {
}
}
if let Some(hover_listener) = stateful.hover_listener.take() {
let was_hovered = element_state.hover_state.clone();
let has_mouse_down = element_state.pending_mouse_down.clone();
cx.on_mouse_event(move |view_state, event: &MouseMoveEvent, phase, cx| {
if phase != DispatchPhase::Bubble {
return;
}
let is_hovered =
bounds.contains_point(&event.position) && has_mouse_down.lock().is_none();
let mut was_hovered = was_hovered.lock();
if is_hovered != was_hovered.clone() {
*was_hovered = is_hovered;
drop(was_hovered);
hover_listener(view_state, is_hovered, cx);
}
});
}
if let Some(tooltip_builder) = stateful.tooltip_builder.take() {
let active_tooltip = element_state.active_tooltip.clone();
let pending_mouse_down = element_state.pending_mouse_down.clone();
cx.on_mouse_event(move |_, event: &MouseMoveEvent, phase, cx| {
if phase != DispatchPhase::Bubble {
return;
}
let is_hovered = bounds.contains_point(&event.position)
&& pending_mouse_down.lock().is_none();
if !is_hovered {
active_tooltip.lock().take();
return;
}
if active_tooltip.lock().is_none() {
let task = cx.spawn({
let active_tooltip = active_tooltip.clone();
let tooltip_builder = tooltip_builder.clone();
move |view, mut cx| async move {
cx.background_executor().timer(TOOLTIP_DELAY).await;
view.update(&mut cx, move |view_state, cx| {
active_tooltip.lock().replace(ActiveTooltip {
waiting: None,
tooltip: Some(AnyTooltip {
view: tooltip_builder(view_state, cx),
cursor_offset: cx.mouse_position() + TOOLTIP_OFFSET,
}),
});
cx.notify();
})
.ok();
}
});
active_tooltip.lock().replace(ActiveTooltip {
waiting: Some(task),
tooltip: None,
});
}
});
if let Some(active_tooltip) = element_state.active_tooltip.lock().as_ref() {
if active_tooltip.tooltip.is_some() {
cx.active_tooltip = active_tooltip.tooltip.clone()
}
}
}
let active_state = element_state.active_state.clone();
if active_state.lock().is_none() {
let active_group_bounds = stateful
@ -639,6 +744,8 @@ pub struct StatefulInteraction<V> {
active_style: StyleRefinement,
group_active_style: Option<GroupStyle>,
drag_listener: Option<DragListener<V>>,
hover_listener: Option<HoverListener<V>>,
tooltip_builder: Option<TooltipBuilder<V>>,
}
impl<V: 'static> ElementInteraction<V> for StatefulInteraction<V> {
@ -666,6 +773,8 @@ impl<V> From<ElementId> for StatefulInteraction<V> {
stateless: StatelessInteraction::default(),
click_listeners: SmallVec::new(),
drag_listener: None,
hover_listener: None,
tooltip_builder: None,
active_style: StyleRefinement::default(),
group_active_style: None,
}
@ -695,6 +804,8 @@ impl<V> StatelessInteraction<V> {
stateless: self,
click_listeners: SmallVec::new(),
drag_listener: None,
hover_listener: None,
tooltip_builder: None,
active_style: StyleRefinement::default(),
group_active_style: None,
}
@ -746,8 +857,16 @@ impl ActiveState {
#[derive(Default)]
pub struct InteractiveElementState {
active_state: Arc<Mutex<ActiveState>>,
hover_state: Arc<Mutex<bool>>,
pending_mouse_down: Arc<Mutex<Option<MouseDownEvent>>>,
scroll_offset: Option<Arc<Mutex<Point<Pixels>>>>,
active_tooltip: Arc<Mutex<Option<ActiveTooltip>>>,
}
struct ActiveTooltip {
#[allow(unused)] // used to drop the task
waiting: Option<Task<()>>,
tooltip: Option<AnyTooltip>,
}
impl InteractiveElementState {
@ -1097,6 +1216,10 @@ pub type ClickListener<V> = Box<dyn Fn(&mut V, &ClickEvent, &mut ViewContext<V>)
pub(crate) type DragListener<V> =
Box<dyn Fn(&mut V, Point<Pixels>, &mut ViewContext<V>) -> AnyDrag + 'static>;
pub(crate) type HoverListener<V> = Box<dyn Fn(&mut V, bool, &mut ViewContext<V>) + 'static>;
pub(crate) type TooltipBuilder<V> = Arc<dyn Fn(&mut V, &mut ViewContext<V>) -> AnyView + 'static>;
pub type KeyListener<V> = Box<
dyn Fn(
&mut V,

View file

@ -11,11 +11,7 @@ use objc::{
};
use parking::{Parker, Unparker};
use parking_lot::Mutex;
use std::{
ffi::c_void,
sync::Arc,
time::{Duration, SystemTime},
};
use std::{ffi::c_void, sync::Arc, time::Duration};
include!(concat!(env!("OUT_DIR"), "/dispatch_sys.rs"));
@ -62,16 +58,10 @@ impl PlatformDispatcher for MacDispatcher {
}
fn dispatch_after(&self, duration: Duration, runnable: Runnable) {
let now = SystemTime::now();
let after_duration = now
.duration_since(SystemTime::UNIX_EPOCH)
.unwrap()
.as_nanos() as u64
+ duration.as_nanos() as u64;
unsafe {
let queue =
dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT.try_into().unwrap(), 0);
let when = dispatch_time(0, after_duration as i64);
let when = dispatch_time(DISPATCH_TIME_NOW as u64, duration.as_nanos() as i64);
dispatch_after_f(
when,
queue,

View file

@ -1,8 +1,8 @@
use crate::{
black, phi, point, rems, AbsoluteLength, BorrowAppContext, BorrowWindow, Bounds, ContentMask,
Corners, CornersRefinement, DefiniteLength, Edges, EdgesRefinement, Font, FontFeatures,
FontStyle, FontWeight, Hsla, Length, Pixels, Point, PointRefinement, Result, Rgba,
SharedString, Size, SizeRefinement, Styled, TextRun, ViewContext, WindowContext,
Corners, CornersRefinement, CursorStyle, DefiniteLength, Edges, EdgesRefinement, Font,
FontFeatures, FontStyle, FontWeight, Hsla, Length, Pixels, Point, PointRefinement, Result,
Rgba, SharedString, Size, SizeRefinement, Styled, TextRun, ViewContext, WindowContext,
};
use refineable::{Cascade, Refineable};
use smallvec::SmallVec;
@ -19,6 +19,9 @@ pub struct Style {
/// What layout strategy should be used?
pub display: Display,
/// Should the element be painted on screen?
pub visibility: Visibility,
// Overflow properties
/// How children overflowing their container should affect layout
#[refineable]
@ -98,6 +101,9 @@ pub struct Style {
/// TEXT
pub text: TextStyleRefinement,
/// The mouse cursor style shown when the mouse pointer is over an element.
pub mouse_cursor: Option<CursorStyle>,
pub z_index: Option<u32>,
}
@ -107,6 +113,13 @@ impl Styled for StyleRefinement {
}
}
#[derive(Default, Clone, Copy, Debug, Eq, PartialEq)]
pub enum Visibility {
#[default]
Visible,
Hidden,
}
#[derive(Clone, Debug)]
pub struct BoxShadow {
pub color: Hsla,
@ -297,6 +310,7 @@ impl Default for Style {
fn default() -> Self {
Style {
display: Display::Block,
visibility: Visibility::Visible,
overflow: Point {
x: Overflow::Visible,
y: Overflow::Visible,
@ -328,6 +342,7 @@ impl Default for Style {
corner_radii: Corners::default(),
box_shadow: Default::default(),
text: TextStyleRefinement::default(),
mouse_cursor: None,
z_index: None,
}
}

View file

@ -1,7 +1,7 @@
use crate::{
self as gpui2, hsla, point, px, relative, rems, AbsoluteLength, AlignItems, DefiniteLength,
Display, Fill, FlexDirection, Hsla, JustifyContent, Length, Position, SharedString,
StyleRefinement,
self as gpui, hsla, point, px, relative, rems, AbsoluteLength, AlignItems, CursorStyle,
DefiniteLength, Display, Fill, FlexDirection, Hsla, JustifyContent, Length, Position,
SharedString, StyleRefinement, Visibility,
};
use crate::{BoxShadow, TextStyleRefinement};
use smallvec::smallvec;
@ -61,6 +61,54 @@ pub trait Styled {
self
}
/// Sets the visibility of the element to `visible`.
/// [Docs](https://tailwindcss.com/docs/visibility)
fn visible(mut self) -> Self
where
Self: Sized,
{
self.style().visibility = Some(Visibility::Visible);
self
}
/// Sets the visibility of the element to `hidden`.
/// [Docs](https://tailwindcss.com/docs/visibility)
fn invisible(mut self) -> Self
where
Self: Sized,
{
self.style().visibility = Some(Visibility::Hidden);
self
}
fn cursor(mut self, cursor: CursorStyle) -> Self
where
Self: Sized,
{
self.style().mouse_cursor = Some(cursor);
self
}
/// Sets the cursor style when hovering an element to `default`.
/// [Docs](https://tailwindcss.com/docs/cursor)
fn cursor_default(mut self) -> Self
where
Self: Sized,
{
self.style().mouse_cursor = Some(CursorStyle::Arrow);
self
}
/// Sets the cursor style when hovering an element to `pointer`.
/// [Docs](https://tailwindcss.com/docs/cursor)
fn cursor_pointer(mut self) -> Self
where
Self: Sized,
{
self.style().mouse_cursor = Some(CursorStyle::PointingHand);
self
}
/// Sets the flex direction of the element to `column`.
/// [Docs](https://tailwindcss.com/docs/flex-direction#column)
fn flex_col(mut self) -> Self

View file

@ -38,7 +38,7 @@ where
lock.subscribers
.entry(emitter_key.clone())
.or_default()
.insert(Default::default())
.get_or_insert_with(|| Default::default())
.insert(subscriber_id, callback);
let this = self.0.clone();
Subscription {

View file

@ -1,14 +1,14 @@
use crate::{
px, size, Action, AnyBox, AnyDrag, AnyView, AppContext, AsyncWindowContext, AvailableSpace,
Bounds, BoxShadow, Context, Corners, DevicePixels, DispatchContext, DisplayId, Edges, Effect,
Entity, EntityId, EventEmitter, FileDropEvent, FocusEvent, FontId, GlobalElementId, GlyphId,
Hsla, ImageData, InputEvent, IsZero, KeyListener, KeyMatch, KeyMatcher, Keystroke, LayoutId,
Model, ModelContext, Modifiers, MonochromeSprite, MouseButton, MouseDownEvent, MouseMoveEvent,
MouseUpEvent, Path, Pixels, PlatformAtlas, PlatformDisplay, PlatformWindow, Point,
PolychromeSprite, PromptLevel, Quad, Render, RenderGlyphParams, RenderImageParams,
RenderSvgParams, ScaledPixels, SceneBuilder, Shadow, SharedString, Size, Style, SubscriberSet,
Subscription, TaffyLayoutEngine, Task, Underline, UnderlineStyle, View, VisualContext,
WeakView, WindowBounds, WindowOptions, SUBPIXEL_VARIANTS,
Bounds, BoxShadow, Context, Corners, CursorStyle, DevicePixels, DispatchContext, DisplayId,
Edges, Effect, Entity, EntityId, EventEmitter, FileDropEvent, FocusEvent, FontId,
GlobalElementId, GlyphId, Hsla, ImageData, InputEvent, IsZero, KeyListener, KeyMatch,
KeyMatcher, Keystroke, LayoutId, Model, ModelContext, Modifiers, MonochromeSprite, MouseButton,
MouseDownEvent, MouseMoveEvent, MouseUpEvent, Path, Pixels, PlatformAtlas, PlatformDisplay,
PlatformWindow, Point, PolychromeSprite, PromptLevel, Quad, Render, RenderGlyphParams,
RenderImageParams, RenderSvgParams, ScaledPixels, SceneBuilder, Shadow, SharedString, Size,
Style, SubscriberSet, Subscription, TaffyLayoutEngine, Task, Underline, UnderlineStyle, View,
VisualContext, WeakView, WindowBounds, WindowOptions, SUBPIXEL_VARIANTS,
};
use anyhow::{anyhow, Result};
use collections::HashMap;
@ -190,6 +190,7 @@ pub struct Window {
pub(crate) focus_handles: Arc<RwLock<SlotMap<FocusId, AtomicUsize>>>,
default_prevented: bool,
mouse_position: Point<Pixels>,
requested_cursor_style: Option<CursorStyle>,
scale_factor: f32,
bounds: WindowBounds,
bounds_observers: SubscriberSet<(), AnyObserver>,
@ -283,6 +284,7 @@ impl Window {
focus_handles: Arc::new(RwLock::new(SlotMap::with_key())),
default_prevented: true,
mouse_position,
requested_cursor_style: None,
scale_factor,
bounds,
bounds_observers: SubscriberSet::new(),
@ -669,6 +671,10 @@ impl<'a> WindowContext<'a> {
self.window.mouse_position
}
pub fn set_cursor_style(&mut self, style: CursorStyle) {
self.window.requested_cursor_style = Some(style)
}
/// Called during painting to invoke the given closure in a new stacking context. The given
/// z-index is interpreted relative to the previous call to `stack`.
pub fn stack<R>(&mut self, z_index: u32, f: impl FnOnce(&mut Self) -> R) -> R {
@ -981,12 +987,27 @@ impl<'a> WindowContext<'a> {
cx.active_drag = Some(active_drag);
});
});
} else if let Some(active_tooltip) = self.app.active_tooltip.take() {
self.stack(1, |cx| {
cx.with_element_offset(Some(active_tooltip.cursor_offset), |cx| {
let available_space =
size(AvailableSpace::MinContent, AvailableSpace::MinContent);
active_tooltip.view.draw(available_space, cx);
});
});
}
self.window.root_view = Some(root_view);
let scene = self.window.scene_builder.build();
self.window.platform_window.draw(scene);
let cursor_style = self
.window
.requested_cursor_style
.take()
.unwrap_or(CursorStyle::Arrow);
self.platform.set_cursor_style(cursor_style);
self.window.dirty = false;
}

View file

@ -28,9 +28,9 @@ pub fn derive_component(input: TokenStream) -> TokenStream {
let (_, ty_generics, _) = ast.generics.split_for_impl();
let expanded = quote! {
impl #impl_generics gpui2::Component<#view_type> for #name #ty_generics #where_clause {
fn render(self) -> gpui2::AnyElement<#view_type> {
(move |view_state: &mut #view_type, cx: &mut gpui2::ViewContext<'_, #view_type>| self.render(view_state, cx))
impl #impl_generics gpui::Component<#view_type> for #name #ty_generics #where_clause {
fn render(self) -> gpui::AnyElement<#view_type> {
(move |view_state: &mut #view_type, cx: &mut gpui::ViewContext<'_, #view_type>| self.render(view_state, cx))
.render()
}
}

View file

@ -123,7 +123,7 @@ fn generate_predefined_setter(
.iter()
.map(|field_tokens| {
quote! {
style.#field_tokens = Some((#negation_token gpui2::#length_tokens).into());
style.#field_tokens = Some((#negation_token gpui::#length_tokens).into());
}
})
.collect::<Vec<_>>();
@ -163,7 +163,7 @@ fn generate_custom_value_setter(
let method = quote! {
#[doc = #doc_string]
fn #method_name(mut self, length: impl std::clone::Clone + Into<gpui2::#length_type>) -> Self where Self: std::marker::Sized {
fn #method_name(mut self, length: impl std::clone::Clone + Into<gpui::#length_type>) -> Self where Self: std::marker::Sized {
let style = self.style();
#(#field_assignments)*
self

View file

@ -175,6 +175,7 @@ pub fn test(args: TokenStream, function: TokenStream) -> TokenStream {
inner_fn_args.extend(quote!(&mut #cx_varname_lock,));
cx_teardowns.extend(quote!(
#cx_varname_lock.quit();
drop(#cx_varname_lock);
dispatcher.run_until_parked();
));
continue;

View file

@ -170,6 +170,8 @@ pub fn test(args: TokenStream, function: TokenStream) -> TokenStream {
#max_retries,
#detect_nondeterminism,
&mut |cx, foreground_platform, deterministic, seed| {
// some of the macro contents do not use all variables, silence the warnings
let _ = (&cx, &foreground_platform, &deterministic, &seed);
#cx_vars
cx.foreground().run(#inner_fn_name(#inner_fn_args));
#cx_teardowns
@ -247,6 +249,8 @@ pub fn test(args: TokenStream, function: TokenStream) -> TokenStream {
#max_retries,
#detect_nondeterminism,
&mut |cx, foreground_platform, deterministic, seed| {
// some of the macro contents do not use all variables, silence the warnings
let _ = (&cx, &foreground_platform, &deterministic, &seed);
#cx_vars
#inner_fn_name(#inner_fn_args);
#cx_teardowns

View file

@ -16,14 +16,14 @@ name = "test_app"
test-support = [
"async-trait",
"collections/test-support",
"gpui2/test-support",
"gpui/test-support",
"live_kit_server",
"nanoid",
]
[dependencies]
collections = { path = "../collections", optional = true }
gpui2 = { package = "gpui2", path = "../gpui2", optional = true }
gpui = { package = "gpui2", path = "../gpui2", optional = true }
live_kit_server = { path = "../live_kit_server", optional = true }
media = { path = "../media" }
@ -41,7 +41,7 @@ nanoid = { version ="0.4", optional = true}
[dev-dependencies]
collections = { path = "../collections", features = ["test-support"] }
gpui2 = { package = "gpui2", path = "../gpui2", features = ["test-support"] }
gpui = { package = "gpui2", path = "../gpui2", features = ["test-support"] }
live_kit_server = { path = "../live_kit_server" }
media = { path = "../media" }
nanoid = "0.4"

View file

@ -1,7 +1,7 @@
use std::{sync::Arc, time::Duration};
use futures::StreamExt;
use gpui2::KeyBinding;
use gpui::KeyBinding;
use live_kit_client2::{
LocalAudioTrack, LocalVideoTrack, RemoteAudioTrackUpdate, RemoteVideoTrackUpdate, Room,
};
@ -16,7 +16,7 @@ struct Quit;
fn main() {
SimpleLogger::init(LevelFilter::Info, Default::default()).expect("could not initialize logger");
gpui2::App::production(Arc::new(())).run(|cx| {
gpui::App::production(Arc::new(())).run(|cx| {
#[cfg(any(test, feature = "test-support"))]
println!("USING TEST LIVEKIT");
@ -173,6 +173,6 @@ fn main() {
});
}
fn quit(_: &Quit, cx: &mut gpui2::AppContext) {
fn quit(_: &Quit, cx: &mut gpui::AppContext) {
cx.quit();
}

View file

@ -2,7 +2,7 @@ use anyhow::{anyhow, Context, Result};
use async_trait::async_trait;
use collections::{BTreeMap, HashMap};
use futures::Stream;
use gpui2::BackgroundExecutor;
use gpui::BackgroundExecutor;
use live_kit_server::token;
use media::core_video::CVImageBuffer;
use parking_lot::Mutex;

View file

@ -16,9 +16,33 @@ pub fn derive_refineable(input: TokenStream) -> TokenStream {
..
} = parse_macro_input!(input);
let impl_debug_on_refinement = attrs
.iter()
.any(|attr| attr.path.is_ident("refineable") && attr.tokens.to_string().contains("debug"));
let refineable_attr = attrs.iter().find(|attr| attr.path.is_ident("refineable"));
let mut impl_debug_on_refinement = false;
let mut derive_serialize_on_refinement = false;
let mut derive_deserialize_on_refinement = false;
if let Some(refineable_attr) = refineable_attr {
if let Ok(syn::Meta::List(meta_list)) = refineable_attr.parse_meta() {
for nested in meta_list.nested {
let syn::NestedMeta::Meta(syn::Meta::Path(path)) = nested else {
continue;
};
if path.is_ident("debug") {
impl_debug_on_refinement = true;
}
if path.is_ident("serialize") {
derive_serialize_on_refinement = true;
}
if path.is_ident("deserialize") {
derive_deserialize_on_refinement = true;
}
}
}
}
let refinement_ident = format_ident!("{}Refinement", ident);
let (impl_generics, ty_generics, where_clause) = generics.split_for_impl();
@ -235,8 +259,22 @@ pub fn derive_refineable(input: TokenStream) -> TokenStream {
quote! {}
};
let derive_serialize = if derive_serialize_on_refinement {
quote! { #[derive(serde::Serialize)]}
} else {
quote! {}
};
let derive_deserialize = if derive_deserialize_on_refinement {
quote! { #[derive(serde::Deserialize)]}
} else {
quote! {}
};
let gen = quote! {
#[derive(Clone)]
#derive_serialize
#derive_deserialize
pub struct #refinement_ident #impl_generics {
#( #field_visibilities #field_names: #wrapped_types ),*
}

View file

@ -89,88 +89,96 @@ message Envelope {
FormatBuffersResponse format_buffers_response = 70;
GetCompletions get_completions = 71;
GetCompletionsResponse get_completions_response = 72;
ApplyCompletionAdditionalEdits apply_completion_additional_edits = 73;
ApplyCompletionAdditionalEditsResponse apply_completion_additional_edits_response = 74;
GetCodeActions get_code_actions = 75;
GetCodeActionsResponse get_code_actions_response = 76;
GetHover get_hover = 77;
GetHoverResponse get_hover_response = 78;
ApplyCodeAction apply_code_action = 79;
ApplyCodeActionResponse apply_code_action_response = 80;
PrepareRename prepare_rename = 81;
PrepareRenameResponse prepare_rename_response = 82;
PerformRename perform_rename = 83;
PerformRenameResponse perform_rename_response = 84;
SearchProject search_project = 85;
SearchProjectResponse search_project_response = 86;
ResolveCompletionDocumentation resolve_completion_documentation = 73;
ResolveCompletionDocumentationResponse resolve_completion_documentation_response = 74;
ApplyCompletionAdditionalEdits apply_completion_additional_edits = 75;
ApplyCompletionAdditionalEditsResponse apply_completion_additional_edits_response = 76;
GetCodeActions get_code_actions = 77;
GetCodeActionsResponse get_code_actions_response = 78;
GetHover get_hover = 79;
GetHoverResponse get_hover_response = 80;
ApplyCodeAction apply_code_action = 81;
ApplyCodeActionResponse apply_code_action_response = 82;
PrepareRename prepare_rename = 83;
PrepareRenameResponse prepare_rename_response = 84;
PerformRename perform_rename = 85;
PerformRenameResponse perform_rename_response = 86;
SearchProject search_project = 87;
SearchProjectResponse search_project_response = 88;
UpdateContacts update_contacts = 87;
UpdateInviteInfo update_invite_info = 88;
ShowContacts show_contacts = 89;
UpdateContacts update_contacts = 89;
UpdateInviteInfo update_invite_info = 90;
ShowContacts show_contacts = 91;
GetUsers get_users = 90;
FuzzySearchUsers fuzzy_search_users = 91;
UsersResponse users_response = 92;
RequestContact request_contact = 93;
RespondToContactRequest respond_to_contact_request = 94;
RemoveContact remove_contact = 95;
GetUsers get_users = 92;
FuzzySearchUsers fuzzy_search_users = 93;
UsersResponse users_response = 94;
RequestContact request_contact = 95;
RespondToContactRequest respond_to_contact_request = 96;
RemoveContact remove_contact = 97;
Follow follow = 96;
FollowResponse follow_response = 97;
UpdateFollowers update_followers = 98;
Unfollow unfollow = 99;
GetPrivateUserInfo get_private_user_info = 100;
GetPrivateUserInfoResponse get_private_user_info_response = 101;
UpdateDiffBase update_diff_base = 102;
Follow follow = 98;
FollowResponse follow_response = 99;
UpdateFollowers update_followers = 100;
Unfollow unfollow = 101;
GetPrivateUserInfo get_private_user_info = 102;
GetPrivateUserInfoResponse get_private_user_info_response = 103;
UpdateDiffBase update_diff_base = 104;
OnTypeFormatting on_type_formatting = 103;
OnTypeFormattingResponse on_type_formatting_response = 104;
OnTypeFormatting on_type_formatting = 105;
OnTypeFormattingResponse on_type_formatting_response = 106;
UpdateWorktreeSettings update_worktree_settings = 105;
UpdateWorktreeSettings update_worktree_settings = 107;
InlayHints inlay_hints = 106;
InlayHintsResponse inlay_hints_response = 107;
ResolveInlayHint resolve_inlay_hint = 108;
ResolveInlayHintResponse resolve_inlay_hint_response = 109;
RefreshInlayHints refresh_inlay_hints = 110;
InlayHints inlay_hints = 108;
InlayHintsResponse inlay_hints_response = 109;
ResolveInlayHint resolve_inlay_hint = 110;
ResolveInlayHintResponse resolve_inlay_hint_response = 111;
RefreshInlayHints refresh_inlay_hints = 112;
CreateChannel create_channel = 111;
CreateChannelResponse create_channel_response = 112;
InviteChannelMember invite_channel_member = 113;
RemoveChannelMember remove_channel_member = 114;
RespondToChannelInvite respond_to_channel_invite = 115;
UpdateChannels update_channels = 116;
JoinChannel join_channel = 117;
DeleteChannel delete_channel = 118;
GetChannelMembers get_channel_members = 119;
GetChannelMembersResponse get_channel_members_response = 120;
SetChannelMemberAdmin set_channel_member_admin = 121;
RenameChannel rename_channel = 122;
RenameChannelResponse rename_channel_response = 123;
CreateChannel create_channel = 113;
CreateChannelResponse create_channel_response = 114;
InviteChannelMember invite_channel_member = 115;
RemoveChannelMember remove_channel_member = 116;
RespondToChannelInvite respond_to_channel_invite = 117;
UpdateChannels update_channels = 118;
JoinChannel join_channel = 119;
DeleteChannel delete_channel = 120;
GetChannelMembers get_channel_members = 121;
GetChannelMembersResponse get_channel_members_response = 122;
SetChannelMemberRole set_channel_member_role = 123;
RenameChannel rename_channel = 124;
RenameChannelResponse rename_channel_response = 125;
JoinChannelBuffer join_channel_buffer = 124;
JoinChannelBufferResponse join_channel_buffer_response = 125;
UpdateChannelBuffer update_channel_buffer = 126;
LeaveChannelBuffer leave_channel_buffer = 127;
UpdateChannelBufferCollaborators update_channel_buffer_collaborators = 128;
RejoinChannelBuffers rejoin_channel_buffers = 129;
RejoinChannelBuffersResponse rejoin_channel_buffers_response = 130;
AckBufferOperation ack_buffer_operation = 143;
JoinChannelBuffer join_channel_buffer = 126;
JoinChannelBufferResponse join_channel_buffer_response = 127;
UpdateChannelBuffer update_channel_buffer = 128;
LeaveChannelBuffer leave_channel_buffer = 129;
UpdateChannelBufferCollaborators update_channel_buffer_collaborators = 130;
RejoinChannelBuffers rejoin_channel_buffers = 131;
RejoinChannelBuffersResponse rejoin_channel_buffers_response = 132;
AckBufferOperation ack_buffer_operation = 133;
JoinChannelChat join_channel_chat = 131;
JoinChannelChatResponse join_channel_chat_response = 132;
LeaveChannelChat leave_channel_chat = 133;
SendChannelMessage send_channel_message = 134;
SendChannelMessageResponse send_channel_message_response = 135;
ChannelMessageSent channel_message_sent = 136;
GetChannelMessages get_channel_messages = 137;
GetChannelMessagesResponse get_channel_messages_response = 138;
RemoveChannelMessage remove_channel_message = 139;
AckChannelMessage ack_channel_message = 144;
JoinChannelChat join_channel_chat = 134;
JoinChannelChatResponse join_channel_chat_response = 135;
LeaveChannelChat leave_channel_chat = 136;
SendChannelMessage send_channel_message = 137;
SendChannelMessageResponse send_channel_message_response = 138;
ChannelMessageSent channel_message_sent = 139;
GetChannelMessages get_channel_messages = 140;
GetChannelMessagesResponse get_channel_messages_response = 141;
RemoveChannelMessage remove_channel_message = 142;
AckChannelMessage ack_channel_message = 143;
GetChannelMessagesById get_channel_messages_by_id = 144;
LinkChannel link_channel = 140;
UnlinkChannel unlink_channel = 141;
MoveChannel move_channel = 142; // current max: 144
MoveChannel move_channel = 147;
SetChannelVisibility set_channel_visibility = 148;
AddNotification add_notification = 149;
GetNotifications get_notifications = 150;
GetNotificationsResponse get_notifications_response = 151;
DeleteNotification delete_notification = 152;
MarkNotificationRead mark_notification_read = 153; // Current max
}
}
@ -332,6 +340,7 @@ message RoomUpdated {
message LiveKitConnectionInfo {
string server_url = 1;
string token = 2;
bool can_publish = 3;
}
message ShareProject {
@ -832,6 +841,17 @@ message ResolveState {
}
}
message ResolveCompletionDocumentation {
uint64 project_id = 1;
uint64 language_server_id = 2;
bytes lsp_completion = 3;
}
message ResolveCompletionDocumentationResponse {
string text = 1;
bool is_markdown = 2;
}
message ResolveInlayHint {
uint64 project_id = 1;
uint64 buffer_id = 2;
@ -950,13 +970,10 @@ message LspDiskBasedDiagnosticsUpdated {}
message UpdateChannels {
repeated Channel channels = 1;
repeated ChannelEdge insert_edge = 2;
repeated ChannelEdge delete_edge = 3;
repeated uint64 delete_channels = 4;
repeated Channel channel_invitations = 5;
repeated uint64 remove_channel_invitations = 6;
repeated ChannelParticipants channel_participants = 7;
repeated ChannelPermission channel_permissions = 8;
repeated UnseenChannelMessage unseen_channel_messages = 9;
repeated UnseenChannelBufferChange unseen_channel_buffer_changes = 10;
}
@ -972,14 +989,9 @@ message UnseenChannelBufferChange {
repeated VectorClockEntry version = 3;
}
message ChannelEdge {
uint64 channel_id = 1;
uint64 parent_id = 2;
}
message ChannelPermission {
uint64 channel_id = 1;
bool is_admin = 2;
ChannelRole role = 3;
}
message ChannelParticipants {
@ -1005,8 +1017,8 @@ message GetChannelMembersResponse {
message ChannelMember {
uint64 user_id = 1;
bool admin = 2;
Kind kind = 3;
ChannelRole role = 4;
enum Kind {
Member = 0;
@ -1028,7 +1040,7 @@ message CreateChannelResponse {
message InviteChannelMember {
uint64 channel_id = 1;
uint64 user_id = 2;
bool admin = 3;
ChannelRole role = 4;
}
message RemoveChannelMember {
@ -1036,10 +1048,22 @@ message RemoveChannelMember {
uint64 user_id = 2;
}
message SetChannelMemberAdmin {
enum ChannelRole {
Admin = 0;
Member = 1;
Guest = 2;
Banned = 3;
}
message SetChannelMemberRole {
uint64 channel_id = 1;
uint64 user_id = 2;
bool admin = 3;
ChannelRole role = 3;
}
message SetChannelVisibility {
uint64 channel_id = 1;
ChannelVisibility visibility = 2;
}
message RenameChannel {
@ -1068,6 +1092,7 @@ message SendChannelMessage {
uint64 channel_id = 1;
string body = 2;
Nonce nonce = 3;
repeated ChatMention mentions = 4;
}
message RemoveChannelMessage {
@ -1099,20 +1124,13 @@ message GetChannelMessagesResponse {
bool done = 2;
}
message LinkChannel {
uint64 channel_id = 1;
uint64 to = 2;
}
message UnlinkChannel {
uint64 channel_id = 1;
uint64 from = 2;
message GetChannelMessagesById {
repeated uint64 message_ids = 1;
}
message MoveChannel {
uint64 channel_id = 1;
uint64 from = 2;
uint64 to = 3;
optional uint64 to = 2;
}
message JoinChannelBuffer {
@ -1125,6 +1143,12 @@ message ChannelMessage {
uint64 timestamp = 3;
uint64 sender_id = 4;
Nonce nonce = 5;
repeated ChatMention mentions = 6;
}
message ChatMention {
Range range = 1;
uint64 user_id = 2;
}
message RejoinChannelBuffers {
@ -1216,7 +1240,6 @@ message ShowContacts {}
message IncomingContactRequest {
uint64 requester_id = 1;
bool should_notify = 2;
}
message UpdateDiagnostics {
@ -1533,16 +1556,23 @@ message Nonce {
uint64 lower_half = 2;
}
enum ChannelVisibility {
Public = 0;
Members = 1;
}
message Channel {
uint64 id = 1;
string name = 2;
ChannelVisibility visibility = 3;
ChannelRole role = 4;
repeated uint64 parent_path = 5;
}
message Contact {
uint64 user_id = 1;
bool online = 2;
bool busy = 3;
bool should_notify = 4;
}
message WorktreeMetadata {
@ -1557,3 +1587,34 @@ message UpdateDiffBase {
uint64 buffer_id = 2;
optional string diff_base = 3;
}
message GetNotifications {
optional uint64 before_id = 1;
}
message AddNotification {
Notification notification = 1;
}
message GetNotificationsResponse {
repeated Notification notifications = 1;
bool done = 2;
}
message DeleteNotification {
uint64 notification_id = 1;
}
message MarkNotificationRead {
uint64 notification_id = 1;
}
message Notification {
uint64 id = 1;
uint64 timestamp = 2;
string kind = 3;
optional uint64 entity_id = 4;
string content = 5;
bool is_read = 6;
optional bool response = 7;
}

View file

@ -133,6 +133,9 @@ impl fmt::Display for PeerId {
messages!(
(Ack, Foreground),
(AckBufferOperation, Background),
(AckChannelMessage, Background),
(AddNotification, Foreground),
(AddProjectCollaborator, Foreground),
(ApplyCodeAction, Background),
(ApplyCodeActionResponse, Background),
@ -143,57 +146,74 @@ messages!(
(Call, Foreground),
(CallCanceled, Foreground),
(CancelCall, Foreground),
(ChannelMessageSent, Foreground),
(CopyProjectEntry, Foreground),
(CreateBufferForPeer, Foreground),
(CreateChannel, Foreground),
(CreateChannelResponse, Foreground),
(ChannelMessageSent, Foreground),
(CreateProjectEntry, Foreground),
(CreateRoom, Foreground),
(CreateRoomResponse, Foreground),
(DeclineCall, Foreground),
(DeleteChannel, Foreground),
(DeleteNotification, Foreground),
(DeleteProjectEntry, Foreground),
(Error, Foreground),
(ExpandProjectEntry, Foreground),
(ExpandProjectEntryResponse, Foreground),
(Follow, Foreground),
(FollowResponse, Foreground),
(FormatBuffers, Foreground),
(FormatBuffersResponse, Foreground),
(FuzzySearchUsers, Foreground),
(GetChannelMembers, Foreground),
(GetChannelMembersResponse, Foreground),
(GetChannelMessages, Background),
(GetChannelMessagesById, Background),
(GetChannelMessagesResponse, Background),
(GetCodeActions, Background),
(GetCodeActionsResponse, Background),
(GetHover, Background),
(GetHoverResponse, Background),
(GetChannelMessages, Background),
(GetChannelMessagesResponse, Background),
(SendChannelMessage, Background),
(SendChannelMessageResponse, Background),
(GetCompletions, Background),
(GetCompletionsResponse, Background),
(GetDefinition, Background),
(GetDefinitionResponse, Background),
(GetTypeDefinition, Background),
(GetTypeDefinitionResponse, Background),
(GetDocumentHighlights, Background),
(GetDocumentHighlightsResponse, Background),
(GetReferences, Background),
(GetReferencesResponse, Background),
(GetHover, Background),
(GetHoverResponse, Background),
(GetNotifications, Foreground),
(GetNotificationsResponse, Foreground),
(GetPrivateUserInfo, Foreground),
(GetPrivateUserInfoResponse, Foreground),
(GetProjectSymbols, Background),
(GetProjectSymbolsResponse, Background),
(GetReferences, Background),
(GetReferencesResponse, Background),
(GetTypeDefinition, Background),
(GetTypeDefinitionResponse, Background),
(GetUsers, Foreground),
(Hello, Foreground),
(IncomingCall, Foreground),
(InlayHints, Background),
(InlayHintsResponse, Background),
(InviteChannelMember, Foreground),
(UsersResponse, Foreground),
(JoinChannel, Foreground),
(JoinChannelBuffer, Foreground),
(JoinChannelBufferResponse, Foreground),
(JoinChannelChat, Foreground),
(JoinChannelChatResponse, Foreground),
(JoinProject, Foreground),
(JoinProjectResponse, Foreground),
(JoinRoom, Foreground),
(JoinRoomResponse, Foreground),
(JoinChannelChat, Foreground),
(JoinChannelChatResponse, Foreground),
(LeaveChannelBuffer, Background),
(LeaveChannelChat, Foreground),
(LeaveProject, Foreground),
(LeaveRoom, Foreground),
(MarkNotificationRead, Foreground),
(MoveChannel, Foreground),
(OnTypeFormatting, Background),
(OnTypeFormattingResponse, Background),
(OpenBufferById, Background),
(OpenBufferByPath, Background),
(OpenBufferForSymbol, Background),
@ -201,58 +221,56 @@ messages!(
(OpenBufferResponse, Background),
(PerformRename, Background),
(PerformRenameResponse, Background),
(OnTypeFormatting, Background),
(OnTypeFormattingResponse, Background),
(InlayHints, Background),
(InlayHintsResponse, Background),
(ResolveInlayHint, Background),
(ResolveInlayHintResponse, Background),
(RefreshInlayHints, Foreground),
(Ping, Foreground),
(PrepareRename, Background),
(PrepareRenameResponse, Background),
(ExpandProjectEntryResponse, Foreground),
(ProjectEntryResponse, Foreground),
(RefreshInlayHints, Foreground),
(RejoinChannelBuffers, Foreground),
(RejoinChannelBuffersResponse, Foreground),
(RejoinRoom, Foreground),
(RejoinRoomResponse, Foreground),
(RemoveContact, Foreground),
(RemoveChannelMember, Foreground),
(RemoveChannelMessage, Foreground),
(ReloadBuffers, Foreground),
(ReloadBuffersResponse, Foreground),
(RemoveChannelMember, Foreground),
(RemoveChannelMessage, Foreground),
(RemoveContact, Foreground),
(RemoveProjectCollaborator, Foreground),
(RenameProjectEntry, Foreground),
(RequestContact, Foreground),
(RespondToContactRequest, Foreground),
(RespondToChannelInvite, Foreground),
(JoinChannel, Foreground),
(RoomUpdated, Foreground),
(SaveBuffer, Foreground),
(RenameChannel, Foreground),
(RenameChannelResponse, Foreground),
(SetChannelMemberAdmin, Foreground),
(RenameProjectEntry, Foreground),
(RequestContact, Foreground),
(ResolveCompletionDocumentation, Background),
(ResolveCompletionDocumentationResponse, Background),
(ResolveInlayHint, Background),
(ResolveInlayHintResponse, Background),
(RespondToChannelInvite, Foreground),
(RespondToContactRequest, Foreground),
(RoomUpdated, Foreground),
(SaveBuffer, Foreground),
(SetChannelMemberRole, Foreground),
(SetChannelVisibility, Foreground),
(SearchProject, Background),
(SearchProjectResponse, Background),
(SendChannelMessage, Background),
(SendChannelMessageResponse, Background),
(ShareProject, Foreground),
(ShareProjectResponse, Foreground),
(ShowContacts, Foreground),
(StartLanguageServer, Foreground),
(SynchronizeBuffers, Foreground),
(SynchronizeBuffersResponse, Foreground),
(RejoinChannelBuffers, Foreground),
(RejoinChannelBuffersResponse, Foreground),
(Test, Foreground),
(Unfollow, Foreground),
(UnshareProject, Foreground),
(UpdateBuffer, Foreground),
(UpdateBufferFile, Foreground),
(UpdateContacts, Foreground),
(DeleteChannel, Foreground),
(MoveChannel, Foreground),
(LinkChannel, Foreground),
(UnlinkChannel, Foreground),
(UpdateChannelBuffer, Foreground),
(UpdateChannelBufferCollaborators, Foreground),
(UpdateChannels, Foreground),
(UpdateContacts, Foreground),
(UpdateDiagnosticSummary, Foreground),
(UpdateDiffBase, Foreground),
(UpdateFollowers, Foreground),
(UpdateInviteInfo, Foreground),
(UpdateLanguageServer, Foreground),
@ -261,18 +279,7 @@ messages!(
(UpdateProjectCollaborator, Foreground),
(UpdateWorktree, Foreground),
(UpdateWorktreeSettings, Foreground),
(UpdateDiffBase, Foreground),
(GetPrivateUserInfo, Foreground),
(GetPrivateUserInfoResponse, Foreground),
(GetChannelMembers, Foreground),
(GetChannelMembersResponse, Foreground),
(JoinChannelBuffer, Foreground),
(JoinChannelBufferResponse, Foreground),
(LeaveChannelBuffer, Background),
(UpdateChannelBuffer, Foreground),
(UpdateChannelBufferCollaborators, Foreground),
(AckBufferOperation, Background),
(AckChannelMessage, Background),
(UsersResponse, Foreground),
);
request_messages!(
@ -284,72 +291,78 @@ request_messages!(
(Call, Ack),
(CancelCall, Ack),
(CopyProjectEntry, ProjectEntryResponse),
(CreateChannel, CreateChannelResponse),
(CreateProjectEntry, ProjectEntryResponse),
(CreateRoom, CreateRoomResponse),
(CreateChannel, CreateChannelResponse),
(DeclineCall, Ack),
(DeleteChannel, Ack),
(DeleteProjectEntry, ProjectEntryResponse),
(ExpandProjectEntry, ExpandProjectEntryResponse),
(Follow, FollowResponse),
(FormatBuffers, FormatBuffersResponse),
(FuzzySearchUsers, UsersResponse),
(GetChannelMembers, GetChannelMembersResponse),
(GetChannelMessages, GetChannelMessagesResponse),
(GetChannelMessagesById, GetChannelMessagesResponse),
(GetCodeActions, GetCodeActionsResponse),
(GetHover, GetHoverResponse),
(GetCompletions, GetCompletionsResponse),
(GetDefinition, GetDefinitionResponse),
(GetTypeDefinition, GetTypeDefinitionResponse),
(GetDocumentHighlights, GetDocumentHighlightsResponse),
(GetReferences, GetReferencesResponse),
(GetHover, GetHoverResponse),
(GetNotifications, GetNotificationsResponse),
(GetPrivateUserInfo, GetPrivateUserInfoResponse),
(GetProjectSymbols, GetProjectSymbolsResponse),
(FuzzySearchUsers, UsersResponse),
(GetReferences, GetReferencesResponse),
(GetTypeDefinition, GetTypeDefinitionResponse),
(GetUsers, UsersResponse),
(IncomingCall, Ack),
(InlayHints, InlayHintsResponse),
(InviteChannelMember, Ack),
(JoinChannel, JoinRoomResponse),
(JoinChannelBuffer, JoinChannelBufferResponse),
(JoinChannelChat, JoinChannelChatResponse),
(JoinProject, JoinProjectResponse),
(JoinRoom, JoinRoomResponse),
(JoinChannelChat, JoinChannelChatResponse),
(LeaveChannelBuffer, Ack),
(LeaveRoom, Ack),
(RejoinRoom, RejoinRoomResponse),
(IncomingCall, Ack),
(MarkNotificationRead, Ack),
(MoveChannel, Ack),
(OnTypeFormatting, OnTypeFormattingResponse),
(OpenBufferById, OpenBufferResponse),
(OpenBufferByPath, OpenBufferResponse),
(OpenBufferForSymbol, OpenBufferForSymbolResponse),
(Ping, Ack),
(PerformRename, PerformRenameResponse),
(Ping, Ack),
(PrepareRename, PrepareRenameResponse),
(OnTypeFormatting, OnTypeFormattingResponse),
(InlayHints, InlayHintsResponse),
(ResolveInlayHint, ResolveInlayHintResponse),
(RefreshInlayHints, Ack),
(RejoinChannelBuffers, RejoinChannelBuffersResponse),
(RejoinRoom, RejoinRoomResponse),
(ReloadBuffers, ReloadBuffersResponse),
(RequestContact, Ack),
(RemoveChannelMember, Ack),
(RemoveContact, Ack),
(RespondToContactRequest, Ack),
(RespondToChannelInvite, Ack),
(SetChannelMemberAdmin, Ack),
(SendChannelMessage, SendChannelMessageResponse),
(GetChannelMessages, GetChannelMessagesResponse),
(GetChannelMembers, GetChannelMembersResponse),
(JoinChannel, JoinRoomResponse),
(RemoveChannelMessage, Ack),
(DeleteChannel, Ack),
(RenameProjectEntry, ProjectEntryResponse),
(RemoveContact, Ack),
(RenameChannel, RenameChannelResponse),
(LinkChannel, Ack),
(UnlinkChannel, Ack),
(MoveChannel, Ack),
(RenameProjectEntry, ProjectEntryResponse),
(RequestContact, Ack),
(
ResolveCompletionDocumentation,
ResolveCompletionDocumentationResponse
),
(ResolveInlayHint, ResolveInlayHintResponse),
(RespondToChannelInvite, Ack),
(RespondToContactRequest, Ack),
(SaveBuffer, BufferSaved),
(SearchProject, SearchProjectResponse),
(SendChannelMessage, SendChannelMessageResponse),
(SetChannelMemberRole, Ack),
(SetChannelVisibility, Ack),
(ShareProject, ShareProjectResponse),
(SynchronizeBuffers, SynchronizeBuffersResponse),
(RejoinChannelBuffers, RejoinChannelBuffersResponse),
(Test, Test),
(UpdateBuffer, Ack),
(UpdateParticipantLocation, Ack),
(UpdateProject, Ack),
(UpdateWorktree, Ack),
(JoinChannelBuffer, JoinChannelBufferResponse),
(LeaveChannelBuffer, Ack)
);
entity_messages!(
@ -368,25 +381,26 @@ entity_messages!(
GetCodeActions,
GetCompletions,
GetDefinition,
GetTypeDefinition,
GetDocumentHighlights,
GetHover,
GetReferences,
GetProjectSymbols,
GetReferences,
GetTypeDefinition,
InlayHints,
JoinProject,
LeaveProject,
OnTypeFormatting,
OpenBufferById,
OpenBufferByPath,
OpenBufferForSymbol,
PerformRename,
OnTypeFormatting,
InlayHints,
ResolveInlayHint,
RefreshInlayHints,
PrepareRename,
RefreshInlayHints,
ReloadBuffers,
RemoveProjectCollaborator,
RenameProjectEntry,
ResolveCompletionDocumentation,
ResolveInlayHint,
SaveBuffer,
SearchProject,
StartLanguageServer,
@ -395,19 +409,19 @@ entity_messages!(
UpdateBuffer,
UpdateBufferFile,
UpdateDiagnosticSummary,
UpdateDiffBase,
UpdateLanguageServer,
UpdateProject,
UpdateProjectCollaborator,
UpdateWorktree,
UpdateWorktreeSettings,
UpdateDiffBase
);
entity_messages!(
channel_id,
ChannelMessageSent,
UpdateChannelBuffer,
RemoveChannelMessage,
UpdateChannelBuffer,
UpdateChannelBufferCollaborators,
);

View file

@ -14,7 +14,7 @@ anyhow.workspace = true
backtrace-on-stack-overflow = "0.3.0"
clap = { version = "4.4", features = ["derive", "string"] }
chrono = "0.4"
gpui2 = { path = "../gpui2" }
gpui = { package = "gpui2", path = "../gpui2" }
itertools = "0.11.0"
log.workspace = true
rust-embed.workspace = true
@ -29,4 +29,4 @@ ui = { package = "ui2", path = "../ui2", features = ["stories"] }
util = { path = "../util" }
[dev-dependencies]
gpui2 = { path = "../gpui2", features = ["test-support"] }
gpui = { package = "gpui2", path = "../gpui2", features = ["test-support"] }

View file

@ -1,7 +1,7 @@
use std::borrow::Cow;
use anyhow::{anyhow, Result};
use gpui2::{AssetSource, SharedString};
use gpui::{AssetSource, SharedString};
use rust_embed::RustEmbed;
#[derive(RustEmbed)]

View file

@ -1,97 +0,0 @@
use gpui2::{
div, ArcCow, Element, EventContext, Interactive, IntoElement, MouseButton, ParentElement,
StyleHelpers, ViewContext,
};
use std::{marker::PhantomData, rc::Rc};
struct ButtonHandlers<V, D> {
click: Option<Rc<dyn Fn(&mut V, &D, &mut EventContext<V>)>>,
}
impl<V, D> Default for ButtonHandlers<V, D> {
fn default() -> Self {
Self { click: None }
}
}
#[derive(Component)]
pub struct Button<V: 'static, D: 'static> {
handlers: ButtonHandlers<V, D>,
label: Option<ArcCow<'static, str>>,
icon: Option<ArcCow<'static, str>>,
data: Rc<D>,
view_type: PhantomData<V>,
}
// Impl block for buttons without data.
// See below for an impl block for any button.
impl<V: 'static> Button<V, ()> {
fn new() -> Self {
Self {
handlers: ButtonHandlers::default(),
label: None,
icon: None,
data: Rc::new(()),
view_type: PhantomData,
}
}
pub fn data<D: 'static>(self, data: D) -> Button<V, D> {
Button {
handlers: ButtonHandlers::default(),
label: self.label,
icon: self.icon,
data: Rc::new(data),
view_type: PhantomData,
}
}
}
// Impl block for button regardless of its data type.
impl<V: 'static, D: 'static> Button<V, D> {
pub fn label(mut self, label: impl Into<ArcCow<'static, str>>) -> Self {
self.label = Some(label.into());
self
}
pub fn icon(mut self, icon: impl Into<ArcCow<'static, str>>) -> Self {
self.icon = Some(icon.into());
self
}
pub fn on_click(
mut self,
handler: impl Fn(&mut V, &D, &mut EventContext<V>) + 'static,
) -> Self {
self.handlers.click = Some(Rc::new(handler));
self
}
}
pub fn button<V>() -> Button<V, ()> {
Button::new()
}
impl<V: 'static, D: 'static> Button<V, D> {
fn render(
&mut self,
view: &mut V,
cx: &mut ViewContext<V>,
) -> impl IntoElement<V> + Interactive<V> {
// let colors = &cx.theme::<Theme>().colors;
let button = div()
// .fill(colors.error(0.5))
.h_4()
.children(self.label.clone());
if let Some(handler) = self.handlers.click.clone() {
let data = self.data.clone();
button.on_mouse_down(MouseButton::Left, move |view, event, cx| {
handler(view, data.as_ref(), cx)
})
} else {
button
}
}
}

View file

@ -1,5 +1,5 @@
use crate::story::Story;
use gpui2::{px, Div, Render};
use gpui::{px, Div, Render};
use theme2::{default_color_scales, ColorScaleStep};
use ui::prelude::*;
@ -20,7 +20,7 @@ impl Render for ColorsStory {
.flex_col()
.gap_1()
.overflow_y_scroll()
.text_color(gpui2::white())
.text_color(gpui::white())
.children(color_scales.into_iter().map(|scale| {
div()
.flex()

View file

@ -1,4 +1,4 @@
use gpui2::{
use gpui::{
div, Div, FocusEnabled, Focusable, KeyBinding, ParentElement, Render, StatefulInteraction,
StatelessInteractive, Styled, View, VisualContext, WindowContext,
};
@ -33,7 +33,7 @@ impl FocusStory {
impl Render for FocusStory {
type Element = Div<Self, StatefulInteraction<Self>, FocusEnabled<Self>>;
fn render(&mut self, cx: &mut gpui2::ViewContext<Self>) -> Self::Element {
fn render(&mut self, cx: &mut gpui::ViewContext<Self>) -> Self::Element {
let theme = cx.theme();
let color_1 = theme.styles.git.created;
let color_2 = theme.styles.git.modified;

View file

@ -1,8 +1,5 @@
use crate::{
story::Story,
story_selector::{ComponentStory, ElementStory},
};
use gpui2::{Div, Render, StatefulInteraction, View, VisualContext};
use crate::{story::Story, story_selector::ComponentStory};
use gpui::{Div, Render, StatefulInteraction, View, VisualContext};
use strum::IntoEnumIterator;
use ui::prelude::*;
@ -18,9 +15,6 @@ impl Render for KitchenSinkStory {
type Element = Div<Self, StatefulInteraction<Self>>;
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
let element_stories = ElementStory::iter()
.map(|selector| selector.story(cx))
.collect::<Vec<_>>();
let component_stories = ComponentStory::iter()
.map(|selector| selector.story(cx))
.collect::<Vec<_>>();
@ -29,8 +23,6 @@ impl Render for KitchenSinkStory {
.id("kitchen-sink")
.overflow_y_scroll()
.child(Story::title(cx, "Kitchen Sink"))
.child(Story::label(cx, "Elements"))
.child(div().flex().flex_col().children(element_stories))
.child(Story::label(cx, "Components"))
.child(div().flex().flex_col().children(component_stories))
// Add a bit of space at the bottom of the kitchen sink so elements

View file

@ -1,4 +1,4 @@
use gpui2::{
use gpui::{
div, px, Component, Div, ParentElement, Render, SharedString, StatefulInteraction, Styled,
View, VisualContext, WindowContext,
};
@ -15,7 +15,7 @@ impl ScrollStory {
impl Render for ScrollStory {
type Element = Div<Self, StatefulInteraction<Self>>;
fn render(&mut self, cx: &mut gpui2::ViewContext<Self>) -> Self::Element {
fn render(&mut self, cx: &mut gpui::ViewContext<Self>) -> Self::Element {
let theme = cx.theme();
let color_1 = theme.styles.git.created;
let color_2 = theme.styles.git.modified;

View file

@ -1,4 +1,4 @@
use gpui2::{div, white, Div, ParentElement, Render, Styled, View, VisualContext, WindowContext};
use gpui::{div, white, Div, ParentElement, Render, Styled, View, VisualContext, WindowContext};
pub struct TextStory;
@ -11,7 +11,7 @@ impl TextStory {
impl Render for TextStory {
type Element = Div<Self>;
fn render(&mut self, cx: &mut gpui2::ViewContext<Self>) -> Self::Element {
fn render(&mut self, cx: &mut gpui::ViewContext<Self>) -> Self::Element {
div().size_full().bg(white()).child(concat!(
"The quick brown fox jumps over the lazy dog. ",
"Meanwhile, the lazy dog decided it was time for a change. ",

View file

@ -1,4 +1,4 @@
use gpui2::{px, rgb, Div, Hsla, Render};
use gpui::{px, rgb, Div, Hsla, Render};
use ui::prelude::*;
use crate::story::Story;

View file

@ -5,57 +5,33 @@ use crate::stories::*;
use anyhow::anyhow;
use clap::builder::PossibleValue;
use clap::ValueEnum;
use gpui2::{AnyView, VisualContext};
use gpui::{AnyView, VisualContext};
use strum::{EnumIter, EnumString, IntoEnumIterator};
use ui::{prelude::*, AvatarStory, ButtonStory, DetailsStory, IconStory, InputStory, LabelStory};
#[derive(Debug, PartialEq, Eq, Clone, Copy, strum::Display, EnumString, EnumIter)]
#[strum(serialize_all = "snake_case")]
pub enum ElementStory {
Avatar,
Button,
Colors,
Details,
Focus,
Icon,
Input,
Label,
Scroll,
Text,
ZIndex,
}
impl ElementStory {
pub fn story(&self, cx: &mut WindowContext) -> AnyView {
match self {
Self::Colors => cx.build_view(|_| ColorsStory).into(),
Self::Avatar => cx.build_view(|_| AvatarStory).into(),
Self::Button => cx.build_view(|_| ButtonStory).into(),
Self::Details => cx.build_view(|_| DetailsStory).into(),
Self::Focus => FocusStory::view(cx).into(),
Self::Icon => cx.build_view(|_| IconStory).into(),
Self::Input => cx.build_view(|_| InputStory).into(),
Self::Label => cx.build_view(|_| LabelStory).into(),
Self::Scroll => ScrollStory::view(cx).into(),
Self::Text => TextStory::view(cx).into(),
Self::ZIndex => cx.build_view(|_| ZIndexStory).into(),
}
}
}
use ui::prelude::*;
use ui::{AvatarStory, ButtonStory, DetailsStory, IconStory, InputStory, LabelStory};
#[derive(Debug, PartialEq, Eq, Clone, Copy, strum::Display, EnumString, EnumIter)]
#[strum(serialize_all = "snake_case")]
pub enum ComponentStory {
AssistantPanel,
Avatar,
Breadcrumb,
Buffer,
Button,
ChatPanel,
Checkbox,
CollabPanel,
Colors,
CommandPalette,
Copilot,
ContextMenu,
Copilot,
Details,
Facepile,
Focus,
Icon,
Input,
Keybinding,
Label,
LanguageSelector,
MultiBuffer,
NotificationsPanel,
@ -63,29 +39,42 @@ pub enum ComponentStory {
Panel,
ProjectPanel,
RecentProjects,
Scroll,
Tab,
TabBar,
Terminal,
Text,
ThemeSelector,
TitleBar,
Toast,
Toolbar,
TrafficLights,
Workspace,
ZIndex,
}
impl ComponentStory {
pub fn story(&self, cx: &mut WindowContext) -> AnyView {
match self {
Self::AssistantPanel => cx.build_view(|_| ui::AssistantPanelStory).into(),
Self::Buffer => cx.build_view(|_| ui::BufferStory).into(),
Self::Avatar => cx.build_view(|_| AvatarStory).into(),
Self::Breadcrumb => cx.build_view(|_| ui::BreadcrumbStory).into(),
Self::Buffer => cx.build_view(|_| ui::BufferStory).into(),
Self::Button => cx.build_view(|_| ButtonStory).into(),
Self::ChatPanel => cx.build_view(|_| ui::ChatPanelStory).into(),
Self::Checkbox => cx.build_view(|_| ui::CheckboxStory).into(),
Self::CollabPanel => cx.build_view(|_| ui::CollabPanelStory).into(),
Self::Colors => cx.build_view(|_| ColorsStory).into(),
Self::CommandPalette => cx.build_view(|_| ui::CommandPaletteStory).into(),
Self::ContextMenu => cx.build_view(|_| ui::ContextMenuStory).into(),
Self::Copilot => cx.build_view(|_| ui::CopilotModalStory).into(),
Self::Details => cx.build_view(|_| DetailsStory).into(),
Self::Facepile => cx.build_view(|_| ui::FacepileStory).into(),
Self::Focus => FocusStory::view(cx).into(),
Self::Icon => cx.build_view(|_| IconStory).into(),
Self::Input => cx.build_view(|_| InputStory).into(),
Self::Keybinding => cx.build_view(|_| ui::KeybindingStory).into(),
Self::Label => cx.build_view(|_| LabelStory).into(),
Self::LanguageSelector => cx.build_view(|_| ui::LanguageSelectorStory).into(),
Self::MultiBuffer => cx.build_view(|_| ui::MultiBufferStory).into(),
Self::NotificationsPanel => cx.build_view(|cx| ui::NotificationsPanelStory).into(),
@ -93,23 +82,24 @@ impl ComponentStory {
Self::Panel => cx.build_view(|cx| ui::PanelStory).into(),
Self::ProjectPanel => cx.build_view(|_| ui::ProjectPanelStory).into(),
Self::RecentProjects => cx.build_view(|_| ui::RecentProjectsStory).into(),
Self::Scroll => ScrollStory::view(cx).into(),
Self::Tab => cx.build_view(|_| ui::TabStory).into(),
Self::TabBar => cx.build_view(|_| ui::TabBarStory).into(),
Self::Terminal => cx.build_view(|_| ui::TerminalStory).into(),
Self::Text => TextStory::view(cx).into(),
Self::ThemeSelector => cx.build_view(|_| ui::ThemeSelectorStory).into(),
Self::TitleBar => ui::TitleBarStory::view(cx).into(),
Self::Toast => cx.build_view(|_| ui::ToastStory).into(),
Self::Toolbar => cx.build_view(|_| ui::ToolbarStory).into(),
Self::TrafficLights => cx.build_view(|_| ui::TrafficLightsStory).into(),
Self::Copilot => cx.build_view(|_| ui::CopilotModalStory).into(),
Self::TitleBar => ui::TitleBarStory::view(cx).into(),
Self::Workspace => ui::WorkspaceStory::view(cx).into(),
Self::ZIndex => cx.build_view(|_| ZIndexStory).into(),
}
}
}
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
pub enum StorySelector {
Element(ElementStory),
Component(ComponentStory),
KitchenSink,
}
@ -126,13 +116,6 @@ impl FromStr for StorySelector {
return Ok(Self::KitchenSink);
}
if let Some((_, story)) = story.split_once("elements/") {
let element_story = ElementStory::from_str(story)
.with_context(|| format!("story not found for element '{story}'"))?;
return Ok(Self::Element(element_story));
}
if let Some((_, story)) = story.split_once("components/") {
let component_story = ComponentStory::from_str(story)
.with_context(|| format!("story not found for component '{story}'"))?;
@ -147,7 +130,6 @@ impl FromStr for StorySelector {
impl StorySelector {
pub fn story(&self, cx: &mut WindowContext) -> AnyView {
match self {
Self::Element(element_story) => element_story.story(cx),
Self::Component(component_story) => component_story.story(cx),
Self::KitchenSink => KitchenSinkStory::view(cx).into(),
}
@ -160,11 +142,9 @@ static ALL_STORY_SELECTORS: OnceLock<Vec<StorySelector>> = OnceLock::new();
impl ValueEnum for StorySelector {
fn value_variants<'a>() -> &'a [Self] {
let stories = ALL_STORY_SELECTORS.get_or_init(|| {
let element_stories = ElementStory::iter().map(StorySelector::Element);
let component_stories = ComponentStory::iter().map(StorySelector::Component);
element_stories
.chain(component_stories)
component_stories
.chain(std::iter::once(StorySelector::KitchenSink))
.collect::<Vec<_>>()
});
@ -174,7 +154,6 @@ impl ValueEnum for StorySelector {
fn to_possible_value(&self) -> Option<clap::builder::PossibleValue> {
let value = match self {
Self::Element(story) => format!("elements/{story}"),
Self::Component(story) => format!("components/{story}"),
Self::KitchenSink => "kitchen_sink".to_string(),
};

View file

@ -8,7 +8,7 @@ mod story_selector;
use std::sync::Arc;
use clap::Parser;
use gpui2::{
use gpui::{
div, px, size, AnyView, AppContext, Bounds, Div, Render, ViewContext, VisualContext,
WindowBounds, WindowOptions,
};
@ -22,7 +22,7 @@ use ui::prelude::*;
use crate::assets::Assets;
use crate::story_selector::StorySelector;
// gpui2::actions! {
// gpui::actions! {
// storybook,
// [ToggleInspector]
// }
@ -51,7 +51,7 @@ fn main() {
let theme_name = args.theme.unwrap_or("Zed Pro Moonlight".to_string());
let asset_source = Arc::new(Assets);
gpui2::App::production(asset_source).run(move |cx| {
gpui::App::production(asset_source).run(move |cx| {
load_embedded_fonts(cx).unwrap();
let mut store = SettingsStore::default();
@ -116,7 +116,7 @@ impl Render for StoryWrapper {
}
}
fn load_embedded_fonts(cx: &AppContext) -> gpui2::Result<()> {
fn load_embedded_fonts(cx: &AppContext) -> gpui::Result<()> {
let font_paths = cx.asset_source().list("fonts")?;
let mut embedded_fonts = Vec::new();
for font_path in font_paths {

View file

@ -1,6 +1,6 @@
// todo!()
use alacritty_terminal::term::color::Rgb as AlacRgb;
// use gpui2::color::Color;
// use gpui::color::Color;
// use theme2::TerminalStyle;
///Converts a 2, 8, or 24 bit color ANSI color to the GPUI equivalent

View file

@ -1,4 +1,4 @@
use gpui::{HighlightStyle, Hsla};
use gpui::Hsla;
use refineable::Refineable;
use crate::SyntaxTheme;
@ -64,24 +64,26 @@ pub struct GitStatusColors {
pub renamed: Hsla,
}
#[derive(Refineable, Clone, Debug, Default)]
#[refineable(debug)]
#[derive(Refineable, Clone, Debug)]
#[refineable(debug, deserialize)]
pub struct ThemeColors {
pub border: Hsla,
pub border_variant: Hsla,
pub border_focused: Hsla,
pub border_selected: Hsla,
pub border_transparent: Hsla,
pub elevated_surface: Hsla,
pub surface: Hsla,
pub border_disabled: Hsla,
pub elevated_surface_background: Hsla,
pub surface_background: Hsla,
pub background: Hsla,
pub element: Hsla,
pub element_background: Hsla,
pub element_hover: Hsla,
pub element_active: Hsla,
pub element_selected: Hsla,
pub element_disabled: Hsla,
pub element_placeholder: Hsla,
pub element_drop_target: Hsla,
pub ghost_element: Hsla,
pub ghost_element_background: Hsla,
pub ghost_element_hover: Hsla,
pub ghost_element_active: Hsla,
pub ghost_element_selected: Hsla,
@ -96,38 +98,57 @@ pub struct ThemeColors {
pub icon_disabled: Hsla,
pub icon_placeholder: Hsla,
pub icon_accent: Hsla,
pub status_bar: Hsla,
pub title_bar: Hsla,
pub toolbar: Hsla,
pub tab_bar: Hsla,
pub tab_inactive: Hsla,
pub tab_active: Hsla,
pub editor: Hsla,
pub editor_gutter: Hsla,
pub editor_subheader: Hsla,
pub editor_active_line: Hsla,
pub editor_highlighted_line: Hsla,
pub status_bar_background: Hsla,
pub title_bar_background: Hsla,
pub toolbar_background: Hsla,
pub tab_bar_background: Hsla,
pub tab_inactive_background: Hsla,
pub tab_active_background: Hsla,
pub editor_background: Hsla,
pub editor_gutter_background: Hsla,
pub editor_subheader_background: Hsla,
pub editor_active_line_background: Hsla,
pub editor_highlighted_line_background: Hsla,
pub editor_line_number: Hsla,
pub editor_active_line_number: Hsla,
pub editor_invisible: Hsla,
pub editor_wrap_guide: Hsla,
pub editor_active_wrap_guide: Hsla,
pub terminal_background: Hsla,
pub terminal_ansi_bright_black: Hsla,
pub terminal_ansi_bright_red: Hsla,
pub terminal_ansi_bright_green: Hsla,
pub terminal_ansi_bright_yellow: Hsla,
pub terminal_ansi_bright_blue: Hsla,
pub terminal_ansi_bright_magenta: Hsla,
pub terminal_ansi_bright_cyan: Hsla,
pub terminal_ansi_bright_white: Hsla,
pub terminal_ansi_black: Hsla,
pub terminal_ansi_red: Hsla,
pub terminal_ansi_green: Hsla,
pub terminal_ansi_yellow: Hsla,
pub terminal_ansi_blue: Hsla,
pub terminal_ansi_magenta: Hsla,
pub terminal_ansi_cyan: Hsla,
pub terminal_ansi_white: Hsla,
}
#[derive(Refineable, Clone)]
pub struct ThemeStyles {
pub system: SystemColors,
#[refineable]
pub colors: ThemeColors,
pub status: StatusColors,
pub git: GitStatusColors,
pub player: PlayerColors,
pub syntax: SyntaxTheme,
pub inlay_highlight_style: HighlightStyle,
pub suggestion_highlight_style: HighlightStyle,
}
#[cfg(test)]
mod tests {
use serde_json::json;
use super::*;
#[test]
@ -169,4 +190,16 @@ mod tests {
assert_eq!(colors.text, magenta);
assert_eq!(colors.background, green);
}
#[test]
fn deserialize_theme_colors_refinement_from_json() {
let colors: ThemeColorsRefinement = serde_json::from_value(json!({
"background": "#ff00ff",
"text": "#ff0000"
}))
.unwrap();
assert_eq!(colors.background, Some(gpui::rgb(0xff00ff)));
assert_eq!(colors.text, Some(gpui::rgb(0xff0000)));
}
}

View file

@ -205,18 +205,20 @@ impl ThemeColors {
border: neutral().light().step_6(),
border_variant: neutral().light().step_5(),
border_focused: blue().light().step_5(),
border_disabled: neutral().light().step_3(),
border_selected: blue().light().step_5(),
border_transparent: system.transparent,
elevated_surface: neutral().light().step_2(),
surface: neutral().light().step_2(),
elevated_surface_background: neutral().light().step_2(),
surface_background: neutral().light().step_2(),
background: neutral().light().step_1(),
element: neutral().light().step_3(),
element_background: neutral().light().step_3(),
element_hover: neutral().light().step_4(),
element_active: neutral().light().step_5(),
element_selected: neutral().light().step_5(),
element_disabled: neutral().light_alpha().step_3(),
element_placeholder: neutral().light().step_11(),
element_drop_target: blue().light_alpha().step_2(),
ghost_element: system.transparent,
ghost_element_background: system.transparent,
ghost_element_hover: neutral().light().step_4(),
ghost_element_active: neutral().light().step_5(),
ghost_element_selected: neutral().light().step_5(),
@ -231,22 +233,39 @@ impl ThemeColors {
icon_disabled: neutral().light().step_9(),
icon_placeholder: neutral().light().step_10(),
icon_accent: blue().light().step_11(),
status_bar: neutral().light().step_2(),
title_bar: neutral().light().step_2(),
toolbar: neutral().light().step_1(),
tab_bar: neutral().light().step_2(),
tab_active: neutral().light().step_1(),
tab_inactive: neutral().light().step_2(),
editor: neutral().light().step_1(),
editor_gutter: neutral().light().step_1(), // todo!("pick the right colors")
editor_subheader: neutral().light().step_2(),
editor_active_line: neutral().light_alpha().step_3(),
status_bar_background: neutral().light().step_2(),
title_bar_background: neutral().light().step_2(),
toolbar_background: neutral().light().step_1(),
tab_bar_background: neutral().light().step_2(),
tab_active_background: neutral().light().step_1(),
tab_inactive_background: neutral().light().step_2(),
editor_background: neutral().light().step_1(),
editor_gutter_background: neutral().light().step_1(), // todo!("pick the right colors")
editor_subheader_background: neutral().light().step_2(),
editor_active_line_background: neutral().light_alpha().step_3(),
editor_line_number: neutral().light_alpha().step_3(), // todo!("pick the right colors")
editor_active_line_number: neutral().light_alpha().step_3(), // todo!("pick the right colors")
editor_highlighted_line: neutral().light_alpha().step_4(), // todo!("pick the right colors")
editor_highlighted_line_background: neutral().light_alpha().step_4(), // todo!("pick the right colors")
editor_invisible: neutral().light_alpha().step_4(), // todo!("pick the right colors")
editor_wrap_guide: neutral().light_alpha().step_4(), // todo!("pick the right colors")
editor_active_wrap_guide: neutral().light_alpha().step_4(), // todo!("pick the right colors")
terminal_background: neutral().light().step_1(),
terminal_ansi_black: black().light().step_12(),
terminal_ansi_red: red().light().step_11(),
terminal_ansi_green: green().light().step_11(),
terminal_ansi_yellow: yellow().light().step_11(),
terminal_ansi_blue: blue().light().step_11(),
terminal_ansi_magenta: violet().light().step_11(),
terminal_ansi_cyan: cyan().light().step_11(),
terminal_ansi_white: neutral().light().step_12(),
terminal_ansi_bright_black: black().light().step_11(),
terminal_ansi_bright_red: red().light().step_10(),
terminal_ansi_bright_green: green().light().step_10(),
terminal_ansi_bright_yellow: yellow().light().step_10(),
terminal_ansi_bright_blue: blue().light().step_10(),
terminal_ansi_bright_magenta: violet().light().step_10(),
terminal_ansi_bright_cyan: cyan().light().step_10(),
terminal_ansi_bright_white: neutral().light().step_11(),
}
}
@ -257,18 +276,20 @@ impl ThemeColors {
border: neutral().dark().step_6(),
border_variant: neutral().dark().step_5(),
border_focused: blue().dark().step_5(),
border_disabled: neutral().dark().step_3(),
border_selected: blue().dark().step_5(),
border_transparent: system.transparent,
elevated_surface: neutral().dark().step_2(),
surface: neutral().dark().step_2(),
elevated_surface_background: neutral().dark().step_2(),
surface_background: neutral().dark().step_2(),
background: neutral().dark().step_1(),
element: neutral().dark().step_3(),
element_background: neutral().dark().step_3(),
element_hover: neutral().dark().step_4(),
element_active: neutral().dark().step_5(),
element_selected: neutral().dark().step_5(),
element_disabled: neutral().dark_alpha().step_3(),
element_placeholder: neutral().dark().step_11(),
element_drop_target: blue().dark_alpha().step_2(),
ghost_element: system.transparent,
ghost_element_background: system.transparent,
ghost_element_hover: neutral().dark().step_4(),
ghost_element_active: neutral().dark().step_5(),
ghost_element_selected: neutral().dark().step_5(),
@ -283,22 +304,39 @@ impl ThemeColors {
icon_disabled: neutral().dark().step_9(),
icon_placeholder: neutral().dark().step_10(),
icon_accent: blue().dark().step_11(),
status_bar: neutral().dark().step_2(),
title_bar: neutral().dark().step_2(),
toolbar: neutral().dark().step_1(),
tab_bar: neutral().dark().step_2(),
tab_active: neutral().dark().step_1(),
tab_inactive: neutral().dark().step_2(),
editor: neutral().dark().step_1(),
editor_gutter: neutral().dark().step_1(), // todo!("pick the right colors")
editor_subheader: neutral().dark().step_2(),
editor_active_line: neutral().dark_alpha().step_3(),
status_bar_background: neutral().dark().step_2(),
title_bar_background: neutral().dark().step_2(),
toolbar_background: neutral().dark().step_1(),
tab_bar_background: neutral().dark().step_2(),
tab_active_background: neutral().dark().step_1(),
tab_inactive_background: neutral().dark().step_2(),
editor_background: neutral().dark().step_1(),
editor_gutter_background: neutral().dark().step_1(), // todo!("pick the right colors")
editor_subheader_background: neutral().dark().step_2(),
editor_active_line_background: neutral().dark_alpha().step_3(),
editor_line_number: neutral().dark_alpha().step_3(), // todo!("pick the right colors")
editor_active_line_number: neutral().dark_alpha().step_3(), // todo!("pick the right colors")
editor_highlighted_line: neutral().dark_alpha().step_4(), // todo!("pick the right colors")
editor_highlighted_line_background: neutral().dark_alpha().step_4(), // todo!("pick the right colors")
editor_invisible: neutral().dark_alpha().step_4(), // todo!("pick the right colors")
editor_wrap_guide: neutral().dark_alpha().step_4(), // todo!("pick the right colors")
editor_active_wrap_guide: neutral().dark_alpha().step_4(), // todo!("pick the right colors")
terminal_background: neutral().dark().step_1(),
terminal_ansi_black: black().dark().step_12(),
terminal_ansi_red: red().dark().step_11(),
terminal_ansi_green: green().dark().step_11(),
terminal_ansi_yellow: yellow().dark().step_11(),
terminal_ansi_blue: blue().dark().step_11(),
terminal_ansi_magenta: violet().dark().step_11(),
terminal_ansi_cyan: cyan().dark().step_11(),
terminal_ansi_white: neutral().dark().step_12(),
terminal_ansi_bright_black: black().dark().step_11(),
terminal_ansi_bright_red: red().dark().step_10(),
terminal_ansi_bright_green: green().dark().step_10(),
terminal_ansi_bright_yellow: yellow().dark().step_10(),
terminal_ansi_bright_blue: blue().dark().step_10(),
terminal_ansi_bright_magenta: violet().dark().step_10(),
terminal_ansi_bright_cyan: cyan().dark().step_10(),
terminal_ansi_bright_white: neutral().dark().step_11(),
}
}
}

View file

@ -15,8 +15,6 @@ fn zed_pro_daylight() -> ThemeVariant {
git: GitStatusColors::default(),
player: PlayerColors::default(),
syntax: SyntaxTheme::default_light(),
inlay_highlight_style: Default::default(),
suggestion_highlight_style: Default::default(),
},
}
}
@ -33,8 +31,6 @@ pub(crate) fn zed_pro_moonlight() -> ThemeVariant {
git: GitStatusColors::default(),
player: PlayerColors::default(),
syntax: SyntaxTheme::default_dark(),
inlay_highlight_style: Default::default(),
suggestion_highlight_style: Default::default(),
},
}
}

View file

@ -1,4 +1,4 @@
use crate::{zed_pro_family, ThemeFamily, ThemeVariant};
use crate::{all_imported_themes, zed_pro_family, ThemeFamily, ThemeVariant};
use anyhow::{anyhow, Result};
use gpui::SharedString;
use std::{collections::HashMap, sync::Arc};
@ -42,7 +42,10 @@ impl Default for ThemeRegistry {
themes: HashMap::default(),
};
this.insert_theme_families([zed_pro_family()]);
let mut all_themes = vec![zed_pro_family()];
all_themes.extend(all_imported_themes());
this.insert_theme_families(all_themes);
this
}

View file

@ -5,6 +5,7 @@ mod registry;
mod scale;
mod settings;
mod syntax;
mod themes;
use std::sync::Arc;
@ -16,10 +17,11 @@ pub use registry::*;
pub use scale::*;
pub use settings::*;
pub use syntax::*;
pub use themes::*;
use gpui::{AppContext, Hsla, SharedString};
#[derive(Debug, Clone, PartialEq)]
#[derive(Debug, PartialEq, Clone, Copy)]
pub enum Appearance {
Light,
Dark,
@ -41,8 +43,7 @@ impl ActiveTheme for AppContext {
}
pub struct ThemeFamily {
#[allow(dead_code)]
pub(crate) id: String,
pub id: String,
pub name: SharedString,
pub author: SharedString,
pub themes: Vec<ThemeVariant>,
@ -52,8 +53,7 @@ pub struct ThemeFamily {
impl ThemeFamily {}
pub struct ThemeVariant {
#[allow(dead_code)]
pub(crate) id: String,
pub id: String,
pub name: SharedString,
pub appearance: Appearance,
pub styles: ThemeStyles,

View file

@ -0,0 +1,333 @@
use gpui::rgba;
use crate::{
default_color_scales, Appearance, GitStatusColors, PlayerColor, PlayerColors, StatusColors,
SyntaxTheme, SystemColors, ThemeColors, ThemeFamily, ThemeStyles, ThemeVariant,
};
pub fn andromeda() -> ThemeFamily {
ThemeFamily {
id: "192bb9a2-a028-4c9a-b713-4c92330b3fab".into(),
name: "Andromeda".into(),
author: "Eliver Lara (EliverLara)".into(),
themes: vec![
ThemeVariant {
id: "a3aaa73f-f225-41bd-8d52-77ca1df0b7f7".into(),
name: "Andromeda".into(),
appearance: Appearance::Dark,
styles: ThemeStyles {
system: SystemColors {
transparent: rgba(0x00000000).into(),
mac_os_traffic_light_red: rgba(0xec6b5fff).into(),
mac_os_traffic_light_yellow: rgba(0xf3bf4dff).into(),
mac_os_traffic_light_green: rgba(0x61c454ff).into(),
},
colors: ThemeColors {
border: rgba(0x1b1d23ff).into(),
border_variant: rgba(0x1b1d23ff).into(),
border_focused: rgba(0x1b1d23ff).into(),
border_disabled: rgba(0x1b1d23ff).into(),
border_selected: rgba(0x1b1d23ff).into(),
border_transparent: rgba(0x1b1d23ff).into(),
elevated_surface_background: rgba(0x23262eff).into(),
surface_background: rgba(0x23262eff).into(),
background: rgba(0x23262eff).into(),
element_background: rgba(0x00e8c5cc).into(),
element_hover: rgba(0x272a2dff).into(),
element_active: rgba(0x2e3135ff).into(),
element_selected: rgba(0x2e3135ff).into(),
element_disabled: rgba(0xddeaf814).into(),
element_placeholder: rgba(0xb0b4baff).into(),
element_drop_target: rgba(0x1166fb18).into(),
ghost_element_background: rgba(0x00000000).into(),
ghost_element_hover: rgba(0x272a2dff).into(),
ghost_element_active: rgba(0x2e3135ff).into(),
ghost_element_selected: rgba(0x2e3135ff).into(),
ghost_element_disabled: rgba(0xddeaf814).into(),
text: rgba(0xd4cdd8ff).into(),
text_muted: rgba(0xb0b4baff).into(),
text_placeholder: rgba(0x767a83ff).into(),
text_disabled: rgba(0x696e77ff).into(),
text_accent: rgba(0x6fb8ffff).into(),
icon: rgba(0xb0b4baff).into(),
icon_muted: rgba(0x767a83ff).into(),
icon_disabled: rgba(0x696e77ff).into(),
icon_placeholder: rgba(0x767a83ff).into(),
icon_accent: rgba(0x6fb8ffff).into(),
status_bar_background: rgba(0x18191bff).into(),
title_bar_background: rgba(0x18191bff).into(),
toolbar_background: rgba(0x111113ff).into(),
tab_bar_background: rgba(0x18191bff).into(),
tab_inactive_background: rgba(0x23262eff).into(),
tab_active_background: rgba(0x23262eff).into(),
editor_background: rgba(0x111113ff).into(),
editor_subheader_background: rgba(0x18191bff).into(),
editor_active_line: rgba(0xddeaf814).into(),
terminal_background: rgba(0x111113ff).into(),
terminal_ansi_bright_black: rgba(0x000000e6).into(),
terminal_ansi_bright_red: rgba(0xee5d42ff).into(),
terminal_ansi_bright_green: rgba(0x95e072ff).into(),
terminal_ansi_bright_yellow: rgba(0xffe66dff).into(),
terminal_ansi_bright_blue: rgba(0x7bb7ffff).into(),
terminal_ansi_bright_magenta: rgba(0xff00a9ff).into(),
terminal_ansi_bright_cyan: rgba(0x00e8c6ff).into(),
terminal_ansi_bright_white: rgba(0xb0b4baff).into(),
terminal_ansi_black: rgba(0x000000f2).into(),
terminal_ansi_red: rgba(0xee5d42ff).into(),
terminal_ansi_green: rgba(0x95e072ff).into(),
terminal_ansi_yellow: rgba(0xffe66dff).into(),
terminal_ansi_blue: rgba(0x7bb7ffff).into(),
terminal_ansi_magenta: rgba(0xff00a9ff).into(),
terminal_ansi_cyan: rgba(0x00e8c6ff).into(),
terminal_ansi_white: rgba(0xedeef0ff).into(),
},
status: StatusColors {
conflict: rgba(0xff9592ff).into(),
created: rgba(0x70cf82ff).into(),
deleted: rgba(0xff9592ff).into(),
error: rgba(0xff9592ff).into(),
hidden: rgba(0xb0b4baff).into(),
ignored: rgba(0xb0b4baff).into(),
info: rgba(0x6fb8ffff).into(),
modified: rgba(0xf5e147ff).into(),
renamed: rgba(0x6fb8ffff).into(),
success: rgba(0x70cf82ff).into(),
warning: rgba(0xf5e147ff).into(),
},
git: GitStatusColors {
conflict: rgba(0xffa057ff).into(),
created: rgba(0x70cf82ff).into(),
deleted: rgba(0xff9592ff).into(),
ignored: rgba(0xb0b4baff).into(),
modified: rgba(0xf5e147ff).into(),
renamed: rgba(0x6fb8ffff).into(),
},
player: PlayerColors(vec![
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
]),
syntax: SyntaxTheme {
highlights: vec![
("attribute".into(), rgba(0x4ccce6ff).into()),
("boolean".into(), rgba(0xff977dff).into()),
("comment".into(), rgba(0xb0b4baff).into()),
("comment.doc".into(), rgba(0xe0dffeff).into()),
("constant".into(), rgba(0x8c323aff).into()),
("constructor".into(), rgba(0x8c323aff).into()),
("embedded".into(), rgba(0x8c323aff).into()),
("emphasis".into(), rgba(0x8c323aff).into()),
("emphasis.strong".into(), rgba(0x8c323aff).into()),
("enum".into(), rgba(0x8c323aff).into()),
("function".into(), rgba(0x8c323aff).into()),
("hint".into(), rgba(0x8c323aff).into()),
("keyword".into(), rgba(0xffa057ff).into()),
("label".into(), rgba(0x8c323aff).into()),
("link_text".into(), rgba(0x8c323aff).into()),
("link_uri".into(), rgba(0x8c323aff).into()),
("number".into(), rgba(0x8c323aff).into()),
("operator".into(), rgba(0x8c323aff).into()),
("predictive".into(), rgba(0x8c323aff).into()),
("preproc".into(), rgba(0x8c323aff).into()),
("primary".into(), rgba(0x8c323aff).into()),
("property".into(), rgba(0x8c323aff).into()),
("punctuation".into(), rgba(0xb0b4baff).into()),
("punctuation.bracket".into(), rgba(0xb0b4baff).into()),
("punctuation.delimiter".into(), rgba(0xb0b4baff).into()),
("punctuation.list_marker".into(), rgba(0x6fb8ffff).into()),
("punctuation.special".into(), rgba(0x8c323aff).into()),
("string".into(), rgba(0x1ed8a3ff).into()),
("string.escape".into(), rgba(0x8c323aff).into()),
("string.regex".into(), rgba(0xff977dff).into()),
("string.special".into(), rgba(0x8c323aff).into()),
("string.special.symbol".into(), rgba(0x8c323aff).into()),
("tag".into(), rgba(0x8c323aff).into()),
("text.literal".into(), rgba(0x8c323aff).into()),
("title".into(), rgba(0x8c323aff).into()),
("type".into(), rgba(0x8c323aff).into()),
("variable".into(), rgba(0x8c323aff).into()),
("variable.special".into(), rgba(0x8c323aff).into()),
("variant".into(), rgba(0x8c323aff).into()),
],
},
},
},
ThemeVariant {
id: "91a17b19-1e74-487e-b0a0-56e2e5360ab8".into(),
name: "Andromeda Bordered".into(),
appearance: Appearance::Dark,
styles: ThemeStyles {
system: SystemColors {
transparent: rgba(0x00000000).into(),
mac_os_traffic_light_red: rgba(0xec6b5fff).into(),
mac_os_traffic_light_yellow: rgba(0xf3bf4dff).into(),
mac_os_traffic_light_green: rgba(0x61c454ff).into(),
},
colors: ThemeColors {
border: rgba(0x1b1d23ff).into(),
border_variant: rgba(0x1b1d23ff).into(),
border_focused: rgba(0x1b1d23ff).into(),
border_disabled: rgba(0x1b1d23ff).into(),
border_selected: rgba(0x1b1d23ff).into(),
border_transparent: rgba(0x1b1d23ff).into(),
elevated_surface_background: rgba(0x23262eff).into(),
surface_background: rgba(0x23262eff).into(),
background: rgba(0x262933ff).into(),
element_background: rgba(0x00e8c5cc).into(),
element_hover: rgba(0x272a2dff).into(),
element_active: rgba(0x2e3135ff).into(),
element_selected: rgba(0x2e3135ff).into(),
element_disabled: rgba(0xddeaf814).into(),
element_placeholder: rgba(0xb0b4baff).into(),
element_drop_target: rgba(0x1166fb18).into(),
ghost_element_background: rgba(0x00000000).into(),
ghost_element_hover: rgba(0x272a2dff).into(),
ghost_element_active: rgba(0x2e3135ff).into(),
ghost_element_selected: rgba(0x2e3135ff).into(),
ghost_element_disabled: rgba(0xddeaf814).into(),
text: rgba(0xd4cdd8ff).into(),
text_muted: rgba(0xb0b4baff).into(),
text_placeholder: rgba(0x767a83ff).into(),
text_disabled: rgba(0x696e77ff).into(),
text_accent: rgba(0x6fb8ffff).into(),
icon: rgba(0xb0b4baff).into(),
icon_muted: rgba(0x767a83ff).into(),
icon_disabled: rgba(0x696e77ff).into(),
icon_placeholder: rgba(0x767a83ff).into(),
icon_accent: rgba(0x6fb8ffff).into(),
status_bar_background: rgba(0x18191bff).into(),
title_bar_background: rgba(0x18191bff).into(),
toolbar_background: rgba(0x111113ff).into(),
tab_bar_background: rgba(0x18191bff).into(),
tab_inactive_background: rgba(0x23262eff).into(),
tab_active_background: rgba(0x262933ff).into(),
editor_background: rgba(0x111113ff).into(),
editor_subheader_background: rgba(0x18191bff).into(),
editor_active_line: rgba(0xddeaf814).into(),
terminal_background: rgba(0x111113ff).into(),
terminal_ansi_bright_black: rgba(0x000000e6).into(),
terminal_ansi_bright_red: rgba(0xee5d42ff).into(),
terminal_ansi_bright_green: rgba(0x95e072ff).into(),
terminal_ansi_bright_yellow: rgba(0xffe66dff).into(),
terminal_ansi_bright_blue: rgba(0x7bb7ffff).into(),
terminal_ansi_bright_magenta: rgba(0xff00a9ff).into(),
terminal_ansi_bright_cyan: rgba(0x00e8c6ff).into(),
terminal_ansi_bright_white: rgba(0xb0b4baff).into(),
terminal_ansi_black: rgba(0x000000f2).into(),
terminal_ansi_red: rgba(0xee5d42ff).into(),
terminal_ansi_green: rgba(0x95e072ff).into(),
terminal_ansi_yellow: rgba(0xffe66dff).into(),
terminal_ansi_blue: rgba(0x7bb7ffff).into(),
terminal_ansi_magenta: rgba(0xff00a9ff).into(),
terminal_ansi_cyan: rgba(0x00e8c6ff).into(),
terminal_ansi_white: rgba(0xedeef0ff).into(),
},
status: StatusColors {
conflict: rgba(0xff9592ff).into(),
created: rgba(0x70cf82ff).into(),
deleted: rgba(0xff9592ff).into(),
error: rgba(0xff9592ff).into(),
hidden: rgba(0xb0b4baff).into(),
ignored: rgba(0xb0b4baff).into(),
info: rgba(0x6fb8ffff).into(),
modified: rgba(0xf5e147ff).into(),
renamed: rgba(0x6fb8ffff).into(),
success: rgba(0x70cf82ff).into(),
warning: rgba(0xf5e147ff).into(),
},
git: GitStatusColors {
conflict: rgba(0xffa057ff).into(),
created: rgba(0x70cf82ff).into(),
deleted: rgba(0xff9592ff).into(),
ignored: rgba(0xb0b4baff).into(),
modified: rgba(0xf5e147ff).into(),
renamed: rgba(0x6fb8ffff).into(),
},
player: PlayerColors(vec![
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
]),
syntax: SyntaxTheme {
highlights: vec![
("attribute".into(), rgba(0x4ccce6ff).into()),
("boolean".into(), rgba(0xff977dff).into()),
("comment".into(), rgba(0xb0b4baff).into()),
("comment.doc".into(), rgba(0xe0dffeff).into()),
("constant".into(), rgba(0x8c323aff).into()),
("constructor".into(), rgba(0x8c323aff).into()),
("embedded".into(), rgba(0x8c323aff).into()),
("emphasis".into(), rgba(0x8c323aff).into()),
("emphasis.strong".into(), rgba(0x8c323aff).into()),
("enum".into(), rgba(0x8c323aff).into()),
("function".into(), rgba(0x8c323aff).into()),
("hint".into(), rgba(0x8c323aff).into()),
("keyword".into(), rgba(0xffa057ff).into()),
("label".into(), rgba(0x8c323aff).into()),
("link_text".into(), rgba(0x8c323aff).into()),
("link_uri".into(), rgba(0x8c323aff).into()),
("number".into(), rgba(0x8c323aff).into()),
("operator".into(), rgba(0x8c323aff).into()),
("predictive".into(), rgba(0x8c323aff).into()),
("preproc".into(), rgba(0x8c323aff).into()),
("primary".into(), rgba(0x8c323aff).into()),
("property".into(), rgba(0x8c323aff).into()),
("punctuation".into(), rgba(0xb0b4baff).into()),
("punctuation.bracket".into(), rgba(0xb0b4baff).into()),
("punctuation.delimiter".into(), rgba(0xb0b4baff).into()),
("punctuation.list_marker".into(), rgba(0x6fb8ffff).into()),
("punctuation.special".into(), rgba(0x8c323aff).into()),
("string".into(), rgba(0x1ed8a3ff).into()),
("string.escape".into(), rgba(0x8c323aff).into()),
("string.regex".into(), rgba(0xff977dff).into()),
("string.special".into(), rgba(0x8c323aff).into()),
("string.special.symbol".into(), rgba(0x8c323aff).into()),
("tag".into(), rgba(0x8c323aff).into()),
("text.literal".into(), rgba(0x8c323aff).into()),
("title".into(), rgba(0x8c323aff).into()),
("type".into(), rgba(0x8c323aff).into()),
("variable".into(), rgba(0x8c323aff).into()),
("variable.special".into(), rgba(0x8c323aff).into()),
("variant".into(), rgba(0x8c323aff).into()),
],
},
},
},
],
scales: default_color_scales(),
}
}

View file

@ -0,0 +1,491 @@
use gpui::rgba;
use crate::{
default_color_scales, Appearance, GitStatusColors, PlayerColor, PlayerColors, StatusColors,
SyntaxTheme, SystemColors, ThemeColors, ThemeFamily, ThemeStyles, ThemeVariant,
};
pub fn ayu() -> ThemeFamily {
ThemeFamily {
id: "5ace5bd5-0231-4f26-a69f-40a96dd4163e".into(),
name: "Ayu".into(),
author: "dempfi (Ike Ku)".into(),
themes: vec![
ThemeVariant {
id: "7781d65c-4575-421d-af3c-061ab0b0478a".into(),
name: "Ayu Light".into(),
appearance: Appearance::Light,
styles: ThemeStyles {
system: SystemColors {
transparent: rgba(0x00000000).into(),
mac_os_traffic_light_red: rgba(0xec6b5fff).into(),
mac_os_traffic_light_yellow: rgba(0xf3bf4dff).into(),
mac_os_traffic_light_green: rgba(0x61c454ff).into(),
},
colors: ThemeColors {
border: rgba(0x6b7d8f1f).into(),
border_variant: rgba(0x6b7d8f1f).into(),
border_focused: rgba(0x6b7d8f1f).into(),
border_disabled: rgba(0x6b7d8f1f).into(),
border_selected: rgba(0x6b7d8f1f).into(),
border_transparent: rgba(0x6b7d8f1f).into(),
elevated_surface_background: rgba(0xf8f9faff).into(),
surface_background: rgba(0xf8f9faff).into(),
background: rgba(0xf8f9faff).into(),
element_background: rgba(0xffaa32ff).into(),
element_hover: rgba(0xe8e8ecff).into(),
element_active: rgba(0xe0e1e6ff).into(),
element_selected: rgba(0xe0e1e6ff).into(),
element_disabled: rgba(0x0000320f).into(),
element_placeholder: rgba(0x60646cff).into(),
element_drop_target: rgba(0x008bff0b).into(),
ghost_element_background: rgba(0x00000000).into(),
ghost_element_hover: rgba(0xe8e8ecff).into(),
ghost_element_active: rgba(0xe0e1e6ff).into(),
ghost_element_selected: rgba(0xe0e1e6ff).into(),
ghost_element_disabled: rgba(0x0000320f).into(),
text: rgba(0x8a9199ff).into(),
text_muted: rgba(0x60646cff).into(),
text_placeholder: rgba(0x80838dff).into(),
text_disabled: rgba(0x8b8d98ff).into(),
text_accent: rgba(0x0c73ceff).into(),
icon: rgba(0x60646cff).into(),
icon_muted: rgba(0x80838dff).into(),
icon_disabled: rgba(0x8b8d98ff).into(),
icon_placeholder: rgba(0x80838dff).into(),
icon_accent: rgba(0x0c73ceff).into(),
status_bar_background: rgba(0xf9f9fbff).into(),
title_bar_background: rgba(0xf9f9fbff).into(),
toolbar_background: rgba(0xfcfcfdff).into(),
tab_bar_background: rgba(0xf9f9fbff).into(),
tab_inactive_background: rgba(0xf8f9faff).into(),
tab_active_background: rgba(0xf8f9faff).into(),
editor_background: rgba(0xfcfcfdff).into(),
editor_subheader_background: rgba(0xf9f9fbff).into(),
editor_active_line: rgba(0x0000320f).into(),
terminal_background: rgba(0xf8f9faff).into(),
terminal_ansi_bright_black: rgba(0x686868ff).into(),
terminal_ansi_bright_red: rgba(0xef7070ff).into(),
terminal_ansi_bright_green: rgba(0x86b300ff).into(),
terminal_ansi_bright_yellow: rgba(0xf2ad48ff).into(),
terminal_ansi_bright_blue: rgba(0x389ee6ff).into(),
terminal_ansi_bright_magenta: rgba(0xa37accff).into(),
terminal_ansi_bright_cyan: rgba(0x4bbf98ff).into(),
terminal_ansi_bright_white: rgba(0xd1d1d1ff).into(),
terminal_ansi_black: rgba(0x000000ff).into(),
terminal_ansi_red: rgba(0xea6c6dff).into(),
terminal_ansi_green: rgba(0x6cbf43ff).into(),
terminal_ansi_yellow: rgba(0xeca944ff).into(),
terminal_ansi_blue: rgba(0x3198e1ff).into(),
terminal_ansi_magenta: rgba(0x9e75c7ff).into(),
terminal_ansi_cyan: rgba(0x46ba94ff).into(),
terminal_ansi_white: rgba(0xc7c7c7ff).into(),
},
status: StatusColors {
conflict: rgba(0xff9592ff).into(),
created: rgba(0x70cf82ff).into(),
deleted: rgba(0xff9592ff).into(),
error: rgba(0xff9592ff).into(),
hidden: rgba(0xb0b4baff).into(),
ignored: rgba(0xb0b4baff).into(),
info: rgba(0x6fb8ffff).into(),
modified: rgba(0xf5e147ff).into(),
renamed: rgba(0x6fb8ffff).into(),
success: rgba(0x70cf82ff).into(),
warning: rgba(0xf5e147ff).into(),
},
git: GitStatusColors {
conflict: rgba(0xffa057ff).into(),
created: rgba(0x70cf82ff).into(),
deleted: rgba(0xff9592ff).into(),
ignored: rgba(0xb0b4baff).into(),
modified: rgba(0xf5e147ff).into(),
renamed: rgba(0x6fb8ffff).into(),
},
player: PlayerColors(vec![
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
]),
syntax: SyntaxTheme {
highlights: vec![
("attribute".into(), rgba(0x4ccce6ff).into()),
("boolean".into(), rgba(0xff977dff).into()),
("comment".into(), rgba(0xb0b4baff).into()),
("comment.doc".into(), rgba(0xe0dffeff).into()),
("constant".into(), rgba(0x8c323aff).into()),
("constructor".into(), rgba(0x8c323aff).into()),
("embedded".into(), rgba(0x8c323aff).into()),
("emphasis".into(), rgba(0x8c323aff).into()),
("emphasis.strong".into(), rgba(0x8c323aff).into()),
("enum".into(), rgba(0x8c323aff).into()),
("function".into(), rgba(0x8c323aff).into()),
("hint".into(), rgba(0x8c323aff).into()),
("keyword".into(), rgba(0xffa057ff).into()),
("label".into(), rgba(0x8c323aff).into()),
("link_text".into(), rgba(0x8c323aff).into()),
("link_uri".into(), rgba(0x8c323aff).into()),
("number".into(), rgba(0x8c323aff).into()),
("operator".into(), rgba(0x8c323aff).into()),
("predictive".into(), rgba(0x8c323aff).into()),
("preproc".into(), rgba(0x8c323aff).into()),
("primary".into(), rgba(0x8c323aff).into()),
("property".into(), rgba(0x8c323aff).into()),
("punctuation".into(), rgba(0xb0b4baff).into()),
("punctuation.bracket".into(), rgba(0xb0b4baff).into()),
("punctuation.delimiter".into(), rgba(0xb0b4baff).into()),
("punctuation.list_marker".into(), rgba(0x6fb8ffff).into()),
("punctuation.special".into(), rgba(0x8c323aff).into()),
("string".into(), rgba(0x1ed8a3ff).into()),
("string.escape".into(), rgba(0x8c323aff).into()),
("string.regex".into(), rgba(0xff977dff).into()),
("string.special".into(), rgba(0x8c323aff).into()),
("string.special.symbol".into(), rgba(0x8c323aff).into()),
("tag".into(), rgba(0x8c323aff).into()),
("text.literal".into(), rgba(0x8c323aff).into()),
("title".into(), rgba(0x8c323aff).into()),
("type".into(), rgba(0x8c323aff).into()),
("variable".into(), rgba(0x8c323aff).into()),
("variable.special".into(), rgba(0x8c323aff).into()),
("variant".into(), rgba(0x8c323aff).into()),
],
},
},
},
ThemeVariant {
id: "68066666-5e56-4937-9434-510ffd0fe05f".into(),
name: "Ayu Mirage".into(),
appearance: Appearance::Dark,
styles: ThemeStyles {
system: SystemColors {
transparent: rgba(0x00000000).into(),
mac_os_traffic_light_red: rgba(0xec6b5fff).into(),
mac_os_traffic_light_yellow: rgba(0xf3bf4dff).into(),
mac_os_traffic_light_green: rgba(0x61c454ff).into(),
},
colors: ThemeColors {
border: rgba(0x171a24ff).into(),
border_variant: rgba(0x171a24ff).into(),
border_focused: rgba(0x171a24ff).into(),
border_disabled: rgba(0x171a24ff).into(),
border_selected: rgba(0x171a24ff).into(),
border_transparent: rgba(0x171a24ff).into(),
elevated_surface_background: rgba(0x1f2430ff).into(),
surface_background: rgba(0x1f2430ff).into(),
background: rgba(0x1f2430ff).into(),
element_background: rgba(0xffcb65ff).into(),
element_hover: rgba(0x272a2dff).into(),
element_active: rgba(0x2e3135ff).into(),
element_selected: rgba(0x2e3135ff).into(),
element_disabled: rgba(0xddeaf814).into(),
element_placeholder: rgba(0xb0b4baff).into(),
element_drop_target: rgba(0x1166fb18).into(),
ghost_element_background: rgba(0x00000000).into(),
ghost_element_hover: rgba(0x272a2dff).into(),
ghost_element_active: rgba(0x2e3135ff).into(),
ghost_element_selected: rgba(0x2e3135ff).into(),
ghost_element_disabled: rgba(0xddeaf814).into(),
text: rgba(0x707a8cff).into(),
text_muted: rgba(0xb0b4baff).into(),
text_placeholder: rgba(0x767a83ff).into(),
text_disabled: rgba(0x696e77ff).into(),
text_accent: rgba(0x6fb8ffff).into(),
icon: rgba(0xb0b4baff).into(),
icon_muted: rgba(0x767a83ff).into(),
icon_disabled: rgba(0x696e77ff).into(),
icon_placeholder: rgba(0x767a83ff).into(),
icon_accent: rgba(0x6fb8ffff).into(),
status_bar_background: rgba(0x18191bff).into(),
title_bar_background: rgba(0x18191bff).into(),
toolbar_background: rgba(0x111113ff).into(),
tab_bar_background: rgba(0x18191bff).into(),
tab_inactive_background: rgba(0x1f2430ff).into(),
tab_active_background: rgba(0x1f2430ff).into(),
editor_background: rgba(0x111113ff).into(),
editor_subheader_background: rgba(0x18191bff).into(),
editor_active_line: rgba(0xddeaf814).into(),
terminal_background: rgba(0x1f2430ff).into(),
terminal_ansi_bright_black: rgba(0x686868ff).into(),
terminal_ansi_bright_red: rgba(0xf18678ff).into(),
terminal_ansi_bright_green: rgba(0xd4fe7fff).into(),
terminal_ansi_bright_yellow: rgba(0xffd173ff).into(),
terminal_ansi_bright_blue: rgba(0x73cfffff).into(),
terminal_ansi_bright_magenta: rgba(0xdfbfffff).into(),
terminal_ansi_bright_cyan: rgba(0x95e6cbff).into(),
terminal_ansi_bright_white: rgba(0xffffffff).into(),
terminal_ansi_black: rgba(0x171a24ff).into(),
terminal_ansi_red: rgba(0xed8173ff).into(),
terminal_ansi_green: rgba(0x86d96bff).into(),
terminal_ansi_yellow: rgba(0xfacc6eff).into(),
terminal_ansi_blue: rgba(0x6ccafaff).into(),
terminal_ansi_magenta: rgba(0xdabafaff).into(),
terminal_ansi_cyan: rgba(0x90e1c6ff).into(),
terminal_ansi_white: rgba(0xc7c7c7ff).into(),
},
status: StatusColors {
conflict: rgba(0xff9592ff).into(),
created: rgba(0x70cf82ff).into(),
deleted: rgba(0xff9592ff).into(),
error: rgba(0xff9592ff).into(),
hidden: rgba(0xb0b4baff).into(),
ignored: rgba(0xb0b4baff).into(),
info: rgba(0x6fb8ffff).into(),
modified: rgba(0xf5e147ff).into(),
renamed: rgba(0x6fb8ffff).into(),
success: rgba(0x70cf82ff).into(),
warning: rgba(0xf5e147ff).into(),
},
git: GitStatusColors {
conflict: rgba(0xffa057ff).into(),
created: rgba(0x70cf82ff).into(),
deleted: rgba(0xff9592ff).into(),
ignored: rgba(0xb0b4baff).into(),
modified: rgba(0xf5e147ff).into(),
renamed: rgba(0x6fb8ffff).into(),
},
player: PlayerColors(vec![
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
]),
syntax: SyntaxTheme {
highlights: vec![
("attribute".into(), rgba(0x4ccce6ff).into()),
("boolean".into(), rgba(0xff977dff).into()),
("comment".into(), rgba(0xb0b4baff).into()),
("comment.doc".into(), rgba(0xe0dffeff).into()),
("constant".into(), rgba(0x8c323aff).into()),
("constructor".into(), rgba(0x8c323aff).into()),
("embedded".into(), rgba(0x8c323aff).into()),
("emphasis".into(), rgba(0x8c323aff).into()),
("emphasis.strong".into(), rgba(0x8c323aff).into()),
("enum".into(), rgba(0x8c323aff).into()),
("function".into(), rgba(0x8c323aff).into()),
("hint".into(), rgba(0x8c323aff).into()),
("keyword".into(), rgba(0xffa057ff).into()),
("label".into(), rgba(0x8c323aff).into()),
("link_text".into(), rgba(0x8c323aff).into()),
("link_uri".into(), rgba(0x8c323aff).into()),
("number".into(), rgba(0x8c323aff).into()),
("operator".into(), rgba(0x8c323aff).into()),
("predictive".into(), rgba(0x8c323aff).into()),
("preproc".into(), rgba(0x8c323aff).into()),
("primary".into(), rgba(0x8c323aff).into()),
("property".into(), rgba(0x8c323aff).into()),
("punctuation".into(), rgba(0xb0b4baff).into()),
("punctuation.bracket".into(), rgba(0xb0b4baff).into()),
("punctuation.delimiter".into(), rgba(0xb0b4baff).into()),
("punctuation.list_marker".into(), rgba(0x6fb8ffff).into()),
("punctuation.special".into(), rgba(0x8c323aff).into()),
("string".into(), rgba(0x1ed8a3ff).into()),
("string.escape".into(), rgba(0x8c323aff).into()),
("string.regex".into(), rgba(0xff977dff).into()),
("string.special".into(), rgba(0x8c323aff).into()),
("string.special.symbol".into(), rgba(0x8c323aff).into()),
("tag".into(), rgba(0x8c323aff).into()),
("text.literal".into(), rgba(0x8c323aff).into()),
("title".into(), rgba(0x8c323aff).into()),
("type".into(), rgba(0x8c323aff).into()),
("variable".into(), rgba(0x8c323aff).into()),
("variable.special".into(), rgba(0x8c323aff).into()),
("variant".into(), rgba(0x8c323aff).into()),
],
},
},
},
ThemeVariant {
id: "d4f949b8-e5b9-4337-a52e-2ed1752a6c4f".into(),
name: "Ayu Dark".into(),
appearance: Appearance::Dark,
styles: ThemeStyles {
system: SystemColors {
transparent: rgba(0x00000000).into(),
mac_os_traffic_light_red: rgba(0xec6b5fff).into(),
mac_os_traffic_light_yellow: rgba(0xf3bf4dff).into(),
mac_os_traffic_light_green: rgba(0x61c454ff).into(),
},
colors: ThemeColors {
border: rgba(0x1e232bff).into(),
border_variant: rgba(0x1e232bff).into(),
border_focused: rgba(0x1e232bff).into(),
border_disabled: rgba(0x1e232bff).into(),
border_selected: rgba(0x1e232bff).into(),
border_transparent: rgba(0x1e232bff).into(),
elevated_surface_background: rgba(0x0b0e14ff).into(),
surface_background: rgba(0x0b0e14ff).into(),
background: rgba(0x0b0e14ff).into(),
element_background: rgba(0xe6b450ff).into(),
element_hover: rgba(0x272a2dff).into(),
element_active: rgba(0x2e3135ff).into(),
element_selected: rgba(0x2e3135ff).into(),
element_disabled: rgba(0xddeaf814).into(),
element_placeholder: rgba(0xb0b4baff).into(),
element_drop_target: rgba(0x1166fb18).into(),
ghost_element_background: rgba(0x00000000).into(),
ghost_element_hover: rgba(0x272a2dff).into(),
ghost_element_active: rgba(0x2e3135ff).into(),
ghost_element_selected: rgba(0x2e3135ff).into(),
ghost_element_disabled: rgba(0xddeaf814).into(),
text: rgba(0x565b66ff).into(),
text_muted: rgba(0xb0b4baff).into(),
text_placeholder: rgba(0x767a83ff).into(),
text_disabled: rgba(0x696e77ff).into(),
text_accent: rgba(0x6fb8ffff).into(),
icon: rgba(0xb0b4baff).into(),
icon_muted: rgba(0x767a83ff).into(),
icon_disabled: rgba(0x696e77ff).into(),
icon_placeholder: rgba(0x767a83ff).into(),
icon_accent: rgba(0x6fb8ffff).into(),
status_bar_background: rgba(0x18191bff).into(),
title_bar_background: rgba(0x18191bff).into(),
toolbar_background: rgba(0x111113ff).into(),
tab_bar_background: rgba(0x18191bff).into(),
tab_inactive_background: rgba(0x0b0e14ff).into(),
tab_active_background: rgba(0x0b0e14ff).into(),
editor_background: rgba(0x111113ff).into(),
editor_subheader_background: rgba(0x18191bff).into(),
editor_active_line: rgba(0xddeaf814).into(),
terminal_background: rgba(0x0b0e14ff).into(),
terminal_ansi_bright_black: rgba(0x686868ff).into(),
terminal_ansi_bright_red: rgba(0xef7077ff).into(),
terminal_ansi_bright_green: rgba(0xa9d94bff).into(),
terminal_ansi_bright_yellow: rgba(0xffb353ff).into(),
terminal_ansi_bright_blue: rgba(0x59c2ffff).into(),
terminal_ansi_bright_magenta: rgba(0xd2a6ffff).into(),
terminal_ansi_bright_cyan: rgba(0x95e6cbff).into(),
terminal_ansi_bright_white: rgba(0xffffffff).into(),
terminal_ansi_black: rgba(0x1e232bff).into(),
terminal_ansi_red: rgba(0xea6c72ff).into(),
terminal_ansi_green: rgba(0x7ed962ff).into(),
terminal_ansi_yellow: rgba(0xf9af4fff).into(),
terminal_ansi_blue: rgba(0x52bdfaff).into(),
terminal_ansi_magenta: rgba(0xcca1faff).into(),
terminal_ansi_cyan: rgba(0x90e1c6ff).into(),
terminal_ansi_white: rgba(0xc7c7c7ff).into(),
},
status: StatusColors {
conflict: rgba(0xff9592ff).into(),
created: rgba(0x70cf82ff).into(),
deleted: rgba(0xff9592ff).into(),
error: rgba(0xff9592ff).into(),
hidden: rgba(0xb0b4baff).into(),
ignored: rgba(0xb0b4baff).into(),
info: rgba(0x6fb8ffff).into(),
modified: rgba(0xf5e147ff).into(),
renamed: rgba(0x6fb8ffff).into(),
success: rgba(0x70cf82ff).into(),
warning: rgba(0xf5e147ff).into(),
},
git: GitStatusColors {
conflict: rgba(0xffa057ff).into(),
created: rgba(0x70cf82ff).into(),
deleted: rgba(0xff9592ff).into(),
ignored: rgba(0xb0b4baff).into(),
modified: rgba(0xf5e147ff).into(),
renamed: rgba(0x6fb8ffff).into(),
},
player: PlayerColors(vec![
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
]),
syntax: SyntaxTheme {
highlights: vec![
("attribute".into(), rgba(0x4ccce6ff).into()),
("boolean".into(), rgba(0xff977dff).into()),
("comment".into(), rgba(0xb0b4baff).into()),
("comment.doc".into(), rgba(0xe0dffeff).into()),
("constant".into(), rgba(0x8c323aff).into()),
("constructor".into(), rgba(0x8c323aff).into()),
("embedded".into(), rgba(0x8c323aff).into()),
("emphasis".into(), rgba(0x8c323aff).into()),
("emphasis.strong".into(), rgba(0x8c323aff).into()),
("enum".into(), rgba(0x8c323aff).into()),
("function".into(), rgba(0x8c323aff).into()),
("hint".into(), rgba(0x8c323aff).into()),
("keyword".into(), rgba(0xffa057ff).into()),
("label".into(), rgba(0x8c323aff).into()),
("link_text".into(), rgba(0x8c323aff).into()),
("link_uri".into(), rgba(0x8c323aff).into()),
("number".into(), rgba(0x8c323aff).into()),
("operator".into(), rgba(0x8c323aff).into()),
("predictive".into(), rgba(0x8c323aff).into()),
("preproc".into(), rgba(0x8c323aff).into()),
("primary".into(), rgba(0x8c323aff).into()),
("property".into(), rgba(0x8c323aff).into()),
("punctuation".into(), rgba(0xb0b4baff).into()),
("punctuation.bracket".into(), rgba(0xb0b4baff).into()),
("punctuation.delimiter".into(), rgba(0xb0b4baff).into()),
("punctuation.list_marker".into(), rgba(0x6fb8ffff).into()),
("punctuation.special".into(), rgba(0x8c323aff).into()),
("string".into(), rgba(0x1ed8a3ff).into()),
("string.escape".into(), rgba(0x8c323aff).into()),
("string.regex".into(), rgba(0xff977dff).into()),
("string.special".into(), rgba(0x8c323aff).into()),
("string.special.symbol".into(), rgba(0x8c323aff).into()),
("tag".into(), rgba(0x8c323aff).into()),
("text.literal".into(), rgba(0x8c323aff).into()),
("title".into(), rgba(0x8c323aff).into()),
("type".into(), rgba(0x8c323aff).into()),
("variable".into(), rgba(0x8c323aff).into()),
("variable.special".into(), rgba(0x8c323aff).into()),
("variant".into(), rgba(0x8c323aff).into()),
],
},
},
},
],
scales: default_color_scales(),
}
}

View file

@ -0,0 +1,173 @@
use gpui::rgba;
use crate::{
default_color_scales, Appearance, GitStatusColors, PlayerColor, PlayerColors, StatusColors,
SyntaxTheme, SystemColors, ThemeColors, ThemeFamily, ThemeStyles, ThemeVariant,
};
pub fn dracula() -> ThemeFamily {
ThemeFamily {
id: "20b9a8c0-0b74-483b-bed2-be7a053e1321".into(),
name: "Dracula".into(),
author: "Zeno Rocha".into(),
themes: vec![ThemeVariant {
id: "02f5624f-9b0a-48e0-8897-4557adc8f104".into(),
name: "Dracula".into(),
appearance: Appearance::Dark,
styles: ThemeStyles {
system: SystemColors {
transparent: rgba(0x00000000).into(),
mac_os_traffic_light_red: rgba(0xec6b5fff).into(),
mac_os_traffic_light_yellow: rgba(0xf3bf4dff).into(),
mac_os_traffic_light_green: rgba(0x61c454ff).into(),
},
colors: ThemeColors {
border: rgba(0xbd93f9ff).into(),
border_variant: rgba(0xbd93f9ff).into(),
border_focused: rgba(0xbd93f9ff).into(),
border_disabled: rgba(0xbd93f9ff).into(),
border_selected: rgba(0xbd93f9ff).into(),
border_transparent: rgba(0xbd93f9ff).into(),
elevated_surface_background: rgba(0x282a35ff).into(),
surface_background: rgba(0x282a35ff).into(),
background: rgba(0x282a35ff).into(),
element_background: rgba(0x44475aff).into(),
element_hover: rgba(0x272a2dff).into(),
element_active: rgba(0x2e3135ff).into(),
element_selected: rgba(0x2e3135ff).into(),
element_disabled: rgba(0xddeaf814).into(),
element_placeholder: rgba(0xb0b4baff).into(),
element_drop_target: rgba(0x1166fb18).into(),
ghost_element_background: rgba(0x00000000).into(),
ghost_element_hover: rgba(0x272a2dff).into(),
ghost_element_active: rgba(0x2e3135ff).into(),
ghost_element_selected: rgba(0x2e3135ff).into(),
ghost_element_disabled: rgba(0xddeaf814).into(),
text: rgba(0xf8f8f2ff).into(),
text_muted: rgba(0xb0b4baff).into(),
text_placeholder: rgba(0x767a83ff).into(),
text_disabled: rgba(0x696e77ff).into(),
text_accent: rgba(0x6fb8ffff).into(),
icon: rgba(0xb0b4baff).into(),
icon_muted: rgba(0x767a83ff).into(),
icon_disabled: rgba(0x696e77ff).into(),
icon_placeholder: rgba(0x767a83ff).into(),
icon_accent: rgba(0x6fb8ffff).into(),
status_bar_background: rgba(0x18191bff).into(),
title_bar_background: rgba(0x18191bff).into(),
toolbar_background: rgba(0x111113ff).into(),
tab_bar_background: rgba(0x18191bff).into(),
tab_inactive_background: rgba(0x21222cff).into(),
tab_active_background: rgba(0x282a35ff).into(),
editor_background: rgba(0x111113ff).into(),
editor_subheader_background: rgba(0x18191bff).into(),
editor_active_line: rgba(0xddeaf814).into(),
terminal_background: rgba(0x282a35ff).into(),
terminal_ansi_bright_black: rgba(0x6272a4ff).into(),
terminal_ansi_bright_red: rgba(0xff6d6dff).into(),
terminal_ansi_bright_green: rgba(0x69ff94ff).into(),
terminal_ansi_bright_yellow: rgba(0xffffa5ff).into(),
terminal_ansi_bright_blue: rgba(0xd6abfeff).into(),
terminal_ansi_bright_magenta: rgba(0xff92dfff).into(),
terminal_ansi_bright_cyan: rgba(0xa3fefeff).into(),
terminal_ansi_bright_white: rgba(0xffffffff).into(),
terminal_ansi_black: rgba(0x21222cff).into(),
terminal_ansi_red: rgba(0xff5555ff).into(),
terminal_ansi_green: rgba(0x50fa7bff).into(),
terminal_ansi_yellow: rgba(0xf1fa8cff).into(),
terminal_ansi_blue: rgba(0xbd93f9ff).into(),
terminal_ansi_magenta: rgba(0xff79c6ff).into(),
terminal_ansi_cyan: rgba(0x8be9fdff).into(),
terminal_ansi_white: rgba(0xf8f8f2ff).into(),
},
status: StatusColors {
conflict: rgba(0xff9592ff).into(),
created: rgba(0x70cf82ff).into(),
deleted: rgba(0xff9592ff).into(),
error: rgba(0xff9592ff).into(),
hidden: rgba(0xb0b4baff).into(),
ignored: rgba(0xb0b4baff).into(),
info: rgba(0x6fb8ffff).into(),
modified: rgba(0xf5e147ff).into(),
renamed: rgba(0x6fb8ffff).into(),
success: rgba(0x70cf82ff).into(),
warning: rgba(0xf5e147ff).into(),
},
git: GitStatusColors {
conflict: rgba(0xffa057ff).into(),
created: rgba(0x70cf82ff).into(),
deleted: rgba(0xff9592ff).into(),
ignored: rgba(0xb0b4baff).into(),
modified: rgba(0xf5e147ff).into(),
renamed: rgba(0x6fb8ffff).into(),
},
player: PlayerColors(vec![
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
]),
syntax: SyntaxTheme {
highlights: vec![
("attribute".into(), rgba(0x4ccce6ff).into()),
("boolean".into(), rgba(0xff977dff).into()),
("comment".into(), rgba(0xb0b4baff).into()),
("comment.doc".into(), rgba(0xe0dffeff).into()),
("constant".into(), rgba(0x8c323aff).into()),
("constructor".into(), rgba(0x8c323aff).into()),
("embedded".into(), rgba(0x8c323aff).into()),
("emphasis".into(), rgba(0x8c323aff).into()),
("emphasis.strong".into(), rgba(0x8c323aff).into()),
("enum".into(), rgba(0x8c323aff).into()),
("function".into(), rgba(0x8c323aff).into()),
("hint".into(), rgba(0x8c323aff).into()),
("keyword".into(), rgba(0xffa057ff).into()),
("label".into(), rgba(0x8c323aff).into()),
("link_text".into(), rgba(0x8c323aff).into()),
("link_uri".into(), rgba(0x8c323aff).into()),
("number".into(), rgba(0x8c323aff).into()),
("operator".into(), rgba(0x8c323aff).into()),
("predictive".into(), rgba(0x8c323aff).into()),
("preproc".into(), rgba(0x8c323aff).into()),
("primary".into(), rgba(0x8c323aff).into()),
("property".into(), rgba(0x8c323aff).into()),
("punctuation".into(), rgba(0xb0b4baff).into()),
("punctuation.bracket".into(), rgba(0xb0b4baff).into()),
("punctuation.delimiter".into(), rgba(0xb0b4baff).into()),
("punctuation.list_marker".into(), rgba(0x6fb8ffff).into()),
("punctuation.special".into(), rgba(0x8c323aff).into()),
("string".into(), rgba(0x1ed8a3ff).into()),
("string.escape".into(), rgba(0x8c323aff).into()),
("string.regex".into(), rgba(0xff977dff).into()),
("string.special".into(), rgba(0x8c323aff).into()),
("string.special.symbol".into(), rgba(0x8c323aff).into()),
("tag".into(), rgba(0x8c323aff).into()),
("text.literal".into(), rgba(0x8c323aff).into()),
("title".into(), rgba(0x8c323aff).into()),
("type".into(), rgba(0x8c323aff).into()),
("variable".into(), rgba(0x8c323aff).into()),
("variable.special".into(), rgba(0x8c323aff).into()),
("variant".into(), rgba(0x8c323aff).into()),
],
},
},
}],
scales: default_color_scales(),
}
}

View file

@ -0,0 +1,965 @@
use gpui::rgba;
use crate::{
default_color_scales, Appearance, GitStatusColors, PlayerColor, PlayerColors, StatusColors,
SyntaxTheme, SystemColors, ThemeColors, ThemeFamily, ThemeStyles, ThemeVariant,
};
pub fn gruvbox() -> ThemeFamily {
ThemeFamily {
id: "c0b7f0e7-f261-4a33-a2bf-baf2e140aac4".into(),
name: "Gruvbox".into(),
author: "morhetz".into(),
themes: vec![
ThemeVariant {
id: "fb9f8f64-372b-4fda-8dbd-d610c97a9691".into(),
name: "Gruvbox Dark Hard".into(),
appearance: Appearance::Dark,
styles: ThemeStyles {
system: SystemColors {
transparent: rgba(0x00000000).into(),
mac_os_traffic_light_red: rgba(0xec6b5fff).into(),
mac_os_traffic_light_yellow: rgba(0xf3bf4dff).into(),
mac_os_traffic_light_green: rgba(0x61c454ff).into(),
},
colors: ThemeColors {
border: rgba(0x3c3836ff).into(),
border_variant: rgba(0x3c3836ff).into(),
border_focused: rgba(0x3c3836ff).into(),
border_disabled: rgba(0x3c3836ff).into(),
border_selected: rgba(0x3c3836ff).into(),
border_transparent: rgba(0x3c3836ff).into(),
elevated_surface_background: rgba(0x18191bff).into(),
surface_background: rgba(0x18191bff).into(),
background: rgba(0x1d2021ff).into(),
element_background: rgba(0x44858780).into(),
element_hover: rgba(0x272a2dff).into(),
element_active: rgba(0x2e3135ff).into(),
element_selected: rgba(0x2e3135ff).into(),
element_disabled: rgba(0xddeaf814).into(),
element_placeholder: rgba(0xb0b4baff).into(),
element_drop_target: rgba(0x1166fb18).into(),
ghost_element_background: rgba(0x00000000).into(),
ghost_element_hover: rgba(0x272a2dff).into(),
ghost_element_active: rgba(0x2e3135ff).into(),
ghost_element_selected: rgba(0x2e3135ff).into(),
ghost_element_disabled: rgba(0xddeaf814).into(),
text: rgba(0xebdbb2ff).into(),
text_muted: rgba(0xb0b4baff).into(),
text_placeholder: rgba(0x767a83ff).into(),
text_disabled: rgba(0x696e77ff).into(),
text_accent: rgba(0x6fb8ffff).into(),
icon: rgba(0xb0b4baff).into(),
icon_muted: rgba(0x767a83ff).into(),
icon_disabled: rgba(0x696e77ff).into(),
icon_placeholder: rgba(0x767a83ff).into(),
icon_accent: rgba(0x6fb8ffff).into(),
status_bar_background: rgba(0x18191bff).into(),
title_bar_background: rgba(0x18191bff).into(),
toolbar_background: rgba(0x111113ff).into(),
tab_bar_background: rgba(0x18191bff).into(),
tab_inactive_background: rgba(0x1d2021ff).into(),
tab_active_background: rgba(0x32302fff).into(),
editor_background: rgba(0x111113ff).into(),
editor_subheader_background: rgba(0x18191bff).into(),
editor_active_line: rgba(0xddeaf814).into(),
terminal_background: rgba(0x1d2021ff).into(),
terminal_ansi_bright_black: rgba(0x928374ff).into(),
terminal_ansi_bright_red: rgba(0xfb4833ff).into(),
terminal_ansi_bright_green: rgba(0xb8bb25ff).into(),
terminal_ansi_bright_yellow: rgba(0xfabd2eff).into(),
terminal_ansi_bright_blue: rgba(0x83a598ff).into(),
terminal_ansi_bright_magenta: rgba(0xd3869bff).into(),
terminal_ansi_bright_cyan: rgba(0x8ec07cff).into(),
terminal_ansi_bright_white: rgba(0xebdbb2ff).into(),
terminal_ansi_black: rgba(0x3c3836ff).into(),
terminal_ansi_red: rgba(0xcc241cff).into(),
terminal_ansi_green: rgba(0x989719ff).into(),
terminal_ansi_yellow: rgba(0xd79920ff).into(),
terminal_ansi_blue: rgba(0x448587ff).into(),
terminal_ansi_magenta: rgba(0xb16185ff).into(),
terminal_ansi_cyan: rgba(0x679d6aff).into(),
terminal_ansi_white: rgba(0xa89984ff).into(),
},
status: StatusColors {
conflict: rgba(0xff9592ff).into(),
created: rgba(0x70cf82ff).into(),
deleted: rgba(0xff9592ff).into(),
error: rgba(0xff9592ff).into(),
hidden: rgba(0xb0b4baff).into(),
ignored: rgba(0xb0b4baff).into(),
info: rgba(0x6fb8ffff).into(),
modified: rgba(0xf5e147ff).into(),
renamed: rgba(0x6fb8ffff).into(),
success: rgba(0x70cf82ff).into(),
warning: rgba(0xf5e147ff).into(),
},
git: GitStatusColors {
conflict: rgba(0xffa057ff).into(),
created: rgba(0x70cf82ff).into(),
deleted: rgba(0xff9592ff).into(),
ignored: rgba(0xb0b4baff).into(),
modified: rgba(0xf5e147ff).into(),
renamed: rgba(0x6fb8ffff).into(),
},
player: PlayerColors(vec![
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
]),
syntax: SyntaxTheme {
highlights: vec![
("attribute".into(), rgba(0x4ccce6ff).into()),
("boolean".into(), rgba(0xff977dff).into()),
("comment".into(), rgba(0xb0b4baff).into()),
("comment.doc".into(), rgba(0xe0dffeff).into()),
("constant".into(), rgba(0x8c323aff).into()),
("constructor".into(), rgba(0x8c323aff).into()),
("embedded".into(), rgba(0x8c323aff).into()),
("emphasis".into(), rgba(0x8c323aff).into()),
("emphasis.strong".into(), rgba(0x8c323aff).into()),
("enum".into(), rgba(0x8c323aff).into()),
("function".into(), rgba(0x8c323aff).into()),
("hint".into(), rgba(0x8c323aff).into()),
("keyword".into(), rgba(0xffa057ff).into()),
("label".into(), rgba(0x8c323aff).into()),
("link_text".into(), rgba(0x8c323aff).into()),
("link_uri".into(), rgba(0x8c323aff).into()),
("number".into(), rgba(0x8c323aff).into()),
("operator".into(), rgba(0x8c323aff).into()),
("predictive".into(), rgba(0x8c323aff).into()),
("preproc".into(), rgba(0x8c323aff).into()),
("primary".into(), rgba(0x8c323aff).into()),
("property".into(), rgba(0x8c323aff).into()),
("punctuation".into(), rgba(0xb0b4baff).into()),
("punctuation.bracket".into(), rgba(0xb0b4baff).into()),
("punctuation.delimiter".into(), rgba(0xb0b4baff).into()),
("punctuation.list_marker".into(), rgba(0x6fb8ffff).into()),
("punctuation.special".into(), rgba(0x8c323aff).into()),
("string".into(), rgba(0x1ed8a3ff).into()),
("string.escape".into(), rgba(0x8c323aff).into()),
("string.regex".into(), rgba(0xff977dff).into()),
("string.special".into(), rgba(0x8c323aff).into()),
("string.special.symbol".into(), rgba(0x8c323aff).into()),
("tag".into(), rgba(0x8c323aff).into()),
("text.literal".into(), rgba(0x8c323aff).into()),
("title".into(), rgba(0x8c323aff).into()),
("type".into(), rgba(0x8c323aff).into()),
("variable".into(), rgba(0x8c323aff).into()),
("variable.special".into(), rgba(0x8c323aff).into()),
("variant".into(), rgba(0x8c323aff).into()),
],
},
},
},
ThemeVariant {
id: "72f0ea45-33bc-49d8-9f52-87540f858fb4".into(),
name: "Gruvbox Dark Medium".into(),
appearance: Appearance::Dark,
styles: ThemeStyles {
system: SystemColors {
transparent: rgba(0x00000000).into(),
mac_os_traffic_light_red: rgba(0xec6b5fff).into(),
mac_os_traffic_light_yellow: rgba(0xf3bf4dff).into(),
mac_os_traffic_light_green: rgba(0x61c454ff).into(),
},
colors: ThemeColors {
border: rgba(0x3c3836ff).into(),
border_variant: rgba(0x3c3836ff).into(),
border_focused: rgba(0x3c3836ff).into(),
border_disabled: rgba(0x3c3836ff).into(),
border_selected: rgba(0x3c3836ff).into(),
border_transparent: rgba(0x3c3836ff).into(),
elevated_surface_background: rgba(0x18191bff).into(),
surface_background: rgba(0x18191bff).into(),
background: rgba(0x282828ff).into(),
element_background: rgba(0x44858780).into(),
element_hover: rgba(0x272a2dff).into(),
element_active: rgba(0x2e3135ff).into(),
element_selected: rgba(0x2e3135ff).into(),
element_disabled: rgba(0xddeaf814).into(),
element_placeholder: rgba(0xb0b4baff).into(),
element_drop_target: rgba(0x1166fb18).into(),
ghost_element_background: rgba(0x00000000).into(),
ghost_element_hover: rgba(0x272a2dff).into(),
ghost_element_active: rgba(0x2e3135ff).into(),
ghost_element_selected: rgba(0x2e3135ff).into(),
ghost_element_disabled: rgba(0xddeaf814).into(),
text: rgba(0xebdbb2ff).into(),
text_muted: rgba(0xb0b4baff).into(),
text_placeholder: rgba(0x767a83ff).into(),
text_disabled: rgba(0x696e77ff).into(),
text_accent: rgba(0x6fb8ffff).into(),
icon: rgba(0xb0b4baff).into(),
icon_muted: rgba(0x767a83ff).into(),
icon_disabled: rgba(0x696e77ff).into(),
icon_placeholder: rgba(0x767a83ff).into(),
icon_accent: rgba(0x6fb8ffff).into(),
status_bar_background: rgba(0x18191bff).into(),
title_bar_background: rgba(0x18191bff).into(),
toolbar_background: rgba(0x111113ff).into(),
tab_bar_background: rgba(0x18191bff).into(),
tab_inactive_background: rgba(0x282828ff).into(),
tab_active_background: rgba(0x3c3836ff).into(),
editor_background: rgba(0x111113ff).into(),
editor_subheader_background: rgba(0x18191bff).into(),
editor_active_line: rgba(0xddeaf814).into(),
terminal_background: rgba(0x282828ff).into(),
terminal_ansi_bright_black: rgba(0x928374ff).into(),
terminal_ansi_bright_red: rgba(0xfb4833ff).into(),
terminal_ansi_bright_green: rgba(0xb8bb25ff).into(),
terminal_ansi_bright_yellow: rgba(0xfabd2eff).into(),
terminal_ansi_bright_blue: rgba(0x83a598ff).into(),
terminal_ansi_bright_magenta: rgba(0xd3869bff).into(),
terminal_ansi_bright_cyan: rgba(0x8ec07cff).into(),
terminal_ansi_bright_white: rgba(0xebdbb2ff).into(),
terminal_ansi_black: rgba(0x3c3836ff).into(),
terminal_ansi_red: rgba(0xcc241cff).into(),
terminal_ansi_green: rgba(0x989719ff).into(),
terminal_ansi_yellow: rgba(0xd79920ff).into(),
terminal_ansi_blue: rgba(0x448587ff).into(),
terminal_ansi_magenta: rgba(0xb16185ff).into(),
terminal_ansi_cyan: rgba(0x679d6aff).into(),
terminal_ansi_white: rgba(0xa89984ff).into(),
},
status: StatusColors {
conflict: rgba(0xff9592ff).into(),
created: rgba(0x70cf82ff).into(),
deleted: rgba(0xff9592ff).into(),
error: rgba(0xff9592ff).into(),
hidden: rgba(0xb0b4baff).into(),
ignored: rgba(0xb0b4baff).into(),
info: rgba(0x6fb8ffff).into(),
modified: rgba(0xf5e147ff).into(),
renamed: rgba(0x6fb8ffff).into(),
success: rgba(0x70cf82ff).into(),
warning: rgba(0xf5e147ff).into(),
},
git: GitStatusColors {
conflict: rgba(0xffa057ff).into(),
created: rgba(0x70cf82ff).into(),
deleted: rgba(0xff9592ff).into(),
ignored: rgba(0xb0b4baff).into(),
modified: rgba(0xf5e147ff).into(),
renamed: rgba(0x6fb8ffff).into(),
},
player: PlayerColors(vec![
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
]),
syntax: SyntaxTheme {
highlights: vec![
("attribute".into(), rgba(0x4ccce6ff).into()),
("boolean".into(), rgba(0xff977dff).into()),
("comment".into(), rgba(0xb0b4baff).into()),
("comment.doc".into(), rgba(0xe0dffeff).into()),
("constant".into(), rgba(0x8c323aff).into()),
("constructor".into(), rgba(0x8c323aff).into()),
("embedded".into(), rgba(0x8c323aff).into()),
("emphasis".into(), rgba(0x8c323aff).into()),
("emphasis.strong".into(), rgba(0x8c323aff).into()),
("enum".into(), rgba(0x8c323aff).into()),
("function".into(), rgba(0x8c323aff).into()),
("hint".into(), rgba(0x8c323aff).into()),
("keyword".into(), rgba(0xffa057ff).into()),
("label".into(), rgba(0x8c323aff).into()),
("link_text".into(), rgba(0x8c323aff).into()),
("link_uri".into(), rgba(0x8c323aff).into()),
("number".into(), rgba(0x8c323aff).into()),
("operator".into(), rgba(0x8c323aff).into()),
("predictive".into(), rgba(0x8c323aff).into()),
("preproc".into(), rgba(0x8c323aff).into()),
("primary".into(), rgba(0x8c323aff).into()),
("property".into(), rgba(0x8c323aff).into()),
("punctuation".into(), rgba(0xb0b4baff).into()),
("punctuation.bracket".into(), rgba(0xb0b4baff).into()),
("punctuation.delimiter".into(), rgba(0xb0b4baff).into()),
("punctuation.list_marker".into(), rgba(0x6fb8ffff).into()),
("punctuation.special".into(), rgba(0x8c323aff).into()),
("string".into(), rgba(0x1ed8a3ff).into()),
("string.escape".into(), rgba(0x8c323aff).into()),
("string.regex".into(), rgba(0xff977dff).into()),
("string.special".into(), rgba(0x8c323aff).into()),
("string.special.symbol".into(), rgba(0x8c323aff).into()),
("tag".into(), rgba(0x8c323aff).into()),
("text.literal".into(), rgba(0x8c323aff).into()),
("title".into(), rgba(0x8c323aff).into()),
("type".into(), rgba(0x8c323aff).into()),
("variable".into(), rgba(0x8c323aff).into()),
("variable.special".into(), rgba(0x8c323aff).into()),
("variant".into(), rgba(0x8c323aff).into()),
],
},
},
},
ThemeVariant {
id: "5ea1cdf8-6ed0-4e54-b44a-14c6634701cf".into(),
name: "Gruvbox Dark Soft".into(),
appearance: Appearance::Dark,
styles: ThemeStyles {
system: SystemColors {
transparent: rgba(0x00000000).into(),
mac_os_traffic_light_red: rgba(0xec6b5fff).into(),
mac_os_traffic_light_yellow: rgba(0xf3bf4dff).into(),
mac_os_traffic_light_green: rgba(0x61c454ff).into(),
},
colors: ThemeColors {
border: rgba(0x3c3836ff).into(),
border_variant: rgba(0x3c3836ff).into(),
border_focused: rgba(0x3c3836ff).into(),
border_disabled: rgba(0x3c3836ff).into(),
border_selected: rgba(0x3c3836ff).into(),
border_transparent: rgba(0x3c3836ff).into(),
elevated_surface_background: rgba(0x18191bff).into(),
surface_background: rgba(0x18191bff).into(),
background: rgba(0x32302fff).into(),
element_background: rgba(0x44858780).into(),
element_hover: rgba(0x272a2dff).into(),
element_active: rgba(0x2e3135ff).into(),
element_selected: rgba(0x2e3135ff).into(),
element_disabled: rgba(0xddeaf814).into(),
element_placeholder: rgba(0xb0b4baff).into(),
element_drop_target: rgba(0x1166fb18).into(),
ghost_element_background: rgba(0x00000000).into(),
ghost_element_hover: rgba(0x272a2dff).into(),
ghost_element_active: rgba(0x2e3135ff).into(),
ghost_element_selected: rgba(0x2e3135ff).into(),
ghost_element_disabled: rgba(0xddeaf814).into(),
text: rgba(0xebdbb2ff).into(),
text_muted: rgba(0xb0b4baff).into(),
text_placeholder: rgba(0x767a83ff).into(),
text_disabled: rgba(0x696e77ff).into(),
text_accent: rgba(0x6fb8ffff).into(),
icon: rgba(0xb0b4baff).into(),
icon_muted: rgba(0x767a83ff).into(),
icon_disabled: rgba(0x696e77ff).into(),
icon_placeholder: rgba(0x767a83ff).into(),
icon_accent: rgba(0x6fb8ffff).into(),
status_bar_background: rgba(0x18191bff).into(),
title_bar_background: rgba(0x18191bff).into(),
toolbar_background: rgba(0x111113ff).into(),
tab_bar_background: rgba(0x18191bff).into(),
tab_inactive_background: rgba(0x32302fff).into(),
tab_active_background: rgba(0x504945ff).into(),
editor_background: rgba(0x111113ff).into(),
editor_subheader_background: rgba(0x18191bff).into(),
editor_active_line: rgba(0xddeaf814).into(),
terminal_background: rgba(0x32302fff).into(),
terminal_ansi_bright_black: rgba(0x928374ff).into(),
terminal_ansi_bright_red: rgba(0xfb4833ff).into(),
terminal_ansi_bright_green: rgba(0xb8bb25ff).into(),
terminal_ansi_bright_yellow: rgba(0xfabd2eff).into(),
terminal_ansi_bright_blue: rgba(0x83a598ff).into(),
terminal_ansi_bright_magenta: rgba(0xd3869bff).into(),
terminal_ansi_bright_cyan: rgba(0x8ec07cff).into(),
terminal_ansi_bright_white: rgba(0xebdbb2ff).into(),
terminal_ansi_black: rgba(0x3c3836ff).into(),
terminal_ansi_red: rgba(0xcc241cff).into(),
terminal_ansi_green: rgba(0x989719ff).into(),
terminal_ansi_yellow: rgba(0xd79920ff).into(),
terminal_ansi_blue: rgba(0x448587ff).into(),
terminal_ansi_magenta: rgba(0xb16185ff).into(),
terminal_ansi_cyan: rgba(0x679d6aff).into(),
terminal_ansi_white: rgba(0xa89984ff).into(),
},
status: StatusColors {
conflict: rgba(0xff9592ff).into(),
created: rgba(0x70cf82ff).into(),
deleted: rgba(0xff9592ff).into(),
error: rgba(0xff9592ff).into(),
hidden: rgba(0xb0b4baff).into(),
ignored: rgba(0xb0b4baff).into(),
info: rgba(0x6fb8ffff).into(),
modified: rgba(0xf5e147ff).into(),
renamed: rgba(0x6fb8ffff).into(),
success: rgba(0x70cf82ff).into(),
warning: rgba(0xf5e147ff).into(),
},
git: GitStatusColors {
conflict: rgba(0xffa057ff).into(),
created: rgba(0x70cf82ff).into(),
deleted: rgba(0xff9592ff).into(),
ignored: rgba(0xb0b4baff).into(),
modified: rgba(0xf5e147ff).into(),
renamed: rgba(0x6fb8ffff).into(),
},
player: PlayerColors(vec![
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
]),
syntax: SyntaxTheme {
highlights: vec![
("attribute".into(), rgba(0x4ccce6ff).into()),
("boolean".into(), rgba(0xff977dff).into()),
("comment".into(), rgba(0xb0b4baff).into()),
("comment.doc".into(), rgba(0xe0dffeff).into()),
("constant".into(), rgba(0x8c323aff).into()),
("constructor".into(), rgba(0x8c323aff).into()),
("embedded".into(), rgba(0x8c323aff).into()),
("emphasis".into(), rgba(0x8c323aff).into()),
("emphasis.strong".into(), rgba(0x8c323aff).into()),
("enum".into(), rgba(0x8c323aff).into()),
("function".into(), rgba(0x8c323aff).into()),
("hint".into(), rgba(0x8c323aff).into()),
("keyword".into(), rgba(0xffa057ff).into()),
("label".into(), rgba(0x8c323aff).into()),
("link_text".into(), rgba(0x8c323aff).into()),
("link_uri".into(), rgba(0x8c323aff).into()),
("number".into(), rgba(0x8c323aff).into()),
("operator".into(), rgba(0x8c323aff).into()),
("predictive".into(), rgba(0x8c323aff).into()),
("preproc".into(), rgba(0x8c323aff).into()),
("primary".into(), rgba(0x8c323aff).into()),
("property".into(), rgba(0x8c323aff).into()),
("punctuation".into(), rgba(0xb0b4baff).into()),
("punctuation.bracket".into(), rgba(0xb0b4baff).into()),
("punctuation.delimiter".into(), rgba(0xb0b4baff).into()),
("punctuation.list_marker".into(), rgba(0x6fb8ffff).into()),
("punctuation.special".into(), rgba(0x8c323aff).into()),
("string".into(), rgba(0x1ed8a3ff).into()),
("string.escape".into(), rgba(0x8c323aff).into()),
("string.regex".into(), rgba(0xff977dff).into()),
("string.special".into(), rgba(0x8c323aff).into()),
("string.special.symbol".into(), rgba(0x8c323aff).into()),
("tag".into(), rgba(0x8c323aff).into()),
("text.literal".into(), rgba(0x8c323aff).into()),
("title".into(), rgba(0x8c323aff).into()),
("type".into(), rgba(0x8c323aff).into()),
("variable".into(), rgba(0x8c323aff).into()),
("variable.special".into(), rgba(0x8c323aff).into()),
("variant".into(), rgba(0x8c323aff).into()),
],
},
},
},
ThemeVariant {
id: "b0c9082f-00c8-4a02-a4de-9fd7af97c7f2".into(),
name: "Gruvbox Light Hard".into(),
appearance: Appearance::Light,
styles: ThemeStyles {
system: SystemColors {
transparent: rgba(0x00000000).into(),
mac_os_traffic_light_red: rgba(0xec6b5fff).into(),
mac_os_traffic_light_yellow: rgba(0xf3bf4dff).into(),
mac_os_traffic_light_green: rgba(0x61c454ff).into(),
},
colors: ThemeColors {
border: rgba(0xebdbb2ff).into(),
border_variant: rgba(0xebdbb2ff).into(),
border_focused: rgba(0xebdbb2ff).into(),
border_disabled: rgba(0xebdbb2ff).into(),
border_selected: rgba(0xebdbb2ff).into(),
border_transparent: rgba(0xebdbb2ff).into(),
elevated_surface_background: rgba(0xf9f9fbff).into(),
surface_background: rgba(0xf9f9fbff).into(),
background: rgba(0xf9f5d7ff).into(),
element_background: rgba(0x44858780).into(),
element_hover: rgba(0xe8e8ecff).into(),
element_active: rgba(0xe0e1e6ff).into(),
element_selected: rgba(0xe0e1e6ff).into(),
element_disabled: rgba(0x0000320f).into(),
element_placeholder: rgba(0x60646cff).into(),
element_drop_target: rgba(0x008bff0b).into(),
ghost_element_background: rgba(0x00000000).into(),
ghost_element_hover: rgba(0xe8e8ecff).into(),
ghost_element_active: rgba(0xe0e1e6ff).into(),
ghost_element_selected: rgba(0xe0e1e6ff).into(),
ghost_element_disabled: rgba(0x0000320f).into(),
text: rgba(0x3c3836ff).into(),
text_muted: rgba(0x60646cff).into(),
text_placeholder: rgba(0x80838dff).into(),
text_disabled: rgba(0x8b8d98ff).into(),
text_accent: rgba(0x0c73ceff).into(),
icon: rgba(0x60646cff).into(),
icon_muted: rgba(0x80838dff).into(),
icon_disabled: rgba(0x8b8d98ff).into(),
icon_placeholder: rgba(0x80838dff).into(),
icon_accent: rgba(0x0c73ceff).into(),
status_bar_background: rgba(0xf9f9fbff).into(),
title_bar_background: rgba(0xf9f9fbff).into(),
toolbar_background: rgba(0xfcfcfdff).into(),
tab_bar_background: rgba(0xf9f9fbff).into(),
tab_inactive_background: rgba(0xf9f5d7ff).into(),
tab_active_background: rgba(0xf2e5bcff).into(),
editor_background: rgba(0xfcfcfdff).into(),
editor_subheader_background: rgba(0xf9f9fbff).into(),
editor_active_line: rgba(0x0000320f).into(),
terminal_background: rgba(0xf9f5d7ff).into(),
terminal_ansi_bright_black: rgba(0x928374ff).into(),
terminal_ansi_bright_red: rgba(0x9d0006ff).into(),
terminal_ansi_bright_green: rgba(0x79740eff).into(),
terminal_ansi_bright_yellow: rgba(0xb57613ff).into(),
terminal_ansi_bright_blue: rgba(0x066578ff).into(),
terminal_ansi_bright_magenta: rgba(0x8f3e71ff).into(),
terminal_ansi_bright_cyan: rgba(0x427b58ff).into(),
terminal_ansi_bright_white: rgba(0x3c3836ff).into(),
terminal_ansi_black: rgba(0xebdbb2ff).into(),
terminal_ansi_red: rgba(0xcc241cff).into(),
terminal_ansi_green: rgba(0x989719ff).into(),
terminal_ansi_yellow: rgba(0xd79920ff).into(),
terminal_ansi_blue: rgba(0x448587ff).into(),
terminal_ansi_magenta: rgba(0xb16185ff).into(),
terminal_ansi_cyan: rgba(0x679d6aff).into(),
terminal_ansi_white: rgba(0x7c6f64ff).into(),
},
status: StatusColors {
conflict: rgba(0xff9592ff).into(),
created: rgba(0x70cf82ff).into(),
deleted: rgba(0xff9592ff).into(),
error: rgba(0xff9592ff).into(),
hidden: rgba(0xb0b4baff).into(),
ignored: rgba(0xb0b4baff).into(),
info: rgba(0x6fb8ffff).into(),
modified: rgba(0xf5e147ff).into(),
renamed: rgba(0x6fb8ffff).into(),
success: rgba(0x70cf82ff).into(),
warning: rgba(0xf5e147ff).into(),
},
git: GitStatusColors {
conflict: rgba(0xffa057ff).into(),
created: rgba(0x70cf82ff).into(),
deleted: rgba(0xff9592ff).into(),
ignored: rgba(0xb0b4baff).into(),
modified: rgba(0xf5e147ff).into(),
renamed: rgba(0x6fb8ffff).into(),
},
player: PlayerColors(vec![
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
]),
syntax: SyntaxTheme {
highlights: vec![
("attribute".into(), rgba(0x4ccce6ff).into()),
("boolean".into(), rgba(0xff977dff).into()),
("comment".into(), rgba(0xb0b4baff).into()),
("comment.doc".into(), rgba(0xe0dffeff).into()),
("constant".into(), rgba(0x8c323aff).into()),
("constructor".into(), rgba(0x8c323aff).into()),
("embedded".into(), rgba(0x8c323aff).into()),
("emphasis".into(), rgba(0x8c323aff).into()),
("emphasis.strong".into(), rgba(0x8c323aff).into()),
("enum".into(), rgba(0x8c323aff).into()),
("function".into(), rgba(0x8c323aff).into()),
("hint".into(), rgba(0x8c323aff).into()),
("keyword".into(), rgba(0xffa057ff).into()),
("label".into(), rgba(0x8c323aff).into()),
("link_text".into(), rgba(0x8c323aff).into()),
("link_uri".into(), rgba(0x8c323aff).into()),
("number".into(), rgba(0x8c323aff).into()),
("operator".into(), rgba(0x8c323aff).into()),
("predictive".into(), rgba(0x8c323aff).into()),
("preproc".into(), rgba(0x8c323aff).into()),
("primary".into(), rgba(0x8c323aff).into()),
("property".into(), rgba(0x8c323aff).into()),
("punctuation".into(), rgba(0xb0b4baff).into()),
("punctuation.bracket".into(), rgba(0xb0b4baff).into()),
("punctuation.delimiter".into(), rgba(0xb0b4baff).into()),
("punctuation.list_marker".into(), rgba(0x6fb8ffff).into()),
("punctuation.special".into(), rgba(0x8c323aff).into()),
("string".into(), rgba(0x1ed8a3ff).into()),
("string.escape".into(), rgba(0x8c323aff).into()),
("string.regex".into(), rgba(0xff977dff).into()),
("string.special".into(), rgba(0x8c323aff).into()),
("string.special.symbol".into(), rgba(0x8c323aff).into()),
("tag".into(), rgba(0x8c323aff).into()),
("text.literal".into(), rgba(0x8c323aff).into()),
("title".into(), rgba(0x8c323aff).into()),
("type".into(), rgba(0x8c323aff).into()),
("variable".into(), rgba(0x8c323aff).into()),
("variable.special".into(), rgba(0x8c323aff).into()),
("variant".into(), rgba(0x8c323aff).into()),
],
},
},
},
ThemeVariant {
id: "172c281c-ff0a-496e-8794-880e2fc3aa49".into(),
name: "Gruvbox Light Medium".into(),
appearance: Appearance::Light,
styles: ThemeStyles {
system: SystemColors {
transparent: rgba(0x00000000).into(),
mac_os_traffic_light_red: rgba(0xec6b5fff).into(),
mac_os_traffic_light_yellow: rgba(0xf3bf4dff).into(),
mac_os_traffic_light_green: rgba(0x61c454ff).into(),
},
colors: ThemeColors {
border: rgba(0xebdbb2ff).into(),
border_variant: rgba(0xebdbb2ff).into(),
border_focused: rgba(0xebdbb2ff).into(),
border_disabled: rgba(0xebdbb2ff).into(),
border_selected: rgba(0xebdbb2ff).into(),
border_transparent: rgba(0xebdbb2ff).into(),
elevated_surface_background: rgba(0xf9f9fbff).into(),
surface_background: rgba(0xf9f9fbff).into(),
background: rgba(0xfbf1c7ff).into(),
element_background: rgba(0x44858780).into(),
element_hover: rgba(0xe8e8ecff).into(),
element_active: rgba(0xe0e1e6ff).into(),
element_selected: rgba(0xe0e1e6ff).into(),
element_disabled: rgba(0x0000320f).into(),
element_placeholder: rgba(0x60646cff).into(),
element_drop_target: rgba(0x008bff0b).into(),
ghost_element_background: rgba(0x00000000).into(),
ghost_element_hover: rgba(0xe8e8ecff).into(),
ghost_element_active: rgba(0xe0e1e6ff).into(),
ghost_element_selected: rgba(0xe0e1e6ff).into(),
ghost_element_disabled: rgba(0x0000320f).into(),
text: rgba(0x3c3836ff).into(),
text_muted: rgba(0x60646cff).into(),
text_placeholder: rgba(0x80838dff).into(),
text_disabled: rgba(0x8b8d98ff).into(),
text_accent: rgba(0x0c73ceff).into(),
icon: rgba(0x60646cff).into(),
icon_muted: rgba(0x80838dff).into(),
icon_disabled: rgba(0x8b8d98ff).into(),
icon_placeholder: rgba(0x80838dff).into(),
icon_accent: rgba(0x0c73ceff).into(),
status_bar_background: rgba(0xf9f9fbff).into(),
title_bar_background: rgba(0xf9f9fbff).into(),
toolbar_background: rgba(0xfcfcfdff).into(),
tab_bar_background: rgba(0xf9f9fbff).into(),
tab_inactive_background: rgba(0xfbf1c7ff).into(),
tab_active_background: rgba(0xebdbb2ff).into(),
editor_background: rgba(0xfcfcfdff).into(),
editor_subheader_background: rgba(0xf9f9fbff).into(),
editor_active_line: rgba(0x0000320f).into(),
terminal_background: rgba(0xfbf1c7ff).into(),
terminal_ansi_bright_black: rgba(0x928374ff).into(),
terminal_ansi_bright_red: rgba(0x9d0006ff).into(),
terminal_ansi_bright_green: rgba(0x79740eff).into(),
terminal_ansi_bright_yellow: rgba(0xb57613ff).into(),
terminal_ansi_bright_blue: rgba(0x066578ff).into(),
terminal_ansi_bright_magenta: rgba(0x8f3e71ff).into(),
terminal_ansi_bright_cyan: rgba(0x427b58ff).into(),
terminal_ansi_bright_white: rgba(0x3c3836ff).into(),
terminal_ansi_black: rgba(0xebdbb2ff).into(),
terminal_ansi_red: rgba(0xcc241cff).into(),
terminal_ansi_green: rgba(0x989719ff).into(),
terminal_ansi_yellow: rgba(0xd79920ff).into(),
terminal_ansi_blue: rgba(0x448587ff).into(),
terminal_ansi_magenta: rgba(0xb16185ff).into(),
terminal_ansi_cyan: rgba(0x679d6aff).into(),
terminal_ansi_white: rgba(0x7c6f64ff).into(),
},
status: StatusColors {
conflict: rgba(0xff9592ff).into(),
created: rgba(0x70cf82ff).into(),
deleted: rgba(0xff9592ff).into(),
error: rgba(0xff9592ff).into(),
hidden: rgba(0xb0b4baff).into(),
ignored: rgba(0xb0b4baff).into(),
info: rgba(0x6fb8ffff).into(),
modified: rgba(0xf5e147ff).into(),
renamed: rgba(0x6fb8ffff).into(),
success: rgba(0x70cf82ff).into(),
warning: rgba(0xf5e147ff).into(),
},
git: GitStatusColors {
conflict: rgba(0xffa057ff).into(),
created: rgba(0x70cf82ff).into(),
deleted: rgba(0xff9592ff).into(),
ignored: rgba(0xb0b4baff).into(),
modified: rgba(0xf5e147ff).into(),
renamed: rgba(0x6fb8ffff).into(),
},
player: PlayerColors(vec![
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
]),
syntax: SyntaxTheme {
highlights: vec![
("attribute".into(), rgba(0x4ccce6ff).into()),
("boolean".into(), rgba(0xff977dff).into()),
("comment".into(), rgba(0xb0b4baff).into()),
("comment.doc".into(), rgba(0xe0dffeff).into()),
("constant".into(), rgba(0x8c323aff).into()),
("constructor".into(), rgba(0x8c323aff).into()),
("embedded".into(), rgba(0x8c323aff).into()),
("emphasis".into(), rgba(0x8c323aff).into()),
("emphasis.strong".into(), rgba(0x8c323aff).into()),
("enum".into(), rgba(0x8c323aff).into()),
("function".into(), rgba(0x8c323aff).into()),
("hint".into(), rgba(0x8c323aff).into()),
("keyword".into(), rgba(0xffa057ff).into()),
("label".into(), rgba(0x8c323aff).into()),
("link_text".into(), rgba(0x8c323aff).into()),
("link_uri".into(), rgba(0x8c323aff).into()),
("number".into(), rgba(0x8c323aff).into()),
("operator".into(), rgba(0x8c323aff).into()),
("predictive".into(), rgba(0x8c323aff).into()),
("preproc".into(), rgba(0x8c323aff).into()),
("primary".into(), rgba(0x8c323aff).into()),
("property".into(), rgba(0x8c323aff).into()),
("punctuation".into(), rgba(0xb0b4baff).into()),
("punctuation.bracket".into(), rgba(0xb0b4baff).into()),
("punctuation.delimiter".into(), rgba(0xb0b4baff).into()),
("punctuation.list_marker".into(), rgba(0x6fb8ffff).into()),
("punctuation.special".into(), rgba(0x8c323aff).into()),
("string".into(), rgba(0x1ed8a3ff).into()),
("string.escape".into(), rgba(0x8c323aff).into()),
("string.regex".into(), rgba(0xff977dff).into()),
("string.special".into(), rgba(0x8c323aff).into()),
("string.special.symbol".into(), rgba(0x8c323aff).into()),
("tag".into(), rgba(0x8c323aff).into()),
("text.literal".into(), rgba(0x8c323aff).into()),
("title".into(), rgba(0x8c323aff).into()),
("type".into(), rgba(0x8c323aff).into()),
("variable".into(), rgba(0x8c323aff).into()),
("variable.special".into(), rgba(0x8c323aff).into()),
("variant".into(), rgba(0x8c323aff).into()),
],
},
},
},
ThemeVariant {
id: "b94f3305-b755-44f2-948c-cfd8c9d3158f".into(),
name: "Gruvbox Light Soft".into(),
appearance: Appearance::Light,
styles: ThemeStyles {
system: SystemColors {
transparent: rgba(0x00000000).into(),
mac_os_traffic_light_red: rgba(0xec6b5fff).into(),
mac_os_traffic_light_yellow: rgba(0xf3bf4dff).into(),
mac_os_traffic_light_green: rgba(0x61c454ff).into(),
},
colors: ThemeColors {
border: rgba(0xebdbb2ff).into(),
border_variant: rgba(0xebdbb2ff).into(),
border_focused: rgba(0xebdbb2ff).into(),
border_disabled: rgba(0xebdbb2ff).into(),
border_selected: rgba(0xebdbb2ff).into(),
border_transparent: rgba(0xebdbb2ff).into(),
elevated_surface_background: rgba(0xf9f9fbff).into(),
surface_background: rgba(0xf9f9fbff).into(),
background: rgba(0xf2e5bcff).into(),
element_background: rgba(0x44858780).into(),
element_hover: rgba(0xe8e8ecff).into(),
element_active: rgba(0xe0e1e6ff).into(),
element_selected: rgba(0xe0e1e6ff).into(),
element_disabled: rgba(0x0000320f).into(),
element_placeholder: rgba(0x60646cff).into(),
element_drop_target: rgba(0x008bff0b).into(),
ghost_element_background: rgba(0x00000000).into(),
ghost_element_hover: rgba(0xe8e8ecff).into(),
ghost_element_active: rgba(0xe0e1e6ff).into(),
ghost_element_selected: rgba(0xe0e1e6ff).into(),
ghost_element_disabled: rgba(0x0000320f).into(),
text: rgba(0x3c3836ff).into(),
text_muted: rgba(0x60646cff).into(),
text_placeholder: rgba(0x80838dff).into(),
text_disabled: rgba(0x8b8d98ff).into(),
text_accent: rgba(0x0c73ceff).into(),
icon: rgba(0x60646cff).into(),
icon_muted: rgba(0x80838dff).into(),
icon_disabled: rgba(0x8b8d98ff).into(),
icon_placeholder: rgba(0x80838dff).into(),
icon_accent: rgba(0x0c73ceff).into(),
status_bar_background: rgba(0xf9f9fbff).into(),
title_bar_background: rgba(0xf9f9fbff).into(),
toolbar_background: rgba(0xfcfcfdff).into(),
tab_bar_background: rgba(0xf9f9fbff).into(),
tab_inactive_background: rgba(0xf2e5bcff).into(),
tab_active_background: rgba(0xd5c4a1ff).into(),
editor_background: rgba(0xfcfcfdff).into(),
editor_subheader_background: rgba(0xf9f9fbff).into(),
editor_active_line: rgba(0x0000320f).into(),
terminal_background: rgba(0xf2e5bcff).into(),
terminal_ansi_bright_black: rgba(0x928374ff).into(),
terminal_ansi_bright_red: rgba(0x9d0006ff).into(),
terminal_ansi_bright_green: rgba(0x79740eff).into(),
terminal_ansi_bright_yellow: rgba(0xb57613ff).into(),
terminal_ansi_bright_blue: rgba(0x066578ff).into(),
terminal_ansi_bright_magenta: rgba(0x8f3e71ff).into(),
terminal_ansi_bright_cyan: rgba(0x427b58ff).into(),
terminal_ansi_bright_white: rgba(0x3c3836ff).into(),
terminal_ansi_black: rgba(0xebdbb2ff).into(),
terminal_ansi_red: rgba(0xcc241cff).into(),
terminal_ansi_green: rgba(0x989719ff).into(),
terminal_ansi_yellow: rgba(0xd79920ff).into(),
terminal_ansi_blue: rgba(0x448587ff).into(),
terminal_ansi_magenta: rgba(0xb16185ff).into(),
terminal_ansi_cyan: rgba(0x679d6aff).into(),
terminal_ansi_white: rgba(0x7c6f64ff).into(),
},
status: StatusColors {
conflict: rgba(0xff9592ff).into(),
created: rgba(0x70cf82ff).into(),
deleted: rgba(0xff9592ff).into(),
error: rgba(0xff9592ff).into(),
hidden: rgba(0xb0b4baff).into(),
ignored: rgba(0xb0b4baff).into(),
info: rgba(0x6fb8ffff).into(),
modified: rgba(0xf5e147ff).into(),
renamed: rgba(0x6fb8ffff).into(),
success: rgba(0x70cf82ff).into(),
warning: rgba(0xf5e147ff).into(),
},
git: GitStatusColors {
conflict: rgba(0xffa057ff).into(),
created: rgba(0x70cf82ff).into(),
deleted: rgba(0xff9592ff).into(),
ignored: rgba(0xb0b4baff).into(),
modified: rgba(0xf5e147ff).into(),
renamed: rgba(0x6fb8ffff).into(),
},
player: PlayerColors(vec![
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
]),
syntax: SyntaxTheme {
highlights: vec![
("attribute".into(), rgba(0x4ccce6ff).into()),
("boolean".into(), rgba(0xff977dff).into()),
("comment".into(), rgba(0xb0b4baff).into()),
("comment.doc".into(), rgba(0xe0dffeff).into()),
("constant".into(), rgba(0x8c323aff).into()),
("constructor".into(), rgba(0x8c323aff).into()),
("embedded".into(), rgba(0x8c323aff).into()),
("emphasis".into(), rgba(0x8c323aff).into()),
("emphasis.strong".into(), rgba(0x8c323aff).into()),
("enum".into(), rgba(0x8c323aff).into()),
("function".into(), rgba(0x8c323aff).into()),
("hint".into(), rgba(0x8c323aff).into()),
("keyword".into(), rgba(0xffa057ff).into()),
("label".into(), rgba(0x8c323aff).into()),
("link_text".into(), rgba(0x8c323aff).into()),
("link_uri".into(), rgba(0x8c323aff).into()),
("number".into(), rgba(0x8c323aff).into()),
("operator".into(), rgba(0x8c323aff).into()),
("predictive".into(), rgba(0x8c323aff).into()),
("preproc".into(), rgba(0x8c323aff).into()),
("primary".into(), rgba(0x8c323aff).into()),
("property".into(), rgba(0x8c323aff).into()),
("punctuation".into(), rgba(0xb0b4baff).into()),
("punctuation.bracket".into(), rgba(0xb0b4baff).into()),
("punctuation.delimiter".into(), rgba(0xb0b4baff).into()),
("punctuation.list_marker".into(), rgba(0x6fb8ffff).into()),
("punctuation.special".into(), rgba(0x8c323aff).into()),
("string".into(), rgba(0x1ed8a3ff).into()),
("string.escape".into(), rgba(0x8c323aff).into()),
("string.regex".into(), rgba(0xff977dff).into()),
("string.special".into(), rgba(0x8c323aff).into()),
("string.special.symbol".into(), rgba(0x8c323aff).into()),
("tag".into(), rgba(0x8c323aff).into()),
("text.literal".into(), rgba(0x8c323aff).into()),
("title".into(), rgba(0x8c323aff).into()),
("type".into(), rgba(0x8c323aff).into()),
("variable".into(), rgba(0x8c323aff).into()),
("variable.special".into(), rgba(0x8c323aff).into()),
("variant".into(), rgba(0x8c323aff).into()),
],
},
},
},
],
scales: default_color_scales(),
}
}

View file

@ -0,0 +1,41 @@
// mod andromeda;
// mod ayu;
// mod dracula;
// mod gruvbox;
// mod night_owl;
// mod nord;
// mod notctis;
// mod palenight;
// mod rose_pine;
// mod solarized;
// mod synthwave_84;
// pub use andromeda::*;
// pub use ayu::*;
// pub use dracula::*;
// pub use gruvbox::*;
// pub use night_owl::*;
// pub use nord::*;
// pub use notctis::*;
// pub use palenight::*;
// pub use rose_pine::*;
// pub use solarized::*;
// pub use synthwave_84::*;
use crate::ThemeFamily;
pub fn all_imported_themes() -> Vec<ThemeFamily> {
vec![
// rose_pine(),
// night_owl(),
// andromeda(),
// synthwave_84(),
// palenight(),
// dracula(),
// solarized(),
// nord(),
// notctis(),
// ayu(),
// gruvbox(),
]
}

View file

@ -0,0 +1,333 @@
use gpui::rgba;
use crate::{
default_color_scales, Appearance, GitStatusColors, PlayerColor, PlayerColors, StatusColors,
SyntaxTheme, SystemColors, ThemeColors, ThemeFamily, ThemeStyles, ThemeVariant,
};
pub fn night_owl() -> ThemeFamily {
ThemeFamily {
id: "b6469599-df68-4604-be9d-44f63d877d53".into(),
name: "Night Owl".into(),
author: "Sarah Drasner (sdras)".into(),
themes: vec![
ThemeVariant {
id: "2a04e5fa-e266-475b-b965-3d92efe77ad9".into(),
name: "Night Owl".into(),
appearance: Appearance::Dark,
styles: ThemeStyles {
system: SystemColors {
transparent: rgba(0x00000000).into(),
mac_os_traffic_light_red: rgba(0xec6b5fff).into(),
mac_os_traffic_light_yellow: rgba(0xf3bf4dff).into(),
mac_os_traffic_light_green: rgba(0x61c454ff).into(),
},
colors: ThemeColors {
border: rgba(0x5f7e97ff).into(),
border_variant: rgba(0x5f7e97ff).into(),
border_focused: rgba(0x5f7e97ff).into(),
border_disabled: rgba(0x5f7e97ff).into(),
border_selected: rgba(0x5f7e97ff).into(),
border_transparent: rgba(0x5f7e97ff).into(),
elevated_surface_background: rgba(0x011526ff).into(),
surface_background: rgba(0x011526ff).into(),
background: rgba(0x011526ff).into(),
element_background: rgba(0x7d56c1cc).into(),
element_hover: rgba(0x272a2dff).into(),
element_active: rgba(0x2e3135ff).into(),
element_selected: rgba(0x2e3135ff).into(),
element_disabled: rgba(0xddeaf814).into(),
element_placeholder: rgba(0xb0b4baff).into(),
element_drop_target: rgba(0x1166fb18).into(),
ghost_element_background: rgba(0x00000000).into(),
ghost_element_hover: rgba(0x272a2dff).into(),
ghost_element_active: rgba(0x2e3135ff).into(),
ghost_element_selected: rgba(0x2e3135ff).into(),
ghost_element_disabled: rgba(0xddeaf814).into(),
text: rgba(0xd6deebff).into(),
text_muted: rgba(0xb0b4baff).into(),
text_placeholder: rgba(0x767a83ff).into(),
text_disabled: rgba(0x696e77ff).into(),
text_accent: rgba(0x6fb8ffff).into(),
icon: rgba(0xb0b4baff).into(),
icon_muted: rgba(0x767a83ff).into(),
icon_disabled: rgba(0x696e77ff).into(),
icon_placeholder: rgba(0x767a83ff).into(),
icon_accent: rgba(0x6fb8ffff).into(),
status_bar_background: rgba(0x18191bff).into(),
title_bar_background: rgba(0x18191bff).into(),
toolbar_background: rgba(0x111113ff).into(),
tab_bar_background: rgba(0x18191bff).into(),
tab_inactive_background: rgba(0x01101cff).into(),
tab_active_background: rgba(0x0a2842ff).into(),
editor_background: rgba(0x111113ff).into(),
editor_subheader_background: rgba(0x18191bff).into(),
editor_active_line: rgba(0xddeaf814).into(),
terminal_background: rgba(0x111113ff).into(),
terminal_ansi_bright_black: rgba(0x575656ff).into(),
terminal_ansi_bright_red: rgba(0xef524fff).into(),
terminal_ansi_bright_green: rgba(0x21da6eff).into(),
terminal_ansi_bright_yellow: rgba(0xffeb95ff).into(),
terminal_ansi_bright_blue: rgba(0x82aaffff).into(),
terminal_ansi_bright_magenta: rgba(0xc792eaff).into(),
terminal_ansi_bright_cyan: rgba(0x7fdbcaff).into(),
terminal_ansi_bright_white: rgba(0xffffffff).into(),
terminal_ansi_black: rgba(0x011526ff).into(),
terminal_ansi_red: rgba(0xef524fff).into(),
terminal_ansi_green: rgba(0x21da6eff).into(),
terminal_ansi_yellow: rgba(0xc5e478ff).into(),
terminal_ansi_blue: rgba(0x82aaffff).into(),
terminal_ansi_magenta: rgba(0xc792eaff).into(),
terminal_ansi_cyan: rgba(0x20c7a7ff).into(),
terminal_ansi_white: rgba(0xffffffff).into(),
},
status: StatusColors {
conflict: rgba(0xff9592ff).into(),
created: rgba(0x70cf82ff).into(),
deleted: rgba(0xff9592ff).into(),
error: rgba(0xff9592ff).into(),
hidden: rgba(0xb0b4baff).into(),
ignored: rgba(0xb0b4baff).into(),
info: rgba(0x6fb8ffff).into(),
modified: rgba(0xf5e147ff).into(),
renamed: rgba(0x6fb8ffff).into(),
success: rgba(0x70cf82ff).into(),
warning: rgba(0xf5e147ff).into(),
},
git: GitStatusColors {
conflict: rgba(0xffa057ff).into(),
created: rgba(0x70cf82ff).into(),
deleted: rgba(0xff9592ff).into(),
ignored: rgba(0xb0b4baff).into(),
modified: rgba(0xf5e147ff).into(),
renamed: rgba(0x6fb8ffff).into(),
},
player: PlayerColors(vec![
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
]),
syntax: SyntaxTheme {
highlights: vec![
("attribute".into(), rgba(0x4ccce6ff).into()),
("boolean".into(), rgba(0xff977dff).into()),
("comment".into(), rgba(0xb0b4baff).into()),
("comment.doc".into(), rgba(0xe0dffeff).into()),
("constant".into(), rgba(0x8c323aff).into()),
("constructor".into(), rgba(0x8c323aff).into()),
("embedded".into(), rgba(0x8c323aff).into()),
("emphasis".into(), rgba(0x8c323aff).into()),
("emphasis.strong".into(), rgba(0x8c323aff).into()),
("enum".into(), rgba(0x8c323aff).into()),
("function".into(), rgba(0x8c323aff).into()),
("hint".into(), rgba(0x8c323aff).into()),
("keyword".into(), rgba(0xffa057ff).into()),
("label".into(), rgba(0x8c323aff).into()),
("link_text".into(), rgba(0x8c323aff).into()),
("link_uri".into(), rgba(0x8c323aff).into()),
("number".into(), rgba(0x8c323aff).into()),
("operator".into(), rgba(0x8c323aff).into()),
("predictive".into(), rgba(0x8c323aff).into()),
("preproc".into(), rgba(0x8c323aff).into()),
("primary".into(), rgba(0x8c323aff).into()),
("property".into(), rgba(0x8c323aff).into()),
("punctuation".into(), rgba(0xb0b4baff).into()),
("punctuation.bracket".into(), rgba(0xb0b4baff).into()),
("punctuation.delimiter".into(), rgba(0xb0b4baff).into()),
("punctuation.list_marker".into(), rgba(0x6fb8ffff).into()),
("punctuation.special".into(), rgba(0x8c323aff).into()),
("string".into(), rgba(0x1ed8a3ff).into()),
("string.escape".into(), rgba(0x8c323aff).into()),
("string.regex".into(), rgba(0xff977dff).into()),
("string.special".into(), rgba(0x8c323aff).into()),
("string.special.symbol".into(), rgba(0x8c323aff).into()),
("tag".into(), rgba(0x8c323aff).into()),
("text.literal".into(), rgba(0x8c323aff).into()),
("title".into(), rgba(0x8c323aff).into()),
("type".into(), rgba(0x8c323aff).into()),
("variable".into(), rgba(0x8c323aff).into()),
("variable.special".into(), rgba(0x8c323aff).into()),
("variant".into(), rgba(0x8c323aff).into()),
],
},
},
},
ThemeVariant {
id: "91901d29-1c1f-49ef-ac69-c25639425f7c".into(),
name: "Night Owl Light".into(),
appearance: Appearance::Light,
styles: ThemeStyles {
system: SystemColors {
transparent: rgba(0x00000000).into(),
mac_os_traffic_light_red: rgba(0xec6b5fff).into(),
mac_os_traffic_light_yellow: rgba(0xf3bf4dff).into(),
mac_os_traffic_light_green: rgba(0x61c454ff).into(),
},
colors: ThemeColors {
border: rgba(0xd9d9d9ff).into(),
border_variant: rgba(0xd9d9d9ff).into(),
border_focused: rgba(0xd9d9d9ff).into(),
border_disabled: rgba(0xd9d9d9ff).into(),
border_selected: rgba(0xd9d9d9ff).into(),
border_transparent: rgba(0xd9d9d9ff).into(),
elevated_surface_background: rgba(0xf0f0f0ff).into(),
surface_background: rgba(0xf0f0f0ff).into(),
background: rgba(0xfbfbfbff).into(),
element_background: rgba(0x29a298ff).into(),
element_hover: rgba(0xe8e8ecff).into(),
element_active: rgba(0xe0e1e6ff).into(),
element_selected: rgba(0xe0e1e6ff).into(),
element_disabled: rgba(0x0000320f).into(),
element_placeholder: rgba(0x60646cff).into(),
element_drop_target: rgba(0x008bff0b).into(),
ghost_element_background: rgba(0x00000000).into(),
ghost_element_hover: rgba(0xe8e8ecff).into(),
ghost_element_active: rgba(0xe0e1e6ff).into(),
ghost_element_selected: rgba(0xe0e1e6ff).into(),
ghost_element_disabled: rgba(0x0000320f).into(),
text: rgba(0x403f53ff).into(),
text_muted: rgba(0x60646cff).into(),
text_placeholder: rgba(0x80838dff).into(),
text_disabled: rgba(0x8b8d98ff).into(),
text_accent: rgba(0x0c73ceff).into(),
icon: rgba(0x60646cff).into(),
icon_muted: rgba(0x80838dff).into(),
icon_disabled: rgba(0x8b8d98ff).into(),
icon_placeholder: rgba(0x80838dff).into(),
icon_accent: rgba(0x0c73ceff).into(),
status_bar_background: rgba(0xf9f9fbff).into(),
title_bar_background: rgba(0xf9f9fbff).into(),
toolbar_background: rgba(0xfcfcfdff).into(),
tab_bar_background: rgba(0xf9f9fbff).into(),
tab_inactive_background: rgba(0xf0f0f0ff).into(),
tab_active_background: rgba(0xf6f6f6ff).into(),
editor_background: rgba(0xfcfcfdff).into(),
editor_subheader_background: rgba(0xf9f9fbff).into(),
editor_active_line: rgba(0x0000320f).into(),
terminal_background: rgba(0xf6f6f6ff).into(),
terminal_ansi_bright_black: rgba(0x403f53ff).into(),
terminal_ansi_bright_red: rgba(0xde3c3aff).into(),
terminal_ansi_bright_green: rgba(0x07916aff).into(),
terminal_ansi_bright_yellow: rgba(0xdaa900ff).into(),
terminal_ansi_bright_blue: rgba(0x278dd7ff).into(),
terminal_ansi_bright_magenta: rgba(0xd64289ff).into(),
terminal_ansi_bright_cyan: rgba(0x29a298ff).into(),
terminal_ansi_bright_white: rgba(0xf0f0f0ff).into(),
terminal_ansi_black: rgba(0x403f53ff).into(),
terminal_ansi_red: rgba(0xde3c3aff).into(),
terminal_ansi_green: rgba(0x07916aff).into(),
terminal_ansi_yellow: rgba(0xe0ae01ff).into(),
terminal_ansi_blue: rgba(0x278dd7ff).into(),
terminal_ansi_magenta: rgba(0xd64289ff).into(),
terminal_ansi_cyan: rgba(0x29a298ff).into(),
terminal_ansi_white: rgba(0xf0f0f0ff).into(),
},
status: StatusColors {
conflict: rgba(0xff9592ff).into(),
created: rgba(0x70cf82ff).into(),
deleted: rgba(0xff9592ff).into(),
error: rgba(0xff9592ff).into(),
hidden: rgba(0xb0b4baff).into(),
ignored: rgba(0xb0b4baff).into(),
info: rgba(0x6fb8ffff).into(),
modified: rgba(0xf5e147ff).into(),
renamed: rgba(0x6fb8ffff).into(),
success: rgba(0x70cf82ff).into(),
warning: rgba(0xf5e147ff).into(),
},
git: GitStatusColors {
conflict: rgba(0xffa057ff).into(),
created: rgba(0x70cf82ff).into(),
deleted: rgba(0xff9592ff).into(),
ignored: rgba(0xb0b4baff).into(),
modified: rgba(0xf5e147ff).into(),
renamed: rgba(0x6fb8ffff).into(),
},
player: PlayerColors(vec![
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
]),
syntax: SyntaxTheme {
highlights: vec![
("attribute".into(), rgba(0x4ccce6ff).into()),
("boolean".into(), rgba(0xff977dff).into()),
("comment".into(), rgba(0xb0b4baff).into()),
("comment.doc".into(), rgba(0xe0dffeff).into()),
("constant".into(), rgba(0x8c323aff).into()),
("constructor".into(), rgba(0x8c323aff).into()),
("embedded".into(), rgba(0x8c323aff).into()),
("emphasis".into(), rgba(0x8c323aff).into()),
("emphasis.strong".into(), rgba(0x8c323aff).into()),
("enum".into(), rgba(0x8c323aff).into()),
("function".into(), rgba(0x8c323aff).into()),
("hint".into(), rgba(0x8c323aff).into()),
("keyword".into(), rgba(0xffa057ff).into()),
("label".into(), rgba(0x8c323aff).into()),
("link_text".into(), rgba(0x8c323aff).into()),
("link_uri".into(), rgba(0x8c323aff).into()),
("number".into(), rgba(0x8c323aff).into()),
("operator".into(), rgba(0x8c323aff).into()),
("predictive".into(), rgba(0x8c323aff).into()),
("preproc".into(), rgba(0x8c323aff).into()),
("primary".into(), rgba(0x8c323aff).into()),
("property".into(), rgba(0x8c323aff).into()),
("punctuation".into(), rgba(0xb0b4baff).into()),
("punctuation.bracket".into(), rgba(0xb0b4baff).into()),
("punctuation.delimiter".into(), rgba(0xb0b4baff).into()),
("punctuation.list_marker".into(), rgba(0x6fb8ffff).into()),
("punctuation.special".into(), rgba(0x8c323aff).into()),
("string".into(), rgba(0x1ed8a3ff).into()),
("string.escape".into(), rgba(0x8c323aff).into()),
("string.regex".into(), rgba(0xff977dff).into()),
("string.special".into(), rgba(0x8c323aff).into()),
("string.special.symbol".into(), rgba(0x8c323aff).into()),
("tag".into(), rgba(0x8c323aff).into()),
("text.literal".into(), rgba(0x8c323aff).into()),
("title".into(), rgba(0x8c323aff).into()),
("type".into(), rgba(0x8c323aff).into()),
("variable".into(), rgba(0x8c323aff).into()),
("variable.special".into(), rgba(0x8c323aff).into()),
("variant".into(), rgba(0x8c323aff).into()),
],
},
},
},
],
scales: default_color_scales(),
}
}

View file

@ -0,0 +1,173 @@
use gpui::rgba;
use crate::{
default_color_scales, Appearance, GitStatusColors, PlayerColor, PlayerColors, StatusColors,
SyntaxTheme, SystemColors, ThemeColors, ThemeFamily, ThemeStyles, ThemeVariant,
};
pub fn nord() -> ThemeFamily {
ThemeFamily {
id: "dcd03133-f540-47e7-9360-91bb1c94d16e".into(),
name: "Nord".into(),
author: "Sven Greb (svengreb)".into(),
themes: vec![ThemeVariant {
id: "ed7e8c08-321a-41f0-bd22-ca92c0b42e0e".into(),
name: "Nord".into(),
appearance: Appearance::Dark,
styles: ThemeStyles {
system: SystemColors {
transparent: rgba(0x00000000).into(),
mac_os_traffic_light_red: rgba(0xec6b5fff).into(),
mac_os_traffic_light_yellow: rgba(0xf3bf4dff).into(),
mac_os_traffic_light_green: rgba(0x61c454ff).into(),
},
colors: ThemeColors {
border: rgba(0x3b4252ff).into(),
border_variant: rgba(0x3b4252ff).into(),
border_focused: rgba(0x3b4252ff).into(),
border_disabled: rgba(0x3b4252ff).into(),
border_selected: rgba(0x3b4252ff).into(),
border_transparent: rgba(0x3b4252ff).into(),
elevated_surface_background: rgba(0x2e3440ff).into(),
surface_background: rgba(0x2e3440ff).into(),
background: rgba(0x2e3440ff).into(),
element_background: rgba(0x88bfd0ee).into(),
element_hover: rgba(0x272a2dff).into(),
element_active: rgba(0x2e3135ff).into(),
element_selected: rgba(0x2e3135ff).into(),
element_disabled: rgba(0xddeaf814).into(),
element_placeholder: rgba(0xb0b4baff).into(),
element_drop_target: rgba(0x1166fb18).into(),
ghost_element_background: rgba(0x00000000).into(),
ghost_element_hover: rgba(0x272a2dff).into(),
ghost_element_active: rgba(0x2e3135ff).into(),
ghost_element_selected: rgba(0x2e3135ff).into(),
ghost_element_disabled: rgba(0xddeaf814).into(),
text: rgba(0xd8dee9ff).into(),
text_muted: rgba(0xb0b4baff).into(),
text_placeholder: rgba(0x767a83ff).into(),
text_disabled: rgba(0x696e77ff).into(),
text_accent: rgba(0x6fb8ffff).into(),
icon: rgba(0xb0b4baff).into(),
icon_muted: rgba(0x767a83ff).into(),
icon_disabled: rgba(0x696e77ff).into(),
icon_placeholder: rgba(0x767a83ff).into(),
icon_accent: rgba(0x6fb8ffff).into(),
status_bar_background: rgba(0x18191bff).into(),
title_bar_background: rgba(0x18191bff).into(),
toolbar_background: rgba(0x111113ff).into(),
tab_bar_background: rgba(0x18191bff).into(),
tab_inactive_background: rgba(0x2e3440ff).into(),
tab_active_background: rgba(0x3b4252ff).into(),
editor_background: rgba(0x111113ff).into(),
editor_subheader_background: rgba(0x18191bff).into(),
editor_active_line: rgba(0xddeaf814).into(),
terminal_background: rgba(0x2e3440ff).into(),
terminal_ansi_bright_black: rgba(0x4c566aff).into(),
terminal_ansi_bright_red: rgba(0xbf616aff).into(),
terminal_ansi_bright_green: rgba(0xa3be8cff).into(),
terminal_ansi_bright_yellow: rgba(0xebcb8bff).into(),
terminal_ansi_bright_blue: rgba(0x81a1c1ff).into(),
terminal_ansi_bright_magenta: rgba(0xb48eacff).into(),
terminal_ansi_bright_cyan: rgba(0x8fbcbbff).into(),
terminal_ansi_bright_white: rgba(0xeceff4ff).into(),
terminal_ansi_black: rgba(0x3b4252ff).into(),
terminal_ansi_red: rgba(0xbf616aff).into(),
terminal_ansi_green: rgba(0xa3be8cff).into(),
terminal_ansi_yellow: rgba(0xebcb8bff).into(),
terminal_ansi_blue: rgba(0x81a1c1ff).into(),
terminal_ansi_magenta: rgba(0xb48eacff).into(),
terminal_ansi_cyan: rgba(0x88bfd0ff).into(),
terminal_ansi_white: rgba(0xe5e9f0ff).into(),
},
status: StatusColors {
conflict: rgba(0xff9592ff).into(),
created: rgba(0x70cf82ff).into(),
deleted: rgba(0xff9592ff).into(),
error: rgba(0xff9592ff).into(),
hidden: rgba(0xb0b4baff).into(),
ignored: rgba(0xb0b4baff).into(),
info: rgba(0x6fb8ffff).into(),
modified: rgba(0xf5e147ff).into(),
renamed: rgba(0x6fb8ffff).into(),
success: rgba(0x70cf82ff).into(),
warning: rgba(0xf5e147ff).into(),
},
git: GitStatusColors {
conflict: rgba(0xffa057ff).into(),
created: rgba(0x70cf82ff).into(),
deleted: rgba(0xff9592ff).into(),
ignored: rgba(0xb0b4baff).into(),
modified: rgba(0xf5e147ff).into(),
renamed: rgba(0x6fb8ffff).into(),
},
player: PlayerColors(vec![
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
]),
syntax: SyntaxTheme {
highlights: vec![
("attribute".into(), rgba(0x4ccce6ff).into()),
("boolean".into(), rgba(0xff977dff).into()),
("comment".into(), rgba(0xb0b4baff).into()),
("comment.doc".into(), rgba(0xe0dffeff).into()),
("constant".into(), rgba(0x8c323aff).into()),
("constructor".into(), rgba(0x8c323aff).into()),
("embedded".into(), rgba(0x8c323aff).into()),
("emphasis".into(), rgba(0x8c323aff).into()),
("emphasis.strong".into(), rgba(0x8c323aff).into()),
("enum".into(), rgba(0x8c323aff).into()),
("function".into(), rgba(0x8c323aff).into()),
("hint".into(), rgba(0x8c323aff).into()),
("keyword".into(), rgba(0xffa057ff).into()),
("label".into(), rgba(0x8c323aff).into()),
("link_text".into(), rgba(0x8c323aff).into()),
("link_uri".into(), rgba(0x8c323aff).into()),
("number".into(), rgba(0x8c323aff).into()),
("operator".into(), rgba(0x8c323aff).into()),
("predictive".into(), rgba(0x8c323aff).into()),
("preproc".into(), rgba(0x8c323aff).into()),
("primary".into(), rgba(0x8c323aff).into()),
("property".into(), rgba(0x8c323aff).into()),
("punctuation".into(), rgba(0xb0b4baff).into()),
("punctuation.bracket".into(), rgba(0xb0b4baff).into()),
("punctuation.delimiter".into(), rgba(0xb0b4baff).into()),
("punctuation.list_marker".into(), rgba(0x6fb8ffff).into()),
("punctuation.special".into(), rgba(0x8c323aff).into()),
("string".into(), rgba(0x1ed8a3ff).into()),
("string.escape".into(), rgba(0x8c323aff).into()),
("string.regex".into(), rgba(0xff977dff).into()),
("string.special".into(), rgba(0x8c323aff).into()),
("string.special.symbol".into(), rgba(0x8c323aff).into()),
("tag".into(), rgba(0x8c323aff).into()),
("text.literal".into(), rgba(0x8c323aff).into()),
("title".into(), rgba(0x8c323aff).into()),
("type".into(), rgba(0x8c323aff).into()),
("variable".into(), rgba(0x8c323aff).into()),
("variable.special".into(), rgba(0x8c323aff).into()),
("variant".into(), rgba(0x8c323aff).into()),
],
},
},
}],
scales: default_color_scales(),
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,491 @@
use gpui::rgba;
use crate::{
default_color_scales, Appearance, GitStatusColors, PlayerColor, PlayerColors, StatusColors,
SyntaxTheme, SystemColors, ThemeColors, ThemeFamily, ThemeStyles, ThemeVariant,
};
pub fn palenight() -> ThemeFamily {
ThemeFamily {
id: "3187cd2f-29da-4bde-9621-83016df3b393".into(),
name: "Palenight".into(),
author: "Olaolu Olawuyi (whizkydee)".into(),
themes: vec![
ThemeVariant {
id: "0eaa3098-3aa2-4b8e-b1df-92d9ebd9a0b8".into(),
name: "Palenight".into(),
appearance: Appearance::Dark,
styles: ThemeStyles {
system: SystemColors {
transparent: rgba(0x00000000).into(),
mac_os_traffic_light_red: rgba(0xec6b5fff).into(),
mac_os_traffic_light_yellow: rgba(0xf3bf4dff).into(),
mac_os_traffic_light_green: rgba(0x61c454ff).into(),
},
colors: ThemeColors {
border: rgba(0x282b3bff).into(),
border_variant: rgba(0x282b3bff).into(),
border_focused: rgba(0x282b3bff).into(),
border_disabled: rgba(0x282b3bff).into(),
border_selected: rgba(0x282b3bff).into(),
border_transparent: rgba(0x282b3bff).into(),
elevated_surface_background: rgba(0x292c3eff).into(),
surface_background: rgba(0x292c3eff).into(),
background: rgba(0x292c3eff).into(),
element_background: rgba(0x7d56c1cc).into(),
element_hover: rgba(0x272a2dff).into(),
element_active: rgba(0x2e3135ff).into(),
element_selected: rgba(0x2e3135ff).into(),
element_disabled: rgba(0xddeaf814).into(),
element_placeholder: rgba(0xb0b4baff).into(),
element_drop_target: rgba(0x1166fb18).into(),
ghost_element_background: rgba(0x00000000).into(),
ghost_element_hover: rgba(0x272a2dff).into(),
ghost_element_active: rgba(0x2e3135ff).into(),
ghost_element_selected: rgba(0x2e3135ff).into(),
ghost_element_disabled: rgba(0xddeaf814).into(),
text: rgba(0xffffffff).into(),
text_muted: rgba(0xb0b4baff).into(),
text_placeholder: rgba(0x767a83ff).into(),
text_disabled: rgba(0x696e77ff).into(),
text_accent: rgba(0x6fb8ffff).into(),
icon: rgba(0xb0b4baff).into(),
icon_muted: rgba(0x767a83ff).into(),
icon_disabled: rgba(0x696e77ff).into(),
icon_placeholder: rgba(0x767a83ff).into(),
icon_accent: rgba(0x6fb8ffff).into(),
status_bar_background: rgba(0x18191bff).into(),
title_bar_background: rgba(0x18191bff).into(),
toolbar_background: rgba(0x111113ff).into(),
tab_bar_background: rgba(0x18191bff).into(),
tab_inactive_background: rgba(0x31364aff).into(),
tab_active_background: rgba(0x292c3eff).into(),
editor_background: rgba(0x111113ff).into(),
editor_subheader_background: rgba(0x18191bff).into(),
editor_active_line: rgba(0xddeaf814).into(),
terminal_background: rgba(0x111113ff).into(),
terminal_ansi_bright_black: rgba(0x676e95ff).into(),
terminal_ansi_bright_red: rgba(0xff5571ff).into(),
terminal_ansi_bright_green: rgba(0xc3e88dff).into(),
terminal_ansi_bright_yellow: rgba(0xffcb6bff).into(),
terminal_ansi_bright_blue: rgba(0x82aaffff).into(),
terminal_ansi_bright_magenta: rgba(0xc792eaff).into(),
terminal_ansi_bright_cyan: rgba(0x89ddffff).into(),
terminal_ansi_bright_white: rgba(0xffffffff).into(),
terminal_ansi_black: rgba(0x676e95ff).into(),
terminal_ansi_red: rgba(0xff5571ff).into(),
terminal_ansi_green: rgba(0xa9c77dff).into(),
terminal_ansi_yellow: rgba(0xffcb6bff).into(),
terminal_ansi_blue: rgba(0x82aaffff).into(),
terminal_ansi_magenta: rgba(0xc792eaff).into(),
terminal_ansi_cyan: rgba(0x89ddffff).into(),
terminal_ansi_white: rgba(0xffffffff).into(),
},
status: StatusColors {
conflict: rgba(0xff9592ff).into(),
created: rgba(0x70cf82ff).into(),
deleted: rgba(0xff9592ff).into(),
error: rgba(0xff9592ff).into(),
hidden: rgba(0xb0b4baff).into(),
ignored: rgba(0xb0b4baff).into(),
info: rgba(0x6fb8ffff).into(),
modified: rgba(0xf5e147ff).into(),
renamed: rgba(0x6fb8ffff).into(),
success: rgba(0x70cf82ff).into(),
warning: rgba(0xf5e147ff).into(),
},
git: GitStatusColors {
conflict: rgba(0xffa057ff).into(),
created: rgba(0x70cf82ff).into(),
deleted: rgba(0xff9592ff).into(),
ignored: rgba(0xb0b4baff).into(),
modified: rgba(0xf5e147ff).into(),
renamed: rgba(0x6fb8ffff).into(),
},
player: PlayerColors(vec![
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
]),
syntax: SyntaxTheme {
highlights: vec![
("attribute".into(), rgba(0x4ccce6ff).into()),
("boolean".into(), rgba(0xff977dff).into()),
("comment".into(), rgba(0xb0b4baff).into()),
("comment.doc".into(), rgba(0xe0dffeff).into()),
("constant".into(), rgba(0x8c323aff).into()),
("constructor".into(), rgba(0x8c323aff).into()),
("embedded".into(), rgba(0x8c323aff).into()),
("emphasis".into(), rgba(0x8c323aff).into()),
("emphasis.strong".into(), rgba(0x8c323aff).into()),
("enum".into(), rgba(0x8c323aff).into()),
("function".into(), rgba(0x8c323aff).into()),
("hint".into(), rgba(0x8c323aff).into()),
("keyword".into(), rgba(0xffa057ff).into()),
("label".into(), rgba(0x8c323aff).into()),
("link_text".into(), rgba(0x8c323aff).into()),
("link_uri".into(), rgba(0x8c323aff).into()),
("number".into(), rgba(0x8c323aff).into()),
("operator".into(), rgba(0x8c323aff).into()),
("predictive".into(), rgba(0x8c323aff).into()),
("preproc".into(), rgba(0x8c323aff).into()),
("primary".into(), rgba(0x8c323aff).into()),
("property".into(), rgba(0x8c323aff).into()),
("punctuation".into(), rgba(0xb0b4baff).into()),
("punctuation.bracket".into(), rgba(0xb0b4baff).into()),
("punctuation.delimiter".into(), rgba(0xb0b4baff).into()),
("punctuation.list_marker".into(), rgba(0x6fb8ffff).into()),
("punctuation.special".into(), rgba(0x8c323aff).into()),
("string".into(), rgba(0x1ed8a3ff).into()),
("string.escape".into(), rgba(0x8c323aff).into()),
("string.regex".into(), rgba(0xff977dff).into()),
("string.special".into(), rgba(0x8c323aff).into()),
("string.special.symbol".into(), rgba(0x8c323aff).into()),
("tag".into(), rgba(0x8c323aff).into()),
("text.literal".into(), rgba(0x8c323aff).into()),
("title".into(), rgba(0x8c323aff).into()),
("type".into(), rgba(0x8c323aff).into()),
("variable".into(), rgba(0x8c323aff).into()),
("variable.special".into(), rgba(0x8c323aff).into()),
("variant".into(), rgba(0x8c323aff).into()),
],
},
},
},
ThemeVariant {
id: "b6a27c72-c5b1-431b-8bfe-29e33dbcb337".into(),
name: "Palenight Operator".into(),
appearance: Appearance::Dark,
styles: ThemeStyles {
system: SystemColors {
transparent: rgba(0x00000000).into(),
mac_os_traffic_light_red: rgba(0xec6b5fff).into(),
mac_os_traffic_light_yellow: rgba(0xf3bf4dff).into(),
mac_os_traffic_light_green: rgba(0x61c454ff).into(),
},
colors: ThemeColors {
border: rgba(0x282b3bff).into(),
border_variant: rgba(0x282b3bff).into(),
border_focused: rgba(0x282b3bff).into(),
border_disabled: rgba(0x282b3bff).into(),
border_selected: rgba(0x282b3bff).into(),
border_transparent: rgba(0x282b3bff).into(),
elevated_surface_background: rgba(0x292c3eff).into(),
surface_background: rgba(0x292c3eff).into(),
background: rgba(0x292c3eff).into(),
element_background: rgba(0x7d56c1cc).into(),
element_hover: rgba(0x272a2dff).into(),
element_active: rgba(0x2e3135ff).into(),
element_selected: rgba(0x2e3135ff).into(),
element_disabled: rgba(0xddeaf814).into(),
element_placeholder: rgba(0xb0b4baff).into(),
element_drop_target: rgba(0x1166fb18).into(),
ghost_element_background: rgba(0x00000000).into(),
ghost_element_hover: rgba(0x272a2dff).into(),
ghost_element_active: rgba(0x2e3135ff).into(),
ghost_element_selected: rgba(0x2e3135ff).into(),
ghost_element_disabled: rgba(0xddeaf814).into(),
text: rgba(0xffffffff).into(),
text_muted: rgba(0xb0b4baff).into(),
text_placeholder: rgba(0x767a83ff).into(),
text_disabled: rgba(0x696e77ff).into(),
text_accent: rgba(0x6fb8ffff).into(),
icon: rgba(0xb0b4baff).into(),
icon_muted: rgba(0x767a83ff).into(),
icon_disabled: rgba(0x696e77ff).into(),
icon_placeholder: rgba(0x767a83ff).into(),
icon_accent: rgba(0x6fb8ffff).into(),
status_bar_background: rgba(0x18191bff).into(),
title_bar_background: rgba(0x18191bff).into(),
toolbar_background: rgba(0x111113ff).into(),
tab_bar_background: rgba(0x18191bff).into(),
tab_inactive_background: rgba(0x31364aff).into(),
tab_active_background: rgba(0x292c3eff).into(),
editor_background: rgba(0x111113ff).into(),
editor_subheader_background: rgba(0x18191bff).into(),
editor_active_line: rgba(0xddeaf814).into(),
terminal_background: rgba(0x111113ff).into(),
terminal_ansi_bright_black: rgba(0x676e95ff).into(),
terminal_ansi_bright_red: rgba(0xff5571ff).into(),
terminal_ansi_bright_green: rgba(0xc3e88dff).into(),
terminal_ansi_bright_yellow: rgba(0xffcb6bff).into(),
terminal_ansi_bright_blue: rgba(0x82aaffff).into(),
terminal_ansi_bright_magenta: rgba(0xc792eaff).into(),
terminal_ansi_bright_cyan: rgba(0x89ddffff).into(),
terminal_ansi_bright_white: rgba(0xffffffff).into(),
terminal_ansi_black: rgba(0x676e95ff).into(),
terminal_ansi_red: rgba(0xff5571ff).into(),
terminal_ansi_green: rgba(0xa9c77dff).into(),
terminal_ansi_yellow: rgba(0xffcb6bff).into(),
terminal_ansi_blue: rgba(0x82aaffff).into(),
terminal_ansi_magenta: rgba(0xc792eaff).into(),
terminal_ansi_cyan: rgba(0x89ddffff).into(),
terminal_ansi_white: rgba(0xffffffff).into(),
},
status: StatusColors {
conflict: rgba(0xff9592ff).into(),
created: rgba(0x70cf82ff).into(),
deleted: rgba(0xff9592ff).into(),
error: rgba(0xff9592ff).into(),
hidden: rgba(0xb0b4baff).into(),
ignored: rgba(0xb0b4baff).into(),
info: rgba(0x6fb8ffff).into(),
modified: rgba(0xf5e147ff).into(),
renamed: rgba(0x6fb8ffff).into(),
success: rgba(0x70cf82ff).into(),
warning: rgba(0xf5e147ff).into(),
},
git: GitStatusColors {
conflict: rgba(0xffa057ff).into(),
created: rgba(0x70cf82ff).into(),
deleted: rgba(0xff9592ff).into(),
ignored: rgba(0xb0b4baff).into(),
modified: rgba(0xf5e147ff).into(),
renamed: rgba(0x6fb8ffff).into(),
},
player: PlayerColors(vec![
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
]),
syntax: SyntaxTheme {
highlights: vec![
("attribute".into(), rgba(0x4ccce6ff).into()),
("boolean".into(), rgba(0xff977dff).into()),
("comment".into(), rgba(0xb0b4baff).into()),
("comment.doc".into(), rgba(0xe0dffeff).into()),
("constant".into(), rgba(0x8c323aff).into()),
("constructor".into(), rgba(0x8c323aff).into()),
("embedded".into(), rgba(0x8c323aff).into()),
("emphasis".into(), rgba(0x8c323aff).into()),
("emphasis.strong".into(), rgba(0x8c323aff).into()),
("enum".into(), rgba(0x8c323aff).into()),
("function".into(), rgba(0x8c323aff).into()),
("hint".into(), rgba(0x8c323aff).into()),
("keyword".into(), rgba(0xffa057ff).into()),
("label".into(), rgba(0x8c323aff).into()),
("link_text".into(), rgba(0x8c323aff).into()),
("link_uri".into(), rgba(0x8c323aff).into()),
("number".into(), rgba(0x8c323aff).into()),
("operator".into(), rgba(0x8c323aff).into()),
("predictive".into(), rgba(0x8c323aff).into()),
("preproc".into(), rgba(0x8c323aff).into()),
("primary".into(), rgba(0x8c323aff).into()),
("property".into(), rgba(0x8c323aff).into()),
("punctuation".into(), rgba(0xb0b4baff).into()),
("punctuation.bracket".into(), rgba(0xb0b4baff).into()),
("punctuation.delimiter".into(), rgba(0xb0b4baff).into()),
("punctuation.list_marker".into(), rgba(0x6fb8ffff).into()),
("punctuation.special".into(), rgba(0x8c323aff).into()),
("string".into(), rgba(0x1ed8a3ff).into()),
("string.escape".into(), rgba(0x8c323aff).into()),
("string.regex".into(), rgba(0xff977dff).into()),
("string.special".into(), rgba(0x8c323aff).into()),
("string.special.symbol".into(), rgba(0x8c323aff).into()),
("tag".into(), rgba(0x8c323aff).into()),
("text.literal".into(), rgba(0x8c323aff).into()),
("title".into(), rgba(0x8c323aff).into()),
("type".into(), rgba(0x8c323aff).into()),
("variable".into(), rgba(0x8c323aff).into()),
("variable.special".into(), rgba(0x8c323aff).into()),
("variant".into(), rgba(0x8c323aff).into()),
],
},
},
},
ThemeVariant {
id: "4015bf85-061c-45ff-81ba-a31f017aac83".into(),
name: "Palenight (Mild Contrast)".into(),
appearance: Appearance::Dark,
styles: ThemeStyles {
system: SystemColors {
transparent: rgba(0x00000000).into(),
mac_os_traffic_light_red: rgba(0xec6b5fff).into(),
mac_os_traffic_light_yellow: rgba(0xf3bf4dff).into(),
mac_os_traffic_light_green: rgba(0x61c454ff).into(),
},
colors: ThemeColors {
border: rgba(0x2c2f40ff).into(),
border_variant: rgba(0x2c2f40ff).into(),
border_focused: rgba(0x2c2f40ff).into(),
border_disabled: rgba(0x2c2f40ff).into(),
border_selected: rgba(0x2c2f40ff).into(),
border_transparent: rgba(0x2c2f40ff).into(),
elevated_surface_background: rgba(0x25283aff).into(),
surface_background: rgba(0x25283aff).into(),
background: rgba(0x292c3eff).into(),
element_background: rgba(0x7d56c1cc).into(),
element_hover: rgba(0x272a2dff).into(),
element_active: rgba(0x2e3135ff).into(),
element_selected: rgba(0x2e3135ff).into(),
element_disabled: rgba(0xddeaf814).into(),
element_placeholder: rgba(0xb0b4baff).into(),
element_drop_target: rgba(0x1166fb18).into(),
ghost_element_background: rgba(0x00000000).into(),
ghost_element_hover: rgba(0x272a2dff).into(),
ghost_element_active: rgba(0x2e3135ff).into(),
ghost_element_selected: rgba(0x2e3135ff).into(),
ghost_element_disabled: rgba(0xddeaf814).into(),
text: rgba(0xffffffff).into(),
text_muted: rgba(0xb0b4baff).into(),
text_placeholder: rgba(0x767a83ff).into(),
text_disabled: rgba(0x696e77ff).into(),
text_accent: rgba(0x6fb8ffff).into(),
icon: rgba(0xb0b4baff).into(),
icon_muted: rgba(0x767a83ff).into(),
icon_disabled: rgba(0x696e77ff).into(),
icon_placeholder: rgba(0x767a83ff).into(),
icon_accent: rgba(0x6fb8ffff).into(),
status_bar_background: rgba(0x18191bff).into(),
title_bar_background: rgba(0x18191bff).into(),
toolbar_background: rgba(0x111113ff).into(),
tab_bar_background: rgba(0x18191bff).into(),
tab_inactive_background: rgba(0x31364aff).into(),
tab_active_background: rgba(0x25283aff).into(),
editor_background: rgba(0x111113ff).into(),
editor_subheader_background: rgba(0x18191bff).into(),
editor_active_line: rgba(0xddeaf814).into(),
terminal_background: rgba(0x111113ff).into(),
terminal_ansi_bright_black: rgba(0x676e95ff).into(),
terminal_ansi_bright_red: rgba(0xff5571ff).into(),
terminal_ansi_bright_green: rgba(0xc3e88dff).into(),
terminal_ansi_bright_yellow: rgba(0xffcb6bff).into(),
terminal_ansi_bright_blue: rgba(0x82aaffff).into(),
terminal_ansi_bright_magenta: rgba(0xc792eaff).into(),
terminal_ansi_bright_cyan: rgba(0x89ddffff).into(),
terminal_ansi_bright_white: rgba(0xffffffff).into(),
terminal_ansi_black: rgba(0x676e95ff).into(),
terminal_ansi_red: rgba(0xff5571ff).into(),
terminal_ansi_green: rgba(0xa9c77dff).into(),
terminal_ansi_yellow: rgba(0xffcb6bff).into(),
terminal_ansi_blue: rgba(0x82aaffff).into(),
terminal_ansi_magenta: rgba(0xc792eaff).into(),
terminal_ansi_cyan: rgba(0x89ddffff).into(),
terminal_ansi_white: rgba(0xffffffff).into(),
},
status: StatusColors {
conflict: rgba(0xff9592ff).into(),
created: rgba(0x70cf82ff).into(),
deleted: rgba(0xff9592ff).into(),
error: rgba(0xff9592ff).into(),
hidden: rgba(0xb0b4baff).into(),
ignored: rgba(0xb0b4baff).into(),
info: rgba(0x6fb8ffff).into(),
modified: rgba(0xf5e147ff).into(),
renamed: rgba(0x6fb8ffff).into(),
success: rgba(0x70cf82ff).into(),
warning: rgba(0xf5e147ff).into(),
},
git: GitStatusColors {
conflict: rgba(0xffa057ff).into(),
created: rgba(0x70cf82ff).into(),
deleted: rgba(0xff9592ff).into(),
ignored: rgba(0xb0b4baff).into(),
modified: rgba(0xf5e147ff).into(),
renamed: rgba(0x6fb8ffff).into(),
},
player: PlayerColors(vec![
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
]),
syntax: SyntaxTheme {
highlights: vec![
("attribute".into(), rgba(0x4ccce6ff).into()),
("boolean".into(), rgba(0xff977dff).into()),
("comment".into(), rgba(0xb0b4baff).into()),
("comment.doc".into(), rgba(0xe0dffeff).into()),
("constant".into(), rgba(0x8c323aff).into()),
("constructor".into(), rgba(0x8c323aff).into()),
("embedded".into(), rgba(0x8c323aff).into()),
("emphasis".into(), rgba(0x8c323aff).into()),
("emphasis.strong".into(), rgba(0x8c323aff).into()),
("enum".into(), rgba(0x8c323aff).into()),
("function".into(), rgba(0x8c323aff).into()),
("hint".into(), rgba(0x8c323aff).into()),
("keyword".into(), rgba(0xffa057ff).into()),
("label".into(), rgba(0x8c323aff).into()),
("link_text".into(), rgba(0x8c323aff).into()),
("link_uri".into(), rgba(0x8c323aff).into()),
("number".into(), rgba(0x8c323aff).into()),
("operator".into(), rgba(0x8c323aff).into()),
("predictive".into(), rgba(0x8c323aff).into()),
("preproc".into(), rgba(0x8c323aff).into()),
("primary".into(), rgba(0x8c323aff).into()),
("property".into(), rgba(0x8c323aff).into()),
("punctuation".into(), rgba(0xb0b4baff).into()),
("punctuation.bracket".into(), rgba(0xb0b4baff).into()),
("punctuation.delimiter".into(), rgba(0xb0b4baff).into()),
("punctuation.list_marker".into(), rgba(0x6fb8ffff).into()),
("punctuation.special".into(), rgba(0x8c323aff).into()),
("string".into(), rgba(0x1ed8a3ff).into()),
("string.escape".into(), rgba(0x8c323aff).into()),
("string.regex".into(), rgba(0xff977dff).into()),
("string.special".into(), rgba(0x8c323aff).into()),
("string.special.symbol".into(), rgba(0x8c323aff).into()),
("tag".into(), rgba(0x8c323aff).into()),
("text.literal".into(), rgba(0x8c323aff).into()),
("title".into(), rgba(0x8c323aff).into()),
("type".into(), rgba(0x8c323aff).into()),
("variable".into(), rgba(0x8c323aff).into()),
("variable.special".into(), rgba(0x8c323aff).into()),
("variant".into(), rgba(0x8c323aff).into()),
],
},
},
},
],
scales: default_color_scales(),
}
}

View file

@ -0,0 +1,491 @@
use gpui::rgba;
use crate::{
default_color_scales, Appearance, GitStatusColors, PlayerColor, PlayerColors, StatusColors,
SyntaxTheme, SystemColors, ThemeColors, ThemeFamily, ThemeStyles, ThemeVariant,
};
pub fn rose_pine() -> ThemeFamily {
ThemeFamily {
id: "48c308b9-7dbe-4a52-b935-0b44d9dac00d".into(),
name: "Rose Pine".into(),
author: "Rosé Pine".into(),
themes: vec![
ThemeVariant {
id: "c2832e85-20cb-4a13-924f-026e68123068".into(),
name: "Rose Pine".into(),
appearance: Appearance::Dark,
styles: ThemeStyles {
system: SystemColors {
transparent: rgba(0x00000000).into(),
mac_os_traffic_light_red: rgba(0xec6b5fff).into(),
mac_os_traffic_light_yellow: rgba(0xf3bf4dff).into(),
mac_os_traffic_light_green: rgba(0x61c454ff).into(),
},
colors: ThemeColors {
border: rgba(0x000000ff).into(),
border_variant: rgba(0x000000ff).into(),
border_focused: rgba(0x000000ff).into(),
border_disabled: rgba(0x000000ff).into(),
border_selected: rgba(0x000000ff).into(),
border_transparent: rgba(0x000000ff).into(),
elevated_surface_background: rgba(0x1f1d2eff).into(),
surface_background: rgba(0x1f1d2eff).into(),
background: rgba(0x191724ff).into(),
element_background: rgba(0xebbcbaff).into(),
element_hover: rgba(0x272a2dff).into(),
element_active: rgba(0x2e3135ff).into(),
element_selected: rgba(0x2e3135ff).into(),
element_disabled: rgba(0xddeaf814).into(),
element_placeholder: rgba(0xb0b4baff).into(),
element_drop_target: rgba(0x1166fb18).into(),
ghost_element_background: rgba(0x00000000).into(),
ghost_element_hover: rgba(0x272a2dff).into(),
ghost_element_active: rgba(0x2e3135ff).into(),
ghost_element_selected: rgba(0x2e3135ff).into(),
ghost_element_disabled: rgba(0xddeaf814).into(),
text: rgba(0xe0def4ff).into(),
text_muted: rgba(0xb0b4baff).into(),
text_placeholder: rgba(0x767a83ff).into(),
text_disabled: rgba(0x696e77ff).into(),
text_accent: rgba(0x6fb8ffff).into(),
icon: rgba(0xb0b4baff).into(),
icon_muted: rgba(0x767a83ff).into(),
icon_disabled: rgba(0x696e77ff).into(),
icon_placeholder: rgba(0x767a83ff).into(),
icon_accent: rgba(0x6fb8ffff).into(),
status_bar_background: rgba(0x18191bff).into(),
title_bar_background: rgba(0x18191bff).into(),
toolbar_background: rgba(0x111113ff).into(),
tab_bar_background: rgba(0x18191bff).into(),
tab_inactive_background: rgba(0x000000ff).into(),
tab_active_background: rgba(0x6e6a861a).into(),
editor_background: rgba(0x111113ff).into(),
editor_subheader_background: rgba(0x18191bff).into(),
editor_active_line: rgba(0xddeaf814).into(),
terminal_background: rgba(0x111113ff).into(),
terminal_ansi_bright_black: rgba(0x908caaff).into(),
terminal_ansi_bright_red: rgba(0xeb6f92ff).into(),
terminal_ansi_bright_green: rgba(0x30738fff).into(),
terminal_ansi_bright_yellow: rgba(0xf5c177ff).into(),
terminal_ansi_bright_blue: rgba(0x9ccfd8ff).into(),
terminal_ansi_bright_magenta: rgba(0xc4a7e7ff).into(),
terminal_ansi_bright_cyan: rgba(0xebbcbaff).into(),
terminal_ansi_bright_white: rgba(0xe0def4ff).into(),
terminal_ansi_black: rgba(0x26233aff).into(),
terminal_ansi_red: rgba(0xeb6f92ff).into(),
terminal_ansi_green: rgba(0x30738fff).into(),
terminal_ansi_yellow: rgba(0xf5c177ff).into(),
terminal_ansi_blue: rgba(0x9ccfd8ff).into(),
terminal_ansi_magenta: rgba(0xc4a7e7ff).into(),
terminal_ansi_cyan: rgba(0xebbcbaff).into(),
terminal_ansi_white: rgba(0xe0def4ff).into(),
},
status: StatusColors {
conflict: rgba(0xff9592ff).into(),
created: rgba(0x70cf82ff).into(),
deleted: rgba(0xff9592ff).into(),
error: rgba(0xff9592ff).into(),
hidden: rgba(0xb0b4baff).into(),
ignored: rgba(0xb0b4baff).into(),
info: rgba(0x6fb8ffff).into(),
modified: rgba(0xf5e147ff).into(),
renamed: rgba(0x6fb8ffff).into(),
success: rgba(0x70cf82ff).into(),
warning: rgba(0xf5e147ff).into(),
},
git: GitStatusColors {
conflict: rgba(0xffa057ff).into(),
created: rgba(0x70cf82ff).into(),
deleted: rgba(0xff9592ff).into(),
ignored: rgba(0xb0b4baff).into(),
modified: rgba(0xf5e147ff).into(),
renamed: rgba(0x6fb8ffff).into(),
},
player: PlayerColors(vec![
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
]),
syntax: SyntaxTheme {
highlights: vec![
("attribute".into(), rgba(0x4ccce6ff).into()),
("boolean".into(), rgba(0xff977dff).into()),
("comment".into(), rgba(0xb0b4baff).into()),
("comment.doc".into(), rgba(0xe0dffeff).into()),
("constant".into(), rgba(0x8c323aff).into()),
("constructor".into(), rgba(0x8c323aff).into()),
("embedded".into(), rgba(0x8c323aff).into()),
("emphasis".into(), rgba(0x8c323aff).into()),
("emphasis.strong".into(), rgba(0x8c323aff).into()),
("enum".into(), rgba(0x8c323aff).into()),
("function".into(), rgba(0x8c323aff).into()),
("hint".into(), rgba(0x8c323aff).into()),
("keyword".into(), rgba(0xffa057ff).into()),
("label".into(), rgba(0x8c323aff).into()),
("link_text".into(), rgba(0x8c323aff).into()),
("link_uri".into(), rgba(0x8c323aff).into()),
("number".into(), rgba(0x8c323aff).into()),
("operator".into(), rgba(0x8c323aff).into()),
("predictive".into(), rgba(0x8c323aff).into()),
("preproc".into(), rgba(0x8c323aff).into()),
("primary".into(), rgba(0x8c323aff).into()),
("property".into(), rgba(0x8c323aff).into()),
("punctuation".into(), rgba(0xb0b4baff).into()),
("punctuation.bracket".into(), rgba(0xb0b4baff).into()),
("punctuation.delimiter".into(), rgba(0xb0b4baff).into()),
("punctuation.list_marker".into(), rgba(0x6fb8ffff).into()),
("punctuation.special".into(), rgba(0x8c323aff).into()),
("string".into(), rgba(0x1ed8a3ff).into()),
("string.escape".into(), rgba(0x8c323aff).into()),
("string.regex".into(), rgba(0xff977dff).into()),
("string.special".into(), rgba(0x8c323aff).into()),
("string.special.symbol".into(), rgba(0x8c323aff).into()),
("tag".into(), rgba(0x8c323aff).into()),
("text.literal".into(), rgba(0x8c323aff).into()),
("title".into(), rgba(0x8c323aff).into()),
("type".into(), rgba(0x8c323aff).into()),
("variable".into(), rgba(0x8c323aff).into()),
("variable.special".into(), rgba(0x8c323aff).into()),
("variant".into(), rgba(0x8c323aff).into()),
],
},
},
},
ThemeVariant {
id: "3f6c3263-86f4-4a0e-92a6-144984aa2d38".into(),
name: "Rose Moon".into(),
appearance: Appearance::Dark,
styles: ThemeStyles {
system: SystemColors {
transparent: rgba(0x00000000).into(),
mac_os_traffic_light_red: rgba(0xec6b5fff).into(),
mac_os_traffic_light_yellow: rgba(0xf3bf4dff).into(),
mac_os_traffic_light_green: rgba(0x61c454ff).into(),
},
colors: ThemeColors {
border: rgba(0x000000ff).into(),
border_variant: rgba(0x000000ff).into(),
border_focused: rgba(0x000000ff).into(),
border_disabled: rgba(0x000000ff).into(),
border_selected: rgba(0x000000ff).into(),
border_transparent: rgba(0x000000ff).into(),
elevated_surface_background: rgba(0x2a273eff).into(),
surface_background: rgba(0x2a273eff).into(),
background: rgba(0x232136ff).into(),
element_background: rgba(0xea9a97ff).into(),
element_hover: rgba(0x272a2dff).into(),
element_active: rgba(0x2e3135ff).into(),
element_selected: rgba(0x2e3135ff).into(),
element_disabled: rgba(0xddeaf814).into(),
element_placeholder: rgba(0xb0b4baff).into(),
element_drop_target: rgba(0x1166fb18).into(),
ghost_element_background: rgba(0x00000000).into(),
ghost_element_hover: rgba(0x272a2dff).into(),
ghost_element_active: rgba(0x2e3135ff).into(),
ghost_element_selected: rgba(0x2e3135ff).into(),
ghost_element_disabled: rgba(0xddeaf814).into(),
text: rgba(0xe0def4ff).into(),
text_muted: rgba(0xb0b4baff).into(),
text_placeholder: rgba(0x767a83ff).into(),
text_disabled: rgba(0x696e77ff).into(),
text_accent: rgba(0x6fb8ffff).into(),
icon: rgba(0xb0b4baff).into(),
icon_muted: rgba(0x767a83ff).into(),
icon_disabled: rgba(0x696e77ff).into(),
icon_placeholder: rgba(0x767a83ff).into(),
icon_accent: rgba(0x6fb8ffff).into(),
status_bar_background: rgba(0x18191bff).into(),
title_bar_background: rgba(0x18191bff).into(),
toolbar_background: rgba(0x111113ff).into(),
tab_bar_background: rgba(0x18191bff).into(),
tab_inactive_background: rgba(0x000000ff).into(),
tab_active_background: rgba(0x817c9c14).into(),
editor_background: rgba(0x111113ff).into(),
editor_subheader_background: rgba(0x18191bff).into(),
editor_active_line: rgba(0xddeaf814).into(),
terminal_background: rgba(0x111113ff).into(),
terminal_ansi_bright_black: rgba(0x908caaff).into(),
terminal_ansi_bright_red: rgba(0xeb6f92ff).into(),
terminal_ansi_bright_green: rgba(0x3d8fb0ff).into(),
terminal_ansi_bright_yellow: rgba(0xf5c177ff).into(),
terminal_ansi_bright_blue: rgba(0x9ccfd8ff).into(),
terminal_ansi_bright_magenta: rgba(0xc4a7e7ff).into(),
terminal_ansi_bright_cyan: rgba(0xea9a97ff).into(),
terminal_ansi_bright_white: rgba(0xe0def4ff).into(),
terminal_ansi_black: rgba(0x393552ff).into(),
terminal_ansi_red: rgba(0xeb6f92ff).into(),
terminal_ansi_green: rgba(0x3d8fb0ff).into(),
terminal_ansi_yellow: rgba(0xf5c177ff).into(),
terminal_ansi_blue: rgba(0x9ccfd8ff).into(),
terminal_ansi_magenta: rgba(0xc4a7e7ff).into(),
terminal_ansi_cyan: rgba(0xea9a97ff).into(),
terminal_ansi_white: rgba(0xe0def4ff).into(),
},
status: StatusColors {
conflict: rgba(0xff9592ff).into(),
created: rgba(0x70cf82ff).into(),
deleted: rgba(0xff9592ff).into(),
error: rgba(0xff9592ff).into(),
hidden: rgba(0xb0b4baff).into(),
ignored: rgba(0xb0b4baff).into(),
info: rgba(0x6fb8ffff).into(),
modified: rgba(0xf5e147ff).into(),
renamed: rgba(0x6fb8ffff).into(),
success: rgba(0x70cf82ff).into(),
warning: rgba(0xf5e147ff).into(),
},
git: GitStatusColors {
conflict: rgba(0xffa057ff).into(),
created: rgba(0x70cf82ff).into(),
deleted: rgba(0xff9592ff).into(),
ignored: rgba(0xb0b4baff).into(),
modified: rgba(0xf5e147ff).into(),
renamed: rgba(0x6fb8ffff).into(),
},
player: PlayerColors(vec![
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
]),
syntax: SyntaxTheme {
highlights: vec![
("attribute".into(), rgba(0x4ccce6ff).into()),
("boolean".into(), rgba(0xff977dff).into()),
("comment".into(), rgba(0xb0b4baff).into()),
("comment.doc".into(), rgba(0xe0dffeff).into()),
("constant".into(), rgba(0x8c323aff).into()),
("constructor".into(), rgba(0x8c323aff).into()),
("embedded".into(), rgba(0x8c323aff).into()),
("emphasis".into(), rgba(0x8c323aff).into()),
("emphasis.strong".into(), rgba(0x8c323aff).into()),
("enum".into(), rgba(0x8c323aff).into()),
("function".into(), rgba(0x8c323aff).into()),
("hint".into(), rgba(0x8c323aff).into()),
("keyword".into(), rgba(0xffa057ff).into()),
("label".into(), rgba(0x8c323aff).into()),
("link_text".into(), rgba(0x8c323aff).into()),
("link_uri".into(), rgba(0x8c323aff).into()),
("number".into(), rgba(0x8c323aff).into()),
("operator".into(), rgba(0x8c323aff).into()),
("predictive".into(), rgba(0x8c323aff).into()),
("preproc".into(), rgba(0x8c323aff).into()),
("primary".into(), rgba(0x8c323aff).into()),
("property".into(), rgba(0x8c323aff).into()),
("punctuation".into(), rgba(0xb0b4baff).into()),
("punctuation.bracket".into(), rgba(0xb0b4baff).into()),
("punctuation.delimiter".into(), rgba(0xb0b4baff).into()),
("punctuation.list_marker".into(), rgba(0x6fb8ffff).into()),
("punctuation.special".into(), rgba(0x8c323aff).into()),
("string".into(), rgba(0x1ed8a3ff).into()),
("string.escape".into(), rgba(0x8c323aff).into()),
("string.regex".into(), rgba(0xff977dff).into()),
("string.special".into(), rgba(0x8c323aff).into()),
("string.special.symbol".into(), rgba(0x8c323aff).into()),
("tag".into(), rgba(0x8c323aff).into()),
("text.literal".into(), rgba(0x8c323aff).into()),
("title".into(), rgba(0x8c323aff).into()),
("type".into(), rgba(0x8c323aff).into()),
("variable".into(), rgba(0x8c323aff).into()),
("variable.special".into(), rgba(0x8c323aff).into()),
("variant".into(), rgba(0x8c323aff).into()),
],
},
},
},
ThemeVariant {
id: "d171cda6-de3b-4528-8559-cd8fb71b2e7c".into(),
name: "Rose Pine Dawn".into(),
appearance: Appearance::Light,
styles: ThemeStyles {
system: SystemColors {
transparent: rgba(0x00000000).into(),
mac_os_traffic_light_red: rgba(0xec6b5fff).into(),
mac_os_traffic_light_yellow: rgba(0xf3bf4dff).into(),
mac_os_traffic_light_green: rgba(0x61c454ff).into(),
},
colors: ThemeColors {
border: rgba(0x000000ff).into(),
border_variant: rgba(0x000000ff).into(),
border_focused: rgba(0x000000ff).into(),
border_disabled: rgba(0x000000ff).into(),
border_selected: rgba(0x000000ff).into(),
border_transparent: rgba(0x000000ff).into(),
elevated_surface_background: rgba(0xfffaf3ff).into(),
surface_background: rgba(0xfffaf3ff).into(),
background: rgba(0xfaf4edff).into(),
element_background: rgba(0xd7827dff).into(),
element_hover: rgba(0xe8e8ecff).into(),
element_active: rgba(0xe0e1e6ff).into(),
element_selected: rgba(0xe0e1e6ff).into(),
element_disabled: rgba(0x0000320f).into(),
element_placeholder: rgba(0x60646cff).into(),
element_drop_target: rgba(0x008bff0b).into(),
ghost_element_background: rgba(0x00000000).into(),
ghost_element_hover: rgba(0xe8e8ecff).into(),
ghost_element_active: rgba(0xe0e1e6ff).into(),
ghost_element_selected: rgba(0xe0e1e6ff).into(),
ghost_element_disabled: rgba(0x0000320f).into(),
text: rgba(0x575279ff).into(),
text_muted: rgba(0x60646cff).into(),
text_placeholder: rgba(0x80838dff).into(),
text_disabled: rgba(0x8b8d98ff).into(),
text_accent: rgba(0x0c73ceff).into(),
icon: rgba(0x60646cff).into(),
icon_muted: rgba(0x80838dff).into(),
icon_disabled: rgba(0x8b8d98ff).into(),
icon_placeholder: rgba(0x80838dff).into(),
icon_accent: rgba(0x0c73ceff).into(),
status_bar_background: rgba(0xf9f9fbff).into(),
title_bar_background: rgba(0xf9f9fbff).into(),
toolbar_background: rgba(0xfcfcfdff).into(),
tab_bar_background: rgba(0xf9f9fbff).into(),
tab_inactive_background: rgba(0x000000ff).into(),
tab_active_background: rgba(0x6e6a860d).into(),
editor_background: rgba(0xfcfcfdff).into(),
editor_subheader_background: rgba(0xf9f9fbff).into(),
editor_active_line: rgba(0x0000320f).into(),
terminal_background: rgba(0xfcfcfdff).into(),
terminal_ansi_bright_black: rgba(0x797593ff).into(),
terminal_ansi_bright_red: rgba(0xb3627aff).into(),
terminal_ansi_bright_green: rgba(0x276983ff).into(),
terminal_ansi_bright_yellow: rgba(0xea9d34ff).into(),
terminal_ansi_bright_blue: rgba(0x55949fff).into(),
terminal_ansi_bright_magenta: rgba(0x9079a9ff).into(),
terminal_ansi_bright_cyan: rgba(0xd7827dff).into(),
terminal_ansi_bright_white: rgba(0x575279ff).into(),
terminal_ansi_black: rgba(0xf2e9e1ff).into(),
terminal_ansi_red: rgba(0xb3627aff).into(),
terminal_ansi_green: rgba(0x276983ff).into(),
terminal_ansi_yellow: rgba(0xea9d34ff).into(),
terminal_ansi_blue: rgba(0x55949fff).into(),
terminal_ansi_magenta: rgba(0x9079a9ff).into(),
terminal_ansi_cyan: rgba(0xd7827dff).into(),
terminal_ansi_white: rgba(0x575279ff).into(),
},
status: StatusColors {
conflict: rgba(0xff9592ff).into(),
created: rgba(0x70cf82ff).into(),
deleted: rgba(0xff9592ff).into(),
error: rgba(0xff9592ff).into(),
hidden: rgba(0xb0b4baff).into(),
ignored: rgba(0xb0b4baff).into(),
info: rgba(0x6fb8ffff).into(),
modified: rgba(0xf5e147ff).into(),
renamed: rgba(0x6fb8ffff).into(),
success: rgba(0x70cf82ff).into(),
warning: rgba(0xf5e147ff).into(),
},
git: GitStatusColors {
conflict: rgba(0xffa057ff).into(),
created: rgba(0x70cf82ff).into(),
deleted: rgba(0xff9592ff).into(),
ignored: rgba(0xb0b4baff).into(),
modified: rgba(0xf5e147ff).into(),
renamed: rgba(0x6fb8ffff).into(),
},
player: PlayerColors(vec![
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
]),
syntax: SyntaxTheme {
highlights: vec![
("attribute".into(), rgba(0x4ccce6ff).into()),
("boolean".into(), rgba(0xff977dff).into()),
("comment".into(), rgba(0xb0b4baff).into()),
("comment.doc".into(), rgba(0xe0dffeff).into()),
("constant".into(), rgba(0x8c323aff).into()),
("constructor".into(), rgba(0x8c323aff).into()),
("embedded".into(), rgba(0x8c323aff).into()),
("emphasis".into(), rgba(0x8c323aff).into()),
("emphasis.strong".into(), rgba(0x8c323aff).into()),
("enum".into(), rgba(0x8c323aff).into()),
("function".into(), rgba(0x8c323aff).into()),
("hint".into(), rgba(0x8c323aff).into()),
("keyword".into(), rgba(0xffa057ff).into()),
("label".into(), rgba(0x8c323aff).into()),
("link_text".into(), rgba(0x8c323aff).into()),
("link_uri".into(), rgba(0x8c323aff).into()),
("number".into(), rgba(0x8c323aff).into()),
("operator".into(), rgba(0x8c323aff).into()),
("predictive".into(), rgba(0x8c323aff).into()),
("preproc".into(), rgba(0x8c323aff).into()),
("primary".into(), rgba(0x8c323aff).into()),
("property".into(), rgba(0x8c323aff).into()),
("punctuation".into(), rgba(0xb0b4baff).into()),
("punctuation.bracket".into(), rgba(0xb0b4baff).into()),
("punctuation.delimiter".into(), rgba(0xb0b4baff).into()),
("punctuation.list_marker".into(), rgba(0x6fb8ffff).into()),
("punctuation.special".into(), rgba(0x8c323aff).into()),
("string".into(), rgba(0x1ed8a3ff).into()),
("string.escape".into(), rgba(0x8c323aff).into()),
("string.regex".into(), rgba(0xff977dff).into()),
("string.special".into(), rgba(0x8c323aff).into()),
("string.special.symbol".into(), rgba(0x8c323aff).into()),
("tag".into(), rgba(0x8c323aff).into()),
("text.literal".into(), rgba(0x8c323aff).into()),
("title".into(), rgba(0x8c323aff).into()),
("type".into(), rgba(0x8c323aff).into()),
("variable".into(), rgba(0x8c323aff).into()),
("variable.special".into(), rgba(0x8c323aff).into()),
("variant".into(), rgba(0x8c323aff).into()),
],
},
},
},
],
scales: default_color_scales(),
}
}

View file

@ -0,0 +1,333 @@
use gpui::rgba;
use crate::{
default_color_scales, Appearance, GitStatusColors, PlayerColor, PlayerColors, StatusColors,
SyntaxTheme, SystemColors, ThemeColors, ThemeFamily, ThemeStyles, ThemeVariant,
};
pub fn solarized() -> ThemeFamily {
ThemeFamily {
id: "9a6f18c9-520f-46ec-9bfb-a7ee73508139".into(),
name: "Solarized".into(),
author: "Ethan Schoonover (altercation)".into(),
themes: vec![
ThemeVariant {
id: "74003db2-7f9a-4d26-8815-020c796bb551".into(),
name: "Solarized Dark".into(),
appearance: Appearance::Dark,
styles: ThemeStyles {
system: SystemColors {
transparent: rgba(0x00000000).into(),
mac_os_traffic_light_red: rgba(0xec6b5fff).into(),
mac_os_traffic_light_yellow: rgba(0xf3bf4dff).into(),
mac_os_traffic_light_green: rgba(0x61c454ff).into(),
},
colors: ThemeColors {
border: rgba(0x003847ff).into(),
border_variant: rgba(0x003847ff).into(),
border_focused: rgba(0x003847ff).into(),
border_disabled: rgba(0x003847ff).into(),
border_selected: rgba(0x003847ff).into(),
border_transparent: rgba(0x003847ff).into(),
elevated_surface_background: rgba(0x18191bff).into(),
surface_background: rgba(0x18191bff).into(),
background: rgba(0x002a35ff).into(),
element_background: rgba(0x29a19899).into(),
element_hover: rgba(0x272a2dff).into(),
element_active: rgba(0x2e3135ff).into(),
element_selected: rgba(0x2e3135ff).into(),
element_disabled: rgba(0xddeaf814).into(),
element_placeholder: rgba(0xb0b4baff).into(),
element_drop_target: rgba(0x1166fb18).into(),
ghost_element_background: rgba(0x00000000).into(),
ghost_element_hover: rgba(0x272a2dff).into(),
ghost_element_active: rgba(0x2e3135ff).into(),
ghost_element_selected: rgba(0x2e3135ff).into(),
ghost_element_disabled: rgba(0xddeaf814).into(),
text: rgba(0xedeef0ff).into(),
text_muted: rgba(0xb0b4baff).into(),
text_placeholder: rgba(0x767a83ff).into(),
text_disabled: rgba(0x696e77ff).into(),
text_accent: rgba(0x6fb8ffff).into(),
icon: rgba(0xb0b4baff).into(),
icon_muted: rgba(0x767a83ff).into(),
icon_disabled: rgba(0x696e77ff).into(),
icon_placeholder: rgba(0x767a83ff).into(),
icon_accent: rgba(0x6fb8ffff).into(),
status_bar_background: rgba(0x18191bff).into(),
title_bar_background: rgba(0x18191bff).into(),
toolbar_background: rgba(0x111113ff).into(),
tab_bar_background: rgba(0x18191bff).into(),
tab_inactive_background: rgba(0x003f51ff).into(),
tab_active_background: rgba(0x002a36ff).into(),
editor_background: rgba(0x111113ff).into(),
editor_subheader_background: rgba(0x18191bff).into(),
editor_active_line: rgba(0xddeaf814).into(),
terminal_background: rgba(0x111113ff).into(),
terminal_ansi_bright_black: rgba(0x586e75ff).into(),
terminal_ansi_bright_red: rgba(0xcb4b15ff).into(),
terminal_ansi_bright_green: rgba(0x859900ff).into(),
terminal_ansi_bright_yellow: rgba(0x657b83ff).into(),
terminal_ansi_bright_blue: rgba(0x839496ff).into(),
terminal_ansi_bright_magenta: rgba(0x6c71c4ff).into(),
terminal_ansi_bright_cyan: rgba(0x93a1a1ff).into(),
terminal_ansi_bright_white: rgba(0x839496ff).into(),
terminal_ansi_black: rgba(0x063642ff).into(),
terminal_ansi_red: rgba(0xdc312eff).into(),
terminal_ansi_green: rgba(0x859900ff).into(),
terminal_ansi_yellow: rgba(0xb58800ff).into(),
terminal_ansi_blue: rgba(0x258ad2ff).into(),
terminal_ansi_magenta: rgba(0xd33582ff).into(),
terminal_ansi_cyan: rgba(0x29a198ff).into(),
terminal_ansi_white: rgba(0x839496ff).into(),
},
status: StatusColors {
conflict: rgba(0xff9592ff).into(),
created: rgba(0x70cf82ff).into(),
deleted: rgba(0xff9592ff).into(),
error: rgba(0xff9592ff).into(),
hidden: rgba(0xb0b4baff).into(),
ignored: rgba(0xb0b4baff).into(),
info: rgba(0x6fb8ffff).into(),
modified: rgba(0xf5e147ff).into(),
renamed: rgba(0x6fb8ffff).into(),
success: rgba(0x70cf82ff).into(),
warning: rgba(0xf5e147ff).into(),
},
git: GitStatusColors {
conflict: rgba(0xffa057ff).into(),
created: rgba(0x70cf82ff).into(),
deleted: rgba(0xff9592ff).into(),
ignored: rgba(0xb0b4baff).into(),
modified: rgba(0xf5e147ff).into(),
renamed: rgba(0x6fb8ffff).into(),
},
player: PlayerColors(vec![
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
]),
syntax: SyntaxTheme {
highlights: vec![
("attribute".into(), rgba(0x4ccce6ff).into()),
("boolean".into(), rgba(0xff977dff).into()),
("comment".into(), rgba(0xb0b4baff).into()),
("comment.doc".into(), rgba(0xe0dffeff).into()),
("constant".into(), rgba(0x8c323aff).into()),
("constructor".into(), rgba(0x8c323aff).into()),
("embedded".into(), rgba(0x8c323aff).into()),
("emphasis".into(), rgba(0x8c323aff).into()),
("emphasis.strong".into(), rgba(0x8c323aff).into()),
("enum".into(), rgba(0x8c323aff).into()),
("function".into(), rgba(0x8c323aff).into()),
("hint".into(), rgba(0x8c323aff).into()),
("keyword".into(), rgba(0xffa057ff).into()),
("label".into(), rgba(0x8c323aff).into()),
("link_text".into(), rgba(0x8c323aff).into()),
("link_uri".into(), rgba(0x8c323aff).into()),
("number".into(), rgba(0x8c323aff).into()),
("operator".into(), rgba(0x8c323aff).into()),
("predictive".into(), rgba(0x8c323aff).into()),
("preproc".into(), rgba(0x8c323aff).into()),
("primary".into(), rgba(0x8c323aff).into()),
("property".into(), rgba(0x8c323aff).into()),
("punctuation".into(), rgba(0xb0b4baff).into()),
("punctuation.bracket".into(), rgba(0xb0b4baff).into()),
("punctuation.delimiter".into(), rgba(0xb0b4baff).into()),
("punctuation.list_marker".into(), rgba(0x6fb8ffff).into()),
("punctuation.special".into(), rgba(0x8c323aff).into()),
("string".into(), rgba(0x1ed8a3ff).into()),
("string.escape".into(), rgba(0x8c323aff).into()),
("string.regex".into(), rgba(0xff977dff).into()),
("string.special".into(), rgba(0x8c323aff).into()),
("string.special.symbol".into(), rgba(0x8c323aff).into()),
("tag".into(), rgba(0x8c323aff).into()),
("text.literal".into(), rgba(0x8c323aff).into()),
("title".into(), rgba(0x8c323aff).into()),
("type".into(), rgba(0x8c323aff).into()),
("variable".into(), rgba(0x8c323aff).into()),
("variable.special".into(), rgba(0x8c323aff).into()),
("variant".into(), rgba(0x8c323aff).into()),
],
},
},
},
ThemeVariant {
id: "43be149b-2604-4eb2-a9ce-c8f902ab3bb3".into(),
name: "Solarized Light".into(),
appearance: Appearance::Light,
styles: ThemeStyles {
system: SystemColors {
transparent: rgba(0x00000000).into(),
mac_os_traffic_light_red: rgba(0xec6b5fff).into(),
mac_os_traffic_light_yellow: rgba(0xf3bf4dff).into(),
mac_os_traffic_light_green: rgba(0x61c454ff).into(),
},
colors: ThemeColors {
border: rgba(0xddd6c1ff).into(),
border_variant: rgba(0xddd6c1ff).into(),
border_focused: rgba(0xddd6c1ff).into(),
border_disabled: rgba(0xddd6c1ff).into(),
border_selected: rgba(0xddd6c1ff).into(),
border_transparent: rgba(0xddd6c1ff).into(),
elevated_surface_background: rgba(0xf9f9fbff).into(),
surface_background: rgba(0xf9f9fbff).into(),
background: rgba(0xfdf6e3ff).into(),
element_background: rgba(0xab9d56ff).into(),
element_hover: rgba(0xe8e8ecff).into(),
element_active: rgba(0xe0e1e6ff).into(),
element_selected: rgba(0xe0e1e6ff).into(),
element_disabled: rgba(0x0000320f).into(),
element_placeholder: rgba(0x60646cff).into(),
element_drop_target: rgba(0x008bff0b).into(),
ghost_element_background: rgba(0x00000000).into(),
ghost_element_hover: rgba(0xe8e8ecff).into(),
ghost_element_active: rgba(0xe0e1e6ff).into(),
ghost_element_selected: rgba(0xe0e1e6ff).into(),
ghost_element_disabled: rgba(0x0000320f).into(),
text: rgba(0x1c2024ff).into(),
text_muted: rgba(0x60646cff).into(),
text_placeholder: rgba(0x80838dff).into(),
text_disabled: rgba(0x8b8d98ff).into(),
text_accent: rgba(0x0c73ceff).into(),
icon: rgba(0x60646cff).into(),
icon_muted: rgba(0x80838dff).into(),
icon_disabled: rgba(0x8b8d98ff).into(),
icon_placeholder: rgba(0x80838dff).into(),
icon_accent: rgba(0x0c73ceff).into(),
status_bar_background: rgba(0xf9f9fbff).into(),
title_bar_background: rgba(0xf9f9fbff).into(),
toolbar_background: rgba(0xfcfcfdff).into(),
tab_bar_background: rgba(0xf9f9fbff).into(),
tab_inactive_background: rgba(0xd3cbb7ff).into(),
tab_active_background: rgba(0xfdf6e3ff).into(),
editor_background: rgba(0xfcfcfdff).into(),
editor_subheader_background: rgba(0xf9f9fbff).into(),
editor_active_line: rgba(0x0000320f).into(),
terminal_background: rgba(0xfcfcfdff).into(),
terminal_ansi_bright_black: rgba(0x657b83ff).into(),
terminal_ansi_bright_red: rgba(0xcb4b15ff).into(),
terminal_ansi_bright_green: rgba(0x859900ff).into(),
terminal_ansi_bright_yellow: rgba(0x657b83ff).into(),
terminal_ansi_bright_blue: rgba(0x839496ff).into(),
terminal_ansi_bright_magenta: rgba(0x6c71c4ff).into(),
terminal_ansi_bright_cyan: rgba(0x93a1a1ff).into(),
terminal_ansi_bright_white: rgba(0xeee8d5ff).into(),
terminal_ansi_black: rgba(0x657b83ff).into(),
terminal_ansi_red: rgba(0xdc312eff).into(),
terminal_ansi_green: rgba(0x859900ff).into(),
terminal_ansi_yellow: rgba(0xb58800ff).into(),
terminal_ansi_blue: rgba(0x258ad2ff).into(),
terminal_ansi_magenta: rgba(0xd33582ff).into(),
terminal_ansi_cyan: rgba(0x29a198ff).into(),
terminal_ansi_white: rgba(0xeee8d5ff).into(),
},
status: StatusColors {
conflict: rgba(0xff9592ff).into(),
created: rgba(0x70cf82ff).into(),
deleted: rgba(0xff9592ff).into(),
error: rgba(0xff9592ff).into(),
hidden: rgba(0xb0b4baff).into(),
ignored: rgba(0xb0b4baff).into(),
info: rgba(0x6fb8ffff).into(),
modified: rgba(0xf5e147ff).into(),
renamed: rgba(0x6fb8ffff).into(),
success: rgba(0x70cf82ff).into(),
warning: rgba(0xf5e147ff).into(),
},
git: GitStatusColors {
conflict: rgba(0xffa057ff).into(),
created: rgba(0x70cf82ff).into(),
deleted: rgba(0xff9592ff).into(),
ignored: rgba(0xb0b4baff).into(),
modified: rgba(0xf5e147ff).into(),
renamed: rgba(0x6fb8ffff).into(),
},
player: PlayerColors(vec![
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
]),
syntax: SyntaxTheme {
highlights: vec![
("attribute".into(), rgba(0x4ccce6ff).into()),
("boolean".into(), rgba(0xff977dff).into()),
("comment".into(), rgba(0xb0b4baff).into()),
("comment.doc".into(), rgba(0xe0dffeff).into()),
("constant".into(), rgba(0x8c323aff).into()),
("constructor".into(), rgba(0x8c323aff).into()),
("embedded".into(), rgba(0x8c323aff).into()),
("emphasis".into(), rgba(0x8c323aff).into()),
("emphasis.strong".into(), rgba(0x8c323aff).into()),
("enum".into(), rgba(0x8c323aff).into()),
("function".into(), rgba(0x8c323aff).into()),
("hint".into(), rgba(0x8c323aff).into()),
("keyword".into(), rgba(0xffa057ff).into()),
("label".into(), rgba(0x8c323aff).into()),
("link_text".into(), rgba(0x8c323aff).into()),
("link_uri".into(), rgba(0x8c323aff).into()),
("number".into(), rgba(0x8c323aff).into()),
("operator".into(), rgba(0x8c323aff).into()),
("predictive".into(), rgba(0x8c323aff).into()),
("preproc".into(), rgba(0x8c323aff).into()),
("primary".into(), rgba(0x8c323aff).into()),
("property".into(), rgba(0x8c323aff).into()),
("punctuation".into(), rgba(0xb0b4baff).into()),
("punctuation.bracket".into(), rgba(0xb0b4baff).into()),
("punctuation.delimiter".into(), rgba(0xb0b4baff).into()),
("punctuation.list_marker".into(), rgba(0x6fb8ffff).into()),
("punctuation.special".into(), rgba(0x8c323aff).into()),
("string".into(), rgba(0x1ed8a3ff).into()),
("string.escape".into(), rgba(0x8c323aff).into()),
("string.regex".into(), rgba(0xff977dff).into()),
("string.special".into(), rgba(0x8c323aff).into()),
("string.special.symbol".into(), rgba(0x8c323aff).into()),
("tag".into(), rgba(0x8c323aff).into()),
("text.literal".into(), rgba(0x8c323aff).into()),
("title".into(), rgba(0x8c323aff).into()),
("type".into(), rgba(0x8c323aff).into()),
("variable".into(), rgba(0x8c323aff).into()),
("variable.special".into(), rgba(0x8c323aff).into()),
("variant".into(), rgba(0x8c323aff).into()),
],
},
},
},
],
scales: default_color_scales(),
}
}

View file

@ -0,0 +1,173 @@
use gpui::rgba;
use crate::{
default_color_scales, Appearance, GitStatusColors, PlayerColor, PlayerColors, StatusColors,
SyntaxTheme, SystemColors, ThemeColors, ThemeFamily, ThemeStyles, ThemeVariant,
};
pub fn synthwave_84() -> ThemeFamily {
ThemeFamily {
id: "5e0f0cd5-5522-45cf-a652-caeb140eb3de".into(),
name: "Synthwave 84".into(),
author: "Robb Owen (robb0wen)".into(),
themes: vec![ThemeVariant {
id: "83110d9e-dbf0-4f36-9a4c-6b396ce9a5a4".into(),
name: "Synthwave 84".into(),
appearance: Appearance::Dark,
styles: ThemeStyles {
system: SystemColors {
transparent: rgba(0x00000000).into(),
mac_os_traffic_light_red: rgba(0xec6b5fff).into(),
mac_os_traffic_light_yellow: rgba(0xf3bf4dff).into(),
mac_os_traffic_light_green: rgba(0x61c454ff).into(),
},
colors: ThemeColors {
border: rgba(0x363a3fff).into(),
border_variant: rgba(0x2e3135ff).into(),
border_focused: rgba(0x004073ff).into(),
border_disabled: rgba(0x212225ff).into(),
border_selected: rgba(0x004073ff).into(),
border_transparent: rgba(0x00000000).into(),
elevated_surface_background: rgba(0x18191bff).into(),
surface_background: rgba(0x18191bff).into(),
background: rgba(0x252334ff).into(),
element_background: rgba(0x614d85ff).into(),
element_hover: rgba(0x272a2dff).into(),
element_active: rgba(0x2e3135ff).into(),
element_selected: rgba(0x2e3135ff).into(),
element_disabled: rgba(0xddeaf814).into(),
element_placeholder: rgba(0xb0b4baff).into(),
element_drop_target: rgba(0x1166fb18).into(),
ghost_element_background: rgba(0x00000000).into(),
ghost_element_hover: rgba(0x272a2dff).into(),
ghost_element_active: rgba(0x2e3135ff).into(),
ghost_element_selected: rgba(0x2e3135ff).into(),
ghost_element_disabled: rgba(0xddeaf814).into(),
text: rgba(0xffffffff).into(),
text_muted: rgba(0xb0b4baff).into(),
text_placeholder: rgba(0x767a83ff).into(),
text_disabled: rgba(0x696e77ff).into(),
text_accent: rgba(0x6fb8ffff).into(),
icon: rgba(0xb0b4baff).into(),
icon_muted: rgba(0x767a83ff).into(),
icon_disabled: rgba(0x696e77ff).into(),
icon_placeholder: rgba(0x767a83ff).into(),
icon_accent: rgba(0x6fb8ffff).into(),
status_bar_background: rgba(0x18191bff).into(),
title_bar_background: rgba(0x18191bff).into(),
toolbar_background: rgba(0x111113ff).into(),
tab_bar_background: rgba(0x18191bff).into(),
tab_inactive_background: rgba(0x252334ff).into(),
tab_active_background: rgba(0x111113ff).into(),
editor_background: rgba(0x111113ff).into(),
editor_subheader_background: rgba(0x18191bff).into(),
editor_active_line: rgba(0xddeaf814).into(),
terminal_background: rgba(0x111113ff).into(),
terminal_ansi_bright_black: rgba(0x000000e6).into(),
terminal_ansi_bright_red: rgba(0xfe444fff).into(),
terminal_ansi_bright_green: rgba(0x71f1b7ff).into(),
terminal_ansi_bright_yellow: rgba(0xfede5cff).into(),
terminal_ansi_bright_blue: rgba(0x02edf9ff).into(),
terminal_ansi_bright_magenta: rgba(0xff7ddaff).into(),
terminal_ansi_bright_cyan: rgba(0x02edf9ff).into(),
terminal_ansi_bright_white: rgba(0xb0b4baff).into(),
terminal_ansi_black: rgba(0x000000f2).into(),
terminal_ansi_red: rgba(0xfe444fff).into(),
terminal_ansi_green: rgba(0x71f1b7ff).into(),
terminal_ansi_yellow: rgba(0xf3e70fff).into(),
terminal_ansi_blue: rgba(0x02edf9ff).into(),
terminal_ansi_magenta: rgba(0xff7ddaff).into(),
terminal_ansi_cyan: rgba(0x02edf9ff).into(),
terminal_ansi_white: rgba(0xedeef0ff).into(),
},
status: StatusColors {
conflict: rgba(0xff9592ff).into(),
created: rgba(0x70cf82ff).into(),
deleted: rgba(0xff9592ff).into(),
error: rgba(0xff9592ff).into(),
hidden: rgba(0xb0b4baff).into(),
ignored: rgba(0xb0b4baff).into(),
info: rgba(0x6fb8ffff).into(),
modified: rgba(0xf5e147ff).into(),
renamed: rgba(0x6fb8ffff).into(),
success: rgba(0x70cf82ff).into(),
warning: rgba(0xf5e147ff).into(),
},
git: GitStatusColors {
conflict: rgba(0xffa057ff).into(),
created: rgba(0x70cf82ff).into(),
deleted: rgba(0xff9592ff).into(),
ignored: rgba(0xb0b4baff).into(),
modified: rgba(0xf5e147ff).into(),
renamed: rgba(0x6fb8ffff).into(),
},
player: PlayerColors(vec![
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
PlayerColor {
cursor: rgba(0x00000000).into(),
background: rgba(0x00000000).into(),
selection: rgba(0x00000000).into(),
},
]),
syntax: SyntaxTheme {
highlights: vec![
("attribute".into(), rgba(0x4ccce6ff).into()),
("boolean".into(), rgba(0xff977dff).into()),
("comment".into(), rgba(0xb0b4baff).into()),
("comment.doc".into(), rgba(0xe0dffeff).into()),
("constant".into(), rgba(0x8c323aff).into()),
("constructor".into(), rgba(0x8c323aff).into()),
("embedded".into(), rgba(0x8c323aff).into()),
("emphasis".into(), rgba(0x8c323aff).into()),
("emphasis.strong".into(), rgba(0x8c323aff).into()),
("enum".into(), rgba(0x8c323aff).into()),
("function".into(), rgba(0x8c323aff).into()),
("hint".into(), rgba(0x8c323aff).into()),
("keyword".into(), rgba(0xffa057ff).into()),
("label".into(), rgba(0x8c323aff).into()),
("link_text".into(), rgba(0x8c323aff).into()),
("link_uri".into(), rgba(0x8c323aff).into()),
("number".into(), rgba(0x8c323aff).into()),
("operator".into(), rgba(0x8c323aff).into()),
("predictive".into(), rgba(0x8c323aff).into()),
("preproc".into(), rgba(0x8c323aff).into()),
("primary".into(), rgba(0x8c323aff).into()),
("property".into(), rgba(0x8c323aff).into()),
("punctuation".into(), rgba(0xb0b4baff).into()),
("punctuation.bracket".into(), rgba(0xb0b4baff).into()),
("punctuation.delimiter".into(), rgba(0xb0b4baff).into()),
("punctuation.list_marker".into(), rgba(0x6fb8ffff).into()),
("punctuation.special".into(), rgba(0x8c323aff).into()),
("string".into(), rgba(0x1ed8a3ff).into()),
("string.escape".into(), rgba(0x8c323aff).into()),
("string.regex".into(), rgba(0xff977dff).into()),
("string.special".into(), rgba(0x8c323aff).into()),
("string.special.symbol".into(), rgba(0x8c323aff).into()),
("tag".into(), rgba(0x8c323aff).into()),
("text.literal".into(), rgba(0x8c323aff).into()),
("title".into(), rgba(0x8c323aff).into()),
("type".into(), rgba(0x8c323aff).into()),
("variable".into(), rgba(0x8c323aff).into()),
("variable.special".into(), rgba(0x8c323aff).into()),
("variant".into(), rgba(0x8c323aff).into()),
],
},
},
}],
scales: default_color_scales(),
}
}

View file

@ -0,0 +1,18 @@
[package]
name = "theme_importer"
version = "0.1.0"
edition = "2021"
publish = false
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
anyhow.workspace = true
convert_case = "0.6.0"
gpui = { package = "gpui2", path = "../gpui2" }
log.workspace = true
rust-embed.workspace = true
serde.workspace = true
simplelog = "0.9"
theme = { package = "theme2", path = "../theme2" }
uuid.workspace = true

View file

@ -0,0 +1,124 @@
# Zed Theme Importer
---
## Usage
- `cargo run -p theme_importer` - Import the context of `assets/themes/src`
---
## Troubleshooting
As the importer generates rust files, you may need to manually do some cleanup in `registry.rs` and `themes/mod.rs` if you remove themes or delete the `themes` folder in the theme crate.
---
## Required Structure
To import a theme or series of themes 3 things are required:
- `family.json`: A JSON file containing the theme family metadata and list of theme variants
- `{theme_name}.json`: One theme json for each theme variant
- `LICENSE`: A license file for the theme family
### `family.json`
#### `name`
The name of the theme family. Avoid special characters.
This will be used for the theme family directory name (lowercased) and the theme family name in the Zed UI.
Good:
- `Rose Pine`
- `Synthwave 84`
- `Monokai Solarized`
Bad:
- `Rosé Pine`
- `Synthwave '84`
- `Monokai (Solarized)`
#### `author`
The author of the theme family. This can be a name or a username.
This will be used for the theme family author in the Zed UI.
#### `themes`
A list of theme variants.
`appearance` can be either `light` or `dark`. This will impact which default fallback colors are used, and where the theme shows up in the Zed UI.
### `{theme_name}.json`
Each theme added to the family must have a corresponding JSON file. This JSON file can be obtained from the VSCode extensions folder (once you have installed it.) This is usually located at `~/.vscode/extensions` (on macOS).
You can use `open ~/.vscode/extensions` to open the folder in Finder directly.
Copy that json file into the theme family directory and tidy up the filenames as needed.
### `LICENSE`
A LICENSE file is required to import a theme family. Failing to provide a complete text license will cause it to be skipped when the import is run.
If the theme only provices a license code (e.g. MIT, Apache 2.0, etc.) then put that code into the LICENSE file.
If no license is provided, either contact the theme creator or don't add the theme.
---
### Complete Example:
An example family with multiple variants:
```json
{
"name": "Ayu",
// When both name and username are available
// prefer the `username (name)` format
"author": "dempfi (Ike Ku)",
"themes": [
{
"name": "Ayu Light",
"file_name": "ayu-light.json",
"appearance": "light"
},
{
"name": "Ayu Mirage",
"file_name": "ayu-mirage.json",
"appearance": "dark"
},
{
"name": "Ayu Dark",
"file_name": "ayu-dark.json",
"appearance": "dark"
}
]
}
```
An example single variant family:
```json
{
"name": "Andromeda",
"author": "Eliver Lara (EliverLara)",
"themes": [
{
"name": "Andromeda",
"file_name": "andromeda.json",
"appearance": "dark"
},
{
"name": "Andromeda Bordered",
"file_name": "andromeda-bordered.json",
"appearance": "dark"
}
]
}
```

View file

@ -0,0 +1,215 @@
mod theme_printer;
mod util;
mod vscode;
use std::fs::{self, File};
use std::io::Write;
use std::path::PathBuf;
use std::str::FromStr;
use anyhow::{anyhow, Context, Result};
use convert_case::{Case, Casing};
use gpui::serde_json;
use log::LevelFilter;
use serde::Deserialize;
use simplelog::SimpleLogger;
use theme::{default_color_scales, Appearance, ThemeFamily};
use vscode::VsCodeThemeConverter;
use crate::theme_printer::ThemeFamilyPrinter;
use crate::vscode::VsCodeTheme;
#[derive(Debug, Deserialize)]
struct FamilyMetadata {
pub name: String,
pub author: String,
pub themes: Vec<ThemeMetadata>,
}
#[derive(Debug, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum ThemeAppearanceJson {
Light,
Dark,
}
impl From<ThemeAppearanceJson> for Appearance {
fn from(value: ThemeAppearanceJson) -> Self {
match value {
ThemeAppearanceJson::Light => Self::Light,
ThemeAppearanceJson::Dark => Self::Dark,
}
}
}
#[derive(Debug, Deserialize)]
pub struct ThemeMetadata {
pub name: String,
pub file_name: String,
pub appearance: ThemeAppearanceJson,
}
fn main() -> Result<()> {
const SOURCE_PATH: &str = "assets/themes/src/vscode";
const OUT_PATH: &str = "crates/theme2/src/themes";
SimpleLogger::init(LevelFilter::Info, Default::default()).expect("could not initialize logger");
println!("Loading themes source...");
let vscode_themes_path = PathBuf::from_str(SOURCE_PATH)?;
if !vscode_themes_path.exists() {
return Err(anyhow!(format!(
"Couldn't find {}, make sure it exists",
SOURCE_PATH
)));
}
let mut theme_families = Vec::new();
for theme_family_dir in fs::read_dir(&vscode_themes_path)? {
let theme_family_dir = theme_family_dir?;
if !theme_family_dir.file_type()?.is_dir() {
continue;
}
let theme_family_slug = theme_family_dir
.path()
.file_stem()
.ok_or(anyhow!("no file stem"))
.map(|stem| stem.to_string_lossy().to_string())?;
let family_metadata_file = File::open(theme_family_dir.path().join("family.json"))
.context(format!(
"no `family.json` found for '{}'",
theme_family_slug
))?;
let license_file_path = theme_family_dir.path().join("LICENSE");
if !license_file_path.exists() {
println!("Skipping theme family '{}' because it does not have a LICENSE file. This theme will only be imported once a LICENSE file is provided.", theme_family_slug);
continue;
}
let family_metadata: FamilyMetadata = serde_json::from_reader(family_metadata_file)
.context(format!(
"failed to parse `family.json` for '{theme_family_slug}'"
))?;
let mut themes = Vec::new();
for theme_metadata in family_metadata.themes {
let theme_file_path = theme_family_dir.path().join(&theme_metadata.file_name);
let theme_file = match File::open(&theme_file_path) {
Ok(file) => file,
Err(_) => {
println!("Failed to open file at path: {:?}", theme_file_path);
continue;
}
};
let vscode_theme: VsCodeTheme = serde_json::from_reader(theme_file)
.context(format!("failed to parse theme {theme_file_path:?}"))?;
let converter = VsCodeThemeConverter::new(vscode_theme, theme_metadata);
let theme = converter.convert()?;
themes.push(theme);
}
let theme_family = ThemeFamily {
id: uuid::Uuid::new_v4().to_string(),
name: family_metadata.name.into(),
author: family_metadata.author.into(),
themes,
scales: default_color_scales(),
};
theme_families.push(theme_family);
}
let themes_output_path = PathBuf::from_str(OUT_PATH)?;
if !themes_output_path.exists() {
println!("Creating directory: {:?}", themes_output_path);
fs::create_dir_all(&themes_output_path)?;
}
let mut mod_rs_file = File::create(themes_output_path.join(format!("mod.rs")))?;
let mut theme_modules = Vec::new();
for theme_family in theme_families {
let theme_family_slug = theme_family.name.to_string().to_case(Case::Snake);
let mut output_file =
File::create(themes_output_path.join(format!("{theme_family_slug}.rs")))?;
println!(
"Creating file: {:?}",
themes_output_path.join(format!("{theme_family_slug}.rs"))
);
let theme_module = format!(
r#"
use gpui::rgba;
use crate::{{
default_color_scales, Appearance, GitStatusColors, PlayerColor, PlayerColors, StatusColors,
SyntaxTheme, SystemColors, ThemeColors, ThemeFamily, ThemeStyles, ThemeVariant,
}};
pub fn {theme_family_slug}() -> ThemeFamily {{
{theme_family_definition}
}}
"#,
theme_family_definition = format!("{:#?}", ThemeFamilyPrinter::new(theme_family))
);
output_file.write_all(theme_module.as_bytes())?;
theme_modules.push(theme_family_slug);
}
let themes_vector_contents = format!(
r#"
use crate::ThemeFamily;
pub(crate) fn all_imported_themes() -> Vec<ThemeFamily> {{
vec![{all_themes}]
}}
"#,
all_themes = theme_modules
.iter()
.map(|module| format!("{}()", module))
.collect::<Vec<_>>()
.join(", ")
);
let mod_rs_contents = format!(
r#"
{mod_statements}
{use_statements}
{themes_vector_contents}
"#,
mod_statements = theme_modules
.iter()
.map(|module| format!("mod {module};"))
.collect::<Vec<_>>()
.join("\n"),
use_statements = theme_modules
.iter()
.map(|module| format!("pub use {module}::*;"))
.collect::<Vec<_>>()
.join("\n"),
themes_vector_contents = themes_vector_contents
);
mod_rs_file.write_all(mod_rs_contents.as_bytes())?;
Ok(())
}

View file

@ -0,0 +1,384 @@
use std::fmt::{self, Debug};
use gpui::{Hsla, Rgba};
use theme::{
Appearance, GitStatusColors, PlayerColor, PlayerColors, StatusColors, SyntaxTheme,
SystemColors, ThemeColors, ThemeFamily, ThemeStyles, ThemeVariant,
};
struct RawSyntaxPrinter<'a>(&'a str);
impl<'a> Debug for RawSyntaxPrinter<'a> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.0)
}
}
struct HslaPrinter(Hsla);
impl Debug for HslaPrinter {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{:?}", IntoPrinter(&Rgba::from(self.0)))
}
}
struct IntoPrinter<'a, D: Debug>(&'a D);
impl<'a, D: Debug> Debug for IntoPrinter<'a, D> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{:?}.into()", self.0)
}
}
pub struct VecPrinter<'a, T>(&'a Vec<T>);
impl<'a, T: Debug> Debug for VecPrinter<'a, T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "vec!{:?}", &self.0)
}
}
pub struct ThemeFamilyPrinter(ThemeFamily);
impl ThemeFamilyPrinter {
pub fn new(theme_family: ThemeFamily) -> Self {
Self(theme_family)
}
}
impl Debug for ThemeFamilyPrinter {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("ThemeFamily")
.field("id", &IntoPrinter(&self.0.id))
.field("name", &IntoPrinter(&self.0.name))
.field("author", &IntoPrinter(&self.0.author))
.field(
"themes",
&VecPrinter(
&self
.0
.themes
.iter()
.map(|theme| ThemeVariantPrinter(theme))
.collect(),
),
)
.field("scales", &RawSyntaxPrinter("default_color_scales()"))
.finish()
}
}
pub struct ThemeVariantPrinter<'a>(&'a ThemeVariant);
impl<'a> Debug for ThemeVariantPrinter<'a> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("ThemeVariant")
.field("id", &IntoPrinter(&self.0.id))
.field("name", &IntoPrinter(&self.0.name))
.field("appearance", &AppearancePrinter(self.0.appearance))
.field("styles", &ThemeStylesPrinter(&self.0.styles))
.finish()
}
}
pub struct AppearancePrinter(Appearance);
impl Debug for AppearancePrinter {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "Appearance::{:?}", self.0)
}
}
pub struct ThemeStylesPrinter<'a>(&'a ThemeStyles);
impl<'a> Debug for ThemeStylesPrinter<'a> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("ThemeStyles")
.field("system", &SystemColorsPrinter(&self.0.system))
.field("colors", &ThemeColorsPrinter(&self.0.colors))
.field("status", &StatusColorsPrinter(&self.0.status))
.field("git", &GitStatusColorsPrinter(&self.0.git))
.field("player", &PlayerColorsPrinter(&self.0.player))
.field("syntax", &SyntaxThemePrinter(&self.0.syntax))
.finish()
}
}
pub struct SystemColorsPrinter<'a>(&'a SystemColors);
impl<'a> Debug for SystemColorsPrinter<'a> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("SystemColors")
.field("transparent", &HslaPrinter(self.0.transparent))
.field(
"mac_os_traffic_light_red",
&HslaPrinter(self.0.mac_os_traffic_light_red),
)
.field(
"mac_os_traffic_light_yellow",
&HslaPrinter(self.0.mac_os_traffic_light_yellow),
)
.field(
"mac_os_traffic_light_green",
&HslaPrinter(self.0.mac_os_traffic_light_green),
)
.finish()
}
}
pub struct ThemeColorsPrinter<'a>(&'a ThemeColors);
impl<'a> Debug for ThemeColorsPrinter<'a> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("ThemeColors")
.field("border", &HslaPrinter(self.0.border))
.field("border_variant", &HslaPrinter(self.0.border_variant))
.field("border_focused", &HslaPrinter(self.0.border_focused))
.field("border_disabled", &HslaPrinter(self.0.border_disabled))
.field("border_selected", &HslaPrinter(self.0.border_selected))
.field(
"border_transparent",
&HslaPrinter(self.0.border_transparent),
)
.field(
"elevated_surface_background",
&HslaPrinter(self.0.elevated_surface_background),
)
.field(
"surface_background",
&HslaPrinter(self.0.surface_background),
)
.field("background", &HslaPrinter(self.0.background))
.field(
"element_background",
&HslaPrinter(self.0.element_background),
)
.field("element_hover", &HslaPrinter(self.0.element_hover))
.field("element_active", &HslaPrinter(self.0.element_active))
.field("element_selected", &HslaPrinter(self.0.element_selected))
.field("element_disabled", &HslaPrinter(self.0.element_disabled))
.field(
"element_placeholder",
&HslaPrinter(self.0.element_placeholder),
)
.field(
"element_drop_target",
&HslaPrinter(self.0.element_drop_target),
)
.field(
"ghost_element_background",
&HslaPrinter(self.0.ghost_element_background),
)
.field(
"ghost_element_hover",
&HslaPrinter(self.0.ghost_element_hover),
)
.field(
"ghost_element_active",
&HslaPrinter(self.0.ghost_element_active),
)
.field(
"ghost_element_selected",
&HslaPrinter(self.0.ghost_element_selected),
)
.field(
"ghost_element_disabled",
&HslaPrinter(self.0.ghost_element_disabled),
)
.field("text", &HslaPrinter(self.0.text))
.field("text_muted", &HslaPrinter(self.0.text_muted))
.field("text_placeholder", &HslaPrinter(self.0.text_placeholder))
.field("text_disabled", &HslaPrinter(self.0.text_disabled))
.field("text_accent", &HslaPrinter(self.0.text_accent))
.field("icon", &HslaPrinter(self.0.icon))
.field("icon_muted", &HslaPrinter(self.0.icon_muted))
.field("icon_disabled", &HslaPrinter(self.0.icon_disabled))
.field("icon_placeholder", &HslaPrinter(self.0.icon_placeholder))
.field("icon_accent", &HslaPrinter(self.0.icon_accent))
.field(
"status_bar_background",
&HslaPrinter(self.0.status_bar_background),
)
.field(
"title_bar_background",
&HslaPrinter(self.0.title_bar_background),
)
.field(
"toolbar_background",
&HslaPrinter(self.0.toolbar_background),
)
.field(
"tab_bar_background",
&HslaPrinter(self.0.tab_bar_background),
)
.field(
"tab_inactive_background",
&HslaPrinter(self.0.tab_inactive_background),
)
.field(
"tab_active_background",
&HslaPrinter(self.0.tab_active_background),
)
.field("editor_background", &HslaPrinter(self.0.editor_background))
.field(
"editor_subheader_background",
&HslaPrinter(self.0.editor_subheader_background),
)
.field(
"editor_active_line",
&HslaPrinter(self.0.editor_active_line_background),
)
.field(
"terminal_background",
&HslaPrinter(self.0.terminal_background),
)
.field(
"terminal_ansi_bright_black",
&HslaPrinter(self.0.terminal_ansi_bright_black),
)
.field(
"terminal_ansi_bright_red",
&HslaPrinter(self.0.terminal_ansi_bright_red),
)
.field(
"terminal_ansi_bright_green",
&HslaPrinter(self.0.terminal_ansi_bright_green),
)
.field(
"terminal_ansi_bright_yellow",
&HslaPrinter(self.0.terminal_ansi_bright_yellow),
)
.field(
"terminal_ansi_bright_blue",
&HslaPrinter(self.0.terminal_ansi_bright_blue),
)
.field(
"terminal_ansi_bright_magenta",
&HslaPrinter(self.0.terminal_ansi_bright_magenta),
)
.field(
"terminal_ansi_bright_cyan",
&HslaPrinter(self.0.terminal_ansi_bright_cyan),
)
.field(
"terminal_ansi_bright_white",
&HslaPrinter(self.0.terminal_ansi_bright_white),
)
.field(
"terminal_ansi_black",
&HslaPrinter(self.0.terminal_ansi_black),
)
.field("terminal_ansi_red", &HslaPrinter(self.0.terminal_ansi_red))
.field(
"terminal_ansi_green",
&HslaPrinter(self.0.terminal_ansi_green),
)
.field(
"terminal_ansi_yellow",
&HslaPrinter(self.0.terminal_ansi_yellow),
)
.field(
"terminal_ansi_blue",
&HslaPrinter(self.0.terminal_ansi_blue),
)
.field(
"terminal_ansi_magenta",
&HslaPrinter(self.0.terminal_ansi_magenta),
)
.field(
"terminal_ansi_cyan",
&HslaPrinter(self.0.terminal_ansi_cyan),
)
.field(
"terminal_ansi_white",
&HslaPrinter(self.0.terminal_ansi_white),
)
.finish()
}
}
pub struct StatusColorsPrinter<'a>(&'a StatusColors);
impl<'a> Debug for StatusColorsPrinter<'a> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("StatusColors")
.field("conflict", &HslaPrinter(self.0.conflict))
.field("created", &HslaPrinter(self.0.created))
.field("deleted", &HslaPrinter(self.0.deleted))
.field("error", &HslaPrinter(self.0.error))
.field("hidden", &HslaPrinter(self.0.hidden))
.field("ignored", &HslaPrinter(self.0.ignored))
.field("info", &HslaPrinter(self.0.info))
.field("modified", &HslaPrinter(self.0.modified))
.field("renamed", &HslaPrinter(self.0.renamed))
.field("success", &HslaPrinter(self.0.success))
.field("warning", &HslaPrinter(self.0.warning))
.finish()
}
}
pub struct GitStatusColorsPrinter<'a>(&'a GitStatusColors);
impl<'a> Debug for GitStatusColorsPrinter<'a> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("GitStatusColors")
.field("conflict", &HslaPrinter(self.0.conflict))
.field("created", &HslaPrinter(self.0.created))
.field("deleted", &HslaPrinter(self.0.deleted))
.field("ignored", &HslaPrinter(self.0.ignored))
.field("modified", &HslaPrinter(self.0.modified))
.field("renamed", &HslaPrinter(self.0.renamed))
.finish()
}
}
pub struct PlayerColorsPrinter<'a>(&'a PlayerColors);
impl<'a> Debug for PlayerColorsPrinter<'a> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_tuple("PlayerColors")
.field(&VecPrinter(
&self
.0
.0
.iter()
.map(|player_color| PlayerColorPrinter(player_color))
.collect(),
))
.finish()
}
}
pub struct PlayerColorPrinter<'a>(&'a PlayerColor);
impl<'a> Debug for PlayerColorPrinter<'a> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("PlayerColor")
.field("cursor", &HslaPrinter(self.0.cursor))
.field("background", &HslaPrinter(self.0.background))
.field("selection", &HslaPrinter(self.0.selection))
.finish()
}
}
pub struct SyntaxThemePrinter<'a>(&'a SyntaxTheme);
impl<'a> Debug for SyntaxThemePrinter<'a> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("SyntaxTheme")
.field(
"highlights",
&VecPrinter(
&self
.0
.highlights
.iter()
.map(|(token, highlight)| {
(IntoPrinter(token), HslaPrinter(highlight.color.unwrap()))
})
.collect(),
),
)
.finish()
}
}

View file

@ -0,0 +1,11 @@
use anyhow::Result;
pub trait Traverse<T, U> {
fn traverse(self, f: impl FnOnce(T) -> Result<U>) -> Result<Option<U>>;
}
impl<T, U> Traverse<T, U> for Option<T> {
fn traverse(self, f: impl FnOnce(T) -> Result<U>) -> Result<Option<U>> {
self.map_or(Ok(None), |value| f(value).map(Some))
}
}

View file

@ -0,0 +1,606 @@
use anyhow::Result;
use gpui::{Hsla, Refineable, Rgba};
use serde::Deserialize;
use theme::{
Appearance, GitStatusColors, PlayerColors, StatusColors, SyntaxTheme, SystemColors,
ThemeColors, ThemeColorsRefinement, ThemeStyles, ThemeVariant,
};
use crate::util::Traverse;
use crate::ThemeMetadata;
#[derive(Deserialize, Debug)]
pub struct VsCodeTheme {
#[serde(rename = "$schema")]
pub schema: Option<String>,
pub name: Option<String>,
pub author: Option<String>,
pub maintainers: Option<Vec<String>>,
#[serde(rename = "semanticClass")]
pub semantic_class: Option<String>,
#[serde(rename = "semanticHighlighting")]
pub semantic_highlighting: Option<bool>,
pub colors: VsCodeColors,
}
#[derive(Debug, Deserialize)]
pub struct VsCodeColors {
#[serde(rename = "terminal.background")]
pub terminal_background: Option<String>,
#[serde(rename = "terminal.foreground")]
pub terminal_foreground: Option<String>,
#[serde(rename = "terminal.ansiBrightBlack")]
pub terminal_ansi_bright_black: Option<String>,
#[serde(rename = "terminal.ansiBrightRed")]
pub terminal_ansi_bright_red: Option<String>,
#[serde(rename = "terminal.ansiBrightGreen")]
pub terminal_ansi_bright_green: Option<String>,
#[serde(rename = "terminal.ansiBrightYellow")]
pub terminal_ansi_bright_yellow: Option<String>,
#[serde(rename = "terminal.ansiBrightBlue")]
pub terminal_ansi_bright_blue: Option<String>,
#[serde(rename = "terminal.ansiBrightMagenta")]
pub terminal_ansi_bright_magenta: Option<String>,
#[serde(rename = "terminal.ansiBrightCyan")]
pub terminal_ansi_bright_cyan: Option<String>,
#[serde(rename = "terminal.ansiBrightWhite")]
pub terminal_ansi_bright_white: Option<String>,
#[serde(rename = "terminal.ansiBlack")]
pub terminal_ansi_black: Option<String>,
#[serde(rename = "terminal.ansiRed")]
pub terminal_ansi_red: Option<String>,
#[serde(rename = "terminal.ansiGreen")]
pub terminal_ansi_green: Option<String>,
#[serde(rename = "terminal.ansiYellow")]
pub terminal_ansi_yellow: Option<String>,
#[serde(rename = "terminal.ansiBlue")]
pub terminal_ansi_blue: Option<String>,
#[serde(rename = "terminal.ansiMagenta")]
pub terminal_ansi_magenta: Option<String>,
#[serde(rename = "terminal.ansiCyan")]
pub terminal_ansi_cyan: Option<String>,
#[serde(rename = "terminal.ansiWhite")]
pub terminal_ansi_white: Option<String>,
#[serde(rename = "focusBorder")]
pub focus_border: Option<String>,
pub foreground: Option<String>,
#[serde(rename = "selection.background")]
pub selection_background: Option<String>,
#[serde(rename = "errorForeground")]
pub error_foreground: Option<String>,
#[serde(rename = "button.background")]
pub button_background: Option<String>,
#[serde(rename = "button.foreground")]
pub button_foreground: Option<String>,
#[serde(rename = "button.secondaryBackground")]
pub button_secondary_background: Option<String>,
#[serde(rename = "button.secondaryForeground")]
pub button_secondary_foreground: Option<String>,
#[serde(rename = "button.secondaryHoverBackground")]
pub button_secondary_hover_background: Option<String>,
#[serde(rename = "dropdown.background")]
pub dropdown_background: Option<String>,
#[serde(rename = "dropdown.border")]
pub dropdown_border: Option<String>,
#[serde(rename = "dropdown.foreground")]
pub dropdown_foreground: Option<String>,
#[serde(rename = "input.background")]
pub input_background: Option<String>,
#[serde(rename = "input.foreground")]
pub input_foreground: Option<String>,
#[serde(rename = "input.border")]
pub input_border: Option<String>,
#[serde(rename = "input.placeholderForeground")]
pub input_placeholder_foreground: Option<String>,
#[serde(rename = "inputOption.activeBorder")]
pub input_option_active_border: Option<String>,
#[serde(rename = "inputValidation.infoBorder")]
pub input_validation_info_border: Option<String>,
#[serde(rename = "inputValidation.warningBorder")]
pub input_validation_warning_border: Option<String>,
#[serde(rename = "inputValidation.errorBorder")]
pub input_validation_error_border: Option<String>,
#[serde(rename = "badge.foreground")]
pub badge_foreground: Option<String>,
#[serde(rename = "badge.background")]
pub badge_background: Option<String>,
#[serde(rename = "progressBar.background")]
pub progress_bar_background: Option<String>,
#[serde(rename = "list.activeSelectionBackground")]
pub list_active_selection_background: Option<String>,
#[serde(rename = "list.activeSelectionForeground")]
pub list_active_selection_foreground: Option<String>,
#[serde(rename = "list.dropBackground")]
pub list_drop_background: Option<String>,
#[serde(rename = "list.focusBackground")]
pub list_focus_background: Option<String>,
#[serde(rename = "list.highlightForeground")]
pub list_highlight_foreground: Option<String>,
#[serde(rename = "list.hoverBackground")]
pub list_hover_background: Option<String>,
#[serde(rename = "list.inactiveSelectionBackground")]
pub list_inactive_selection_background: Option<String>,
#[serde(rename = "list.warningForeground")]
pub list_warning_foreground: Option<String>,
#[serde(rename = "list.errorForeground")]
pub list_error_foreground: Option<String>,
#[serde(rename = "activityBar.background")]
pub activity_bar_background: Option<String>,
#[serde(rename = "activityBar.inactiveForeground")]
pub activity_bar_inactive_foreground: Option<String>,
#[serde(rename = "activityBar.foreground")]
pub activity_bar_foreground: Option<String>,
#[serde(rename = "activityBar.activeBorder")]
pub activity_bar_active_border: Option<String>,
#[serde(rename = "activityBar.activeBackground")]
pub activity_bar_active_background: Option<String>,
#[serde(rename = "activityBarBadge.background")]
pub activity_bar_badge_background: Option<String>,
#[serde(rename = "activityBarBadge.foreground")]
pub activity_bar_badge_foreground: Option<String>,
#[serde(rename = "sideBar.background")]
pub side_bar_background: Option<String>,
#[serde(rename = "sideBarTitle.foreground")]
pub side_bar_title_foreground: Option<String>,
#[serde(rename = "sideBarSectionHeader.background")]
pub side_bar_section_header_background: Option<String>,
#[serde(rename = "sideBarSectionHeader.border")]
pub side_bar_section_header_border: Option<String>,
#[serde(rename = "editorGroup.border")]
pub editor_group_border: Option<String>,
#[serde(rename = "editorGroup.dropBackground")]
pub editor_group_drop_background: Option<String>,
#[serde(rename = "editorGroupHeader.tabsBackground")]
pub editor_group_header_tabs_background: Option<String>,
#[serde(rename = "tab.activeBackground")]
pub tab_active_background: Option<String>,
#[serde(rename = "tab.activeForeground")]
pub tab_active_foreground: Option<String>,
#[serde(rename = "tab.border")]
pub tab_border: Option<String>,
#[serde(rename = "tab.activeBorderTop")]
pub tab_active_border_top: Option<String>,
#[serde(rename = "tab.inactiveBackground")]
pub tab_inactive_background: Option<String>,
#[serde(rename = "tab.inactiveForeground")]
pub tab_inactive_foreground: Option<String>,
#[serde(rename = "editor.foreground")]
pub editor_foreground: Option<String>,
#[serde(rename = "editor.background")]
pub editor_background: Option<String>,
#[serde(rename = "editorLineNumber.foreground")]
pub editor_line_number_foreground: Option<String>,
#[serde(rename = "editor.selectionBackground")]
pub editor_selection_background: Option<String>,
#[serde(rename = "editor.selectionHighlightBackground")]
pub editor_selection_highlight_background: Option<String>,
#[serde(rename = "editor.foldBackground")]
pub editor_fold_background: Option<String>,
#[serde(rename = "editor.wordHighlightBackground")]
pub editor_word_highlight_background: Option<String>,
#[serde(rename = "editor.wordHighlightStrongBackground")]
pub editor_word_highlight_strong_background: Option<String>,
#[serde(rename = "editor.findMatchBackground")]
pub editor_find_match_background: Option<String>,
#[serde(rename = "editor.findMatchHighlightBackground")]
pub editor_find_match_highlight_background: Option<String>,
#[serde(rename = "editor.findRangeHighlightBackground")]
pub editor_find_range_highlight_background: Option<String>,
#[serde(rename = "editor.hoverHighlightBackground")]
pub editor_hover_highlight_background: Option<String>,
#[serde(rename = "editor.lineHighlightBorder")]
pub editor_line_highlight_border: Option<String>,
#[serde(rename = "editorLink.activeForeground")]
pub editor_link_active_foreground: Option<String>,
#[serde(rename = "editor.rangeHighlightBackground")]
pub editor_range_highlight_background: Option<String>,
#[serde(rename = "editor.snippetTabstopHighlightBackground")]
pub editor_snippet_tabstop_highlight_background: Option<String>,
#[serde(rename = "editor.snippetTabstopHighlightBorder")]
pub editor_snippet_tabstop_highlight_border: Option<String>,
#[serde(rename = "editor.snippetFinalTabstopHighlightBackground")]
pub editor_snippet_final_tabstop_highlight_background: Option<String>,
#[serde(rename = "editor.snippetFinalTabstopHighlightBorder")]
pub editor_snippet_final_tabstop_highlight_border: Option<String>,
#[serde(rename = "editorWhitespace.foreground")]
pub editor_whitespace_foreground: Option<String>,
#[serde(rename = "editorIndentGuide.background")]
pub editor_indent_guide_background: Option<String>,
#[serde(rename = "editorIndentGuide.activeBackground")]
pub editor_indent_guide_active_background: Option<String>,
#[serde(rename = "editorRuler.foreground")]
pub editor_ruler_foreground: Option<String>,
#[serde(rename = "editorCodeLens.foreground")]
pub editor_code_lens_foreground: Option<String>,
#[serde(rename = "editorBracketHighlight.foreground1")]
pub editor_bracket_highlight_foreground1: Option<String>,
#[serde(rename = "editorBracketHighlight.foreground2")]
pub editor_bracket_highlight_foreground2: Option<String>,
#[serde(rename = "editorBracketHighlight.foreground3")]
pub editor_bracket_highlight_foreground3: Option<String>,
#[serde(rename = "editorBracketHighlight.foreground4")]
pub editor_bracket_highlight_foreground4: Option<String>,
#[serde(rename = "editorBracketHighlight.foreground5")]
pub editor_bracket_highlight_foreground5: Option<String>,
#[serde(rename = "editorBracketHighlight.foreground6")]
pub editor_bracket_highlight_foreground6: Option<String>,
#[serde(rename = "editorBracketHighlight.unexpectedBracket.foreground")]
pub editor_bracket_highlight_unexpected_bracket_foreground: Option<String>,
#[serde(rename = "editorOverviewRuler.border")]
pub editor_overview_ruler_border: Option<String>,
#[serde(rename = "editorOverviewRuler.selectionHighlightForeground")]
pub editor_overview_ruler_selection_highlight_foreground: Option<String>,
#[serde(rename = "editorOverviewRuler.wordHighlightForeground")]
pub editor_overview_ruler_word_highlight_foreground: Option<String>,
#[serde(rename = "editorOverviewRuler.wordHighlightStrongForeground")]
pub editor_overview_ruler_word_highlight_strong_foreground: Option<String>,
#[serde(rename = "editorOverviewRuler.modifiedForeground")]
pub editor_overview_ruler_modified_foreground: Option<String>,
#[serde(rename = "editorOverviewRuler.addedForeground")]
pub editor_overview_ruler_added_foreground: Option<String>,
#[serde(rename = "editorOverviewRuler.deletedForeground")]
pub editor_overview_ruler_deleted_foreground: Option<String>,
#[serde(rename = "editorOverviewRuler.errorForeground")]
pub editor_overview_ruler_error_foreground: Option<String>,
#[serde(rename = "editorOverviewRuler.warningForeground")]
pub editor_overview_ruler_warning_foreground: Option<String>,
#[serde(rename = "editorOverviewRuler.infoForeground")]
pub editor_overview_ruler_info_foreground: Option<String>,
#[serde(rename = "editorError.foreground")]
pub editor_error_foreground: Option<String>,
#[serde(rename = "editorWarning.foreground")]
pub editor_warning_foreground: Option<String>,
#[serde(rename = "editorGutter.modifiedBackground")]
pub editor_gutter_modified_background: Option<String>,
#[serde(rename = "editorGutter.addedBackground")]
pub editor_gutter_added_background: Option<String>,
#[serde(rename = "editorGutter.deletedBackground")]
pub editor_gutter_deleted_background: Option<String>,
#[serde(rename = "gitDecoration.modifiedResourceForeground")]
pub git_decoration_modified_resource_foreground: Option<String>,
#[serde(rename = "gitDecoration.deletedResourceForeground")]
pub git_decoration_deleted_resource_foreground: Option<String>,
#[serde(rename = "gitDecoration.untrackedResourceForeground")]
pub git_decoration_untracked_resource_foreground: Option<String>,
#[serde(rename = "gitDecoration.ignoredResourceForeground")]
pub git_decoration_ignored_resource_foreground: Option<String>,
#[serde(rename = "gitDecoration.conflictingResourceForeground")]
pub git_decoration_conflicting_resource_foreground: Option<String>,
#[serde(rename = "diffEditor.insertedTextBackground")]
pub diff_editor_inserted_text_background: Option<String>,
#[serde(rename = "diffEditor.removedTextBackground")]
pub diff_editor_removed_text_background: Option<String>,
#[serde(rename = "inlineChat.regionHighlight")]
pub inline_chat_region_highlight: Option<String>,
#[serde(rename = "editorWidget.background")]
pub editor_widget_background: Option<String>,
#[serde(rename = "editorSuggestWidget.background")]
pub editor_suggest_widget_background: Option<String>,
#[serde(rename = "editorSuggestWidget.foreground")]
pub editor_suggest_widget_foreground: Option<String>,
#[serde(rename = "editorSuggestWidget.selectedBackground")]
pub editor_suggest_widget_selected_background: Option<String>,
#[serde(rename = "editorHoverWidget.background")]
pub editor_hover_widget_background: Option<String>,
#[serde(rename = "editorHoverWidget.border")]
pub editor_hover_widget_border: Option<String>,
#[serde(rename = "editorMarkerNavigation.background")]
pub editor_marker_navigation_background: Option<String>,
#[serde(rename = "peekView.border")]
pub peek_view_border: Option<String>,
#[serde(rename = "peekViewEditor.background")]
pub peek_view_editor_background: Option<String>,
#[serde(rename = "peekViewEditor.matchHighlightBackground")]
pub peek_view_editor_match_highlight_background: Option<String>,
#[serde(rename = "peekViewResult.background")]
pub peek_view_result_background: Option<String>,
#[serde(rename = "peekViewResult.fileForeground")]
pub peek_view_result_file_foreground: Option<String>,
#[serde(rename = "peekViewResult.lineForeground")]
pub peek_view_result_line_foreground: Option<String>,
#[serde(rename = "peekViewResult.matchHighlightBackground")]
pub peek_view_result_match_highlight_background: Option<String>,
#[serde(rename = "peekViewResult.selectionBackground")]
pub peek_view_result_selection_background: Option<String>,
#[serde(rename = "peekViewResult.selectionForeground")]
pub peek_view_result_selection_foreground: Option<String>,
#[serde(rename = "peekViewTitle.background")]
pub peek_view_title_background: Option<String>,
#[serde(rename = "peekViewTitleDescription.foreground")]
pub peek_view_title_description_foreground: Option<String>,
#[serde(rename = "peekViewTitleLabel.foreground")]
pub peek_view_title_label_foreground: Option<String>,
#[serde(rename = "merge.currentHeaderBackground")]
pub merge_current_header_background: Option<String>,
#[serde(rename = "merge.incomingHeaderBackground")]
pub merge_incoming_header_background: Option<String>,
#[serde(rename = "editorOverviewRuler.currentContentForeground")]
pub editor_overview_ruler_current_content_foreground: Option<String>,
#[serde(rename = "editorOverviewRuler.incomingContentForeground")]
pub editor_overview_ruler_incoming_content_foreground: Option<String>,
#[serde(rename = "panel.background")]
pub panel_background: Option<String>,
#[serde(rename = "panel.border")]
pub panel_border: Option<String>,
#[serde(rename = "panelTitle.activeBorder")]
pub panel_title_active_border: Option<String>,
#[serde(rename = "panelTitle.activeForeground")]
pub panel_title_active_foreground: Option<String>,
#[serde(rename = "panelTitle.inactiveForeground")]
pub panel_title_inactive_foreground: Option<String>,
#[serde(rename = "statusBar.background")]
pub status_bar_background: Option<String>,
#[serde(rename = "statusBar.foreground")]
pub status_bar_foreground: Option<String>,
#[serde(rename = "statusBar.debuggingBackground")]
pub status_bar_debugging_background: Option<String>,
#[serde(rename = "statusBar.debuggingForeground")]
pub status_bar_debugging_foreground: Option<String>,
#[serde(rename = "statusBar.noFolderBackground")]
pub status_bar_no_folder_background: Option<String>,
#[serde(rename = "statusBar.noFolderForeground")]
pub status_bar_no_folder_foreground: Option<String>,
#[serde(rename = "statusBarItem.prominentBackground")]
pub status_bar_item_prominent_background: Option<String>,
#[serde(rename = "statusBarItem.prominentHoverBackground")]
pub status_bar_item_prominent_hover_background: Option<String>,
#[serde(rename = "statusBarItem.remoteForeground")]
pub status_bar_item_remote_foreground: Option<String>,
#[serde(rename = "statusBarItem.remoteBackground")]
pub status_bar_item_remote_background: Option<String>,
#[serde(rename = "titleBar.activeBackground")]
pub title_bar_active_background: Option<String>,
#[serde(rename = "titleBar.activeForeground")]
pub title_bar_active_foreground: Option<String>,
#[serde(rename = "titleBar.inactiveBackground")]
pub title_bar_inactive_background: Option<String>,
#[serde(rename = "titleBar.inactiveForeground")]
pub title_bar_inactive_foreground: Option<String>,
#[serde(rename = "extensionButton.prominentForeground")]
pub extension_button_prominent_foreground: Option<String>,
#[serde(rename = "extensionButton.prominentBackground")]
pub extension_button_prominent_background: Option<String>,
#[serde(rename = "extensionButton.prominentHoverBackground")]
pub extension_button_prominent_hover_background: Option<String>,
#[serde(rename = "pickerGroup.border")]
pub picker_group_border: Option<String>,
#[serde(rename = "pickerGroup.foreground")]
pub picker_group_foreground: Option<String>,
#[serde(rename = "debugToolBar.background")]
pub debug_tool_bar_background: Option<String>,
#[serde(rename = "walkThrough.embeddedEditorBackground")]
pub walk_through_embedded_editor_background: Option<String>,
#[serde(rename = "settings.headerForeground")]
pub settings_header_foreground: Option<String>,
#[serde(rename = "settings.modifiedItemIndicator")]
pub settings_modified_item_indicator: Option<String>,
#[serde(rename = "settings.dropdownBackground")]
pub settings_dropdown_background: Option<String>,
#[serde(rename = "settings.dropdownForeground")]
pub settings_dropdown_foreground: Option<String>,
#[serde(rename = "settings.dropdownBorder")]
pub settings_dropdown_border: Option<String>,
#[serde(rename = "settings.checkboxBackground")]
pub settings_checkbox_background: Option<String>,
#[serde(rename = "settings.checkboxForeground")]
pub settings_checkbox_foreground: Option<String>,
#[serde(rename = "settings.checkboxBorder")]
pub settings_checkbox_border: Option<String>,
#[serde(rename = "settings.textInputBackground")]
pub settings_text_input_background: Option<String>,
#[serde(rename = "settings.textInputForeground")]
pub settings_text_input_foreground: Option<String>,
#[serde(rename = "settings.textInputBorder")]
pub settings_text_input_border: Option<String>,
#[serde(rename = "settings.numberInputBackground")]
pub settings_number_input_background: Option<String>,
#[serde(rename = "settings.numberInputForeground")]
pub settings_number_input_foreground: Option<String>,
#[serde(rename = "settings.numberInputBorder")]
pub settings_number_input_border: Option<String>,
#[serde(rename = "breadcrumb.foreground")]
pub breadcrumb_foreground: Option<String>,
#[serde(rename = "breadcrumb.background")]
pub breadcrumb_background: Option<String>,
#[serde(rename = "breadcrumb.focusForeground")]
pub breadcrumb_focus_foreground: Option<String>,
#[serde(rename = "breadcrumb.activeSelectionForeground")]
pub breadcrumb_active_selection_foreground: Option<String>,
#[serde(rename = "breadcrumbPicker.background")]
pub breadcrumb_picker_background: Option<String>,
#[serde(rename = "listFilterWidget.background")]
pub list_filter_widget_background: Option<String>,
#[serde(rename = "listFilterWidget.outline")]
pub list_filter_widget_outline: Option<String>,
#[serde(rename = "listFilterWidget.noMatchesOutline")]
pub list_filter_widget_no_matches_outline: Option<String>,
}
fn try_parse_color(color: &str) -> Result<Hsla> {
Ok(Rgba::try_from(color)?.into())
}
pub struct VsCodeThemeConverter {
theme: VsCodeTheme,
theme_metadata: ThemeMetadata,
}
impl VsCodeThemeConverter {
pub fn new(theme: VsCodeTheme, theme_metadata: ThemeMetadata) -> Self {
Self {
theme,
theme_metadata,
}
}
pub fn convert(self) -> Result<ThemeVariant> {
let appearance = self.theme_metadata.appearance.into();
let mut theme_colors = match appearance {
Appearance::Light => ThemeColors::default_light(),
Appearance::Dark => ThemeColors::default_dark(),
};
let vscode_colors = &self.theme.colors;
let theme_colors_refinements = ThemeColorsRefinement {
border: vscode_colors
.panel_border
.as_ref()
.traverse(|color| try_parse_color(&color))?,
border_variant: vscode_colors
.panel_border
.as_ref()
.traverse(|color| try_parse_color(&color))?,
border_focused: vscode_colors
.panel_border
.as_ref()
.traverse(|color| try_parse_color(&color))?,
border_disabled: vscode_colors
.panel_border
.as_ref()
.traverse(|color| try_parse_color(&color))?,
border_selected: vscode_colors
.panel_border
.as_ref()
.traverse(|color| try_parse_color(&color))?,
border_transparent: vscode_colors
.panel_border
.as_ref()
.traverse(|color| try_parse_color(&color))?,
elevated_surface_background: vscode_colors
.panel_background
.as_ref()
.traverse(|color| try_parse_color(&color))?,
surface_background: vscode_colors
.panel_background
.as_ref()
.traverse(|color| try_parse_color(&color))?,
background: vscode_colors
.editor_background
.as_ref()
.traverse(|color| try_parse_color(&color))?,
element_background: vscode_colors
.button_background
.as_ref()
.traverse(|color| try_parse_color(&color))?,
text: vscode_colors
.foreground
.as_ref()
.traverse(|color| try_parse_color(&color))?,
tab_active_background: vscode_colors
.tab_active_background
.as_ref()
.traverse(|color| try_parse_color(&color))?,
tab_inactive_background: vscode_colors
.tab_inactive_background
.as_ref()
.traverse(|color| try_parse_color(&color))?,
terminal_background: vscode_colors
.terminal_background
.as_ref()
.traverse(|color| try_parse_color(&color))?,
terminal_ansi_bright_black: vscode_colors
.terminal_ansi_bright_black
.as_ref()
.traverse(|color| try_parse_color(&color))?,
terminal_ansi_bright_red: vscode_colors
.terminal_ansi_bright_red
.as_ref()
.traverse(|color| try_parse_color(&color))?,
terminal_ansi_bright_green: vscode_colors
.terminal_ansi_bright_green
.as_ref()
.traverse(|color| try_parse_color(&color))?,
terminal_ansi_bright_yellow: vscode_colors
.terminal_ansi_bright_yellow
.as_ref()
.traverse(|color| try_parse_color(&color))?,
terminal_ansi_bright_blue: vscode_colors
.terminal_ansi_bright_blue
.as_ref()
.traverse(|color| try_parse_color(&color))?,
terminal_ansi_bright_magenta: vscode_colors
.terminal_ansi_bright_magenta
.as_ref()
.traverse(|color| try_parse_color(&color))?,
terminal_ansi_bright_cyan: vscode_colors
.terminal_ansi_bright_cyan
.as_ref()
.traverse(|color| try_parse_color(&color))?,
terminal_ansi_bright_white: vscode_colors
.terminal_ansi_bright_white
.as_ref()
.traverse(|color| try_parse_color(&color))?,
terminal_ansi_black: vscode_colors
.terminal_ansi_black
.as_ref()
.traverse(|color| try_parse_color(&color))?,
terminal_ansi_red: vscode_colors
.terminal_ansi_red
.as_ref()
.traverse(|color| try_parse_color(&color))?,
terminal_ansi_green: vscode_colors
.terminal_ansi_green
.as_ref()
.traverse(|color| try_parse_color(&color))?,
terminal_ansi_yellow: vscode_colors
.terminal_ansi_yellow
.as_ref()
.traverse(|color| try_parse_color(&color))?,
terminal_ansi_blue: vscode_colors
.terminal_ansi_blue
.as_ref()
.traverse(|color| try_parse_color(&color))?,
terminal_ansi_magenta: vscode_colors
.terminal_ansi_magenta
.as_ref()
.traverse(|color| try_parse_color(&color))?,
terminal_ansi_cyan: vscode_colors
.terminal_ansi_cyan
.as_ref()
.traverse(|color| try_parse_color(&color))?,
terminal_ansi_white: vscode_colors
.terminal_ansi_white
.as_ref()
.traverse(|color| try_parse_color(&color))?,
..Default::default()
};
theme_colors.refine(&theme_colors_refinements);
Ok(ThemeVariant {
id: uuid::Uuid::new_v4().to_string(),
name: self.theme_metadata.name.into(),
appearance,
styles: ThemeStyles {
system: SystemColors::default(),
colors: theme_colors,
status: StatusColors::default(),
git: GitStatusColors::default(),
player: PlayerColors::default(),
syntax: SyntaxTheme::default_dark(),
},
})
}
}
// #[cfg(test)]
// mod tests {
// use super::*;
// use std::path::PathBuf;
// #[test]
// fn test_deserialize_theme() {
// let manifest_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
// let root_dir = manifest_dir.parent().unwrap().parent().unwrap();
// let mut d = root_dir.to_path_buf();
// d.push("assets/themes/src/vsc/dracula/dracula.json");
// let data = std::fs::read_to_string(d).expect("Unable to read file");
// let result: Theme = serde_json::from_str(&data).unwrap();
// println!("{:#?}", result);
// }
// }

View file

@ -7,7 +7,7 @@ publish = false
[dependencies]
anyhow.workspace = true
chrono = "0.4"
gpui2 = { path = "../gpui2" }
gpui = { package = "gpui2", path = "../gpui2" }
itertools = { version = "0.11.0", optional = true }
serde.workspace = true
settings2 = { path = "../settings2" }

View file

@ -0,0 +1,49 @@
# Building UI with GPUI
## Common patterns
### Method ordering
- id
- Flex properties
- Position properties
- Size properties
- Style properties
- Handlers
- State properties
### Using the Label Component to Create UI Text
The `Label` component helps in displaying text on user interfaces. It creates an interface where specific parameters such as label color, line height style, and strikethrough can be set.
Firstly, to create a `Label` instance, use the `Label::new()` function. This function takes a string that will be displayed as text in the interface.
```rust
Label::new("Hello, world!");
```
Now let's dive a bit deeper into how to customize `Label` instances:
- **Setting Color:** To set the color of the label using various predefined color options such as `Default`, `Muted`, `Created`, `Modified`, `Deleted`, etc, the `color()` function is called on the `Label` instance:
```rust
Label::new("Hello, world!").color(LabelColor::Default);
```
- **Setting Line Height Style:** To set the line height style, the `line_height_style()` function is utilized:
```rust
Label::new("Hello, world!").line_height_style(LineHeightStyle::TextLabel);
```
- **Adding a Strikethrough:** To add a strikethrough in a `Label`, the `set_strikethrough()` function is used:
```rust
Label::new("Hello, world!").set_strikethrough(true);
```
That's it! Now you can use the `Label` component to create and customize text on your application's interface.
## Building a new component
TODO

View file

@ -1,57 +0,0 @@
# Elevation
Elevation in Zed applies to all surfaces and components. Elevation is categorized into levels.
Elevation accomplishes the following:
- Allows surfaces to move in front of or behind others, such as content scrolling beneath app top bars.
- Reflects spatial relationships, for instance, how a floating action buttons shadow intimates its disconnection from a collection of cards.
- Directs attention to structures at the highest elevation, like a temporary dialog arising in front of other surfaces.
Elevations are the initial elevation values assigned to components by default.
Components may transition to a higher elevation in some cases, like user interations.
On such occasions, components transition to predetermined dynamic elevation offsets. These are the typical elevations to which components move when they are not at rest.
## Understanding Elevation
Elevation can be thought of as the physical closeness of an element to the user. Elements with lower elevations are physically further away from the user on the z-axis and appear to be underneath elements with higher elevations.
Material Design 3 has a some great visualizations of elevation that may be helpful to understanding the mental modal of elevation. [Material Design Elevation](https://m3.material.io/styles/elevation/overview)
## Elevation Levels
Zed integrates six unique elevation levels in its design system. The elevation of a surface is expressed as a whole number ranging from 0 to 5, both numbers inclusive. A components elevation is ascertained by combining the components resting elevation with any dynamic elevation offsets.
The levels are detailed as follows:
0. App Background
1. UI Surface
2. Elevated Elements
3. Wash
4. Focused Element
5. Dragged Element
### 0. App Background
The app background constitutes the lowest elevation layer, appearing behind all other surfaces and components. It is predominantly used for the background color of the app.
### 1. UI Surface
The UI Surface is the standard elevation for components and is placed above the app background. It is generally used for the background color of the app bar, card, and sheet.
### 2. Elevated Elements
Elevated elements appear above the UI surface layer surfaces and components. Elevated elements are predominantly used for creating popovers, context menus, and tooltips.
### 3. Wash
Wash denotes a distinct elevation reserved to isolate app UI layers from high elevation components such as modals, notifications, and overlaid panels. The wash may not consistently be visible when these components are active. This layer is often referred to as a scrim or overlay and the background color of the wash is typically deployed in its design.
### 4. Focused Element
Focused elements obtain a higher elevation above surfaces and components at wash elevation. They are often used for modals, notifications, and overlaid panels and indicate that they are the sole element the user is interacting with at the moment.
### 5. Dragged Element
Dragged elements gain the highest elevation, thus appearing above surfaces and components at the elevation of focused elements. These are typically used for elements that are being dragged, following the cursor

View file

@ -0,0 +1,160 @@
# Hello World
Let's work through the prototypical "Build a todo app" example to showcase how we might build a simple component from scratch.
## Setup
We'll create a headline, a list of todo items, and a form to add new items.
~~~rust
struct TodoList<V: 'static> {
headline: SharedString,
items: Vec<TodoItem>,
submit_form: ClickHandler<V>
}
struct TodoItem<V: 'static> {
text: SharedString,
completed: bool,
delete: ClickHandler<V>
}
impl<V: 'static> TodoList<V> {
pub fn new(
// Here we impl Into<SharedString>
headline: impl Into<SharedString>,
items: Vec<TodoItem>,
submit_form: ClickHandler<V>
) -> Self {
Self {
// and here we call .into() so we can simply pass a string
// when creating the headline. This pattern is used throughout
// outr components
headline: headline.into(),
items: Vec::new(),
submit_form,
}
}
}
~~~
All of this is relatively straightforward.
We use [gpui::SharedString] in components instead of [std::string::String]. This allows us to [TODO: someone who actually knows please explain why we use SharedString].
When we want to pass an action we pass a `ClickHandler`. Whenever we want to add an action, the struct it belongs to needs to be generic over the view type `V`.
~~~rust
use gpui::hsla
impl<V: 'static> TodoList<V> {
// ...
fn render(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
div().size_4().bg(hsla(50.0/360.0, 1.0, 0.5, 1.0))
}
}
~~~
Every component needs a render method, and it should return `impl Component<V>`. This basic component will render a 16x16px yellow square on the screen.
A couple of questions might come to mind:
**Why is `size_4()` 16px, not 4px?**
gpui's style system is based on conventions created by [Tailwind CSS](https://tailwindcss.com/). Here is an example of the list of sizes for `width`: [Width - TailwindCSS Docs](https://tailwindcss.com/docs/width).
I'll quote from the Tailwind [Core Concepts](https://tailwindcss.com/docs/utility-first) docs here:
> Now I know what youre thinking, “this is an atrocity, what a horrible mess!”
> and youre right, its kind of ugly. In fact its just about impossible to
> think this is a good idea the first time you see it —
> you have to actually try it.
As you start using the Tailwind-style conventions you will be surprised how quick it makes it to build out UIs.
**Why `50.0/360.0` in `hsla()`?**
gpui [gpui::Hsla] use `0.0-1.0` for all it's values, but it is common for tools to use `0-360` for hue.
This may change in the future, but this is a little trick that let's you use familiar looking values.
## Building out the container
Let's grab our [theme2::colors::ThemeColors] from the theme and start building out a basic container.
We can access the current theme's colors like this:
~~~rust
impl<V: 'static> TodoList<V> {
// ...
fn render(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
let color = cx.theme().colors()
div().size_4().hsla(50.0/360.0, 1.0, 0.5, 1.0)
}
}
~~~
Now we have access to the complete set of colors defined in the theme.
~~~rust
use gpui::hsla
impl<V: 'static> TodoList<V> {
// ...
fn render(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
let color = cx.theme().colors()
div().size_4().bg(color.surface)
}
}
~~~
Let's finish up some basic styles for the container then move on to adding the other elements.
~~~rust
use gpui::hsla
impl<V: 'static> TodoList<V> {
// ...
fn render(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
let color = cx.theme().colors()
div()
// Flex properties
.flex()
.flex_col() // Stack elements vertically
.gap_2() // Add 8px of space between elements
// Size properties
.w_96() // Set width to 384px
.p_4() // Add 16px of padding on all sides
// Color properties
.bg(color.surface) // Set background color
.text_color(color.text) // Set text color
// Border properties
.rounded_md() // Add 4px of border radius
.border() // Add a 1px border
.border_color(color.border)
.child(
"Hello, world!"
)
}
}
~~~
### Headline
TODO
### List of todo items
TODO
### Input
TODO
### End result
TODO

25
crates/ui2/docs/todo.md Normal file
View file

@ -0,0 +1,25 @@
## Documentation priorities:
These are the priorities to get documented, in a rough stack rank order:
- [ ] label
- [ ] button
- [ ] icon_button
- [ ] icon
- [ ] list
- [ ] avatar
- [ ] panel
- [ ] modal
- [ ] palette
- [ ] input
- [ ] facepile
- [ ] player
- [ ] stacks
- [ ] context menu
- [ ] input
- [ ] textarea/multiline input (not built - not an editor)
- [ ] indicator
- [ ] public actor
- [ ] keybinding
- [ ] tab
- [ ] toast

View file

@ -1,71 +1,53 @@
mod assistant_panel;
mod breadcrumb;
mod buffer;
mod buffer_search;
mod chat_panel;
mod collab_panel;
mod command_palette;
mod avatar;
mod button;
mod checkbox;
mod context_menu;
mod copilot;
mod editor_pane;
mod details;
mod facepile;
mod icon;
mod icon_button;
mod indicator;
mod input;
mod keybinding;
mod language_selector;
mod label;
mod list;
mod modal;
mod multi_buffer;
mod notification_toast;
mod notifications_panel;
mod palette;
mod panel;
mod panes;
mod player;
mod player_stack;
mod project_panel;
mod recent_projects;
mod status_bar;
mod slot;
mod stack;
mod tab;
mod tab_bar;
mod terminal;
mod theme_selector;
mod title_bar;
mod toast;
mod toolbar;
mod traffic_lights;
mod workspace;
mod toggle;
mod tool_divider;
mod tooltip;
pub use assistant_panel::*;
pub use breadcrumb::*;
pub use buffer::*;
pub use buffer_search::*;
pub use chat_panel::*;
pub use collab_panel::*;
pub use command_palette::*;
pub use avatar::*;
pub use button::*;
pub use checkbox::*;
pub use context_menu::*;
pub use copilot::*;
pub use editor_pane::*;
pub use details::*;
pub use facepile::*;
pub use icon::*;
pub use icon_button::*;
pub use indicator::*;
pub use input::*;
pub use keybinding::*;
pub use language_selector::*;
pub use label::*;
pub use list::*;
pub use modal::*;
pub use multi_buffer::*;
pub use notification_toast::*;
pub use notifications_panel::*;
pub use palette::*;
pub use panel::*;
pub use panes::*;
pub use player::*;
pub use player_stack::*;
pub use project_panel::*;
pub use recent_projects::*;
pub use status_bar::*;
pub use slot::*;
pub use stack::*;
pub use tab::*;
pub use tab_bar::*;
pub use terminal::*;
pub use theme_selector::*;
pub use title_bar::*;
pub use toast::*;
pub use toolbar::*;
pub use traffic_lights::*;
pub use workspace::*;
pub use toggle::*;
pub use tool_divider::*;
pub use tooltip::*;

View file

@ -1,4 +1,4 @@
use gpui2::img;
use gpui::img;
use crate::prelude::*;
@ -33,7 +33,7 @@ impl Avatar {
img.uri(self.src.clone())
.size_4()
// todo!(Pull the avatar fallback background from the theme.)
.bg(gpui2::red())
.bg(gpui::red())
}
}
@ -44,7 +44,7 @@ pub use stories::*;
mod stories {
use super::*;
use crate::Story;
use gpui2::{Div, Render};
use gpui::{Div, Render};
pub struct AvatarStory;

View file

@ -1,9 +1,28 @@
use std::sync::Arc;
use gpui2::{div, rems, DefiniteLength, Hsla, MouseButton, WindowContext};
use gpui::{div, rems, DefiniteLength, Hsla, MouseButton, WindowContext};
use crate::prelude::*;
use crate::{h_stack, Icon, IconColor, IconElement, Label, LabelColor, LineHeightStyle};
use crate::{prelude::*, IconButton};
/// Provides the flexibility to use either a standard
/// button or an icon button in a given context.
pub enum ButtonOrIconButton<V: 'static> {
Button(Button<V>),
IconButton(IconButton<V>),
}
impl<V: 'static> From<Button<V>> for ButtonOrIconButton<V> {
fn from(value: Button<V>) -> Self {
Self::Button(value)
}
}
impl<V: 'static> From<IconButton<V>> for ButtonOrIconButton<V> {
fn from(value: IconButton<V>) -> Self {
Self::IconButton(value)
}
}
#[derive(Default, PartialEq, Clone, Copy)]
pub enum IconPosition {
@ -22,8 +41,8 @@ pub enum ButtonVariant {
impl ButtonVariant {
pub fn bg_color(&self, cx: &mut WindowContext) -> Hsla {
match self {
ButtonVariant::Ghost => cx.theme().colors().ghost_element,
ButtonVariant::Filled => cx.theme().colors().element,
ButtonVariant::Ghost => cx.theme().colors().ghost_element_background,
ButtonVariant::Filled => cx.theme().colors().element_background,
}
}
@ -42,7 +61,7 @@ impl ButtonVariant {
}
}
pub type ClickHandler<S> = Arc<dyn Fn(&mut S, &mut ViewContext<S>) + Send + Sync>;
pub type ClickHandler<V> = Arc<dyn Fn(&mut V, &mut ViewContext<V>) + Send + Sync>;
struct ButtonHandlers<V: 'static> {
click: Option<ClickHandler<V>>,
@ -215,7 +234,7 @@ pub use stories::*;
mod stories {
use super::*;
use crate::{h_stack, v_stack, LabelColor, Story};
use gpui2::{rems, Div, Render};
use gpui::{rems, Div, Render};
use strum::IntoEnumIterator;
pub struct ButtonStory;

View file

@ -0,0 +1,229 @@
use std::sync::Arc;
use gpui::{
div, Component, ElementId, ParentElement, StatefulInteractive, StatelessInteractive, Styled,
ViewContext,
};
use theme2::ActiveTheme;
use crate::{Icon, IconColor, IconElement, Selection};
pub type CheckHandler<V> = Arc<dyn Fn(Selection, &mut V, &mut ViewContext<V>) + Send + Sync>;
/// # Checkbox
///
/// Checkboxes are used for multiple choices, not for mutually exclusive choices.
/// Each checkbox works independently from other checkboxes in the list,
/// therefore checking an additional box does not affect any other selections.
#[derive(Component)]
pub struct Checkbox<V: 'static> {
id: ElementId,
checked: Selection,
disabled: bool,
on_click: Option<CheckHandler<V>>,
}
impl<V: 'static> Checkbox<V> {
pub fn new(id: impl Into<ElementId>, checked: Selection) -> Self {
Self {
id: id.into(),
checked,
disabled: false,
on_click: None,
}
}
pub fn disabled(mut self, disabled: bool) -> Self {
self.disabled = disabled;
self
}
pub fn on_click(
mut self,
handler: impl 'static + Fn(Selection, &mut V, &mut ViewContext<V>) + Send + Sync,
) -> Self {
self.on_click = Some(Arc::new(handler));
self
}
pub fn render(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
let group_id = format!("checkbox_group_{:?}", self.id);
let icon = match self.checked {
// When selected, we show a checkmark.
Selection::Selected => {
Some(
IconElement::new(Icon::Check)
.size(crate::IconSize::Small)
.color(
// If the checkbox is disabled we change the color of the icon.
if self.disabled {
IconColor::Disabled
} else {
IconColor::Selected
},
),
)
}
// In an indeterminate state, we show a dash.
Selection::Indeterminate => {
Some(
IconElement::new(Icon::Dash)
.size(crate::IconSize::Small)
.color(
// If the checkbox is disabled we change the color of the icon.
if self.disabled {
IconColor::Disabled
} else {
IconColor::Selected
},
),
)
}
// When unselected, we show nothing.
Selection::Unselected => None,
};
// A checkbox could be in an indeterminate state,
// for example the indeterminate state could represent:
// - a group of options of which only some are selected
// - an enabled option that is no longer available
// - a previously agreed to license that has been updated
//
// For the sake of styles we treat the indeterminate state as selected,
// but it's icon will be different.
let selected =
self.checked == Selection::Selected || self.checked == Selection::Indeterminate;
// We could use something like this to make the checkbox background when selected:
//
// ~~~rust
// ...
// .when(selected, |this| {
// this.bg(cx.theme().colors().element_selected)
// })
// ~~~
//
// But we use a match instead here because the checkbox might be disabled,
// and it could be disabled _while_ it is selected, as well as while it is not selected.
let (bg_color, border_color) = match (self.disabled, selected) {
(true, _) => (
cx.theme().colors().ghost_element_disabled,
cx.theme().colors().border_disabled,
),
(false, true) => (
cx.theme().colors().element_selected,
cx.theme().colors().border,
),
(false, false) => (
cx.theme().colors().element_background,
cx.theme().colors().border,
),
};
div()
.id(self.id)
// Rather than adding `px_1()` to add some space around the checkbox,
// we use a larger parent element to create a slightly larger
// click area for the checkbox.
.size_5()
// Because we've enlarged the click area, we need to create a
// `group` to pass down interaction events to the checkbox.
.group(group_id.clone())
.child(
div()
.flex()
// This prevent the flex element from growing
// or shrinking in response to any size changes
.flex_none()
// The combo of `justify_center()` and `items_center()`
// is used frequently to center elements in a flex container.
//
// We use this to center the icon in the checkbox.
.justify_center()
.items_center()
.m_1()
.size_4()
.rounded_sm()
.bg(bg_color)
.border()
.border_color(border_color)
// We only want the interaction states to fire when we
// are in a checkbox that isn't disabled.
.when(!self.disabled, |this| {
// Here instead of `hover()` we use `group_hover()`
// to pass it the group id.
this.group_hover(group_id.clone(), |el| {
el.bg(cx.theme().colors().element_hover)
})
})
.children(icon),
)
.when_some(
self.on_click.filter(|_| !self.disabled),
|this, on_click| {
this.on_click(move |view, _, cx| on_click(self.checked.inverse(), view, cx))
},
)
}
}
#[cfg(feature = "stories")]
pub use stories::*;
#[cfg(feature = "stories")]
mod stories {
use super::*;
use crate::{h_stack, Story};
use gpui::{Div, Render};
pub struct CheckboxStory;
impl Render for CheckboxStory {
type Element = Div<Self>;
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
Story::container(cx)
.child(Story::title_for::<_, Checkbox<Self>>(cx))
.child(Story::label(cx, "Default"))
.child(
h_stack()
.p_2()
.gap_2()
.rounded_md()
.border()
.border_color(cx.theme().colors().border)
.child(Checkbox::new("checkbox-enabled", Selection::Unselected))
.child(Checkbox::new(
"checkbox-intermediate",
Selection::Indeterminate,
))
.child(Checkbox::new("checkbox-selected", Selection::Selected)),
)
.child(Story::label(cx, "Disabled"))
.child(
h_stack()
.p_2()
.gap_2()
.rounded_md()
.border()
.border_color(cx.theme().colors().border)
.child(
Checkbox::new("checkbox-disabled", Selection::Unselected)
.disabled(true),
)
.child(
Checkbox::new(
"checkbox-disabled-intermediate",
Selection::Indeterminate,
)
.disabled(true),
)
.child(
Checkbox::new("checkbox-disabled-selected", Selection::Selected)
.disabled(true),
),
)
}
}
}

View file

@ -8,7 +8,7 @@ pub enum ContextMenuItem {
}
impl ContextMenuItem {
fn to_list_item<V: 'static>(self) -> ListItem<V> {
fn to_list_item<V: 'static>(self) -> ListItem {
match self {
ContextMenuItem::Header(label) => ListSubHeader::new(label).into(),
ContextMenuItem::Entry(label) => {
@ -46,18 +46,15 @@ impl ContextMenu {
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
v_stack()
.flex()
.bg(cx.theme().colors().elevated_surface)
.bg(cx.theme().colors().elevated_surface_background)
.border()
.border_color(cx.theme().colors().border)
.child(
List::new(
self.items
.into_iter()
.map(ContextMenuItem::to_list_item)
.collect(),
)
.toggle(ToggleState::Toggled),
)
.child(List::new(
self.items
.into_iter()
.map(ContextMenuItem::to_list_item::<V>)
.collect(),
))
}
}
@ -68,7 +65,7 @@ pub use stories::*;
mod stories {
use super::*;
use crate::story::Story;
use gpui2::{Div, Render};
use gpui::{Div, Render};
pub struct ContextMenuStory;

View file

@ -47,7 +47,7 @@ pub use stories::*;
mod stories {
use super::*;
use crate::{Button, Story};
use gpui2::{Div, Render};
use gpui::{Div, Render};
pub struct DetailsStory;

View file

@ -33,7 +33,7 @@ pub use stories::*;
mod stories {
use super::*;
use crate::{static_players, Story};
use gpui2::{Div, Render};
use gpui::{Div, Render};
pub struct FacepileStory;

View file

@ -1,4 +1,4 @@
use gpui2::{rems, svg, Hsla};
use gpui::{rems, svg, Hsla};
use strum::EnumIter;
use crate::prelude::*;
@ -22,6 +22,7 @@ pub enum IconColor {
Warning,
Success,
Info,
Selected,
}
impl IconColor {
@ -36,6 +37,7 @@ impl IconColor {
IconColor::Warning => cx.theme().status().warning,
IconColor::Success => cx.theme().status().success,
IconColor::Info => cx.theme().status().info,
IconColor::Selected => cx.theme().colors().icon_accent,
}
}
}
@ -55,6 +57,7 @@ pub enum Icon {
ChevronRight,
ChevronUp,
Close,
Dash,
Exit,
ExclamationTriangle,
File,
@ -112,6 +115,7 @@ impl Icon {
Icon::ChevronRight => "icons/chevron_right.svg",
Icon::ChevronUp => "icons/chevron_up.svg",
Icon::Close => "icons/x.svg",
Icon::Dash => "icons/dash.svg",
Icon::Exit => "icons/exit.svg",
Icon::ExclamationTriangle => "icons/warning.svg",
Icon::File => "icons/file.svg",
@ -182,7 +186,6 @@ impl IconElement {
}
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
let fill = self.color.color(cx);
let svg_size = match self.size {
IconSize::Small => rems(0.75),
IconSize::Medium => rems(0.9375),
@ -192,7 +195,7 @@ impl IconElement {
.size(svg_size)
.flex_none()
.path(self.icon.path())
.text_color(fill)
.text_color(self.color.color(cx))
}
}
@ -201,7 +204,7 @@ pub use stories::*;
#[cfg(feature = "stories")]
mod stories {
use gpui2::{Div, Render};
use gpui::{Div, Render};
use strum::IntoEnumIterator;
use crate::Story;

View file

@ -1,6 +1,6 @@
use std::sync::Arc;
use gpui2::{rems, MouseButton};
use gpui::{rems, MouseButton};
use crate::{h_stack, prelude::*};
use crate::{ClickHandler, Icon, IconColor, IconElement};
@ -73,12 +73,12 @@ impl<V: 'static> IconButton<V> {
let (bg_color, bg_hover_color, bg_active_color) = match self.variant {
ButtonVariant::Filled => (
cx.theme().colors().element,
cx.theme().colors().element_background,
cx.theme().colors().element_hover,
cx.theme().colors().element_active,
),
ButtonVariant::Ghost => (
cx.theme().colors().ghost_element,
cx.theme().colors().ghost_element_background,
cx.theme().colors().ghost_element_hover,
cx.theme().colors().ghost_element_active,
),

View file

@ -1,4 +1,4 @@
use gpui2::px;
use gpui::px;
use crate::prelude::*;
@ -14,7 +14,7 @@ impl UnreadIndicator {
div()
.rounded_full()
.border_2()
.border_color(cx.theme().colors().surface)
.border_color(cx.theme().colors().surface_background)
.w(px(9.0))
.h(px(9.0))
.z_index(2)

View file

@ -59,12 +59,12 @@ impl Input {
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
let (input_bg, input_hover_bg, input_active_bg) = match self.variant {
InputVariant::Ghost => (
cx.theme().colors().ghost_element,
cx.theme().colors().ghost_element_background,
cx.theme().colors().ghost_element_hover,
cx.theme().colors().ghost_element_active,
),
InputVariant::Filled => (
cx.theme().colors().element,
cx.theme().colors().element_background,
cx.theme().colors().element_hover,
cx.theme().colors().element_active,
),
@ -111,7 +111,7 @@ pub use stories::*;
mod stories {
use super::*;
use crate::Story;
use gpui2::{Div, Render};
use gpui::{Div, Render};
pub struct InputStory;

View file

@ -66,7 +66,7 @@ impl Key {
.rounded_md()
.text_sm()
.text_color(cx.theme().colors().text)
.bg(cx.theme().colors().element)
.bg(cx.theme().colors().element_background)
.child(self.key.clone())
}
}
@ -158,7 +158,7 @@ pub use stories::*;
mod stories {
use super::*;
use crate::Story;
use gpui2::{Div, Render};
use gpui::{Div, Render};
use itertools::Itertools;
pub struct KeybindingStory;

View file

@ -1,4 +1,4 @@
use gpui2::{relative, rems, Hsla, WindowContext};
use gpui::{relative, rems, Hsla, WindowContext};
use smallvec::SmallVec;
use crate::prelude::*;
@ -194,7 +194,7 @@ pub use stories::*;
mod stories {
use super::*;
use crate::Story;
use gpui2::{Div, Render};
use gpui::{Div, Render};
pub struct LabelStory;

View file

@ -1,11 +1,11 @@
use gpui2::{div, px, relative, Div};
use gpui::div;
use crate::settings::user_settings;
use crate::{
h_stack, v_stack, Avatar, ClickHandler, Icon, IconColor, IconElement, IconSize, Label,
LabelColor,
disclosure_control, h_stack, v_stack, Avatar, Icon, IconColor, IconElement, IconSize, Label,
LabelColor, Toggle,
};
use crate::{prelude::*, Button};
use crate::{prelude::*, GraphicSlot};
#[derive(Clone, Copy, Default, Debug, PartialEq)]
pub enum ListItemVariant {
@ -29,7 +29,7 @@ pub struct ListHeader {
left_icon: Option<Icon>,
meta: Option<ListHeaderMeta>,
variant: ListItemVariant,
toggleable: Toggleable,
toggle: Toggle,
}
impl ListHeader {
@ -39,17 +39,12 @@ impl ListHeader {
left_icon: None,
meta: None,
variant: ListItemVariant::default(),
toggleable: Toggleable::NotToggleable,
toggle: Toggle::NotToggleable,
}
}
pub fn toggle(mut self, toggle: ToggleState) -> Self {
self.toggleable = toggle.into();
self
}
pub fn toggleable(mut self, toggleable: Toggleable) -> Self {
self.toggleable = toggleable;
pub fn toggle(mut self, toggle: Toggle) -> Self {
self.toggle = toggle;
self
}
@ -63,30 +58,8 @@ impl ListHeader {
self
}
fn disclosure_control<V: 'static>(&self) -> Div<V> {
let is_toggleable = self.toggleable != Toggleable::NotToggleable;
let is_toggled = Toggleable::is_toggled(&self.toggleable);
match (is_toggleable, is_toggled) {
(false, _) => div(),
(_, true) => div().child(
IconElement::new(Icon::ChevronDown)
.color(IconColor::Muted)
.size(IconSize::Small),
),
(_, false) => div().child(
IconElement::new(Icon::ChevronRight)
.color(IconColor::Muted)
.size(IconSize::Small),
),
}
}
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
let is_toggleable = self.toggleable != Toggleable::NotToggleable;
let is_toggled = self.toggleable.is_toggled();
let disclosure_control = self.disclosure_control();
let disclosure_control = disclosure_control(self.toggle);
let meta = match self.meta {
Some(ListHeaderMeta::Tools(icons)) => div().child(
@ -106,7 +79,7 @@ impl ListHeader {
h_stack()
.w_full()
.bg(cx.theme().colors().surface)
.bg(cx.theme().colors().surface_background)
// TODO: Add focus state
// .when(self.state == InteractionState::Focused, |this| {
// this.border()
@ -193,12 +166,6 @@ impl ListSubHeader {
}
}
#[derive(Clone)]
pub enum LeftContent {
Icon(Icon),
Avatar(SharedString),
}
#[derive(Default, PartialEq, Copy, Clone)]
pub enum ListEntrySize {
#[default]
@ -207,44 +174,36 @@ pub enum ListEntrySize {
}
#[derive(Component)]
pub enum ListItem<V: 'static> {
pub enum ListItem {
Entry(ListEntry),
Details(ListDetailsEntry<V>),
Separator(ListSeparator),
Header(ListSubHeader),
}
impl<V: 'static> From<ListEntry> for ListItem<V> {
impl From<ListEntry> for ListItem {
fn from(entry: ListEntry) -> Self {
Self::Entry(entry)
}
}
impl<V: 'static> From<ListDetailsEntry<V>> for ListItem<V> {
fn from(entry: ListDetailsEntry<V>) -> Self {
Self::Details(entry)
}
}
impl<V: 'static> From<ListSeparator> for ListItem<V> {
impl From<ListSeparator> for ListItem {
fn from(entry: ListSeparator) -> Self {
Self::Separator(entry)
}
}
impl<V: 'static> From<ListSubHeader> for ListItem<V> {
impl From<ListSubHeader> for ListItem {
fn from(entry: ListSubHeader) -> Self {
Self::Header(entry)
}
}
impl<V: 'static> ListItem<V> {
fn render(self, view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
impl ListItem {
fn render<V: 'static>(self, view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
match self {
ListItem::Entry(entry) => div().child(entry.render(view, cx)),
ListItem::Separator(separator) => div().child(separator.render(view, cx)),
ListItem::Header(header) => div().child(header.render(view, cx)),
ListItem::Details(details) => div().child(details.render(view, cx)),
}
}
@ -263,31 +222,29 @@ impl<V: 'static> ListItem<V> {
#[derive(Component)]
pub struct ListEntry {
disclosure_control_style: DisclosureControlVisibility,
disabled: bool,
// TODO: Reintroduce this
// disclosure_control_style: DisclosureControlVisibility,
indent_level: u32,
label: Label,
left_content: Option<LeftContent>,
variant: ListItemVariant,
size: ListEntrySize,
state: InteractionState,
toggle: Option<ToggleState>,
left_slot: Option<GraphicSlot>,
overflow: OverflowStyle,
size: ListEntrySize,
toggle: Toggle,
variant: ListItemVariant,
}
impl ListEntry {
pub fn new(label: Label) -> Self {
Self {
disclosure_control_style: DisclosureControlVisibility::default(),
disabled: false,
indent_level: 0,
label,
variant: ListItemVariant::default(),
left_content: None,
size: ListEntrySize::default(),
state: InteractionState::default(),
// TODO: Should use Toggleable::NotToggleable
// or remove Toggleable::NotToggleable from the system
toggle: None,
left_slot: None,
overflow: OverflowStyle::Hidden,
size: ListEntrySize::default(),
toggle: Toggle::NotToggleable,
variant: ListItemVariant::default(),
}
}
@ -301,28 +258,23 @@ impl ListEntry {
self
}
pub fn toggle(mut self, toggle: ToggleState) -> Self {
self.toggle = Some(toggle);
pub fn toggle(mut self, toggle: Toggle) -> Self {
self.toggle = toggle;
self
}
pub fn left_content(mut self, left_content: LeftContent) -> Self {
self.left_content = Some(left_content);
pub fn left_content(mut self, left_content: GraphicSlot) -> Self {
self.left_slot = Some(left_content);
self
}
pub fn left_icon(mut self, left_icon: Icon) -> Self {
self.left_content = Some(LeftContent::Icon(left_icon));
self.left_slot = Some(GraphicSlot::Icon(left_icon));
self
}
pub fn left_avatar(mut self, left_avatar: impl Into<SharedString>) -> Self {
self.left_content = Some(LeftContent::Avatar(left_avatar.into()));
self
}
pub fn state(mut self, state: InteractionState) -> Self {
self.state = state;
self.left_slot = Some(GraphicSlot::Avatar(left_avatar.into()));
self
}
@ -331,63 +283,19 @@ impl ListEntry {
self
}
pub fn disclosure_control_style(
mut self,
disclosure_control_style: DisclosureControlVisibility,
) -> Self {
self.disclosure_control_style = disclosure_control_style;
self
}
fn label_color(&self) -> LabelColor {
match self.state {
InteractionState::Disabled => LabelColor::Disabled,
_ => Default::default(),
}
}
fn icon_color(&self) -> IconColor {
match self.state {
InteractionState::Disabled => IconColor::Disabled,
_ => Default::default(),
}
}
fn disclosure_control<V: 'static>(
&mut self,
cx: &mut ViewContext<V>,
) -> Option<impl Component<V>> {
let disclosure_control_icon = if let Some(ToggleState::Toggled) = self.toggle {
IconElement::new(Icon::ChevronDown)
} else {
IconElement::new(Icon::ChevronRight)
}
.color(IconColor::Muted)
.size(IconSize::Small);
match (self.toggle, self.disclosure_control_style) {
(Some(_), DisclosureControlVisibility::OnHover) => {
Some(div().absolute().neg_left_5().child(disclosure_control_icon))
}
(Some(_), DisclosureControlVisibility::Always) => {
Some(div().child(disclosure_control_icon))
}
(None, _) => None,
}
}
fn render<V: 'static>(mut self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
let settings = user_settings(cx);
let left_content = match self.left_content.clone() {
Some(LeftContent::Icon(i)) => Some(
let left_content = match self.left_slot.clone() {
Some(GraphicSlot::Icon(i)) => Some(
h_stack().child(
IconElement::new(i)
.size(IconSize::Small)
.color(IconColor::Muted),
),
),
Some(LeftContent::Avatar(src)) => Some(h_stack().child(Avatar::new(src))),
Some(GraphicSlot::Avatar(src)) => Some(h_stack().child(Avatar::new(src))),
Some(GraphicSlot::PublicActor(src)) => Some(h_stack().child(Avatar::new(src))),
None => None,
};
@ -399,11 +307,12 @@ impl ListEntry {
div()
.relative()
.group("")
.bg(cx.theme().colors().surface)
.when(self.state == InteractionState::Focused, |this| {
this.border()
.border_color(cx.theme().colors().border_focused)
})
.bg(cx.theme().colors().surface_background)
// TODO: Add focus state
// .when(self.state == InteractionState::Focused, |this| {
// this.border()
// .border_color(cx.theme().colors().border_focused)
// })
.child(
sized_item
.when(self.variant == ListItemVariant::Inset, |this| this.px_2())
@ -425,131 +334,13 @@ impl ListEntry {
.gap_1()
.items_center()
.relative()
.children(self.disclosure_control(cx))
.child(disclosure_control(self.toggle))
.children(left_content)
.child(self.label),
)
}
}
struct ListDetailsEntryHandlers<V: 'static> {
click: Option<ClickHandler<V>>,
}
impl<V: 'static> Default for ListDetailsEntryHandlers<V> {
fn default() -> Self {
Self { click: None }
}
}
#[derive(Component)]
pub struct ListDetailsEntry<V: 'static> {
label: SharedString,
meta: Option<SharedString>,
left_content: Option<LeftContent>,
handlers: ListDetailsEntryHandlers<V>,
actions: Option<Vec<Button<V>>>,
// TODO: make this more generic instead of
// specifically for notifications
seen: bool,
}
impl<V: 'static> ListDetailsEntry<V> {
pub fn new(label: impl Into<SharedString>) -> Self {
Self {
label: label.into(),
meta: None,
left_content: None,
handlers: ListDetailsEntryHandlers::default(),
actions: None,
seen: false,
}
}
pub fn meta(mut self, meta: impl Into<SharedString>) -> Self {
self.meta = Some(meta.into());
self
}
pub fn seen(mut self, seen: bool) -> Self {
self.seen = seen;
self
}
pub fn on_click(mut self, handler: ClickHandler<V>) -> Self {
self.handlers.click = Some(handler);
self
}
pub fn actions(mut self, actions: Vec<Button<V>>) -> Self {
self.actions = Some(actions);
self
}
fn render(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
let settings = user_settings(cx);
let (item_bg, item_bg_hover, item_bg_active) = (
cx.theme().colors().ghost_element,
cx.theme().colors().ghost_element_hover,
cx.theme().colors().ghost_element_active,
);
let label_color = match self.seen {
true => LabelColor::Muted,
false => LabelColor::Default,
};
div()
.relative()
.group("")
.bg(item_bg)
.px_2()
.py_1p5()
.w_full()
.z_index(1)
.when(!self.seen, |this| {
this.child(
div()
.absolute()
.left(px(3.0))
.top_3()
.rounded_full()
.border_2()
.border_color(cx.theme().colors().surface)
.w(px(9.0))
.h(px(9.0))
.z_index(2)
.bg(cx.theme().status().info),
)
})
.child(
v_stack()
.w_full()
.line_height(relative(1.2))
.gap_1()
.child(
div()
.w_5()
.h_5()
.rounded_full()
.bg(cx.theme().colors().icon_accent),
)
.child(Label::new(self.label.clone()).color(label_color))
.children(
self.meta
.map(|meta| Label::new(meta).color(LabelColor::Muted)),
)
.child(
h_stack()
.gap_1()
.justify_end()
.children(self.actions.unwrap_or_default()),
),
)
}
}
#[derive(Clone, Component)]
pub struct ListSeparator;
@ -564,20 +355,22 @@ impl ListSeparator {
}
#[derive(Component)]
pub struct List<V: 'static> {
items: Vec<ListItem<V>>,
pub struct List {
items: Vec<ListItem>,
/// Message to display when the list is empty
/// Defaults to "No items"
empty_message: SharedString,
header: Option<ListHeader>,
toggleable: Toggleable,
toggle: Toggle,
}
impl<V: 'static> List<V> {
pub fn new(items: Vec<ListItem<V>>) -> Self {
impl List {
pub fn new(items: Vec<ListItem>) -> Self {
Self {
items,
empty_message: "No items".into(),
header: None,
toggleable: Toggleable::default(),
toggle: Toggle::NotToggleable,
}
}
@ -591,19 +384,16 @@ impl<V: 'static> List<V> {
self
}
pub fn toggle(mut self, toggle: ToggleState) -> Self {
self.toggleable = toggle.into();
pub fn toggle(mut self, toggle: Toggle) -> Self {
self.toggle = toggle;
self
}
fn render(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
let is_toggleable = self.toggleable != Toggleable::NotToggleable;
let is_toggled = Toggleable::is_toggled(&self.toggleable);
let list_content = match (self.items.is_empty(), is_toggled) {
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
let list_content = match (self.items.is_empty(), self.toggle) {
(false, _) => div().children(self.items),
(true, false) => div(),
(true, true) => {
(true, Toggle::Toggled(false)) => div(),
(true, _) => {
div().child(Label::new(self.empty_message.clone()).color(LabelColor::Muted))
}
};
@ -611,7 +401,7 @@ impl<V: 'static> List<V> {
v_stack()
.w_full()
.py_1()
.children(self.header.map(|header| header.toggleable(self.toggleable)))
.children(self.header.map(|header| header))
.child(list_content)
}
}

View file

@ -1,4 +1,4 @@
use gpui2::AnyElement;
use gpui::AnyElement;
use smallvec::SmallVec;
use crate::{h_stack, prelude::*, v_stack, Button, Icon, IconButton, Label};

View file

@ -1,4 +1,4 @@
use gpui2::rems;
use gpui::rems;
use crate::prelude::*;
use crate::{h_stack, Icon};
@ -34,7 +34,7 @@ impl NotificationToast {
.px_1p5()
.rounded_lg()
.shadow_md()
.bg(cx.theme().colors().elevated_surface)
.bg(cx.theme().colors().elevated_surface_background)
.child(div().size_full().child(self.label.clone()))
}
}

View file

@ -47,7 +47,7 @@ impl Palette {
.id(self.id.clone())
.w_96()
.rounded_lg()
.bg(cx.theme().colors().elevated_surface)
.bg(cx.theme().colors().elevated_surface_background)
.border()
.border_color(cx.theme().colors().border)
.child(
@ -56,7 +56,12 @@ impl Palette {
.child(v_stack().py_0p5().px_1().child(div().px_2().py_0p5().child(
Label::new(self.input_placeholder.clone()).color(LabelColor::Placeholder),
)))
.child(div().h_px().w_full().bg(cx.theme().colors().element))
.child(
div()
.h_px()
.w_full()
.bg(cx.theme().colors().element_background),
)
.child(
v_stack()
.id("items")
@ -148,13 +153,13 @@ impl PaletteItem {
}
}
use gpui2::ElementId;
use gpui::ElementId;
#[cfg(feature = "stories")]
pub use stories::*;
#[cfg(feature = "stories")]
mod stories {
use gpui2::{Div, Render};
use gpui::{Div, Render};
use crate::{ModifierKeys, Story};

View file

@ -1,4 +1,4 @@
use gpui2::{AbsoluteLength, AnyElement};
use gpui::{AbsoluteLength, AnyElement};
use smallvec::SmallVec;
use crate::prelude::*;
@ -107,7 +107,7 @@ impl<V: 'static> Panel<V> {
PanelSide::Right => this.border_l(),
PanelSide::Bottom => this.border_b().w_full().h(current_size),
})
.bg(cx.theme().colors().surface)
.bg(cx.theme().colors().surface_background)
.border_color(cx.theme().colors().border)
.children(self.children)
}
@ -126,7 +126,7 @@ pub use stories::*;
mod stories {
use super::*;
use crate::{Label, Story};
use gpui2::{Div, Render};
use gpui::{Div, Render};
pub struct PanelStory;

View file

@ -1,7 +1,25 @@
use gpui2::{Hsla, ViewContext};
use gpui::{Hsla, ViewContext};
use crate::prelude::*;
/// Represents a person with a Zed account's public profile.
/// All data in this struct should be considered public.
pub struct PublicPlayer {
pub username: SharedString,
pub avatar: SharedString,
pub is_contact: bool,
}
impl PublicPlayer {
pub fn new(username: impl Into<SharedString>, avatar: impl Into<SharedString>) -> Self {
Self {
username: username.into(),
avatar: avatar.into(),
is_contact: false,
}
}
}
#[derive(Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Copy)]
pub enum PlayerStatus {
#[default]

View file

@ -0,0 +1,14 @@
use gpui::SharedString;
use crate::Icon;
#[derive(Debug, Clone)]
/// A slot utility that provides a way to to pass either
/// an icon or an image to a component.
///
/// Can be filled with a []
pub enum GraphicSlot {
Icon(Icon),
Avatar(SharedString),
PublicActor(SharedString),
}

View file

@ -1,4 +1,4 @@
use gpui2::{div, Div};
use gpui::{div, Div};
use crate::prelude::*;

View file

@ -1,6 +1,6 @@
use crate::prelude::*;
use crate::{Icon, IconColor, IconElement, Label, LabelColor};
use gpui2::{red, Div, ElementId, Render, View, VisualContext};
use gpui::{red, Div, ElementId, Render, View, VisualContext};
#[derive(Component, Clone)]
pub struct Tab {
@ -109,12 +109,12 @@ impl Tab {
let (tab_bg, tab_hover_bg, tab_active_bg) = match self.current {
false => (
cx.theme().colors().tab_inactive,
cx.theme().colors().tab_inactive_background,
cx.theme().colors().ghost_element_hover,
cx.theme().colors().ghost_element_active,
),
true => (
cx.theme().colors().tab_active,
cx.theme().colors().tab_active_background,
cx.theme().colors().element_hover,
cx.theme().colors().element_active,
),

View file

@ -1,4 +1,4 @@
use gpui2::AnyElement;
use gpui::AnyElement;
use smallvec::SmallVec;
use crate::prelude::*;
@ -54,7 +54,7 @@ impl<V: 'static> Toast<V> {
.rounded_lg()
.shadow_md()
.overflow_hidden()
.bg(cx.theme().colors().elevated_surface)
.bg(cx.theme().colors().elevated_surface_background)
.children(self.children)
}
}
@ -70,7 +70,7 @@ pub use stories::*;
#[cfg(feature = "stories")]
mod stories {
use gpui2::{Div, Render};
use gpui::{Div, Render};
use crate::{Label, Story};

Some files were not shown because too many files have changed in this diff Show more