Fix bug handling ansi mode sequences
The sense of set_mode and unset_mode was inverted. The TextCursor/ShowCursor mode depended on the incorrect behavior, and that was fixed as well. TextCursor was renamed to ShowCursor to be perfectly clear on the intent.
This commit is contained in:
parent
f5faa40066
commit
09600a3d40
|
@ -53,7 +53,7 @@ pub enum Mode {
|
|||
/// ?1
|
||||
CursorKeys = 1,
|
||||
/// ?25
|
||||
TextCursor = 25,
|
||||
ShowCursor = 25,
|
||||
/// ?12
|
||||
BlinkingCursor = 12,
|
||||
/// ?1049
|
||||
|
@ -69,7 +69,7 @@ impl Mode {
|
|||
Some(match num {
|
||||
1 => Mode::CursorKeys,
|
||||
12 => Mode::BlinkingCursor,
|
||||
25 => Mode::TextCursor,
|
||||
25 => Mode::ShowCursor,
|
||||
1049 => Mode::SwapScreenAndSetRestoreCursor,
|
||||
_ => return None
|
||||
})
|
||||
|
@ -627,7 +627,7 @@ impl Parser {
|
|||
'l' => {
|
||||
let mode = Mode::from_primitive(private, args[0]);
|
||||
match mode {
|
||||
Some(mode) => handler.set_mode(mode),
|
||||
Some(mode) => handler.unset_mode(mode),
|
||||
None => unhandled!(),
|
||||
}
|
||||
},
|
||||
|
@ -639,7 +639,7 @@ impl Parser {
|
|||
'h' => {
|
||||
let mode = Mode::from_primitive(private, args[0]);
|
||||
match mode {
|
||||
Some(mode) => handler.unset_mode(mode),
|
||||
Some(mode) => handler.set_mode(mode),
|
||||
None => unhandled!(),
|
||||
}
|
||||
},
|
||||
|
|
|
@ -250,7 +250,7 @@ fn main() {
|
|||
api.render_grid(terminal.grid(), &mut glyph_cache);
|
||||
|
||||
// Also draw the cursor
|
||||
if !terminal.mode().contains(term::mode::TEXT_CURSOR) {
|
||||
if terminal.mode().contains(term::mode::SHOW_CURSOR) {
|
||||
api.render_cursor(terminal.cursor(), &mut glyph_cache);
|
||||
}
|
||||
})
|
||||
|
|
19
src/term.rs
19
src/term.rs
|
@ -30,8 +30,17 @@ pub static COLORS: &'static [Rgb] = &[
|
|||
|
||||
pub mod mode {
|
||||
bitflags! {
|
||||
pub flags TermMode: u32 {
|
||||
const TEXT_CURSOR = 0b00000001,
|
||||
pub flags TermMode: u8 {
|
||||
const SHOW_CURSOR = 0b00000001,
|
||||
const APP_CURSOR = 0b00000010,
|
||||
const ANY = 0b11111111,
|
||||
const NONE = 0b00000000,
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for TermMode {
|
||||
fn default() -> TermMode {
|
||||
SHOW_CURSOR
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -128,7 +137,7 @@ impl Term {
|
|||
_tty: tty,
|
||||
tabs: tabs,
|
||||
attr: CellFlags::empty(),
|
||||
mode: TermMode::empty(),
|
||||
mode: Default::default(),
|
||||
scroll_region: scroll_region,
|
||||
}
|
||||
}
|
||||
|
@ -429,7 +438,7 @@ impl ansi::Handler for Term {
|
|||
println!("set_mode: {:?}", mode);
|
||||
match mode {
|
||||
ansi::Mode::SwapScreenAndSetRestoreCursor => self.swap_alt(),
|
||||
ansi::Mode::TextCursor => self.mode.insert(mode::TEXT_CURSOR),
|
||||
ansi::Mode::ShowCursor => self.mode.insert(mode::SHOW_CURSOR),
|
||||
_ => {
|
||||
println!(".. ignoring set_mode");
|
||||
}
|
||||
|
@ -440,7 +449,7 @@ impl ansi::Handler for Term {
|
|||
println!("unset_mode: {:?}", mode);
|
||||
match mode {
|
||||
ansi::Mode::SwapScreenAndSetRestoreCursor => self.swap_alt(),
|
||||
ansi::Mode::TextCursor => self.mode.remove(mode::TEXT_CURSOR),
|
||||
ansi::Mode::ShowCursor => self.mode.remove(mode::SHOW_CURSOR),
|
||||
_ => {
|
||||
println!(".. ignoring unset_mode");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue