Compiling again... finally

This commit is contained in:
Mikayla Maki 2022-07-18 17:05:24 -07:00
parent 4f7b6b8b22
commit 005e2cb2be
2 changed files with 31 additions and 26 deletions

View file

@ -37,7 +37,7 @@ use std::{fmt::Debug, ops::Sub};
use crate::{color_translation::convert_color, connection::TerminalConnection, TerminalView}; use crate::{color_translation::convert_color, connection::TerminalConnection, TerminalView};
use self::terminal_layout_context::TerminalLayoutContext; use self::terminal_layout_context::TerminalLayoutTheme;
///Scrolling is unbearably sluggish by default. Alacritty supports a configurable ///Scrolling is unbearably sluggish by default. Alacritty supports a configurable
///Scroll multiplier that is set to 3 by default. This will be removed when I ///Scroll multiplier that is set to 3 by default. This will be removed when I
@ -110,7 +110,10 @@ impl LayoutRect {
fn paint(&self, origin: Vector2F, layout: &LayoutState, cx: &mut PaintContext) { fn paint(&self, origin: Vector2F, layout: &LayoutState, cx: &mut PaintContext) {
let position = point_to_absolute(origin, self.point, layout); let position = point_to_absolute(origin, self.point, layout);
let size = vec2f(layout.em_width.0.ceil(), layout.line_height.0); let size = vec2f(
(layout.em_width.0.ceil() * self.num_of_cells as f32).ceil(),
layout.line_height.0,
);
cx.scene.push_quad(Quad { cx.scene.push_quad(Quad {
bounds: RectF::new(position, size), bounds: RectF::new(position, size),
@ -128,6 +131,7 @@ fn point_to_absolute(origin: Vector2F, point: Point<i32, i32>, layout: &LayoutSt
) )
} }
#[derive(Clone, Debug, Default)]
struct RelativeHighlightedRange { struct RelativeHighlightedRange {
line_index: usize, line_index: usize,
range: Range<usize>, range: Range<usize>,
@ -276,7 +280,7 @@ impl Element for TerminalEl {
constraint: gpui::SizeConstraint, constraint: gpui::SizeConstraint,
cx: &mut gpui::LayoutContext, cx: &mut gpui::LayoutContext,
) -> (gpui::geometry::vector::Vector2F, Self::LayoutState) { ) -> (gpui::geometry::vector::Vector2F, Self::LayoutState) {
let tcx = TerminalLayoutContext::new(cx.global::<Settings>(), &cx.font_cache()); let tcx = TerminalLayoutTheme::new(cx.global::<Settings>(), &cx.font_cache());
let terminal = self let terminal = self
.connection .connection
@ -483,7 +487,7 @@ impl Element for TerminalEl {
fn layout_cursor( fn layout_cursor(
grid: &Grid<Cell>, grid: &Grid<Cell>,
text_layout_cache: &TextLayoutCache, text_layout_cache: &TextLayoutCache,
tcx: &TerminalLayoutContext, tcx: &TerminalLayoutTheme,
cursor_point: Point, cursor_point: Point,
display_offset: usize, display_offset: usize,
constraint: SizeConstraint, constraint: SizeConstraint,
@ -519,7 +523,7 @@ fn layout_cursor(
fn layout_cursor_text( fn layout_cursor_text(
grid: &Grid<Cell>, grid: &Grid<Cell>,
text_layout_cache: &TextLayoutCache, text_layout_cache: &TextLayoutCache,
tcx: &TerminalLayoutContext, tcx: &TerminalLayoutTheme,
) -> Line { ) -> Line {
let cursor_point = grid.cursor.point; let cursor_point = grid.cursor.point;
let cursor_text = grid[cursor_point.line][cursor_point.column].c.to_string(); let cursor_text = grid[cursor_point.line][cursor_point.column].c.to_string();
@ -611,8 +615,7 @@ fn layout_grid(
rects.push(rect); rects.push(rect);
cur_rect = None cur_rect = None
} }
} } else {
match cur_alac_color { match cur_alac_color {
Some(cur_color) => { Some(cur_color) => {
if cell.bg == cur_color { if cell.bg == cur_color {
@ -639,6 +642,7 @@ fn layout_grid(
} }
} }
} }
}
//Layout current cell text //Layout current cell text
{ {
@ -671,6 +675,7 @@ fn layout_grid(
rects.push(cur_rect.take().unwrap()); rects.push(cur_rect.take().unwrap());
} }
} }
(cells, rects, highlight_ranges) (cells, rects, highlight_ranges)
} }

View file

@ -1,6 +1,6 @@
use super::*; use super::*;
pub struct TerminalLayoutContext<'a> { pub struct TerminalLayoutTheme<'a> {
pub line_height: LineHeight, pub line_height: LineHeight,
pub cell_width: CellWidth, pub cell_width: CellWidth,
pub text_style: TextStyle, pub text_style: TextStyle,
@ -8,7 +8,7 @@ pub struct TerminalLayoutContext<'a> {
pub terminal_theme: &'a TerminalStyle, pub terminal_theme: &'a TerminalStyle,
} }
impl<'a> TerminalLayoutContext<'a> { impl<'a> TerminalLayoutTheme<'a> {
pub fn new(settings: &'a Settings, font_cache: &FontCache) -> Self { pub fn new(settings: &'a Settings, font_cache: &FontCache) -> Self {
let text_style = Self::make_text_style(font_cache, &settings); let text_style = Self::make_text_style(font_cache, &settings);
let line_height = LineHeight(font_cache.line_height(text_style.font_size)); let line_height = LineHeight(font_cache.line_height(text_style.font_size));
@ -16,7 +16,7 @@ impl<'a> TerminalLayoutContext<'a> {
let selection_color = settings.theme.editor.selection.selection; let selection_color = settings.theme.editor.selection.selection;
let terminal_theme = &settings.theme.terminal; let terminal_theme = &settings.theme.terminal;
TerminalLayoutContext { TerminalLayoutTheme {
line_height, line_height,
cell_width, cell_width,
text_style, text_style,