From fe839197464361b5aefa168df849c572e4deb56a Mon Sep 17 00:00:00 2001 From: Mikayla Date: Fri, 1 Dec 2023 17:01:57 -0800 Subject: [PATCH] Get terminal turning on --- crates/client/src/telemetry.rs | 1 - crates/terminal2/src/mappings/colors.rs | 125 ------- crates/terminal2/src/terminal2.rs | 1 + crates/terminal_view2/src/terminal_element.rs | 318 ++++++++++++------ crates/terminal_view2/src/terminal_view.rs | 19 +- 5 files changed, 223 insertions(+), 241 deletions(-) diff --git a/crates/client/src/telemetry.rs b/crates/client/src/telemetry.rs index e2fc8ad3adeebe36b62962a20fa98d027e9ebe0b..a3e7449cf8a4be5a25b4f7eaaa4f3d2379d70d68 100644 --- a/crates/client/src/telemetry.rs +++ b/crates/client/src/telemetry.rs @@ -350,7 +350,6 @@ impl Telemetry { milliseconds_since_first_event: self.milliseconds_since_first_event(), }; - dbg!(telemetry_settings); self.report_clickhouse_event(event, telemetry_settings, true) } diff --git a/crates/terminal2/src/mappings/colors.rs b/crates/terminal2/src/mappings/colors.rs index d3c8443cbf962c68dc3dd124aff2495d0a88ddc0..adcc0d8080c9754c327ce80e4d3f56b1c6405b54 100644 --- a/crates/terminal2/src/mappings/colors.rs +++ b/crates/terminal2/src/mappings/colors.rs @@ -1,118 +1,5 @@ -// todo!() use alacritty_terminal::term::color::Rgb as AlacRgb; -// use gpui::color::Color; -// use theme2::TerminalStyle; -///Converts a 2, 8, or 24 bit color ANSI color to the GPUI equivalent -// pub fn convert_color(alac_color: &AnsiColor, style: &TerminalStyle) -> Color { -// match alac_color { -// //Named and theme defined colors -// alacritty_terminal::ansi::Color::Named(n) => match n { -// alacritty_terminal::ansi::NamedColor::Black => style.black, -// alacritty_terminal::ansi::NamedColor::Red => style.red, -// alacritty_terminal::ansi::NamedColor::Green => style.green, -// alacritty_terminal::ansi::NamedColor::Yellow => style.yellow, -// alacritty_terminal::ansi::NamedColor::Blue => style.blue, -// alacritty_terminal::ansi::NamedColor::Magenta => style.magenta, -// alacritty_terminal::ansi::NamedColor::Cyan => style.cyan, -// alacritty_terminal::ansi::NamedColor::White => style.white, -// alacritty_terminal::ansi::NamedColor::BrightBlack => style.bright_black, -// alacritty_terminal::ansi::NamedColor::BrightRed => style.bright_red, -// alacritty_terminal::ansi::NamedColor::BrightGreen => style.bright_green, -// alacritty_terminal::ansi::NamedColor::BrightYellow => style.bright_yellow, -// alacritty_terminal::ansi::NamedColor::BrightBlue => style.bright_blue, -// alacritty_terminal::ansi::NamedColor::BrightMagenta => style.bright_magenta, -// alacritty_terminal::ansi::NamedColor::BrightCyan => style.bright_cyan, -// alacritty_terminal::ansi::NamedColor::BrightWhite => style.bright_white, -// alacritty_terminal::ansi::NamedColor::Foreground => style.foreground, -// alacritty_terminal::ansi::NamedColor::Background => style.background, -// alacritty_terminal::ansi::NamedColor::Cursor => style.cursor, -// alacritty_terminal::ansi::NamedColor::DimBlack => style.dim_black, -// alacritty_terminal::ansi::NamedColor::DimRed => style.dim_red, -// alacritty_terminal::ansi::NamedColor::DimGreen => style.dim_green, -// alacritty_terminal::ansi::NamedColor::DimYellow => style.dim_yellow, -// alacritty_terminal::ansi::NamedColor::DimBlue => style.dim_blue, -// alacritty_terminal::ansi::NamedColor::DimMagenta => style.dim_magenta, -// alacritty_terminal::ansi::NamedColor::DimCyan => style.dim_cyan, -// alacritty_terminal::ansi::NamedColor::DimWhite => style.dim_white, -// alacritty_terminal::ansi::NamedColor::BrightForeground => style.bright_foreground, -// alacritty_terminal::ansi::NamedColor::DimForeground => style.dim_foreground, -// }, -// //'True' colors -// alacritty_terminal::ansi::Color::Spec(rgb) => Color::new(rgb.r, rgb.g, rgb.b, u8::MAX), -// //8 bit, indexed colors -// alacritty_terminal::ansi::Color::Indexed(i) => get_color_at_index(&(*i as usize), style), -// } -// } - -/// TODO: Move this -///Converts an 8 bit ANSI color to it's GPUI equivalent. -///Accepts usize for compatibility with the alacritty::Colors interface, -///Other than that use case, should only be called with values in the [0,255] range -// pub fn get_color_at_index(index: &usize, style: &TerminalStyle) -> Color { -// match index { -// //0-15 are the same as the named colors above -// 0 => style.black, -// 1 => style.red, -// 2 => style.green, -// 3 => style.yellow, -// 4 => style.blue, -// 5 => style.magenta, -// 6 => style.cyan, -// 7 => style.white, -// 8 => style.bright_black, -// 9 => style.bright_red, -// 10 => style.bright_green, -// 11 => style.bright_yellow, -// 12 => style.bright_blue, -// 13 => style.bright_magenta, -// 14 => style.bright_cyan, -// 15 => style.bright_white, -// //16-231 are mapped to their RGB colors on a 0-5 range per channel -// 16..=231 => { -// let (r, g, b) = rgb_for_index(&(*index as u8)); //Split the index into it's ANSI-RGB components -// let step = (u8::MAX as f32 / 5.).floor() as u8; //Split the RGB range into 5 chunks, with floor so no overflow -// Color::new(r * step, g * step, b * step, u8::MAX) //Map the ANSI-RGB components to an RGB color -// } -// //232-255 are a 24 step grayscale from black to white -// 232..=255 => { -// let i = *index as u8 - 232; //Align index to 0..24 -// let step = (u8::MAX as f32 / 24.).floor() as u8; //Split the RGB grayscale values into 24 chunks -// Color::new(i * step, i * step, i * step, u8::MAX) //Map the ANSI-grayscale components to the RGB-grayscale -// } -// //For compatibility with the alacritty::Colors interface -// 256 => style.foreground, -// 257 => style.background, -// 258 => style.cursor, -// 259 => style.dim_black, -// 260 => style.dim_red, -// 261 => style.dim_green, -// 262 => style.dim_yellow, -// 263 => style.dim_blue, -// 264 => style.dim_magenta, -// 265 => style.dim_cyan, -// 266 => style.dim_white, -// 267 => style.bright_foreground, -// 268 => style.black, //'Dim Background', non-standard color -// _ => Color::new(0, 0, 0, 255), -// } -// } -///Generates the rgb channels in [0, 5] for a given index into the 6x6x6 ANSI color cube -///See: [8 bit ansi color](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit). -/// -///Wikipedia gives a formula for calculating the index for a given color: -/// -///index = 16 + 36 × r + 6 × g + b (0 ≤ r, g, b ≤ 5) -/// -///This function does the reverse, calculating the r, g, and b components from a given index. -// fn rgb_for_index(i: &u8) -> (u8, u8, u8) { -// debug_assert!((&16..=&231).contains(&i)); -// let i = i - 16; -// let r = (i - (i % 36)) / 36; -// let g = ((i % 36) - (i % 6)) / 6; -// let b = (i % 36) % 6; -// (r, g, b) -// } use gpui::Rgba; //Convenience method to convert from a GPUI color to an alacritty Rgb @@ -123,15 +10,3 @@ pub fn to_alac_rgb(color: impl Into) -> AlacRgb { let b = ((color.b * color.a) * 255.) as u8; AlacRgb::new(r, g, b) } - -// #[cfg(test)] -// mod tests { -// #[test] -// fn test_rgb_for_index() { -// //Test every possible value in the color cube -// for i in 16..=231 { -// let (r, g, b) = crate::mappings::colors::rgb_for_index(&(i as u8)); -// assert_eq!(i, 16 + 36 * r + 6 * g + b); -// } -// } -// } diff --git a/crates/terminal2/src/terminal2.rs b/crates/terminal2/src/terminal2.rs index 9f94339504b7c7b1705161bf9ea876021ec49028..761bee26b2882e4089ad3730b14ed9de256f0c87 100644 --- a/crates/terminal2/src/terminal2.rs +++ b/crates/terminal2/src/terminal2.rs @@ -976,6 +976,7 @@ impl Terminal { } pub fn try_sync(&mut self, cx: &mut ModelContext) { + println!("trying to sync"); let term = self.term.clone(); let mut terminal = if let Some(term) = term.try_lock_unfair() { diff --git a/crates/terminal_view2/src/terminal_element.rs b/crates/terminal_view2/src/terminal_element.rs index c2be4f62afcd3ff6463b5b998ba4c8f4c3dcdab0..7b7c2a304140ed2d3e91325e7bb8550281157cd7 100644 --- a/crates/terminal_view2/src/terminal_element.rs +++ b/crates/terminal_view2/src/terminal_element.rs @@ -1,18 +1,17 @@ use editor::{Cursor, HighlightedRange, HighlightedRangeLine}; use gpui::{ - point, px, relative, rems, transparent_black, AnyElement, AppContext, Bounds, Component, - CursorStyle, Element, ElementId, FontStyle, FontWeight, HighlightStyle, Hsla, IntoElement, - IsZero, LayoutId, ModelContext, Overlay, Pixels, Point, Quad, ShapedLine, SharedString, Style, - Styled, TextRun, TextStyle, TextSystem, Underline, UnderlineStyle, ViewContext, WeakModel, + black, point, px, red, relative, transparent_black, AnyElement, Bounds, Element, ElementId, + Font, FontStyle, FontWeight, HighlightStyle, Hsla, IntoElement, LayoutId, Pixels, Point, Rgba, + ShapedLine, Style, TextRun, TextStyle, TextSystem, UnderlineStyle, ViewContext, WeakModel, WhiteSpace, WindowContext, }; use itertools::Itertools; use language::CursorShape; -use ordered_float::OrderedFloat; use settings::Settings; use terminal::{ + alacritty_terminal::ansi::NamedColor, alacritty_terminal::{ - ansi::{Color as AnsiColor, Color::Named, CursorShape as AlacCursorShape, NamedColor}, + ansi::{Color as AnsiColor, Color::Named, CursorShape as AlacCursorShape}, grid::Dimensions, index::Point as AlacPoint, term::{cell::Flags, TermMode}, @@ -20,7 +19,7 @@ use terminal::{ terminal_settings::TerminalSettings, IndexedCell, Terminal, TerminalContent, TerminalSize, }; -use theme::{ActiveTheme, ThemeColors, ThemeSettings}; +use theme::{ActiveTheme, Theme, ThemeSettings}; use std::mem; use std::{fmt::Debug, ops::RangeInclusive}; @@ -80,7 +79,6 @@ impl LayoutCell { origin: Point, layout: &LayoutState, _visible_bounds: Bounds, - _view: &mut TerminalView, cx: &mut WindowContext, ) { let pos = { @@ -92,7 +90,7 @@ impl LayoutCell { ) }; - self.text.paint(pos, layout.size.line_height, cx); + self.text.paint(pos, layout.size.line_height, cx).ok(); } } @@ -120,13 +118,7 @@ impl LayoutRect { } } - fn paint( - &self, - origin: Point, - layout: &LayoutState, - _view: &mut TerminalView, - cx: &mut ViewContext, - ) { + fn paint(&self, origin: Point, layout: &LayoutState, cx: &mut WindowContext) { let position = { let alac_point = self.point; point( @@ -184,7 +176,7 @@ impl TerminalElement { hyperlink: Option<(HighlightStyle, &RangeInclusive)>, cx: &WindowContext<'_>, ) -> (Vec, Vec) { - let theme_colors = cx.theme().colors(); + let theme = cx.theme(); let mut cells = vec![]; let mut rects = vec![]; @@ -225,7 +217,7 @@ impl TerminalElement { cell.point.column.0 as i32, ), 1, - convert_color(&bg, theme_colors), + convert_color(&bg, theme), )); } } @@ -234,7 +226,7 @@ impl TerminalElement { cur_rect = Some(LayoutRect::new( AlacPoint::new(line_index as i32, cell.point.column.0 as i32), 1, - convert_color(&bg, &theme_colors), + convert_color(&bg, &theme), )); } } @@ -249,7 +241,7 @@ impl TerminalElement { &cell, fg, bg, - theme_colors, + theme, text_style, text_system, hyperlink, @@ -312,7 +304,7 @@ impl TerminalElement { indexed: &IndexedCell, fg: terminal::alacritty_terminal::ansi::Color, bg: terminal::alacritty_terminal::ansi::Color, - colors: &ThemeColors, + colors: &Theme, text_style: &TextStyle, text_system: &TextSystem, hyperlink: Option<(HighlightStyle, &RangeInclusive)>, @@ -321,7 +313,7 @@ impl TerminalElement { let fg = convert_color(&fg, &colors); let bg = convert_color(&bg, &colors); - let mut underline = (flags.intersects(Flags::ALL_UNDERLINES) + let underline = (flags.intersects(Flags::ALL_UNDERLINES) || indexed.cell.hyperlink().is_some()) .then(|| UnderlineStyle { color: Some(fg), @@ -329,20 +321,27 @@ impl TerminalElement { wavy: flags.contains(Flags::UNDERCURL), }); - //todo!(support bold and italic) - // let mut properties = Properties::new(); - // if indexed.flags.intersects(Flags::BOLD | Flags::DIM_BOLD) { - // properties = *properties.weight(FontWeight::BOLD); - // } - // if indexed.flags.intersects(Flags::ITALIC) { - // properties = *properties.style(FontStyle::Italic); - // } + let weight = if flags.intersects(Flags::BOLD | Flags::DIM_BOLD) { + FontWeight::BOLD + } else { + FontWeight::NORMAL + }; + + let style = if flags.intersects(Flags::ITALIC) { + FontStyle::Italic + } else { + FontStyle::Normal + }; let mut result = TextRun { len: indexed.c.len_utf8() as usize, color: fg, background_color: Some(bg), - font: text_style.font(), + font: Font { + weight, + style, + ..text_style.font() + }, underline, }; @@ -498,7 +497,6 @@ impl TerminalElement { let (cells, rects) = TerminalElement::layout_grid( cells, &text_style, - // &terminal_theme, &cx.text_system(), // todo!(Terminal tooltips) last_hovered_word, @@ -752,84 +750,54 @@ impl Element for TerminalElement { fn paint(self, bounds: Bounds, _: &mut Self::State, cx: &mut WindowContext<'_>) { let layout = self.compute_layout(bounds, cx); - // todo!() - // let visible_bounds = bounds.intersection(visible_bounds).unwrap_or_default(); - - // //Setup element stuff - // let clip_bounds = Some(visible_bounds); - - // cx.paint_layer(clip_bounds, |cx| { - // let origin = bounds.origin + point(element_state.gutter, 0.); - // // Elements are ephemeral, only at paint time do we know what could be clicked by a mouse - // self.attach_mouse_handlers(origin, visible_bounds, element_state.mode, cx); - - // cx.scene().push_cursor_region(gpui::CursorRegion { - // bounds, - // style: if element_state.hyperlink_tooltip.is_some() { - // CursorStyle::AlacPointingHand - // } else { - // CursorStyle::IBeam - // }, - // }); + let theme = cx.theme(); + cx.paint_quad( + bounds, + Default::default(), + theme.colors().editor_background, + Default::default(), + Hsla::default(), + ); + let origin = bounds.origin + Point::new(layout.gutter, px(0.)); - // cx.paint_layer(clip_bounds, |cx| { - // //Start with a background color - // cx.scene().push_quad(Quad { - // bounds, - // background: Some(element_state.background_color), - // border: Default::default(), - // corner_radii: Default::default(), - // }); - - // for rect in &element_state.rects { - // rect.paint(origin, element_state, view_state, cx); - // } - // }); + for rect in &layout.rects { + rect.paint(origin, &layout, cx); + } - // //Draw Highlighted Backgrounds - // cx.paint_layer(clip_bounds, |cx| { - // for (relative_highlighted_range, color) in - // element_state.relative_highlighted_ranges.iter() - // { - // if let Some((start_y, highlighted_range_lines)) = to_highlighted_range_lines( - // relative_highlighted_range, - // element_state, - // origin, - // ) { - // let hr = HighlightedRange { - // start_y, //Need to change this - // line_height: element_state.size.line_height, - // lines: highlighted_range_lines, - // color: color.clone(), - // //Copied from editor. TODO: move to theme or something - // corner_radius: 0.15 * element_state.size.line_height, - // }; - // hr.paint(bounds, cx); - // } - // } - // }); + cx.with_z_index(1, |cx| { + for (relative_highlighted_range, color) in layout.relative_highlighted_ranges.iter() { + if let Some((start_y, highlighted_range_lines)) = + to_highlighted_range_lines(relative_highlighted_range, &layout, origin) + { + let hr = HighlightedRange { + start_y, //Need to change this + line_height: layout.size.line_height, + lines: highlighted_range_lines, + color: color.clone(), + //Copied from editor. TODO: move to theme or something + corner_radius: 0.15 * layout.size.line_height, + }; + hr.paint(bounds, cx); + } + } + }); - // //Draw the text cells - // cx.paint_layer(clip_bounds, |cx| { - // for cell in &element_state.cells { - // cell.paint(origin, element_state, visible_bounds, view_state, cx); - // } - // }); + cx.with_z_index(2, |cx| { + for cell in &layout.cells { + cell.paint(origin, &layout, bounds, cx); + } + }); - // //Draw cursor - // if self.cursor_visible { - // if let Some(cursor) = &element_state.cursor { - // cx.paint_layer(clip_bounds, |cx| { - // cursor.paint(origin, cx); - // }) - // } - // } + cx.with_z_index(3, |cx| { + if let Some(cursor) = &layout.cursor { + cursor.paint(origin, cx); + } + }); // if let Some(element) = &mut element_state.hyperlink_tooltip { // element.paint(origin, visible_bounds, view_state, cx) // } - // }); } // todo!() remove? @@ -877,7 +845,7 @@ impl IntoElement for TerminalElement { type Element = Self; fn element_id(&self) -> Option { - todo!() + Some("terminal".into()) } fn into_element(self) -> Self::Element { @@ -971,7 +939,147 @@ fn to_highlighted_range_lines( Some((start_y, highlighted_range_lines)) } -// mappings::colors::convert_color -fn convert_color(fg: &terminal::alacritty_terminal::ansi::Color, colors: &ThemeColors) -> Hsla { - todo!() +///Converts a 2, 8, or 24 bit color ANSI color to the GPUI equivalent +fn convert_color(fg: &terminal::alacritty_terminal::ansi::Color, theme: &Theme) -> Hsla { + let colors = theme.colors(); + match fg { + //Named and theme defined colors + terminal::alacritty_terminal::ansi::Color::Named(n) => match n { + NamedColor::Black => colors.terminal_ansi_black, + NamedColor::Red => colors.terminal_ansi_red, + NamedColor::Green => colors.terminal_ansi_green, + NamedColor::Yellow => colors.terminal_ansi_yellow, + NamedColor::Blue => colors.terminal_ansi_blue, + NamedColor::Magenta => colors.terminal_ansi_magenta, + NamedColor::Cyan => colors.terminal_ansi_cyan, + NamedColor::White => colors.terminal_ansi_white, + NamedColor::BrightBlack => colors.terminal_ansi_bright_black, + NamedColor::BrightRed => colors.terminal_ansi_bright_red, + NamedColor::BrightGreen => colors.terminal_ansi_bright_green, + NamedColor::BrightYellow => colors.terminal_ansi_bright_yellow, + NamedColor::BrightBlue => colors.terminal_ansi_bright_blue, + NamedColor::BrightMagenta => colors.terminal_ansi_bright_magenta, + NamedColor::BrightCyan => colors.terminal_ansi_bright_cyan, + NamedColor::BrightWhite => colors.terminal_ansi_bright_white, + NamedColor::Foreground => colors.text, + NamedColor::Background => colors.background, + NamedColor::Cursor => theme.players().local().cursor, + + // todo!(more colors) + NamedColor::DimBlack => red(), + NamedColor::DimRed => red(), + NamedColor::DimGreen => red(), + NamedColor::DimYellow => red(), + NamedColor::DimBlue => red(), + NamedColor::DimMagenta => red(), + NamedColor::DimCyan => red(), + NamedColor::DimWhite => red(), + NamedColor::BrightForeground => red(), + NamedColor::DimForeground => red(), + }, + //'True' colors + terminal::alacritty_terminal::ansi::Color::Spec(rgb) => rgba_color(rgb.r, rgb.g, rgb.b), + //8 bit, indexed colors + terminal::alacritty_terminal::ansi::Color::Indexed(i) => { + get_color_at_index(&(*i as usize), theme) + } + } +} + +///Converts an 8 bit ANSI color to it's GPUI equivalent. +///Accepts usize for compatibility with the alacritty::Colors interface, +///Other than that use case, should only be called with values in the [0,255] range +pub fn get_color_at_index(index: &usize, theme: &Theme) -> Hsla { + let colors = theme.colors(); + + match index { + //0-15 are the same as the named colors above + 0 => colors.terminal_ansi_black, + 1 => colors.terminal_ansi_red, + 2 => colors.terminal_ansi_green, + 3 => colors.terminal_ansi_yellow, + 4 => colors.terminal_ansi_blue, + 5 => colors.terminal_ansi_magenta, + 6 => colors.terminal_ansi_cyan, + 7 => colors.terminal_ansi_white, + 8 => colors.terminal_ansi_bright_black, + 9 => colors.terminal_ansi_bright_red, + 10 => colors.terminal_ansi_bright_green, + 11 => colors.terminal_ansi_bright_yellow, + 12 => colors.terminal_ansi_bright_blue, + 13 => colors.terminal_ansi_bright_magenta, + 14 => colors.terminal_ansi_bright_cyan, + 15 => colors.terminal_ansi_bright_white, + //16-231 are mapped to their RGB colors on a 0-5 range per channel + 16..=231 => { + let (r, g, b) = rgb_for_index(&(*index as u8)); //Split the index into it's ANSI-RGB components + let step = (u8::MAX as f32 / 5.).floor() as u8; //Split the RGB range into 5 chunks, with floor so no overflow + rgba_color(r * step, g * step, b * step) //Map the ANSI-RGB components to an RGB color + } + //232-255 are a 24 step grayscale from black to white + 232..=255 => { + let i = *index as u8 - 232; //Align index to 0..24 + let step = (u8::MAX as f32 / 24.).floor() as u8; //Split the RGB grayscale values into 24 chunks + rgba_color(i * step, i * step, i * step) //Map the ANSI-grayscale components to the RGB-grayscale + } + //For compatibility with the alacritty::Colors interface + 256 => colors.text, + 257 => colors.background, + 258 => theme.players().local().cursor, + + // todo!(more colors) + 259 => red(), //style.dim_black, + 260 => red(), //style.dim_red, + 261 => red(), //style.dim_green, + 262 => red(), //style.dim_yellow, + 263 => red(), //style.dim_blue, + 264 => red(), //style.dim_magenta, + 265 => red(), //style.dim_cyan, + 266 => red(), //style.dim_white, + 267 => red(), //style.bright_foreground, + 268 => colors.terminal_ansi_black, //'Dim Background', non-standard color + + _ => black(), + } +} + +///Generates the rgb channels in [0, 5] for a given index into the 6x6x6 ANSI color cube +///See: [8 bit ansi color](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit). +/// +///Wikipedia gives a formula for calculating the index for a given color: +/// +///index = 16 + 36 × r + 6 × g + b (0 ≤ r, g, b ≤ 5) +/// +///This function does the reverse, calculating the r, g, and b components from a given index. +fn rgb_for_index(i: &u8) -> (u8, u8, u8) { + debug_assert!((&16..=&231).contains(&i)); + let i = i - 16; + let r = (i - (i % 36)) / 36; + let g = ((i % 36) - (i % 6)) / 6; + let b = (i % 36) % 6; + (r, g, b) +} + +fn rgba_color(r: u8, g: u8, b: u8) -> Hsla { + Rgba { + r: (r as f32 / 255.) as f32, + g: (g as f32 / 255.) as f32, + b: (b as f32 / 255.) as f32, + a: 1., + } + .into() +} + +#[cfg(test)] +mod tests { + use crate::terminal_element::rgb_for_index; + + #[test] + fn test_rgb_for_index() { + //Test every possible value in the color cube + for i in 16..=231 { + let (r, g, b) = rgb_for_index(&(i as u8)); + assert_eq!(i, 16 + 36 * r + 6 * g + b); + } + } } diff --git a/crates/terminal_view2/src/terminal_view.rs b/crates/terminal_view2/src/terminal_view.rs index b007d58c34bcb2163f42bd2b88e1979a18152f56..62306a8644267dc3528068b45f977f4f922b2af2 100644 --- a/crates/terminal_view2/src/terminal_view.rs +++ b/crates/terminal_view2/src/terminal_view.rs @@ -25,6 +25,7 @@ use terminal::{ terminal_settings::{TerminalBlink, TerminalSettings, WorkingDirectory}, Event, MaybeNavigationTarget, Terminal, }; +use terminal_element::TerminalElement; use util::{paths::PathLikeWithPosition, ResultExt}; use workspace::{ item::{BreadcrumbText, Item, ItemEvent}, @@ -305,7 +306,6 @@ impl TerminalView { cx, ) })); - dbg!(&position); // todo!() // self.context_menu // .show(position, AnchorCorner::TopLeft, menu_entries, cx); @@ -541,11 +541,13 @@ impl Render for TerminalView { let focused = self.focus_handle.is_focused(cx); div() + .size_full() .relative() .child( div() .z_index(0) .absolute() + .size_full() .on_key_down(cx.listener(Self::key_down)) .on_action(cx.listener(TerminalView::send_text)) .on_action(cx.listener(TerminalView::send_keystroke)) @@ -554,15 +556,12 @@ impl Render for TerminalView { .on_action(cx.listener(TerminalView::clear)) .on_action(cx.listener(TerminalView::show_character_palette)) .on_action(cx.listener(TerminalView::select_all)) - // todo!() - .child( - "TERMINAL HERE", // TerminalElement::new( - // terminal_handle, - // focused, - // self.should_show_cursor(focused, cx), - // self.can_navigate_to_selected_word, - // ) - ) + .child(TerminalElement::new( + terminal_handle, + focused, + self.should_show_cursor(focused, cx), + self.can_navigate_to_selected_word, + )) .on_mouse_down( MouseButton::Right, cx.listener(|this, event: &MouseDownEvent, cx| {