mirror of
https://github.com/wez/wezterm.git
synced 2024-12-23 21:32:13 +03:00
#133 Tab stops, reverse video.
This commit is contained in:
parent
fc2f7b83d2
commit
d3b0881ded
@ -101,8 +101,10 @@ impl TabStop {
|
||||
*t = false;
|
||||
}
|
||||
}
|
||||
TabulationClear::ClearAllCharacterTabStops
|
||||
| TabulationClear::ClearCharacterTabStopsAtActiveLine => {
|
||||
// If we want to exactly match VT100/xterm behavior, then
|
||||
// we cannot honor ClearCharacterTabStopsAtActiveLine.
|
||||
TabulationClear::ClearAllCharacterTabStops => {
|
||||
// | TabulationClear::ClearCharacterTabStopsAtActiveLine => {
|
||||
for t in &mut self.tabs {
|
||||
*t = false;
|
||||
}
|
||||
@ -2103,10 +2105,24 @@ impl TerminalState {
|
||||
// We always output at our "best" rate
|
||||
}
|
||||
|
||||
Mode::SetDecPrivateMode(DecPrivateMode::Code(DecPrivateModeCode::ReverseVideo))
|
||||
| Mode::ResetDecPrivateMode(DecPrivateMode::Code(DecPrivateModeCode::ReverseVideo)) => {
|
||||
// I'm mostly intentionally ignoring this in favor
|
||||
// of respecting the configured colors
|
||||
Mode::SetDecPrivateMode(DecPrivateMode::Code(DecPrivateModeCode::ReverseVideo)) => {
|
||||
// Turn on reverse video for all of the lines on the
|
||||
// display.
|
||||
for y in 0..self.screen.physical_rows as i64 {
|
||||
let line_idx = self.screen.phys_row(VisibleRowIndex::from(y));
|
||||
let line = self.screen.line_mut(line_idx);
|
||||
line.set_reverse(true);
|
||||
}
|
||||
}
|
||||
|
||||
Mode::ResetDecPrivateMode(DecPrivateMode::Code(DecPrivateModeCode::ReverseVideo)) => {
|
||||
// Turn off reverse video for all of the lines on the
|
||||
// display.
|
||||
for y in 0..self.screen.physical_rows as i64 {
|
||||
let line_idx = self.screen.phys_row(VisibleRowIndex::from(y));
|
||||
let line = self.screen.line_mut(line_idx);
|
||||
line.set_reverse(false);
|
||||
}
|
||||
}
|
||||
|
||||
Mode::SetDecPrivateMode(DecPrivateMode::Code(DecPrivateModeCode::Select132Columns))
|
||||
|
@ -22,6 +22,10 @@ bitflags! {
|
||||
const SCANNED_IMPLICIT_HYPERLINKS = 1<<2;
|
||||
/// 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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -97,6 +101,13 @@ impl Line {
|
||||
.map(|chunk| {
|
||||
let mut line = Line {
|
||||
cells: chunk.to_vec(),
|
||||
// AZL TODO:
|
||||
//
|
||||
// How to "| self.bits.LineBits::REVERSE"
|
||||
// here?
|
||||
//
|
||||
// The wrapped line pieces should also be
|
||||
// reversed.
|
||||
bits: LineBits::DIRTY,
|
||||
};
|
||||
if line.cells.len() == width {
|
||||
@ -137,6 +148,25 @@ impl Line {
|
||||
self.bits &= !LineBits::DIRTY;
|
||||
}
|
||||
|
||||
/// 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 & LineBits::REVERSE) == LineBits::REVERSE
|
||||
}
|
||||
|
||||
/// Force the reverse bit set. This also implicitly sets dirty.
|
||||
#[inline]
|
||||
pub fn set_reverse(&mut self, reverse: bool) {
|
||||
if reverse {
|
||||
self.bits |= LineBits::REVERSE;
|
||||
} else {
|
||||
self.bits &= !LineBits::REVERSE;
|
||||
}
|
||||
self.bits |= LineBits::DIRTY;
|
||||
}
|
||||
|
||||
/// If we have any cells with an implicit hyperlink, remove the hyperlink
|
||||
/// from the cell attributes but leave the remainder of the attributes alone.
|
||||
pub fn invalidate_implicit_hyperlinks(&mut self) {
|
||||
|
@ -738,7 +738,10 @@ impl super::TermWindow {
|
||||
let mut bg = bg_color;
|
||||
let mut bg_default = bg_is_default;
|
||||
|
||||
if attrs.reverse() {
|
||||
// Check the line reverse_video flag and flip.
|
||||
if (attrs.reverse() && !params.line.is_reverse())
|
||||
|| (!attrs.reverse() && params.line.is_reverse())
|
||||
{
|
||||
std::mem::swap(&mut fg, &mut bg);
|
||||
bg_default = false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user