1
1
mirror of https://github.com/wez/wezterm.git synced 2024-12-23 05:12:40 +03:00

termwiz: remove reverse video attribute from Line

It didn't really belong there; it was added as a bit of a hack
to propagate screen reverse video mode.

Move that to the RenderableDims struct and remove the related
bits from Line
This commit is contained in:
Wez Furlong 2022-08-24 22:43:47 -07:00
parent f59e1d5fff
commit 5e993c581a
5 changed files with 17 additions and 37 deletions

View File

@ -42,6 +42,8 @@ pub struct RenderableDimensions {
pub dpi: u32,
pub pixel_width: usize,
pub pixel_height: usize,
/// True if the lines should be rendered reversed
pub reverse_video: bool,
}
impl_lua_conversion_dynamic!(RenderableDimensions);
@ -78,14 +80,11 @@ pub fn terminal_get_logical_lines(
) -> Vec<LogicalLine> {
let screen = term.screen();
let mut result = vec![];
let reverse = term.get_reverse_video();
screen.for_each_logical_line_in_stable_range(lines.clone(), |sr, lines| {
let mut physical_lines: Vec<Line> = lines
.iter()
.map(|line| {
let mut line = (*line).clone();
let seqno = line.current_seqno();
line.set_reverse(reverse, seqno);
let line = (*line).clone();
line
})
.collect();
@ -113,16 +112,11 @@ pub fn terminal_get_lines(
term: &mut Terminal,
lines: Range<StableRowIndex>,
) -> (StableRowIndex, Vec<Line>) {
let reverse = term.get_reverse_video();
let screen = term.screen_mut();
let phys_range = screen.stable_range(&lines);
let first = screen.phys_to_stable_row_index(phys_range.start);
let mut lines = screen.lines_in_phys_range(phys_range);
for line in &mut lines {
let seqno = line.current_seqno();
line.set_reverse(reverse, seqno);
}
let lines = screen.lines_in_phys_range(phys_range);
(first, lines)
}
@ -140,5 +134,6 @@ pub fn terminal_get_dimensions(term: &mut Terminal) -> RenderableDimensions {
dpi: screen.dpi,
pixel_width: size.pixel_width,
pixel_height: size.pixel_height,
reverse_video: term.get_reverse_video(),
}
}

View File

@ -233,21 +233,6 @@ impl Line {
self.seqno = self.seqno.max(seqno);
}
/// Check whether the reverse video bit is set. If it is set,
/// then the line should be displayed with foreground/background
/// colors reversed.
#[inline]
pub fn is_reverse(&self) -> bool {
self.bits.contains(LineBits::REVERSE)
}
/// Force the reverse bit set. This also implicitly sets dirty.
#[inline]
pub fn set_reverse(&mut self, reverse: bool, seqno: SequenceNo) {
self.bits.set(LineBits::REVERSE, reverse);
self.update_last_change_seqno(seqno);
}
/// Check whether the line is single-width.
#[inline]
pub fn is_single_width(&self) -> bool {

View File

@ -13,21 +13,17 @@ bitflags! {
/// true if we found implicit hyperlinks in the last scan
const HAS_IMPLICIT_HYPERLINKS = 1<<3;
/// true if this line should be displayed with
/// foreground/background colors reversed
const REVERSE = 1<<4;
/// true if this line should be displayed with
/// in double-width
const DOUBLE_WIDTH = 1<<5;
const DOUBLE_WIDTH = 1<<4;
/// true if this line should be displayed
/// as double-height top-half
const DOUBLE_HEIGHT_TOP = 1<<6;
const DOUBLE_HEIGHT_TOP = 1<<5;
/// true if this line should be displayed
/// as double-height bottom-half
const DOUBLE_HEIGHT_BOTTOM = 1<<7;
const DOUBLE_HEIGHT_BOTTOM = 1<<6;
const DOUBLE_WIDTH_HEIGHT_MASK =
Self::DOUBLE_WIDTH.bits |
@ -44,13 +40,13 @@ bitflags! {
/// true if the line base direction is RTL.
/// When BIDI_ENABLED is also true, this is passed to the bidi algorithm.
/// When rendering, the line will be rendered from RTL.
const RTL = 1<<8;
const RTL = 1<<7;
/// true if the direction for the line should be auto-detected
/// when BIDI_ENABLED is also true.
/// If false, the direction is taken from the RTL bit only.
/// Otherwise, the auto-detect direction is used, falling back
/// to the direction specified by the RTL bit.
const AUTO_DETECT_DIRECTION = 1<<9;
const AUTO_DETECT_DIRECTION = 1<<8;
}
}

View File

@ -76,6 +76,7 @@ impl ClientPane {
dpi: size.dpi,
pixel_width: size.pixel_width,
pixel_height: size.pixel_height,
reverse_video: false,
},
title,
fetch_limiter,

View File

@ -149,6 +149,7 @@ pub struct LineToElementParams<'a> {
pub stable_line_idx: StableRowIndex,
pub window_is_transparent: bool,
pub cursor: &'a StableCursorPosition,
pub reverse_video: bool,
}
use mux::pane::PaneId;
@ -1070,6 +1071,7 @@ impl super::TermWindow {
dpi: self.terminal_size.dpi,
pixel_height: self.render_metrics.cell_size.height as usize,
pixel_width: self.terminal_size.pixel_width,
reverse_video: false,
},
config: &self.config,
cursor_border_color: LinearRgba::default(),
@ -2069,7 +2071,7 @@ impl super::TermWindow {
let mut bg_default = bg_is_default;
// Check the line reverse_video flag and flip.
if attrs.reverse() == !params.line.is_reverse() {
if attrs.reverse() == !params.reverse_video {
std::mem::swap(&mut fg, &mut bg);
bg_default = false;
}
@ -2398,6 +2400,7 @@ impl super::TermWindow {
}),
stable_line_idx: params.stable_line_idx.unwrap_or(0),
window_is_transparent: params.window_is_transparent,
reverse_video: params.dims.reverse_video,
})?;
let bounding_rect = euclid::rect(
@ -2414,7 +2417,7 @@ impl super::TermWindow {
}
}
if params.line.is_reverse() {
if params.dims.reverse_video {
let mut quad = self.filled_rectangle(
layers,
0,
@ -2459,7 +2462,7 @@ impl super::TermWindow {
let mut bg_default = bg_is_default;
// Check the line reverse_video flag and flip.
if attrs.reverse() == !params.line.is_reverse() {
if attrs.reverse() == !params.dims.reverse_video {
std::mem::swap(&mut fg, &mut bg);
bg_default = false;
}