diff --git a/crates/gpui3/src/elements/text.rs b/crates/gpui3/src/elements/text.rs index 7d07331bca..6530a3c423 100644 --- a/crates/gpui3/src/elements/text.rs +++ b/crates/gpui3/src/elements/text.rs @@ -93,11 +93,11 @@ impl Element for Text { line_height = paint_state.line_height; } - let text_style = cx.text_style(); + let _text_style = cx.text_style(); // todo!("We haven't added visible bounds to the new element system yet, so this is a placeholder."); let visible_bounds = bounds; - line.paint(bounds.origin, visible_bounds, line_height, cx); + line.paint(bounds.origin, visible_bounds, line_height, cx)?; Ok(()) } diff --git a/crates/gpui3/src/platform/mac.rs b/crates/gpui3/src/platform/mac.rs index 89b2b420fd..8ad9385c11 100644 --- a/crates/gpui3/src/platform/mac.rs +++ b/crates/gpui3/src/platform/mac.rs @@ -134,6 +134,8 @@ impl NSRectExt for NSRect { } } +// todo! +#[allow(unused)] unsafe fn ns_url_to_path(url: id) -> crate::Result { let path: *mut c_char = msg_send![url, fileSystemRepresentation]; if path.is_null() { diff --git a/crates/gpui3/src/platform/mac/events.rs b/crates/gpui3/src/platform/mac/events.rs index 55853c10a4..700f876a20 100644 --- a/crates/gpui3/src/platform/mac/events.rs +++ b/crates/gpui3/src/platform/mac/events.rs @@ -34,6 +34,8 @@ unsafe fn build_event_source() { mem::forget(source); } +// todo! +#[allow(unused)] pub fn key_to_native(key: &str) -> Cow { use cocoa::appkit::*; let code = match key { diff --git a/crates/gpui3/src/platform/mac/text_system.rs b/crates/gpui3/src/platform/mac/text_system.rs index 8a468b170b..7904e40e64 100644 --- a/crates/gpui3/src/platform/mac/text_system.rs +++ b/crates/gpui3/src/platform/mac/text_system.rs @@ -40,14 +40,13 @@ use super::open_type; #[allow(non_upper_case_globals)] const kCGImageAlphaOnly: u32 = 7; -pub struct MacTextSystem(RwLock); +pub struct MacTextSystem(RwLock); -struct TextSystemState { +struct MacTextSystemState { memory_source: MemSource, system_source: SystemSource, fonts: Vec, font_selections: HashMap, - font_metrics: HashMap, font_ids_by_postscript_name: HashMap, font_ids_by_family_name: HashMap>, postscript_names_by_font_id: HashMap, @@ -55,12 +54,11 @@ struct TextSystemState { impl MacTextSystem { pub fn new() -> Self { - Self(RwLock::new(TextSystemState { + Self(RwLock::new(MacTextSystemState { memory_source: MemSource::empty(), system_source: SystemSource::new(), fonts: Vec::new(), font_selections: HashMap::default(), - font_metrics: HashMap::default(), font_ids_by_postscript_name: HashMap::default(), font_ids_by_family_name: HashMap::default(), postscript_names_by_font_id: HashMap::default(), @@ -173,7 +171,7 @@ impl PlatformTextSystem for MacTextSystem { } } -impl TextSystemState { +impl MacTextSystemState { fn add_fonts(&mut self, fonts: &[Arc>]) -> Result<()> { self.memory_source.add_fonts( fonts diff --git a/crates/gpui3/src/text_system/text_layout_cache.rs b/crates/gpui3/src/text_system/text_layout_cache.rs index 6956b5a53d..455e8bf741 100644 --- a/crates/gpui3/src/text_system/text_layout_cache.rs +++ b/crates/gpui3/src/text_system/text_layout_cache.rs @@ -247,13 +247,14 @@ impl Line { } } + // todo! pub fn paint( &self, origin: Point, visible_bounds: Bounds, line_height: Pixels, cx: &mut WindowContext, - ) { + ) -> Result<()> { let padding_top = (line_height - self.layout.ascent - self.layout.descent) / 2.; let baseline_offset = point(px(0.), padding_top + self.layout.ascent); @@ -264,11 +265,7 @@ impl Line { for run in &self.layout.runs { cx.text_system().with_font(run.font_id, |system, font| { - let max_glyph_width = cx - .text_system() - .bounding_box(font, self.layout.font_size)? - .size - .width; + let max_glyph_width = system.bounding_box(font, self.layout.font_size)?.size.width; for glyph in &run.glyphs { let glyph_origin = origin + baseline_offset + glyph.position; @@ -322,7 +319,6 @@ impl Line { // }); } - // todo!() // if glyph.is_emoji { // cx.scene().push_image_glyph(scene::ImageGlyph { // font_id: run.font_id, @@ -342,7 +338,7 @@ impl Line { } anyhow::Ok(()) - }); + })??; } if let Some((_underline_start, _underline_style)) = underline.take() { @@ -355,6 +351,8 @@ impl Line { // squiggly: underline_style.squiggly, // }); } + + Ok(()) } pub fn paint_wrapped( @@ -371,7 +369,7 @@ impl Line { let mut boundaries = boundaries.into_iter().peekable(); let mut color_runs = self.style_runs.iter(); let mut style_run_end = 0; - let mut color = black(); + let mut _color = black(); // todo! let mut underline: Option<(Point, UnderlineStyle)> = None; let mut glyph_origin = origin; @@ -403,7 +401,7 @@ impl Line { if glyph.index >= style_run_end { if let Some(style_run) = color_runs.next() { style_run_end += style_run.len as usize; - color = style_run.color; + _color = style_run.color; if let Some((_, underline_style)) = &mut underline { if style_run.underline != *underline_style { finished_underline = underline.take(); @@ -427,7 +425,7 @@ impl Line { } } else { style_run_end = self.layout.len; - color = black(); + _color = black(); finished_underline = underline.take(); } } @@ -447,7 +445,6 @@ impl Line { origin: glyph_origin, size: system.bounding_box(font, self.layout.font_size)?.size, }; - // todo!() // if glyph_bounds.intersects(visible_bounds) { // if glyph.is_emoji { // cx.scene().push_image_glyph(scene::ImageGlyph { @@ -467,7 +464,7 @@ impl Line { // } // } anyhow::Ok(()) - })?; + })??; } }