@@ -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<MultiBuffer>, cx: &mut ViewContext<Self>) {
@@ -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 {
@@ -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) {
@@ -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]