diff options
author | Christian Duerr <contact@christianduerr.com> | 2021-01-24 21:45:36 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-24 21:45:36 +0000 |
commit | 530de00049c2afcc562d36ccdb3e6afa2fe396a5 (patch) | |
tree | 3dabbcef3fc4a2041f9027d82243aa0d70928153 /alacritty/src/renderer | |
parent | 7291702f6b4fff10f2470f084abe0785b95659a0 (diff) | |
download | r-alacritty-530de00049c2afcc562d36ccdb3e6afa2fe396a5.tar.gz r-alacritty-530de00049c2afcc562d36ccdb3e6afa2fe396a5.tar.bz2 r-alacritty-530de00049c2afcc562d36ccdb3e6afa2fe396a5.zip |
Move renderable cell transformation to alacritty
This refactors a large chunk of the alacritty_terminal API to expose all
data necessary for rendering uniformly through the `renderable_content`
call. This also no longer transforms the cells for rendering by a GUI
but instead just reports the content from a terminal emulation
perspective. The transformation into renderable cells is now done inside
the alacritty crate.
Since the terminal itself only ever needs to know about modified color
RGB values, the configuration for colors was moved to the alacritty UI
code.
Diffstat (limited to 'alacritty/src/renderer')
-rw-r--r-- | alacritty/src/renderer/mod.rs | 9 | ||||
-rw-r--r-- | alacritty/src/renderer/rects.rs | 16 |
2 files changed, 12 insertions, 13 deletions
diff --git a/alacritty/src/renderer/mod.rs b/alacritty/src/renderer/mod.rs index 39e53b82..1f203332 100644 --- a/alacritty/src/renderer/mod.rs +++ b/alacritty/src/renderer/mod.rs @@ -17,11 +17,11 @@ use unicode_width::UnicodeWidthChar; use alacritty_terminal::index::Point; use alacritty_terminal::term::cell::Flags; use alacritty_terminal::term::color::Rgb; -use alacritty_terminal::term::render::RenderableCell; use alacritty_terminal::term::SizeInfo; use crate::config::font::{Font, FontDescription}; use crate::config::ui_config::{Delta, UIConfig}; +use crate::display::content::RenderableCell; use crate::gl; use crate::gl::types::*; use crate::renderer::rects::{RectRenderer, RenderRect}; @@ -480,8 +480,8 @@ impl Batch { cell_flags.set(RenderingGlyphFlags::WIDE_CHAR, cell.flags.contains(Flags::WIDE_CHAR)); self.instances.push(InstanceData { - col: cell.column.0 as u16, - row: cell.line.0 as u16, + col: cell.point.column.0 as u16, + row: cell.point.line.0 as u16, top: glyph.top, left: glyph.left, @@ -829,8 +829,7 @@ impl<'a> RenderApi<'a> { .chars() .enumerate() .map(|(i, character)| RenderableCell { - line: point.line, - column: point.col + i, + point: Point::new(point.line, point.column + i), character, zerowidth: None, flags: Flags::empty(), diff --git a/alacritty/src/renderer/rects.rs b/alacritty/src/renderer/rects.rs index cfd17379..80886c95 100644 --- a/alacritty/src/renderer/rects.rs +++ b/alacritty/src/renderer/rects.rs @@ -6,9 +6,9 @@ use crossfont::Metrics; use alacritty_terminal::index::{Column, Point}; use alacritty_terminal::term::cell::Flags; use alacritty_terminal::term::color::Rgb; -use alacritty_terminal::term::render::RenderableCell; use alacritty_terminal::term::SizeInfo; +use crate::display::content::RenderableCell; use crate::gl; use crate::gl::types::*; use crate::renderer; @@ -105,8 +105,8 @@ impl RenderLine { mut thickness: f32, color: Rgb, ) -> RenderRect { - let start_x = start.col.0 as f32 * size.cell_width(); - let end_x = (end.col.0 + 1) as f32 * size.cell_width(); + let start_x = start.column.0 as f32 * size.cell_width(); + let end_x = (end.column.0 + 1) as f32 * size.cell_width(); let width = end_x - start_x; // Make sure lines are always visible. @@ -169,16 +169,16 @@ impl RenderLines { } // Include wide char spacer if the current cell is a wide char. - let mut end: Point = cell.into(); + let mut end = cell.point; if cell.flags.contains(Flags::WIDE_CHAR) { - end.col += 1; + end.column += 1; } // Check if there's an active line. if let Some(line) = self.inner.get_mut(&flag).and_then(|lines| lines.last_mut()) { if cell.fg == line.color - && cell.column == line.end.col + 1 - && cell.line == line.end.line + && cell.point.column == line.end.column + 1 + && cell.point.line == line.end.line { // Update the length of the line. line.end = end; @@ -187,7 +187,7 @@ impl RenderLines { } // Start new line if there currently is none. - let line = RenderLine { start: cell.into(), end, color: cell.fg }; + let line = RenderLine { start: cell.point, end, color: cell.fg }; match self.inner.get_mut(&flag) { Some(lines) => lines.push(line), None => { |