Compare commits
2 Commits
v1.0.0-bet
...
chat-patch
| Author | SHA1 | Date | |
|---|---|---|---|
| fec148dcb5 | |||
| 1d57a2deab |
28
Cargo.lock
generated
28
Cargo.lock
generated
@@ -238,7 +238,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "assets"
|
name = "assets"
|
||||||
version = "1.0.0-beta"
|
version = "1.0.0-beta1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"gpui",
|
"gpui",
|
||||||
@@ -535,7 +535,7 @@ checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "auto_update"
|
name = "auto_update"
|
||||||
version = "1.0.0-beta"
|
version = "1.0.0-beta1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"common",
|
"common",
|
||||||
@@ -986,7 +986,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "chat"
|
name = "chat"
|
||||||
version = "1.0.0-beta"
|
version = "1.0.0-beta1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"common",
|
"common",
|
||||||
@@ -1009,7 +1009,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "chat_ui"
|
name = "chat_ui"
|
||||||
version = "1.0.0-beta"
|
version = "1.0.0-beta1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"chat",
|
"chat",
|
||||||
@@ -1240,7 +1240,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "common"
|
name = "common"
|
||||||
version = "1.0.0-beta"
|
version = "1.0.0-beta1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"bech32",
|
"bech32",
|
||||||
@@ -1325,7 +1325,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "coop"
|
name = "coop"
|
||||||
version = "1.0.0-beta"
|
version = "1.0.0-beta1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"assets",
|
"assets",
|
||||||
@@ -1668,7 +1668,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "device"
|
name = "device"
|
||||||
version = "1.0.0-beta"
|
version = "1.0.0-beta1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"common",
|
"common",
|
||||||
@@ -4823,7 +4823,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "person"
|
name = "person"
|
||||||
version = "1.0.0-beta"
|
version = "1.0.0-beta1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"common",
|
"common",
|
||||||
@@ -5560,7 +5560,7 @@ checksum = "dc897dd8d9e8bd1ed8cdad82b5966c3e0ecae09fb1907d58efaa013543185d0a"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "relay_auth"
|
name = "relay_auth"
|
||||||
version = "1.0.0-beta"
|
version = "1.0.0-beta1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"common",
|
"common",
|
||||||
@@ -6243,7 +6243,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "settings"
|
name = "settings"
|
||||||
version = "1.0.0-beta"
|
version = "1.0.0-beta1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"common",
|
"common",
|
||||||
@@ -6512,7 +6512,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "state"
|
name = "state"
|
||||||
version = "1.0.0-beta"
|
version = "1.0.0-beta1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"common",
|
"common",
|
||||||
@@ -6851,7 +6851,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "theme"
|
name = "theme"
|
||||||
version = "1.0.0-beta"
|
version = "1.0.0-beta1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"gpui",
|
"gpui",
|
||||||
@@ -6988,7 +6988,7 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "title_bar"
|
name = "title_bar"
|
||||||
version = "1.0.0-beta"
|
version = "1.0.0-beta1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"common",
|
"common",
|
||||||
@@ -7359,7 +7359,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ui"
|
name = "ui"
|
||||||
version = "1.0.0-beta"
|
version = "1.0.0-beta1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"common",
|
"common",
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ default-members = ["crates/coop"]
|
|||||||
|
|
||||||
[workspace.package]
|
[workspace.package]
|
||||||
version = "1.0.0-beta1"
|
version = "1.0.0-beta1"
|
||||||
edition = "2021"
|
edition = "2024"
|
||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
[workspace.dependencies]
|
[workspace.dependencies]
|
||||||
|
|||||||
@@ -570,10 +570,10 @@ impl ChatRegistry {
|
|||||||
|
|
||||||
// Process each event and group by room hash
|
// Process each event and group by room hash
|
||||||
for raw in events.into_iter() {
|
for raw in events.into_iter() {
|
||||||
if let Ok(rumor) = UnsignedEvent::from_json(&raw.content) {
|
if let Ok(rumor) = UnsignedEvent::from_json(&raw.content)
|
||||||
if rumor.tags.public_keys().peekable().peek().is_some() {
|
&& rumor.tags.public_keys().peekable().peek().is_some()
|
||||||
grouped.entry(rumor.uniq_id()).or_default().push(rumor);
|
{
|
||||||
}
|
grouped.entry(rumor.uniq_id()).or_default().push(rumor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -619,12 +619,11 @@ impl ChatRegistry {
|
|||||||
match self.rooms.iter().find(|e| e.read(cx).id == message.room) {
|
match self.rooms.iter().find(|e| e.read(cx).id == message.room) {
|
||||||
Some(room) => {
|
Some(room) => {
|
||||||
room.update(cx, |this, cx| {
|
room.update(cx, |this, cx| {
|
||||||
if this.kind == RoomKind::Request {
|
if this.kind == RoomKind::Request
|
||||||
if let Some(public_key) = signer.public_key() {
|
&& let Some(public_key) = signer.public_key()
|
||||||
if message.rumor.pubkey == public_key {
|
&& message.rumor.pubkey == public_key
|
||||||
this.set_ongoing(cx);
|
{
|
||||||
}
|
this.set_ongoing(cx);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
this.push_message(message, cx);
|
this.push_message(message, cx);
|
||||||
});
|
});
|
||||||
@@ -682,10 +681,10 @@ async fn try_unwrap(
|
|||||||
gift_wrap: &Event,
|
gift_wrap: &Event,
|
||||||
) -> Result<UnwrappedGift, Error> {
|
) -> Result<UnwrappedGift, Error> {
|
||||||
// Try with the device signer first
|
// Try with the device signer first
|
||||||
if let Some(signer) = device_signer {
|
if let Some(signer) = device_signer
|
||||||
if let Ok(unwrapped) = try_unwrap_with(gift_wrap, signer).await {
|
&& let Ok(unwrapped) = try_unwrap_with(gift_wrap, signer).await
|
||||||
return Ok(unwrapped);
|
{
|
||||||
};
|
return Ok(unwrapped);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Try with the user's signer
|
// Try with the user's signer
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ pub enum Command {
|
|||||||
ChangeSubject(String),
|
ChangeSubject(String),
|
||||||
ChangeSigner(SignerKind),
|
ChangeSigner(SignerKind),
|
||||||
ToggleBackup,
|
ToggleBackup,
|
||||||
Subject,
|
|
||||||
Copy(PublicKey),
|
Copy(PublicKey),
|
||||||
Relays(PublicKey),
|
Relays(PublicKey),
|
||||||
Njump(PublicKey),
|
Njump(PublicKey),
|
||||||
|
|||||||
@@ -154,6 +154,7 @@ impl ChatPanel {
|
|||||||
|
|
||||||
// Define all functions that will run after the current cycle
|
// Define all functions that will run after the current cycle
|
||||||
cx.defer_in(window, |this, window, cx| {
|
cx.defer_in(window, |this, window, cx| {
|
||||||
|
this.connect(cx);
|
||||||
this.handle_notifications(cx);
|
this.handle_notifications(cx);
|
||||||
this.subscribe_room_events(window, cx);
|
this.subscribe_room_events(window, cx);
|
||||||
this.get_messages(window, cx);
|
this.get_messages(window, cx);
|
||||||
@@ -179,6 +180,14 @@ impl ChatPanel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get messaging relays and announcement for each member
|
||||||
|
fn connect(&mut self, cx: &mut Context<Self>) {
|
||||||
|
if let Some(room) = self.room.upgrade() {
|
||||||
|
let task = room.read(cx).connect(cx);
|
||||||
|
self.tasks.push(task);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Handle nostr notifications
|
/// Handle nostr notifications
|
||||||
fn handle_notifications(&mut self, cx: &mut Context<Self>) {
|
fn handle_notifications(&mut self, cx: &mut Context<Self>) {
|
||||||
let nostr = NostrRegistry::global(cx);
|
let nostr = NostrRegistry::global(cx);
|
||||||
@@ -247,11 +256,13 @@ impl ChatPanel {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Subscribe to room events
|
||||||
fn subscribe_room_events(&mut self, window: &mut Window, cx: &mut Context<Self>) {
|
fn subscribe_room_events(&mut self, window: &mut Window, cx: &mut Context<Self>) {
|
||||||
if let Some(room) = self.room.upgrade() {
|
if let Some(room) = self.room.upgrade() {
|
||||||
self.subscriptions.push(
|
self.subscriptions.push(cx.subscribe_in(
|
||||||
// Subscribe to room events
|
&room,
|
||||||
cx.subscribe_in(&room, window, move |this, _room, event, window, cx| {
|
window,
|
||||||
|
move |this, _room, event, window, cx| {
|
||||||
match event {
|
match event {
|
||||||
RoomEvent::Incoming(message) => {
|
RoomEvent::Incoming(message) => {
|
||||||
this.insert_message(message, false, cx);
|
this.insert_message(message, false, cx);
|
||||||
@@ -260,8 +271,8 @@ impl ChatPanel {
|
|||||||
this.get_messages(window, cx);
|
this.get_messages(window, cx);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}),
|
},
|
||||||
);
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -475,10 +486,10 @@ impl ChatPanel {
|
|||||||
/// Get a message by its ID
|
/// Get a message by its ID
|
||||||
fn message(&self, id: &EventId) -> Option<&RenderedMessage> {
|
fn message(&self, id: &EventId) -> Option<&RenderedMessage> {
|
||||||
self.messages.iter().find_map(|msg| {
|
self.messages.iter().find_map(|msg| {
|
||||||
if let Message::User(rendered) = msg {
|
if let Message::User(rendered) = msg
|
||||||
if &rendered.id == id {
|
&& &rendered.id == id
|
||||||
return Some(rendered);
|
{
|
||||||
}
|
return Some(rendered);
|
||||||
}
|
}
|
||||||
None
|
None
|
||||||
})
|
})
|
||||||
@@ -645,9 +656,6 @@ impl ChatPanel {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Command::Subject => {
|
|
||||||
self.open_subject(window, cx);
|
|
||||||
}
|
|
||||||
Command::Copy(public_key) => {
|
Command::Copy(public_key) => {
|
||||||
self.copy_author(public_key, cx);
|
self.copy_author(public_key, cx);
|
||||||
}
|
}
|
||||||
@@ -660,47 +668,6 @@ impl ChatPanel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn open_subject(&mut self, window: &mut Window, cx: &mut Context<Self>) {
|
|
||||||
let subject_input = self.subject_input.clone();
|
|
||||||
|
|
||||||
window.open_modal(cx, move |this, _window, cx| {
|
|
||||||
let subject = subject_input.read(cx).value();
|
|
||||||
|
|
||||||
this.title("Change subject")
|
|
||||||
.show_close(true)
|
|
||||||
.confirm()
|
|
||||||
.child(
|
|
||||||
v_flex()
|
|
||||||
.gap_2()
|
|
||||||
.child(
|
|
||||||
v_flex()
|
|
||||||
.gap_1p5()
|
|
||||||
.child(
|
|
||||||
div()
|
|
||||||
.text_sm()
|
|
||||||
.text_color(cx.theme().text_muted)
|
|
||||||
.child(SharedString::from("Subject:")),
|
|
||||||
)
|
|
||||||
.child(TextInput::new(&subject_input).small()),
|
|
||||||
)
|
|
||||||
.child(
|
|
||||||
div()
|
|
||||||
.italic()
|
|
||||||
.text_xs()
|
|
||||||
.text_color(cx.theme().text_placeholder)
|
|
||||||
.child(SharedString::from(
|
|
||||||
"Subject will be updated when you send a new message.",
|
|
||||||
)),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
.on_ok(move |_ev, window, cx| {
|
|
||||||
window
|
|
||||||
.dispatch_action(Box::new(Command::ChangeSubject(subject.to_string())), cx);
|
|
||||||
true
|
|
||||||
})
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
fn open_relays(&mut self, public_key: &PublicKey, window: &mut Window, cx: &mut Context<Self>) {
|
fn open_relays(&mut self, public_key: &PublicKey, window: &mut Window, cx: &mut Context<Self>) {
|
||||||
let profile = self.profile(public_key, cx);
|
let profile = self.profile(public_key, cx);
|
||||||
|
|
||||||
|
|||||||
@@ -148,26 +148,27 @@ impl RenderOnce for RoomEntry {
|
|||||||
this.on_click(move |event, window, cx| {
|
this.on_click(move |event, window, cx| {
|
||||||
handler(event, window, cx);
|
handler(event, window, cx);
|
||||||
|
|
||||||
if let Some(public_key) = public_key {
|
if let Some(public_key) = public_key
|
||||||
if self.kind != Some(RoomKind::Ongoing) && screening {
|
&& self.kind != Some(RoomKind::Ongoing)
|
||||||
let screening = screening::init(public_key, window, cx);
|
&& screening
|
||||||
|
{
|
||||||
|
let screening = screening::init(public_key, window, cx);
|
||||||
|
|
||||||
window.open_modal(cx, move |this, _window, _cx| {
|
window.open_modal(cx, move |this, _window, _cx| {
|
||||||
this.confirm()
|
this.confirm()
|
||||||
.child(screening.clone())
|
.child(screening.clone())
|
||||||
.button_props(
|
.button_props(
|
||||||
ModalButtonProps::default()
|
ModalButtonProps::default()
|
||||||
.cancel_text("Ignore")
|
.cancel_text("Ignore")
|
||||||
.ok_text("Response"),
|
.ok_text("Response"),
|
||||||
)
|
)
|
||||||
.on_cancel(move |_event, window, cx| {
|
.on_cancel(move |_event, window, cx| {
|
||||||
window.dispatch_action(Box::new(ClosePanel), cx);
|
window.dispatch_action(Box::new(ClosePanel), cx);
|
||||||
// Prevent closing the modal on click
|
// Prevent closing the modal on click
|
||||||
// modal will be automatically closed after closing panel
|
// modal will be automatically closed after closing panel
|
||||||
false
|
false
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -366,7 +366,11 @@ impl Sidebar {
|
|||||||
self.new_requests = false;
|
self.new_requests = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_list_items(&self, range: Range<usize>, cx: &Context<Self>) -> Vec<impl IntoElement> {
|
fn render_list_items(
|
||||||
|
&self,
|
||||||
|
range: Range<usize>,
|
||||||
|
cx: &Context<Self>,
|
||||||
|
) -> Vec<impl IntoElement + use<>> {
|
||||||
let chat = ChatRegistry::global(cx);
|
let chat = ChatRegistry::global(cx);
|
||||||
let rooms = chat.read(cx).rooms(self.filter.read(cx), cx);
|
let rooms = chat.read(cx).rooms(self.filter.read(cx), cx);
|
||||||
|
|
||||||
@@ -398,7 +402,11 @@ impl Sidebar {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Render the contact list
|
/// Render the contact list
|
||||||
fn render_results(&self, range: Range<usize>, cx: &Context<Self>) -> Vec<impl IntoElement> {
|
fn render_results(
|
||||||
|
&self,
|
||||||
|
range: Range<usize>,
|
||||||
|
cx: &Context<Self>,
|
||||||
|
) -> Vec<impl IntoElement + use<>> {
|
||||||
let persons = PersonRegistry::global(cx);
|
let persons = PersonRegistry::global(cx);
|
||||||
|
|
||||||
// Get the contact list
|
// Get the contact list
|
||||||
@@ -431,7 +439,11 @@ impl Sidebar {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Render the contact list
|
/// Render the contact list
|
||||||
fn render_contacts(&self, range: Range<usize>, cx: &Context<Self>) -> Vec<impl IntoElement> {
|
fn render_contacts(
|
||||||
|
&self,
|
||||||
|
range: Range<usize>,
|
||||||
|
cx: &Context<Self>,
|
||||||
|
) -> Vec<impl IntoElement + use<>> {
|
||||||
let persons = PersonRegistry::global(cx);
|
let persons = PersonRegistry::global(cx);
|
||||||
|
|
||||||
// Get the contact list
|
// Get the contact list
|
||||||
@@ -641,7 +653,7 @@ impl Render for Sidebar {
|
|||||||
uniform_list(
|
uniform_list(
|
||||||
"rooms",
|
"rooms",
|
||||||
results.len(),
|
results.len(),
|
||||||
cx.processor(|this, range, _window, cx| {
|
cx.processor(move |this, range, _window, cx| {
|
||||||
this.render_results(range, cx)
|
this.render_results(range, cx)
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
@@ -668,7 +680,7 @@ impl Render for Sidebar {
|
|||||||
uniform_list(
|
uniform_list(
|
||||||
"contacts",
|
"contacts",
|
||||||
contacts.len(),
|
contacts.len(),
|
||||||
cx.processor(move |this, range, _window, cx| {
|
cx.processor(|this, range, _window, cx| {
|
||||||
this.render_contacts(range, cx)
|
this.render_contacts(range, cx)
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -228,14 +228,14 @@ impl Workspace {
|
|||||||
where
|
where
|
||||||
P: PanelView,
|
P: PanelView,
|
||||||
{
|
{
|
||||||
if let Some(root) = window.root::<Root>().flatten() {
|
if let Some(root) = window.root::<Root>().flatten()
|
||||||
if let Ok(workspace) = root.read(cx).view().clone().downcast::<Self>() {
|
&& let Ok(workspace) = root.read(cx).view().clone().downcast::<Self>()
|
||||||
workspace.update(cx, |this, cx| {
|
{
|
||||||
this.dock.update(cx, |this, cx| {
|
workspace.update(cx, |this, cx| {
|
||||||
this.add_panel(Arc::new(panel), placement, window, cx);
|
this.dock.update(cx, |this, cx| {
|
||||||
});
|
this.add_panel(Arc::new(panel), placement, window, cx);
|
||||||
});
|
});
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -582,7 +582,7 @@ impl Workspace {
|
|||||||
window.push_notification(note, cx);
|
window.push_notification(note, cx);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn titlebar_left(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
fn titlebar_left(&mut self, cx: &mut Context<Self>) -> impl IntoElement {
|
||||||
let nostr = NostrRegistry::global(cx);
|
let nostr = NostrRegistry::global(cx);
|
||||||
let signer = nostr.read(cx).signer();
|
let signer = nostr.read(cx).signer();
|
||||||
let current_user = signer.public_key();
|
let current_user = signer.public_key();
|
||||||
@@ -661,7 +661,7 @@ impl Workspace {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn titlebar_right(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
fn titlebar_right(&mut self, cx: &mut Context<Self>) -> impl IntoElement {
|
||||||
let relay_connected = self.relay_connected;
|
let relay_connected = self.relay_connected;
|
||||||
let inbox_connected = self.inbox_connected;
|
let inbox_connected = self.inbox_connected;
|
||||||
|
|
||||||
@@ -802,8 +802,8 @@ impl Render for Workspace {
|
|||||||
let notification_layer = Root::render_notification_layer(window, cx);
|
let notification_layer = Root::render_notification_layer(window, cx);
|
||||||
|
|
||||||
// Titlebar elements
|
// Titlebar elements
|
||||||
let left = self.titlebar_left(window, cx).into_any_element();
|
let left = self.titlebar_left(cx).into_any_element();
|
||||||
let right = self.titlebar_right(window, cx).into_any_element();
|
let right = self.titlebar_right(cx).into_any_element();
|
||||||
|
|
||||||
// Update title bar children
|
// Update title bar children
|
||||||
self.titlebar.update(cx, |this, _cx| {
|
self.titlebar.update(cx, |this, _cx| {
|
||||||
|
|||||||
@@ -728,10 +728,10 @@ struct DeviceNotification;
|
|||||||
|
|
||||||
/// Verify the author of an event
|
/// Verify the author of an event
|
||||||
async fn verify_author(client: &Client, event: &Event) -> bool {
|
async fn verify_author(client: &Client, event: &Event) -> bool {
|
||||||
if let Some(signer) = client.signer() {
|
if let Some(signer) = client.signer()
|
||||||
if let Ok(public_key) = signer.get_public_key().await {
|
&& let Ok(public_key) = signer.get_public_key().await
|
||||||
return public_key == event.pubkey;
|
{
|
||||||
}
|
return public_key == event.pubkey;
|
||||||
}
|
}
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -123,16 +123,16 @@ impl Person {
|
|||||||
|
|
||||||
/// Get profile name
|
/// Get profile name
|
||||||
pub fn name(&self) -> SharedString {
|
pub fn name(&self) -> SharedString {
|
||||||
if let Some(display_name) = self.metadata().display_name.as_ref() {
|
if let Some(display_name) = self.metadata().display_name.as_ref()
|
||||||
if !display_name.is_empty() {
|
&& !display_name.is_empty()
|
||||||
return SharedString::from(display_name);
|
{
|
||||||
}
|
return SharedString::from(display_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(name) = self.metadata().name.as_ref() {
|
if let Some(name) = self.metadata().name.as_ref()
|
||||||
if !name.is_empty() {
|
&& !name.is_empty()
|
||||||
return SharedString::from(name);
|
{
|
||||||
}
|
return SharedString::from(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
SharedString::from(shorten_pubkey(self.public_key(), 4))
|
SharedString::from(shorten_pubkey(self.public_key(), 4))
|
||||||
|
|||||||
@@ -657,11 +657,11 @@ impl NostrRegistry {
|
|||||||
let mut results: Vec<PublicKey> = Vec::with_capacity(FIND_LIMIT);
|
let mut results: Vec<PublicKey> = Vec::with_capacity(FIND_LIMIT);
|
||||||
|
|
||||||
// Return early if the query is a valid NIP-05 address
|
// Return early if the query is a valid NIP-05 address
|
||||||
if let Some(task) = address_task {
|
if let Some(task) = address_task
|
||||||
if let Ok(public_key) = task.await {
|
&& let Ok(public_key) = task.await
|
||||||
results.push(public_key);
|
{
|
||||||
return Ok(results);
|
results.push(public_key);
|
||||||
}
|
return Ok(results);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return early if the query is a valid public key
|
// Return early if the query is a valid public key
|
||||||
|
|||||||
@@ -271,22 +271,22 @@ impl Dock {
|
|||||||
let mut right_dock_size = px(0.0);
|
let mut right_dock_size = px(0.0);
|
||||||
|
|
||||||
// Get the size of the left dock if it's open and not the current dock
|
// Get the size of the left dock if it's open and not the current dock
|
||||||
if let Some(left_dock) = &dock_area.left_dock {
|
if let Some(left_dock) = &dock_area.left_dock
|
||||||
if left_dock.entity_id() != cx.entity().entity_id() {
|
&& left_dock.entity_id() != cx.entity().entity_id()
|
||||||
let left_dock_read = left_dock.read(cx);
|
{
|
||||||
if left_dock_read.is_open() {
|
let left_dock_read = left_dock.read(cx);
|
||||||
left_dock_size = left_dock_read.size;
|
if left_dock_read.is_open() {
|
||||||
}
|
left_dock_size = left_dock_read.size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the size of the right dock if it's open and not the current dock
|
// Get the size of the right dock if it's open and not the current dock
|
||||||
if let Some(right_dock) = &dock_area.right_dock {
|
if let Some(right_dock) = &dock_area.right_dock
|
||||||
if right_dock.entity_id() != cx.entity().entity_id() {
|
&& right_dock.entity_id() != cx.entity().entity_id()
|
||||||
let right_dock_read = right_dock.read(cx);
|
{
|
||||||
if right_dock_read.is_open() {
|
let right_dock_read = right_dock.read(cx);
|
||||||
right_dock_size = right_dock_read.size;
|
if right_dock_read.is_open() {
|
||||||
}
|
right_dock_size = right_dock_read.size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -70,10 +70,10 @@ impl StackPanel {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(parent) = &self.parent {
|
if let Some(parent) = &self.parent
|
||||||
if let Some(parent) = parent.upgrade() {
|
&& let Some(parent) = parent.upgrade()
|
||||||
return parent.read(cx).is_last_panel(cx);
|
{
|
||||||
}
|
return parent.read(cx).is_last_panel(cx);
|
||||||
}
|
}
|
||||||
|
|
||||||
true
|
true
|
||||||
@@ -297,12 +297,11 @@ impl StackPanel {
|
|||||||
|
|
||||||
/// Find the first top left in the stack.
|
/// Find the first top left in the stack.
|
||||||
pub fn left_top_tab_panel(&self, check_parent: bool, cx: &App) -> Option<Entity<TabPanel>> {
|
pub fn left_top_tab_panel(&self, check_parent: bool, cx: &App) -> Option<Entity<TabPanel>> {
|
||||||
if check_parent {
|
if check_parent
|
||||||
if let Some(parent) = self.parent.as_ref().and_then(|parent| parent.upgrade()) {
|
&& let Some(parent) = self.parent.as_ref().and_then(|parent| parent.upgrade())
|
||||||
if let Some(panel) = parent.read(cx).left_top_tab_panel(true, cx) {
|
&& let Some(panel) = parent.read(cx).left_top_tab_panel(true, cx)
|
||||||
return Some(panel);
|
{
|
||||||
}
|
return Some(panel);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let first_panel = self.panels.first();
|
let first_panel = self.panels.first();
|
||||||
@@ -321,12 +320,11 @@ impl StackPanel {
|
|||||||
|
|
||||||
/// Find the first top right in the stack.
|
/// Find the first top right in the stack.
|
||||||
pub fn right_top_tab_panel(&self, check_parent: bool, cx: &App) -> Option<Entity<TabPanel>> {
|
pub fn right_top_tab_panel(&self, check_parent: bool, cx: &App) -> Option<Entity<TabPanel>> {
|
||||||
if check_parent {
|
if check_parent
|
||||||
if let Some(parent) = self.parent.as_ref().and_then(|parent| parent.upgrade()) {
|
&& let Some(parent) = self.parent.as_ref().and_then(|parent| parent.upgrade())
|
||||||
if let Some(panel) = parent.read(cx).right_top_tab_panel(true, cx) {
|
&& let Some(panel) = parent.read(cx).right_top_tab_panel(true, cx)
|
||||||
return Some(panel);
|
{
|
||||||
}
|
return Some(panel);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let panel = if self.axis.is_vertical() {
|
let panel = if self.axis.is_vertical() {
|
||||||
|
|||||||
@@ -232,14 +232,13 @@ impl TabPanel {
|
|||||||
.any(|p| p.panel_id(cx) == panel.panel_id(cx))
|
.any(|p| p.panel_id(cx) == panel.panel_id(cx))
|
||||||
{
|
{
|
||||||
// Set the active panel to the matched panel
|
// Set the active panel to the matched panel
|
||||||
if active {
|
if active
|
||||||
if let Some(ix) = self
|
&& let Some(ix) = self
|
||||||
.panels
|
.panels
|
||||||
.iter()
|
.iter()
|
||||||
.position(|p| p.panel_id(cx) == panel.panel_id(cx))
|
.position(|p| p.panel_id(cx) == panel.panel_id(cx))
|
||||||
{
|
{
|
||||||
self.set_active_ix(ix, window, cx);
|
self.set_active_ix(ix, window, cx);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@@ -372,12 +371,11 @@ impl TabPanel {
|
|||||||
|
|
||||||
/// Return true if self or parent only have last panel.
|
/// Return true if self or parent only have last panel.
|
||||||
fn is_last_panel(&self, cx: &App) -> bool {
|
fn is_last_panel(&self, cx: &App) -> bool {
|
||||||
if let Some(parent) = &self.stack_panel {
|
if let Some(parent) = &self.stack_panel
|
||||||
if let Some(stack_panel) = parent.upgrade() {
|
&& let Some(stack_panel) = parent.upgrade()
|
||||||
if !stack_panel.read(cx).is_last_panel(cx) {
|
&& !stack_panel.read(cx).is_last_panel(cx)
|
||||||
return false;
|
{
|
||||||
}
|
return false;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
self.panels.len() <= 1
|
self.panels.len() <= 1
|
||||||
@@ -1103,10 +1101,10 @@ impl TabPanel {
|
|||||||
window: &mut Window,
|
window: &mut Window,
|
||||||
cx: &mut Context<Self>,
|
cx: &mut Context<Self>,
|
||||||
) {
|
) {
|
||||||
if self.panels.len() > 1 {
|
if self.panels.len() > 1
|
||||||
if let Some(panel) = self.active_panel(cx) {
|
&& let Some(panel) = self.active_panel(cx)
|
||||||
self.remove_panel(&panel, window, cx);
|
{
|
||||||
}
|
self.remove_panel(&panel, window, cx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,10 +2,10 @@ use std::ops::Range;
|
|||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
use gpui::{
|
use gpui::{
|
||||||
fill, point, px, relative, size, App, Bounds, Corners, Element, ElementId, ElementInputHandler,
|
App, Bounds, Corners, Element, ElementId, ElementInputHandler, Entity, GlobalElementId, Hitbox,
|
||||||
Entity, GlobalElementId, Hitbox, IntoElement, LayoutId, MouseButton, MouseMoveEvent, Path,
|
IntoElement, LayoutId, MouseButton, MouseMoveEvent, Path, Pixels, Point, ShapedLine,
|
||||||
Pixels, Point, ShapedLine, SharedString, Size, Style, TextAlign, TextRun, UnderlineStyle,
|
SharedString, Size, Style, TextAlign, TextRun, UnderlineStyle, Window, fill, point, px,
|
||||||
Window,
|
relative, size,
|
||||||
};
|
};
|
||||||
use rope::Rope;
|
use rope::Rope;
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
@@ -348,10 +348,10 @@ impl TextElement {
|
|||||||
let mut rev_line_corners = line_corners.iter().rev().peekable();
|
let mut rev_line_corners = line_corners.iter().rev().peekable();
|
||||||
while let Some(corners) = rev_line_corners.next() {
|
while let Some(corners) = rev_line_corners.next() {
|
||||||
points.push(corners.top_left);
|
points.push(corners.top_left);
|
||||||
if let Some(next) = rev_line_corners.peek() {
|
if let Some(next) = rev_line_corners.peek()
|
||||||
if next.top_left.x > corners.top_left.x {
|
&& next.top_left.x > corners.top_left.x
|
||||||
points.push(point(next.top_left.x, corners.top_left.y));
|
{
|
||||||
}
|
points.push(point(next.top_left.x, corners.top_left.y));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -376,10 +376,10 @@ impl TextElement {
|
|||||||
) -> Option<Path<Pixels>> {
|
) -> Option<Path<Pixels>> {
|
||||||
let state = self.state.read(cx);
|
let state = self.state.read(cx);
|
||||||
let mut selected_range = state.selected_range;
|
let mut selected_range = state.selected_range;
|
||||||
if let Some(ime_marked_range) = &state.ime_marked_range {
|
if let Some(ime_marked_range) = &state.ime_marked_range
|
||||||
if !ime_marked_range.is_empty() {
|
&& !ime_marked_range.is_empty()
|
||||||
selected_range = (ime_marked_range.end..ime_marked_range.end).into();
|
{
|
||||||
}
|
selected_range = (ime_marked_range.end..ime_marked_range.end).into();
|
||||||
}
|
}
|
||||||
if selected_range.is_empty() {
|
if selected_range.is_empty() {
|
||||||
return None;
|
return None;
|
||||||
@@ -830,11 +830,12 @@ impl Element for TextElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Paint blinking cursor
|
// Paint blinking cursor
|
||||||
if focused && show_cursor {
|
if focused
|
||||||
if let Some(mut cursor_bounds) = prepaint.cursor_bounds.take() {
|
&& show_cursor
|
||||||
cursor_bounds.origin.y += prepaint.cursor_scroll_offset.y;
|
&& let Some(mut cursor_bounds) = prepaint.cursor_bounds.take()
|
||||||
window.paint_quad(fill(cursor_bounds, cx.theme().cursor));
|
{
|
||||||
}
|
cursor_bounds.origin.y += prepaint.cursor_scroll_offset.y;
|
||||||
|
window.paint_quad(fill(cursor_bounds, cx.theme().cursor));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Paint line numbers
|
// Paint line numbers
|
||||||
|
|||||||
@@ -225,13 +225,12 @@ impl MaskPattern {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// check if the fraction part is valid
|
// check if the fraction part is valid
|
||||||
if let Some(frac) = frac_part {
|
if let Some(frac) = frac_part
|
||||||
if !frac
|
&& !frac
|
||||||
.chars()
|
.chars()
|
||||||
.all(|ch| ch.is_ascii_digit() || Some(ch) == *separator)
|
.all(|ch| ch.is_ascii_digit() || Some(ch) == *separator)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
true
|
true
|
||||||
@@ -255,10 +254,10 @@ impl MaskPattern {
|
|||||||
|
|
||||||
if token.is_sep() {
|
if token.is_sep() {
|
||||||
// If next token is match, it's valid
|
// If next token is match, it's valid
|
||||||
if let Some(next_token) = tokens.get(pos + 1) {
|
if let Some(next_token) = tokens.get(pos + 1)
|
||||||
if next_token.is_match(ch) {
|
&& next_token.is_match(ch)
|
||||||
return true;
|
{
|
||||||
}
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,11 +4,11 @@ use std::time::Duration;
|
|||||||
|
|
||||||
use gpui::prelude::FluentBuilder as _;
|
use gpui::prelude::FluentBuilder as _;
|
||||||
use gpui::{
|
use gpui::{
|
||||||
actions, div, point, px, Action, App, AppContext, Bounds, ClipboardItem, Context, Entity,
|
Action, App, AppContext, Bounds, ClipboardItem, Context, Entity, EntityInputHandler,
|
||||||
EntityInputHandler, EventEmitter, FocusHandle, Focusable, InteractiveElement as _, IntoElement,
|
EventEmitter, FocusHandle, Focusable, InteractiveElement as _, IntoElement, KeyBinding,
|
||||||
KeyBinding, KeyDownEvent, MouseButton, MouseDownEvent, MouseMoveEvent, MouseUpEvent,
|
KeyDownEvent, MouseButton, MouseDownEvent, MouseMoveEvent, MouseUpEvent, ParentElement as _,
|
||||||
ParentElement as _, Pixels, Point, Render, ScrollHandle, ScrollWheelEvent, SharedString,
|
Pixels, Point, Render, ScrollHandle, ScrollWheelEvent, SharedString, Styled as _, Subscription,
|
||||||
Styled as _, Subscription, UTF16Selection, Window, WrappedLine,
|
UTF16Selection, Window, WrappedLine, actions, div, point, px,
|
||||||
};
|
};
|
||||||
use lsp_types::Position;
|
use lsp_types::Position;
|
||||||
use rope::{OffsetUtf16, Rope};
|
use rope::{OffsetUtf16, Rope};
|
||||||
@@ -25,9 +25,9 @@ use super::mask_pattern::MaskPattern;
|
|||||||
use super::mode::{InputMode, TabSize};
|
use super::mode::{InputMode, TabSize};
|
||||||
use super::rope_ext::RopeExt;
|
use super::rope_ext::RopeExt;
|
||||||
use super::text_wrapper::{LineItem, TextWrapper};
|
use super::text_wrapper::{LineItem, TextWrapper};
|
||||||
|
use crate::Root;
|
||||||
use crate::history::History;
|
use crate::history::History;
|
||||||
use crate::input::element::RIGHT_MARGIN;
|
use crate::input::element::RIGHT_MARGIN;
|
||||||
use crate::Root;
|
|
||||||
|
|
||||||
#[derive(Action, Clone, PartialEq, Eq, Deserialize)]
|
#[derive(Action, Clone, PartialEq, Eq, Deserialize)]
|
||||||
#[action(namespace = input, no_json)]
|
#[action(namespace = input, no_json)]
|
||||||
@@ -521,16 +521,16 @@ impl InputState {
|
|||||||
let new_row = new_row as usize;
|
let new_row = new_row as usize;
|
||||||
if new_row >= last_layout.visible_range.start {
|
if new_row >= last_layout.visible_range.start {
|
||||||
let visible_row = new_row.saturating_sub(last_layout.visible_range.start);
|
let visible_row = new_row.saturating_sub(last_layout.visible_range.start);
|
||||||
if let Some(line) = last_layout.lines.get(visible_row) {
|
if let Some(line) = last_layout.lines.get(visible_row)
|
||||||
if let Ok(x) = line.closest_index_for_position(
|
&& let Ok(x) = line.closest_index_for_position(
|
||||||
Point {
|
Point {
|
||||||
x: preferred_x,
|
x: preferred_x,
|
||||||
y: px(0.),
|
y: px(0.),
|
||||||
},
|
},
|
||||||
last_layout.line_height,
|
last_layout.line_height,
|
||||||
) {
|
)
|
||||||
new_offset = line_start_offset + x;
|
{
|
||||||
}
|
new_offset = line_start_offset + x;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1355,10 +1355,10 @@ impl InputState {
|
|||||||
) {
|
) {
|
||||||
// If there have IME marked range and is empty (Means pressed Esc to abort IME typing)
|
// If there have IME marked range and is empty (Means pressed Esc to abort IME typing)
|
||||||
// Clear the marked range.
|
// Clear the marked range.
|
||||||
if let Some(ime_marked_range) = &self.ime_marked_range {
|
if let Some(ime_marked_range) = &self.ime_marked_range
|
||||||
if ime_marked_range.is_empty() {
|
&& ime_marked_range.is_empty()
|
||||||
self.ime_marked_range = None;
|
{
|
||||||
}
|
self.ime_marked_range = None;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.selecting = true;
|
self.selecting = true;
|
||||||
@@ -1842,23 +1842,21 @@ impl InputState {
|
|||||||
|
|
||||||
fn previous_boundary(&self, offset: usize) -> usize {
|
fn previous_boundary(&self, offset: usize) -> usize {
|
||||||
let mut offset = self.text.clip_offset(offset.saturating_sub(1), Bias::Left);
|
let mut offset = self.text.clip_offset(offset.saturating_sub(1), Bias::Left);
|
||||||
if let Some(ch) = self.text.char_at(offset) {
|
if let Some(ch) = self.text.char_at(offset)
|
||||||
if ch == '\r' {
|
&& ch == '\r'
|
||||||
offset -= 1;
|
{
|
||||||
}
|
offset -= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
offset
|
offset
|
||||||
}
|
}
|
||||||
|
|
||||||
fn next_boundary(&self, offset: usize) -> usize {
|
fn next_boundary(&self, offset: usize) -> usize {
|
||||||
let mut offset = self.text.clip_offset(offset + 1, Bias::Right);
|
let mut offset = self.text.clip_offset(offset + 1, Bias::Right);
|
||||||
if let Some(ch) = self.text.char_at(offset) {
|
if let Some(ch) = self.text.char_at(offset)
|
||||||
if ch == '\r' {
|
&& ch == '\r'
|
||||||
offset += 1;
|
{
|
||||||
}
|
offset += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
offset
|
offset
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1927,10 +1925,10 @@ impl InputState {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(validate) = &self.validate {
|
if let Some(validate) = &self.validate
|
||||||
if !validate(new_text, cx) {
|
&& !validate(new_text, cx)
|
||||||
return false;
|
{
|
||||||
}
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if !self.mask_pattern.is_valid(new_text) {
|
if !self.mask_pattern.is_valid(new_text) {
|
||||||
@@ -1979,19 +1977,19 @@ impl InputState {
|
|||||||
self.input_bounds = new_bounds;
|
self.input_bounds = new_bounds;
|
||||||
|
|
||||||
// Update text_wrapper wrap_width if changed.
|
// Update text_wrapper wrap_width if changed.
|
||||||
if let Some(last_layout) = self.last_layout.as_ref() {
|
if let Some(last_layout) = self.last_layout.as_ref()
|
||||||
if wrap_width_changed {
|
&& wrap_width_changed
|
||||||
let wrap_width = if !self.soft_wrap {
|
{
|
||||||
// None to disable wrapping (will use Pixels::MAX)
|
let wrap_width = if !self.soft_wrap {
|
||||||
None
|
// None to disable wrapping (will use Pixels::MAX)
|
||||||
} else {
|
None
|
||||||
last_layout.wrap_width
|
} else {
|
||||||
};
|
last_layout.wrap_width
|
||||||
|
};
|
||||||
|
|
||||||
self.text_wrapper.set_wrap_width(wrap_width, cx);
|
self.text_wrapper.set_wrap_width(wrap_width, cx);
|
||||||
self.mode.update_auto_grow(&self.text_wrapper);
|
self.mode.update_auto_grow(&self.text_wrapper);
|
||||||
cx.notify();
|
cx.notify();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2209,20 +2207,18 @@ impl EntityInputHandler for InputState {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if start_origin.is_none() {
|
if start_origin.is_none()
|
||||||
if let Some(p) =
|
&& let Some(p) =
|
||||||
line.position_for_index(range.start.saturating_sub(index_offset), line_height)
|
line.position_for_index(range.start.saturating_sub(index_offset), line_height)
|
||||||
{
|
{
|
||||||
start_origin = Some(p + point(px(0.), y_offset));
|
start_origin = Some(p + point(px(0.), y_offset));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if end_origin.is_none() {
|
if end_origin.is_none()
|
||||||
if let Some(p) =
|
&& let Some(p) =
|
||||||
line.position_for_index(range.end.saturating_sub(index_offset), line_height)
|
line.position_for_index(range.end.saturating_sub(index_offset), line_height)
|
||||||
{
|
{
|
||||||
end_origin = Some(p + point(px(0.), y_offset));
|
end_origin = Some(p + point(px(0.), y_offset));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
index_offset += line.len() + 1;
|
index_offset += line.len() + 1;
|
||||||
|
|||||||
@@ -3,21 +3,21 @@ use std::time::Duration;
|
|||||||
|
|
||||||
use gpui::prelude::FluentBuilder;
|
use gpui::prelude::FluentBuilder;
|
||||||
use gpui::{
|
use gpui::{
|
||||||
div, px, size, uniform_list, App, AppContext, AvailableSpace, ClickEvent, Context,
|
App, AppContext, AvailableSpace, ClickEvent, Context, DefiniteLength, EdgesRefinement, Entity,
|
||||||
DefiniteLength, EdgesRefinement, Entity, EventEmitter, FocusHandle, Focusable,
|
EventEmitter, FocusHandle, Focusable, InteractiveElement, IntoElement, KeyBinding, Length,
|
||||||
InteractiveElement, IntoElement, KeyBinding, Length, ListSizingBehavior, MouseButton,
|
ListSizingBehavior, MouseButton, ParentElement, Render, RenderOnce, ScrollStrategy,
|
||||||
ParentElement, Render, RenderOnce, ScrollStrategy, SharedString, StatefulInteractiveElement,
|
SharedString, StatefulInteractiveElement, StyleRefinement, Styled, Subscription, Task,
|
||||||
StyleRefinement, Styled, Subscription, Task, UniformListScrollHandle, Window,
|
UniformListScrollHandle, Window, div, px, size, uniform_list,
|
||||||
};
|
};
|
||||||
use smol::Timer;
|
use smol::Timer;
|
||||||
use theme::ActiveTheme;
|
use theme::ActiveTheme;
|
||||||
|
|
||||||
use crate::actions::{Cancel, Confirm, SelectDown, SelectUp};
|
use crate::actions::{Cancel, Confirm, SelectDown, SelectUp};
|
||||||
use crate::input::{InputEvent, InputState, TextInput};
|
use crate::input::{InputEvent, InputState, TextInput};
|
||||||
use crate::list::cache::{MeasuredEntrySize, RowEntry, RowsCache};
|
|
||||||
use crate::list::ListDelegate;
|
use crate::list::ListDelegate;
|
||||||
|
use crate::list::cache::{MeasuredEntrySize, RowEntry, RowsCache};
|
||||||
use crate::scroll::{Scrollbar, ScrollbarHandle};
|
use crate::scroll::{Scrollbar, ScrollbarHandle};
|
||||||
use crate::{v_flex, Icon, IconName, IndexPath, Selectable, Sizable, Size, StyledExt};
|
use crate::{Icon, IconName, IndexPath, Selectable, Sizable, Size, StyledExt, v_flex};
|
||||||
|
|
||||||
pub(crate) fn init(cx: &mut App) {
|
pub(crate) fn init(cx: &mut App) {
|
||||||
let context: Option<&str> = Some("List");
|
let context: Option<&str> = Some("List");
|
||||||
@@ -578,10 +578,10 @@ where
|
|||||||
self.prepare_items_if_needed(window, cx);
|
self.prepare_items_if_needed(window, cx);
|
||||||
|
|
||||||
// Scroll to the selected item if it is set.
|
// Scroll to the selected item if it is set.
|
||||||
if let Some((ix, strategy)) = self.deferred_scroll_to_index.take() {
|
if let Some((ix, strategy)) = self.deferred_scroll_to_index.take()
|
||||||
if let Some(item_ix) = self.rows_cache.position_of(&ix) {
|
&& let Some(item_ix) = self.rows_cache.position_of(&ix)
|
||||||
self.scroll_handle.scroll_to_item(item_ix, strategy);
|
{
|
||||||
}
|
self.scroll_handle.scroll_to_item(item_ix, strategy);
|
||||||
}
|
}
|
||||||
|
|
||||||
let loading = self.delegate().loading(cx);
|
let loading = self.delegate().loading(cx);
|
||||||
|
|||||||
@@ -719,13 +719,13 @@ impl PopupMenu {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn active_submenu(&self) -> Option<Entity<PopupMenu>> {
|
pub(crate) fn active_submenu(&self) -> Option<Entity<PopupMenu>> {
|
||||||
if let Some(ix) = self.selected_index {
|
if let Some(ix) = self.selected_index
|
||||||
if let Some(item) = self.menu_items.get(ix) {
|
&& let Some(item) = self.menu_items.get(ix)
|
||||||
return match item {
|
{
|
||||||
PopupMenuItem::Submenu { menu, .. } => Some(menu.clone()),
|
return match item {
|
||||||
_ => None,
|
PopupMenuItem::Submenu { menu, .. } => Some(menu.clone()),
|
||||||
};
|
_ => None,
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
None
|
None
|
||||||
@@ -965,12 +965,11 @@ impl PopupMenu {
|
|||||||
cx: &mut Context<Self>,
|
cx: &mut Context<Self>,
|
||||||
) {
|
) {
|
||||||
// Do not dismiss, if click inside the parent menu
|
// Do not dismiss, if click inside the parent menu
|
||||||
if let Some(parent) = self.parent_menu.as_ref() {
|
if let Some(parent) = self.parent_menu.as_ref()
|
||||||
if let Some(parent) = parent.upgrade() {
|
&& let Some(parent) = parent.upgrade()
|
||||||
if parent.read(cx).bounds.contains(position) {
|
&& parent.read(cx).bounds.contains(position)
|
||||||
return;
|
{
|
||||||
}
|
return;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
self.dismiss(&Cancel, window, cx);
|
self.dismiss(&Cancel, window, cx);
|
||||||
|
|||||||
@@ -296,10 +296,10 @@ impl RenderOnce for Modal {
|
|||||||
let on_close = on_close.clone();
|
let on_close = on_close.clone();
|
||||||
|
|
||||||
move |_, window, cx| {
|
move |_, window, cx| {
|
||||||
if let Some(on_ok) = &on_ok {
|
if let Some(on_ok) = &on_ok
|
||||||
if !on_ok(&ClickEvent::default(), window, cx) {
|
&& !on_ok(&ClickEvent::default(), window, cx)
|
||||||
return;
|
{
|
||||||
}
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
on_close(&ClickEvent::default(), window, cx);
|
on_close(&ClickEvent::default(), window, cx);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
use std::ops::Range;
|
use std::ops::Range;
|
||||||
|
|
||||||
use gpui::{
|
use gpui::{
|
||||||
px, Along, App, Axis, Bounds, Context, ElementId, EventEmitter, IsZero, Pixels, Window,
|
Along, App, Axis, Bounds, Context, ElementId, EventEmitter, IsZero, Pixels, Window, px,
|
||||||
};
|
};
|
||||||
|
|
||||||
mod panel;
|
mod panel;
|
||||||
@@ -142,10 +142,10 @@ impl ResizableState {
|
|||||||
pub(crate) fn remove_panel(&mut self, panel_ix: usize, cx: &mut Context<Self>) {
|
pub(crate) fn remove_panel(&mut self, panel_ix: usize, cx: &mut Context<Self>) {
|
||||||
self.panels.remove(panel_ix);
|
self.panels.remove(panel_ix);
|
||||||
self.sizes.remove(panel_ix);
|
self.sizes.remove(panel_ix);
|
||||||
if let Some(resizing_panel_ix) = self.resizing_panel_ix {
|
if let Some(resizing_panel_ix) = self.resizing_panel_ix
|
||||||
if resizing_panel_ix > panel_ix {
|
&& resizing_panel_ix > panel_ix
|
||||||
self.resizing_panel_ix = Some(resizing_panel_ix - 1);
|
{
|
||||||
}
|
self.resizing_panel_ix = Some(resizing_panel_ix - 1);
|
||||||
}
|
}
|
||||||
self.adjust_to_container_size(cx);
|
self.adjust_to_container_size(cx);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ impl Root {
|
|||||||
pub fn render_notification_layer(
|
pub fn render_notification_layer(
|
||||||
window: &mut Window,
|
window: &mut Window,
|
||||||
cx: &mut App,
|
cx: &mut App,
|
||||||
) -> Option<impl IntoElement> {
|
) -> Option<impl IntoElement + use<>> {
|
||||||
let root = window.root::<Root>()??;
|
let root = window.root::<Root>()??;
|
||||||
|
|
||||||
Some(
|
Some(
|
||||||
@@ -105,7 +105,10 @@ impl Root {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Render the modal layer.
|
/// Render the modal layer.
|
||||||
pub fn render_modal_layer(window: &mut Window, cx: &mut App) -> Option<impl IntoElement> {
|
pub fn render_modal_layer(
|
||||||
|
window: &mut Window,
|
||||||
|
cx: &mut App,
|
||||||
|
) -> Option<impl IntoElement + use<>> {
|
||||||
let root = window.root::<Root>()??;
|
let root = window.root::<Root>()??;
|
||||||
let active_modals = root.read(cx).active_modals.clone();
|
let active_modals = root.read(cx).active_modals.clone();
|
||||||
|
|
||||||
@@ -139,10 +142,10 @@ impl Root {
|
|||||||
})
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
if let Some(ix) = show_overlay_ix {
|
if let Some(ix) = show_overlay_ix
|
||||||
if let Some(modal) = modals.get_mut(ix) {
|
&& let Some(modal) = modals.get_mut(ix)
|
||||||
modal.overlay_visible = true;
|
{
|
||||||
}
|
modal.overlay_visible = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Some(div().children(modals))
|
Some(div().children(modals))
|
||||||
|
|||||||
Reference in New Issue
Block a user