diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 1a0ccba03ce97a9a1943d08aeb788f2978134c07..e3b0e9874bfdc1cadab7abc3f928d997ed46fab3 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -8605,7 +8605,8 @@ impl Editor { } pub fn show_local_cursors(&self, cx: &WindowContext) -> bool { - self.blink_manager.read(cx).visible() && self.focus_handle.is_focused(cx) + (self.read_only(cx) || self.blink_manager.read(cx).visible()) + && self.focus_handle.is_focused(cx) } fn on_buffer_changed(&mut self, _: Model, cx: &mut ViewContext) { diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs index 2b5c97bac5b1e067db5ff1640752c0bc8a9a489d..368fc4b7ca8f88a26cb1840728c917404c0ef521 100644 --- a/crates/editor/src/element.rs +++ b/crates/editor/src/element.rs @@ -1901,7 +1901,13 @@ impl EditorElement { layouts.push(layout); } - selections.push((style.local_player, layouts)); + let player = if editor.read_only(cx) { + cx.theme().players().read_only() + } else { + style.local_player + }; + + selections.push((player, layouts)); } if let Some(collaboration_hub) = &editor.collaboration_hub { diff --git a/crates/gpui/src/color.rs b/crates/gpui/src/color.rs index df16d2c0b5664f7354cbde90e088be3cf1aee589..dc0f5055e70a123b99a7cc8b746ee69bd23652a3 100644 --- a/crates/gpui/src/color.rs +++ b/crates/gpui/src/color.rs @@ -339,6 +339,15 @@ impl Hsla { } } + pub fn grayscale(&self) -> Self { + Hsla { + h: self.h, + s: 0., + l: self.l, + a: self.a, + } + } + /// Fade out the color by a given factor. This factor should be between 0.0 and 1.0. /// Where 0.0 will leave the color unchanged, and 1.0 will completely fade out the color. pub fn fade_out(&mut self, factor: f32) { diff --git a/crates/theme/src/styles/players.rs b/crates/theme/src/styles/players.rs index 9f9b837e47b8c7e2ccf8b0d870214c382bb9cf28..089de247230341bf89fd40da38a13091e7024368 100644 --- a/crates/theme/src/styles/players.rs +++ b/crates/theme/src/styles/players.rs @@ -1,7 +1,7 @@ -use gpui::Hsla; +use gpui::{hsla, Hsla}; use serde_derive::Deserialize; -use crate::{amber, blue, jade, lime, orange, pink, purple, red}; +use crate::{amber, blue, gray, jade, lime, orange, pink, purple, red}; #[derive(Debug, Clone, Copy, Deserialize, Default)] pub struct PlayerColor { @@ -131,6 +131,15 @@ impl PlayerColors { *self.0.last().unwrap() } + pub fn read_only(&self) -> PlayerColor { + let local = self.local(); + PlayerColor { + cursor: local.cursor.grayscale(), + background: local.background.grayscale(), + selection: local.selection.grayscale(), + } + } + pub fn color_for_participant(&self, participant_index: u32) -> PlayerColor { let len = self.0.len() - 1; self.0[(participant_index as usize % len) + 1]