mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-29 05:33:49 +00:00
Compiling again... finally
This commit is contained in:
parent
4f7b6b8b22
commit
005e2cb2be
2 changed files with 31 additions and 26 deletions
|
@ -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,17 +615,25 @@ 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 {
|
cur_rect = cur_rect.take().map(|rect| rect.extend());
|
||||||
cur_rect = cur_rect.take().map(|rect| rect.extend());
|
} else {
|
||||||
} else {
|
cur_alac_color = Some(cell.bg);
|
||||||
cur_alac_color = Some(cell.bg);
|
if let Some(_) = cur_rect {
|
||||||
if let Some(_) = cur_rect {
|
rects.push(cur_rect.take().unwrap());
|
||||||
rects.push(cur_rect.take().unwrap());
|
}
|
||||||
|
cur_rect = Some(LayoutRect::new(
|
||||||
|
Point::new(line_index as i32, cell.point.column.0 as i32),
|
||||||
|
1,
|
||||||
|
convert_color(&cell.bg, &terminal_theme.colors, modal),
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
None => {
|
||||||
|
cur_alac_color = Some(cell.bg);
|
||||||
cur_rect = Some(LayoutRect::new(
|
cur_rect = Some(LayoutRect::new(
|
||||||
Point::new(line_index as i32, cell.point.column.0 as i32),
|
Point::new(line_index as i32, cell.point.column.0 as i32),
|
||||||
1,
|
1,
|
||||||
|
@ -629,14 +641,6 @@ fn layout_grid(
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
None => {
|
|
||||||
cur_alac_color = Some(cell.bg);
|
|
||||||
cur_rect = Some(LayoutRect::new(
|
|
||||||
Point::new(line_index as i32, cell.point.column.0 as i32),
|
|
||||||
1,
|
|
||||||
convert_color(&cell.bg, &terminal_theme.colors, modal),
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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,
|
||||||
|
|
Loading…
Reference in a new issue