WIP
This commit is contained in:
parent
d3b02c4de4
commit
2a672e2126
4 changed files with 722 additions and 355 deletions
|
@ -72,7 +72,7 @@ use smallvec::SmallVec;
|
||||||
use std::{
|
use std::{
|
||||||
any::TypeId,
|
any::TypeId,
|
||||||
borrow::Cow,
|
borrow::Cow,
|
||||||
cmp::{self, Reverse},
|
cmp::{self, Ordering, Reverse},
|
||||||
ops::{ControlFlow, Deref, DerefMut, Range},
|
ops::{ControlFlow, Deref, DerefMut, Range},
|
||||||
path::Path,
|
path::Path,
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
|
@ -81,7 +81,7 @@ use std::{
|
||||||
pub use sum_tree::Bias;
|
pub use sum_tree::Bias;
|
||||||
use sum_tree::TreeMap;
|
use sum_tree::TreeMap;
|
||||||
use text::Rope;
|
use text::Rope;
|
||||||
use theme::ThemeColors;
|
use theme::{ActiveTheme, PlayerColor, ThemeColors};
|
||||||
use util::{post_inc, RangeExt, ResultExt, TryFutureExt};
|
use util::{post_inc, RangeExt, ResultExt, TryFutureExt};
|
||||||
use workspace::{ItemNavHistory, SplitDirection, ViewId, Workspace};
|
use workspace::{ItemNavHistory, SplitDirection, ViewId, Workspace};
|
||||||
|
|
||||||
|
@ -597,6 +597,7 @@ pub enum SoftWrap {
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct EditorStyle {
|
pub struct EditorStyle {
|
||||||
|
pub local_player: PlayerColor,
|
||||||
pub text: TextStyle,
|
pub text: TextStyle,
|
||||||
pub line_height_scalar: f32,
|
pub line_height_scalar: f32,
|
||||||
// pub placeholder_text: Option<TextStyle>,
|
// pub placeholder_text: Option<TextStyle>,
|
||||||
|
@ -8445,13 +8446,13 @@ impl Editor {
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// pub fn highlight_rows(&mut self, rows: Option<Range<u32>>) {
|
pub fn highlight_rows(&mut self, rows: Option<Range<u32>>) {
|
||||||
// self.highlighted_rows = rows;
|
self.highlighted_rows = rows;
|
||||||
// }
|
}
|
||||||
|
|
||||||
// pub fn highlighted_rows(&self) -> Option<Range<u32>> {
|
pub fn highlighted_rows(&self) -> Option<Range<u32>> {
|
||||||
// self.highlighted_rows.clone()
|
self.highlighted_rows.clone()
|
||||||
// }
|
}
|
||||||
|
|
||||||
pub fn highlight_background<T: 'static>(
|
pub fn highlight_background<T: 'static>(
|
||||||
&mut self,
|
&mut self,
|
||||||
|
@ -8540,43 +8541,43 @@ impl Editor {
|
||||||
// })
|
// })
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// pub fn background_highlights_in_range(
|
pub fn background_highlights_in_range(
|
||||||
// &self,
|
&self,
|
||||||
// search_range: Range<Anchor>,
|
search_range: Range<Anchor>,
|
||||||
// display_snapshot: &DisplaySnapshot,
|
display_snapshot: &DisplaySnapshot,
|
||||||
// theme: &Theme,
|
theme: &ThemeColors,
|
||||||
// ) -> Vec<(Range<DisplayPoint>, Color)> {
|
) -> Vec<(Range<DisplayPoint>, Hsla)> {
|
||||||
// let mut results = Vec::new();
|
let mut results = Vec::new();
|
||||||
// for (color_fetcher, ranges) in self.background_highlights.values() {
|
for (color_fetcher, ranges) in self.background_highlights.values() {
|
||||||
// let color = color_fetcher(theme);
|
let color = color_fetcher(theme);
|
||||||
// let start_ix = match ranges.binary_search_by(|probe| {
|
let start_ix = match ranges.binary_search_by(|probe| {
|
||||||
// let cmp = probe
|
let cmp = probe
|
||||||
// .end
|
.end
|
||||||
// .cmp(&search_range.start, &display_snapshot.buffer_snapshot);
|
.cmp(&search_range.start, &display_snapshot.buffer_snapshot);
|
||||||
// if cmp.is_gt() {
|
if cmp.is_gt() {
|
||||||
// Ordering::Greater
|
Ordering::Greater
|
||||||
// } else {
|
} else {
|
||||||
// Ordering::Less
|
Ordering::Less
|
||||||
// }
|
}
|
||||||
// }) {
|
}) {
|
||||||
// Ok(i) | Err(i) => i,
|
Ok(i) | Err(i) => i,
|
||||||
// };
|
};
|
||||||
// for range in &ranges[start_ix..] {
|
for range in &ranges[start_ix..] {
|
||||||
// if range
|
if range
|
||||||
// .start
|
.start
|
||||||
// .cmp(&search_range.end, &display_snapshot.buffer_snapshot)
|
.cmp(&search_range.end, &display_snapshot.buffer_snapshot)
|
||||||
// .is_ge()
|
.is_ge()
|
||||||
// {
|
{
|
||||||
// break;
|
break;
|
||||||
// }
|
}
|
||||||
|
|
||||||
// let start = range.start.to_display_point(&display_snapshot);
|
let start = range.start.to_display_point(&display_snapshot);
|
||||||
// let end = range.end.to_display_point(&display_snapshot);
|
let end = range.end.to_display_point(&display_snapshot);
|
||||||
// results.push((start..end, color))
|
results.push((start..end, color))
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// results
|
results
|
||||||
// }
|
}
|
||||||
|
|
||||||
// pub fn background_highlight_row_ranges<T: 'static>(
|
// pub fn background_highlight_row_ranges<T: 'static>(
|
||||||
// &self,
|
// &self,
|
||||||
|
@ -9326,6 +9327,7 @@ impl Render for Editor {
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
||||||
EditorElement::new(EditorStyle {
|
EditorElement::new(EditorStyle {
|
||||||
|
local_player: cx.theme().players().local(),
|
||||||
text: cx.text_style(),
|
text: cx.text_style(),
|
||||||
line_height_scalar: 1.,
|
line_height_scalar: 1.,
|
||||||
theme_id: 0,
|
theme_id: 0,
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -21,6 +21,22 @@ pub struct PlayerColor {
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct PlayerColors(pub Vec<PlayerColor>);
|
pub struct PlayerColors(pub Vec<PlayerColor>);
|
||||||
|
|
||||||
|
impl PlayerColors {
|
||||||
|
pub fn local(&self) -> PlayerColor {
|
||||||
|
*self.0.first().unwrap()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn absent(&self) -> PlayerColor {
|
||||||
|
todo!("use a valid color");
|
||||||
|
*self.0.last().unwrap()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn color_for_participant(&self, participant_index: u32) -> PlayerColor {
|
||||||
|
let len = self.0.len() - 1;
|
||||||
|
self.0[(participant_index as usize % len) + 1]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Refineable, Clone, Debug)]
|
#[derive(Refineable, Clone, Debug)]
|
||||||
#[refineable(debug)]
|
#[refineable(debug)]
|
||||||
pub struct StatusColors {
|
pub struct StatusColors {
|
||||||
|
@ -89,6 +105,8 @@ pub struct ThemeColors {
|
||||||
pub editor: Hsla,
|
pub editor: Hsla,
|
||||||
pub editor_subheader: Hsla,
|
pub editor_subheader: Hsla,
|
||||||
pub editor_active_line: Hsla,
|
pub editor_active_line: Hsla,
|
||||||
|
pub editor_line_number: Hsla,
|
||||||
|
pub editor_active_line_number: Hsla,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Refineable, Clone)]
|
#[derive(Refineable, Clone)]
|
||||||
|
|
|
@ -58,6 +58,12 @@ pub struct ThemeVariant {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ThemeVariant {
|
impl ThemeVariant {
|
||||||
|
/// Returns the [`ThemeColors`] for the theme.
|
||||||
|
#[inline(always)]
|
||||||
|
pub fn players(&self) -> &PlayerColors {
|
||||||
|
&self.styles.player
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns the [`ThemeColors`] for the theme.
|
/// Returns the [`ThemeColors`] for the theme.
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn colors(&self) -> &ThemeColors {
|
pub fn colors(&self) -> &ThemeColors {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue