aboutsummaryrefslogtreecommitdiff
path: root/src/term/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/term/mod.rs')
-rw-r--r--src/term/mod.rs124
1 files changed, 62 insertions, 62 deletions
diff --git a/src/term/mod.rs b/src/term/mod.rs
index eb25efd6..18858da5 100644
--- a/src/term/mod.rs
+++ b/src/term/mod.rs
@@ -44,7 +44,7 @@ impl<'a> selection::SemanticSearch for &'a Term {
break;
}
- if iter.cur.col == last_col && !cell.flags.contains(cell::WRAPLINE) {
+ if iter.cur.col == last_col && !cell.flags.contains(cell::Flags::WRAPLINE) {
break; // cut off if on new line or hit escape char
}
@@ -65,7 +65,7 @@ impl<'a> selection::SemanticSearch for &'a Term {
point = iter.cur;
- if iter.cur.col == last_col && !cell.flags.contains(cell::WRAPLINE) {
+ if iter.cur.col == last_col && !cell.flags.contains(cell::Flags::WRAPLINE) {
break; // cut off if on new line or hit escape char
}
}
@@ -168,7 +168,7 @@ impl<'a> RenderableCellsIter<'a> {
#[inline]
fn is_wide_cursor(&self, cell: &Cell) -> bool {
- cell.flags.contains(cell::WIDE_CHAR) && (self.cursor.col + 1) < self.grid.num_cols()
+ cell.flags.contains(cell::Flags::WIDE_CHAR) && (self.cursor.col + 1) < self.grid.num_cols()
}
fn populate_beam_cursor(&mut self) {
@@ -264,20 +264,20 @@ impl<'a> RenderableCellsIter<'a> {
/// Check if the cursor should be rendered.
#[inline]
fn cursor_is_visible(&self) -> bool {
- self.mode.contains(mode::SHOW_CURSOR) && self.grid.contains(self.cursor)
+ self.mode.contains(mode::TermMode::SHOW_CURSOR) && self.grid.contains(self.cursor)
}
fn compute_fg_rgb(&self, fg: &Color, cell: &Cell) -> Rgb {
- use self::cell::DIM_BOLD;
+ use self::cell::Flags;
match *fg {
Color::Spec(rgb) => rgb,
Color::Named(ansi) => {
- match (self.config.draw_bold_text_with_bright_colors(), cell.flags & DIM_BOLD) {
+ match (self.config.draw_bold_text_with_bright_colors(), cell.flags & Flags::DIM_BOLD) {
// Draw bold text in bright colors *and* contains bold flag.
- (true, self::cell::DIM_BOLD) |
- (true, self::cell::BOLD) => self.colors[ansi.to_bright()],
+ (true, self::cell::Flags::DIM_BOLD) |
+ (true, self::cell::Flags::BOLD) => self.colors[ansi.to_bright()],
// Cell is marked as dim and not bold
- (_, self::cell::DIM) => self.colors[ansi.to_dim()],
+ (_, self::cell::Flags::DIM) => self.colors[ansi.to_dim()],
// None of the above, keep original color.
_ => self.colors[ansi]
}
@@ -285,12 +285,12 @@ impl<'a> RenderableCellsIter<'a> {
Color::Indexed(idx) => {
let idx = match (
self.config.draw_bold_text_with_bright_colors(),
- cell.flags & DIM_BOLD,
+ cell.flags & Flags::DIM_BOLD,
idx
) {
- (true, self::cell::BOLD, 0...7) => idx as usize + 8,
- (false, self::cell::DIM, 8...15) => idx as usize - 8,
- (false, self::cell::DIM, 0...7) => idx as usize + 260,
+ (true, self::cell::Flags::BOLD, 0...7) => idx as usize + 8,
+ (false, self::cell::Flags::DIM, 8...15) => idx as usize - 8,
+ (false, self::cell::Flags::DIM, 0...7) => idx as usize + 260,
_ => idx as usize,
};
@@ -436,7 +436,7 @@ pub mod mode {
impl Default for TermMode {
fn default() -> TermMode {
- SHOW_CURSOR | LINE_WRAP
+ TermMode::SHOW_CURSOR | TermMode::LINE_WRAP
}
}
}
@@ -854,7 +854,7 @@ impl Term {
trait PushChar {
fn push_char(&mut self, c: char);
fn maybe_newline(&mut self, grid: &Grid<Cell>, line: Line, ending: Column) {
- if ending != Column(0) && !grid[line][ending - 1].flags.contains(cell::WRAPLINE) {
+ if ending != Column(0) && !grid[line][ending - 1].flags.contains(cell::Flags::WRAPLINE) {
self.push_char('\n');
}
}
@@ -888,7 +888,7 @@ impl Term {
None
} else {
for cell in &grid_line[cols.start..line_end] {
- if !cell.flags.contains(cell::WIDE_CHAR_SPACER) {
+ if !cell.flags.contains(cell::Flags::WIDE_CHAR_SPACER) {
self.push(cell.c);
}
}
@@ -1175,7 +1175,7 @@ impl ansi::Handler for Term {
#[inline]
fn input(&mut self, c: char) {
if self.input_needs_wrap {
- if !self.mode.contains(mode::LINE_WRAP) {
+ if !self.mode.contains(mode::TermMode::LINE_WRAP) {
return;
}
@@ -1188,7 +1188,7 @@ impl ansi::Handler for Term {
};
let cell = &mut self.grid[&location];
- cell.flags.insert(cell::WRAPLINE);
+ cell.flags.insert(cell::Flags::WRAPLINE);
}
if (self.cursor.point.line + 1) >= self.scroll_region.end {
@@ -1209,7 +1209,7 @@ impl ansi::Handler for Term {
let num_cols = self.grid.num_cols();
{
// If in insert mode, first shift cells to the right.
- if self.mode.contains(mode::INSERT) && self.cursor.point.col + width < num_cols {
+ if self.mode.contains(mode::TermMode::INSERT) && self.cursor.point.col + width < num_cols {
let line = self.cursor.point.line; // borrowck
let col = self.cursor.point.col;
let line = &mut self.grid[line];
@@ -1228,7 +1228,7 @@ impl ansi::Handler for Term {
// Handle wide chars
if width == 2 {
- cell.flags.insert(cell::WIDE_CHAR);
+ cell.flags.insert(cell::Flags::WIDE_CHAR);
}
}
@@ -1238,7 +1238,7 @@ impl ansi::Handler for Term {
self.cursor.point.col += 1;
let spacer = &mut self.grid[&self.cursor.point];
*spacer = self.cursor.template;
- spacer.flags.insert(cell::WIDE_CHAR_SPACER);
+ spacer.flags.insert(cell::Flags::WIDE_CHAR_SPACER);
}
}
}
@@ -1268,7 +1268,7 @@ impl ansi::Handler for Term {
#[inline]
fn goto(&mut self, line: Line, col: Column) {
trace!("goto: line={}, col={}", line, col);
- let (y_offset, max_y) = if self.mode.contains(mode::ORIGIN) {
+ let (y_offset, max_y) = if self.mode.contains(mode::TermMode::ORIGIN) {
(self.scroll_region.start, self.scroll_region.end - 1)
} else {
(Line(0), self.grid.num_lines() - 1)
@@ -1474,7 +1474,7 @@ impl ansi::Handler for Term {
fn newline(&mut self) {
self.linefeed();
- if self.mode.contains(mode::LINE_FEED_NEW_LINE) {
+ if self.mode.contains(mode::TermMode::LINE_FEED_NEW_LINE) {
self.carriage_return();
}
}
@@ -1740,16 +1740,16 @@ impl ansi::Handler for Term {
self.cursor.template.bg = Color::Named(NamedColor::Background);
self.cursor.template.flags = cell::Flags::empty();
},
- Attr::Reverse => self.cursor.template.flags.insert(cell::INVERSE),
- Attr::CancelReverse => self.cursor.template.flags.remove(cell::INVERSE),
- Attr::Bold => self.cursor.template.flags.insert(cell::BOLD),
- Attr::CancelBold => self.cursor.template.flags.remove(cell::BOLD),
- Attr::Dim => self.cursor.template.flags.insert(cell::DIM),
- Attr::CancelBoldDim => self.cursor.template.flags.remove(cell::BOLD | cell::DIM),
- Attr::Italic => self.cursor.template.flags.insert(cell::ITALIC),
- Attr::CancelItalic => self.cursor.template.flags.remove(cell::ITALIC),
- Attr::Underscore => self.cursor.template.flags.insert(cell::UNDERLINE),
- Attr::CancelUnderline => self.cursor.template.flags.remove(cell::UNDERLINE),
+ Attr::Reverse => self.cursor.template.flags.insert(cell::Flags::INVERSE),
+ Attr::CancelReverse => self.cursor.template.flags.remove(cell::Flags::INVERSE),
+ Attr::Bold => self.cursor.template.flags.insert(cell::Flags::BOLD),
+ Attr::CancelBold => self.cursor.template.flags.remove(cell::Flags::BOLD),
+ Attr::Dim => self.cursor.template.flags.insert(cell::Flags::DIM),
+ Attr::CancelBoldDim => self.cursor.template.flags.remove(cell::Flags::BOLD | cell::Flags::DIM),
+ Attr::Italic => self.cursor.template.flags.insert(cell::Flags::ITALIC),
+ Attr::CancelItalic => self.cursor.template.flags.remove(cell::Flags::ITALIC),
+ Attr::Underscore => self.cursor.template.flags.insert(cell::Flags::UNDERLINE),
+ Attr::CancelUnderline => self.cursor.template.flags.remove(cell::Flags::UNDERLINE),
_ => {
debug!("Term got unhandled attr: {:?}", attr);
}
@@ -1761,25 +1761,25 @@ impl ansi::Handler for Term {
trace!("set_mode: {:?}", mode);
match mode {
ansi::Mode::SwapScreenAndSetRestoreCursor => {
- self.mode.insert(mode::ALT_SCREEN);
+ self.mode.insert(mode::TermMode::ALT_SCREEN);
self.save_cursor_position();
if !self.alt {
self.swap_alt();
}
self.save_cursor_position();
},
- ansi::Mode::ShowCursor => self.mode.insert(mode::SHOW_CURSOR),
- ansi::Mode::CursorKeys => self.mode.insert(mode::APP_CURSOR),
- ansi::Mode::ReportMouseClicks => self.mode.insert(mode::MOUSE_REPORT_CLICK),
- ansi::Mode::ReportMouseMotion => self.mode.insert(mode::MOUSE_MOTION),
- ansi::Mode::ReportFocusInOut => self.mode.insert(mode::FOCUS_IN_OUT),
- ansi::Mode::BracketedPaste => self.mode.insert(mode::BRACKETED_PASTE),
- ansi::Mode::SgrMouse => self.mode.insert(mode::SGR_MOUSE),
- ansi::Mode::LineWrap => self.mode.insert(mode::LINE_WRAP),
- ansi::Mode::LineFeedNewLine => self.mode.insert(mode::LINE_FEED_NEW_LINE),
- ansi::Mode::Origin => self.mode.insert(mode::ORIGIN),
+ ansi::Mode::ShowCursor => self.mode.insert(mode::TermMode::SHOW_CURSOR),
+ ansi::Mode::CursorKeys => self.mode.insert(mode::TermMode::APP_CURSOR),
+ ansi::Mode::ReportMouseClicks => self.mode.insert(mode::TermMode::MOUSE_REPORT_CLICK),
+ ansi::Mode::ReportMouseMotion => self.mode.insert(mode::TermMode::MOUSE_MOTION),
+ ansi::Mode::ReportFocusInOut => self.mode.insert(mode::TermMode::FOCUS_IN_OUT),
+ ansi::Mode::BracketedPaste => self.mode.insert(mode::TermMode::BRACKETED_PASTE),
+ ansi::Mode::SgrMouse => self.mode.insert(mode::TermMode::SGR_MOUSE),
+ ansi::Mode::LineWrap => self.mode.insert(mode::TermMode::LINE_WRAP),
+ ansi::Mode::LineFeedNewLine => self.mode.insert(mode::TermMode::LINE_FEED_NEW_LINE),
+ ansi::Mode::Origin => self.mode.insert(mode::TermMode::ORIGIN),
ansi::Mode::DECCOLM => self.deccolm(),
- ansi::Mode::Insert => self.mode.insert(mode::INSERT), // heh
+ ansi::Mode::Insert => self.mode.insert(mode::TermMode::INSERT), // heh
_ => {
trace!(".. ignoring set_mode");
}
@@ -1791,25 +1791,25 @@ impl ansi::Handler for Term {
trace!("unset_mode: {:?}", mode);
match mode {
ansi::Mode::SwapScreenAndSetRestoreCursor => {
- self.mode.remove(mode::ALT_SCREEN);
+ self.mode.remove(mode::TermMode::ALT_SCREEN);
self.restore_cursor_position();
if self.alt {
self.swap_alt();
}
self.restore_cursor_position();
},
- ansi::Mode::ShowCursor => self.mode.remove(mode::SHOW_CURSOR),
- ansi::Mode::CursorKeys => self.mode.remove(mode::APP_CURSOR),
- ansi::Mode::ReportMouseClicks => self.mode.remove(mode::MOUSE_REPORT_CLICK),
- ansi::Mode::ReportMouseMotion => self.mode.remove(mode::MOUSE_MOTION),
- ansi::Mode::ReportFocusInOut => self.mode.remove(mode::FOCUS_IN_OUT),
- ansi::Mode::BracketedPaste => self.mode.remove(mode::BRACKETED_PASTE),
- ansi::Mode::SgrMouse => self.mode.remove(mode::SGR_MOUSE),
- ansi::Mode::LineWrap => self.mode.remove(mode::LINE_WRAP),
- ansi::Mode::LineFeedNewLine => self.mode.remove(mode::LINE_FEED_NEW_LINE),
- ansi::Mode::Origin => self.mode.remove(mode::ORIGIN),
+ ansi::Mode::ShowCursor => self.mode.remove(mode::TermMode::SHOW_CURSOR),
+ ansi::Mode::CursorKeys => self.mode.remove(mode::TermMode::APP_CURSOR),
+ ansi::Mode::ReportMouseClicks => self.mode.remove(mode::TermMode::MOUSE_REPORT_CLICK),
+ ansi::Mode::ReportMouseMotion => self.mode.remove(mode::TermMode::MOUSE_MOTION),
+ ansi::Mode::ReportFocusInOut => self.mode.remove(mode::TermMode::FOCUS_IN_OUT),
+ ansi::Mode::BracketedPaste => self.mode.remove(mode::TermMode::BRACKETED_PASTE),
+ ansi::Mode::SgrMouse => self.mode.remove(mode::TermMode::SGR_MOUSE),
+ ansi::Mode::LineWrap => self.mode.remove(mode::TermMode::LINE_WRAP),
+ ansi::Mode::LineFeedNewLine => self.mode.remove(mode::TermMode::LINE_FEED_NEW_LINE),
+ ansi::Mode::Origin => self.mode.remove(mode::TermMode::ORIGIN),
ansi::Mode::DECCOLM => self.deccolm(),
- ansi::Mode::Insert => self.mode.remove(mode::INSERT),
+ ansi::Mode::Insert => self.mode.remove(mode::TermMode::INSERT),
_ => {
trace!(".. ignoring unset_mode");
}
@@ -1826,14 +1826,14 @@ impl ansi::Handler for Term {
#[inline]
fn set_keypad_application_mode(&mut self) {
- trace!("set mode::APP_KEYPAD");
- self.mode.insert(mode::APP_KEYPAD);
+ trace!("set mode::TermMode::APP_KEYPAD");
+ self.mode.insert(mode::TermMode::APP_KEYPAD);
}
#[inline]
fn unset_keypad_application_mode(&mut self) {
- trace!("unset mode::APP_KEYPAD");
- self.mode.remove(mode::APP_KEYPAD);
+ trace!("unset mode::TermMode::APP_KEYPAD");
+ self.mode.remove(mode::TermMode::APP_KEYPAD);
}
#[inline]
@@ -1888,7 +1888,7 @@ mod tests {
grid[Line(0)][Column(0)].c = '"';
grid[Line(0)][Column(3)].c = '"';
grid[Line(1)][Column(2)].c = '"';
- grid[Line(0)][Column(4)].flags.insert(cell::WRAPLINE);
+ grid[Line(0)][Column(4)].flags.insert(cell::Flags::WRAPLINE);
let mut escape_chars = String::from("\"");