2016-06-30 03:56:12 +00:00
|
|
|
// Copyright 2016 Joe Wilm, The Alacritty Project Contributors
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
//
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
//! ANSI Terminal Stream Parsing
|
2016-07-04 04:58:35 +00:00
|
|
|
use std::ops::Range;
|
2016-12-04 23:48:30 +00:00
|
|
|
use std::io;
|
2016-07-04 04:58:35 +00:00
|
|
|
|
2016-09-18 18:17:44 +00:00
|
|
|
use vte;
|
|
|
|
|
2016-07-04 04:12:43 +00:00
|
|
|
use index::{Column, Line};
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
|
2016-05-31 03:44:37 +00:00
|
|
|
use ::Rgb;
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
|
2016-12-17 06:13:51 +00:00
|
|
|
/// The processor wraps a `vte::Parser` to ultimately call methods on a Handler
|
2016-09-18 18:17:44 +00:00
|
|
|
pub struct Processor {
|
|
|
|
state: ProcessorState,
|
|
|
|
parser: vte::Parser,
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
}
|
|
|
|
|
2016-09-18 18:17:44 +00:00
|
|
|
/// Internal state for VTE processor
|
|
|
|
struct ProcessorState;
|
|
|
|
|
2016-12-17 06:13:51 +00:00
|
|
|
/// Helper type that implements `vte::Perform`.
|
2016-09-18 18:17:44 +00:00
|
|
|
///
|
|
|
|
/// Processor creates a Performer when running advance and passes the Performer
|
2016-12-17 06:13:51 +00:00
|
|
|
/// to `vte::Parser`.
|
2016-12-04 23:48:30 +00:00
|
|
|
struct Performer<'a, H: Handler + TermInfo + 'a, W: io::Write + 'a> {
|
2016-09-23 17:12:11 +00:00
|
|
|
_state: &'a mut ProcessorState,
|
2016-12-04 23:48:30 +00:00
|
|
|
handler: &'a mut H,
|
|
|
|
writer: &'a mut W
|
2016-09-18 18:17:44 +00:00
|
|
|
}
|
|
|
|
|
2016-12-04 23:48:30 +00:00
|
|
|
impl<'a, H: Handler + TermInfo + 'a, W: io::Write> Performer<'a, H, W> {
|
2016-09-18 18:17:44 +00:00
|
|
|
/// Create a performer
|
|
|
|
#[inline]
|
2016-12-04 23:48:30 +00:00
|
|
|
pub fn new<'b>(
|
|
|
|
state: &'b mut ProcessorState,
|
|
|
|
handler: &'b mut H,
|
|
|
|
writer: &'b mut W,
|
|
|
|
) -> Performer<'b, H, W> {
|
2016-09-18 18:17:44 +00:00
|
|
|
Performer {
|
2016-09-23 17:12:11 +00:00
|
|
|
_state: state,
|
2016-12-04 23:48:30 +00:00
|
|
|
handler: handler,
|
|
|
|
writer: writer,
|
2016-09-18 18:17:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-17 06:13:51 +00:00
|
|
|
impl Default for Processor {
|
|
|
|
fn default() -> Processor {
|
2016-09-18 18:17:44 +00:00
|
|
|
Processor {
|
|
|
|
state: ProcessorState,
|
|
|
|
parser: vte::Parser::new(),
|
|
|
|
}
|
|
|
|
}
|
2016-12-17 06:13:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl Processor {
|
|
|
|
pub fn new() -> Processor {
|
|
|
|
Default::default()
|
|
|
|
}
|
2016-09-18 18:17:44 +00:00
|
|
|
|
|
|
|
#[inline]
|
2016-12-04 23:48:30 +00:00
|
|
|
pub fn advance<H, W>(
|
|
|
|
&mut self,
|
|
|
|
handler: &mut H,
|
|
|
|
byte: u8,
|
|
|
|
writer: &mut W
|
|
|
|
)
|
|
|
|
where H: Handler + TermInfo,
|
|
|
|
W: io::Write
|
|
|
|
{
|
|
|
|
let mut performer = Performer::new(&mut self.state, handler, writer);
|
2016-09-18 18:17:44 +00:00
|
|
|
self.parser.advance(&mut performer, byte);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-06-08 17:39:49 +00:00
|
|
|
/// Trait that provides properties of terminal
|
|
|
|
pub trait TermInfo {
|
2016-07-04 04:12:43 +00:00
|
|
|
fn lines(&self) -> Line;
|
|
|
|
fn cols(&self) -> Column;
|
2016-06-08 17:39:49 +00:00
|
|
|
}
|
|
|
|
|
2016-09-18 18:17:44 +00:00
|
|
|
/// Type that handles actions from the parser
|
|
|
|
///
|
|
|
|
/// XXX Should probably not provide default impls for everything, but it makes
|
|
|
|
/// writing specific handler impls for tests far easier.
|
|
|
|
pub trait Handler {
|
|
|
|
/// A character to be displayed
|
|
|
|
fn input(&mut self, _c: char) {}
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
|
2016-09-18 18:17:44 +00:00
|
|
|
/// Set cursor to position
|
|
|
|
fn goto(&mut self, Line, Column) {}
|
|
|
|
|
|
|
|
/// Set cursor to specific row
|
|
|
|
fn goto_line(&mut self, Line) {}
|
|
|
|
|
|
|
|
/// Set cursor to specific column
|
|
|
|
fn goto_col(&mut self, Column) {}
|
|
|
|
|
|
|
|
/// Insert blank characters in current line starting from cursor
|
2016-10-10 15:29:51 +00:00
|
|
|
fn insert_blank(&mut self, Column) {}
|
2016-09-18 18:17:44 +00:00
|
|
|
|
|
|
|
/// Move cursor up `rows`
|
|
|
|
fn move_up(&mut self, Line) {}
|
|
|
|
|
|
|
|
/// Move cursor down `rows`
|
|
|
|
fn move_down(&mut self, Line) {}
|
|
|
|
|
|
|
|
/// Identify the terminal (should write back to the pty stream)
|
2016-12-04 23:48:30 +00:00
|
|
|
///
|
|
|
|
/// TODO this should probably return an io::Result
|
|
|
|
fn identify_terminal<W: io::Write>(&mut self, &mut W) {}
|
2016-09-18 18:17:44 +00:00
|
|
|
|
|
|
|
/// Move cursor forward `cols`
|
|
|
|
fn move_forward(&mut self, Column) {}
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
|
2016-09-18 18:17:44 +00:00
|
|
|
/// Move cursor backward `cols`
|
|
|
|
fn move_backward(&mut self, Column) {}
|
|
|
|
|
|
|
|
/// Move cursor down `rows` and set to column 1
|
|
|
|
fn move_down_and_cr(&mut self, Line) {}
|
|
|
|
|
|
|
|
/// Move cursor up `rows` and set to column 1
|
|
|
|
fn move_up_and_cr(&mut self, Line) {}
|
|
|
|
|
|
|
|
/// Put `count` tabs
|
|
|
|
fn put_tab(&mut self, _count: i64) {}
|
|
|
|
|
|
|
|
/// Backspace `count` characters
|
|
|
|
fn backspace(&mut self) {}
|
|
|
|
|
|
|
|
/// Carriage return
|
|
|
|
fn carriage_return(&mut self) {}
|
|
|
|
|
|
|
|
/// Linefeed
|
|
|
|
fn linefeed(&mut self) {}
|
|
|
|
|
|
|
|
/// Ring the bell
|
|
|
|
///
|
|
|
|
/// Hopefully this is never implemented
|
|
|
|
fn bell(&mut self) {}
|
|
|
|
|
|
|
|
/// Substitute char under cursor
|
|
|
|
fn substitute(&mut self) {}
|
|
|
|
|
|
|
|
/// Newline
|
|
|
|
fn newline(&mut self) {}
|
|
|
|
|
|
|
|
/// Set current position as a tabstop
|
|
|
|
fn set_horizontal_tabstop(&mut self) {}
|
|
|
|
|
|
|
|
/// Scroll up `rows` rows
|
|
|
|
fn scroll_up(&mut self, Line) {}
|
|
|
|
|
|
|
|
/// Scroll down `rows` rows
|
|
|
|
fn scroll_down(&mut self, Line) {}
|
|
|
|
|
|
|
|
/// Insert `count` blank lines
|
|
|
|
fn insert_blank_lines(&mut self, Line) {}
|
|
|
|
|
|
|
|
/// Delete `count` lines
|
|
|
|
fn delete_lines(&mut self, Line) {}
|
|
|
|
|
|
|
|
/// Erase `count` chars in current line following cursor
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
///
|
2016-12-17 06:48:04 +00:00
|
|
|
/// Erase means resetting to the default state (default colors, no content,
|
|
|
|
/// no mode flags)
|
2016-09-18 18:17:44 +00:00
|
|
|
fn erase_chars(&mut self, Column) {}
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
|
2016-09-18 18:17:44 +00:00
|
|
|
/// Delete `count` chars
|
|
|
|
///
|
2016-12-17 06:48:04 +00:00
|
|
|
/// Deleting a character is like the delete key on the keyboard - everything
|
|
|
|
/// to the right of the deleted things is shifted left.
|
2016-09-18 18:17:44 +00:00
|
|
|
fn delete_chars(&mut self, Column) {}
|
|
|
|
|
|
|
|
/// Move backward `count` tabs
|
|
|
|
fn move_backward_tabs(&mut self, _count: i64) {}
|
|
|
|
|
|
|
|
/// Move forward `count` tabs
|
|
|
|
fn move_forward_tabs(&mut self, _count: i64) {}
|
|
|
|
|
|
|
|
/// Save current cursor position
|
|
|
|
fn save_cursor_position(&mut self) {}
|
|
|
|
|
|
|
|
/// Restore cursor position
|
|
|
|
fn restore_cursor_position(&mut self) {}
|
|
|
|
|
|
|
|
/// Clear current line
|
|
|
|
fn clear_line(&mut self, _mode: LineClearMode) {}
|
|
|
|
|
|
|
|
/// Clear screen
|
|
|
|
fn clear_screen(&mut self, _mode: ClearMode) {}
|
|
|
|
|
|
|
|
/// Clear tab stops
|
|
|
|
fn clear_tabs(&mut self, _mode: TabulationClearMode) {}
|
|
|
|
|
|
|
|
/// Reset terminal state
|
|
|
|
fn reset_state(&mut self) {}
|
|
|
|
|
|
|
|
/// Reverse Index
|
|
|
|
///
|
2016-12-17 06:48:04 +00:00
|
|
|
/// Move the active position to the same horizontal position on the
|
|
|
|
/// preceding line. If the active position is at the top margin, a scroll
|
|
|
|
/// down is performed
|
2016-09-18 18:17:44 +00:00
|
|
|
fn reverse_index(&mut self) {}
|
|
|
|
|
|
|
|
/// set a terminal attribute
|
|
|
|
fn terminal_attribute(&mut self, _attr: Attr) {}
|
|
|
|
|
|
|
|
/// Set mode
|
|
|
|
fn set_mode(&mut self, _mode: Mode) {}
|
|
|
|
|
|
|
|
/// Unset mode
|
|
|
|
fn unset_mode(&mut self, Mode) {}
|
|
|
|
|
|
|
|
/// DECSTBM - Set the terminal scrolling region
|
|
|
|
fn set_scrolling_region(&mut self, Range<Line>) {}
|
|
|
|
|
|
|
|
/// DECKPAM - Set keypad to applications mode (ESCape instead of digits)
|
|
|
|
fn set_keypad_application_mode(&mut self) {}
|
|
|
|
|
|
|
|
/// DECKPNM - Set keypad to numeric mode (digits intead of ESCape seq)
|
|
|
|
fn unset_keypad_application_mode(&mut self) {}
|
2016-05-31 03:44:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Terminal modes
|
|
|
|
#[derive(Debug, Eq, PartialEq)]
|
|
|
|
pub enum Mode {
|
2016-06-08 04:13:08 +00:00
|
|
|
/// ?1
|
|
|
|
CursorKeys = 1,
|
2016-08-20 03:34:33 +00:00
|
|
|
/// ?6
|
|
|
|
Origin = 6,
|
2016-06-08 04:13:08 +00:00
|
|
|
/// ?12
|
|
|
|
BlinkingCursor = 12,
|
2016-08-20 03:34:33 +00:00
|
|
|
/// ?25
|
|
|
|
ShowCursor = 25,
|
2016-11-24 04:25:37 +00:00
|
|
|
/// ?1000
|
|
|
|
ReportMouseClicks = 1000,
|
2017-01-02 02:28:49 +00:00
|
|
|
/// ?1002
|
|
|
|
ReportMouseMotion = 1002,
|
|
|
|
/// ?1006
|
|
|
|
SgrMouse = 1006,
|
2016-06-08 04:13:08 +00:00
|
|
|
/// ?1049
|
2016-05-31 03:44:37 +00:00
|
|
|
SwapScreenAndSetRestoreCursor = 1049,
|
2016-11-28 22:39:37 +00:00
|
|
|
/// ?2004
|
|
|
|
BracketedPaste = 2004,
|
2016-05-31 03:44:37 +00:00
|
|
|
}
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
|
2016-05-31 03:44:37 +00:00
|
|
|
impl Mode {
|
|
|
|
/// Create mode from a primitive
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
///
|
2016-05-31 03:44:37 +00:00
|
|
|
/// TODO lots of unhandled values..
|
2016-06-08 04:13:08 +00:00
|
|
|
pub fn from_primitive(private: bool, num: i64) -> Option<Mode> {
|
|
|
|
if private {
|
|
|
|
Some(match num {
|
|
|
|
1 => Mode::CursorKeys,
|
2016-08-20 03:34:33 +00:00
|
|
|
6 => Mode::Origin,
|
2016-06-08 04:13:08 +00:00
|
|
|
12 => Mode::BlinkingCursor,
|
2016-06-23 16:42:00 +00:00
|
|
|
25 => Mode::ShowCursor,
|
2016-11-24 04:25:37 +00:00
|
|
|
1000 => Mode::ReportMouseClicks,
|
2017-01-02 02:28:49 +00:00
|
|
|
1002 => Mode::ReportMouseMotion,
|
|
|
|
1006 => Mode::SgrMouse,
|
2016-06-08 04:13:08 +00:00
|
|
|
1049 => Mode::SwapScreenAndSetRestoreCursor,
|
2016-11-28 22:39:37 +00:00
|
|
|
2004 => Mode::BracketedPaste,
|
2016-06-08 04:13:08 +00:00
|
|
|
_ => return None
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
// TODO
|
|
|
|
None
|
|
|
|
}
|
2016-05-31 03:44:37 +00:00
|
|
|
}
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Mode for clearing line
|
|
|
|
///
|
|
|
|
/// Relative to cursor
|
|
|
|
#[derive(Debug)]
|
|
|
|
pub enum LineClearMode {
|
|
|
|
/// Clear right of cursor
|
|
|
|
Right,
|
|
|
|
/// Clear left of cursor
|
|
|
|
Left,
|
|
|
|
/// Clear entire line
|
|
|
|
All,
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Mode for clearing terminal
|
|
|
|
///
|
|
|
|
/// Relative to cursor
|
|
|
|
#[derive(Debug)]
|
|
|
|
pub enum ClearMode {
|
|
|
|
/// Clear below cursor
|
|
|
|
Below,
|
|
|
|
/// Clear above cursor
|
|
|
|
Above,
|
|
|
|
/// Clear entire terminal
|
|
|
|
All,
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Mode for clearing tab stops
|
|
|
|
#[derive(Debug)]
|
|
|
|
pub enum TabulationClearMode {
|
|
|
|
/// Clear stop under cursor
|
|
|
|
Current,
|
|
|
|
/// Clear all stops
|
|
|
|
All,
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Standard colors
|
|
|
|
///
|
|
|
|
/// The order here matters since the enum should be castable to a `usize` for
|
|
|
|
/// indexing a color list.
|
2016-11-20 00:16:20 +00:00
|
|
|
#[derive(Debug, Copy, Clone, Eq, PartialEq, PartialOrd, Ord, Serialize, Deserialize)]
|
2016-12-04 19:14:27 +00:00
|
|
|
pub enum NamedColor {
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
/// Black
|
|
|
|
Black = 0,
|
|
|
|
/// Red
|
|
|
|
Red,
|
|
|
|
/// Green
|
|
|
|
Green,
|
|
|
|
/// Yellow
|
|
|
|
Yellow,
|
|
|
|
/// Blue
|
|
|
|
Blue,
|
|
|
|
/// Magenta
|
|
|
|
Magenta,
|
|
|
|
/// Cyan
|
|
|
|
Cyan,
|
|
|
|
/// White
|
|
|
|
White,
|
|
|
|
/// Bright black
|
|
|
|
BrightBlack,
|
|
|
|
/// Bright red
|
|
|
|
BrightRed,
|
|
|
|
/// Bright green
|
|
|
|
BrightGreen,
|
|
|
|
/// Bright yellow
|
|
|
|
BrightYellow,
|
|
|
|
/// Bright blue
|
|
|
|
BrightBlue,
|
|
|
|
/// Bright magenta
|
|
|
|
BrightMagenta,
|
|
|
|
/// Bright cyan
|
|
|
|
BrightCyan,
|
|
|
|
/// Bright white
|
|
|
|
BrightWhite,
|
2016-10-23 22:37:06 +00:00
|
|
|
/// The foreground color
|
2016-12-04 19:14:27 +00:00
|
|
|
Foreground = 256,
|
2016-10-23 22:37:06 +00:00
|
|
|
/// The background color
|
|
|
|
Background,
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
}
|
|
|
|
|
2016-12-04 21:13:44 +00:00
|
|
|
impl NamedColor {
|
|
|
|
pub fn to_bright(&self) -> Self {
|
|
|
|
match *self {
|
|
|
|
NamedColor::Black => NamedColor::BrightBlack,
|
|
|
|
NamedColor::Red => NamedColor::BrightRed,
|
|
|
|
NamedColor::Green => NamedColor::BrightGreen,
|
|
|
|
NamedColor::Yellow => NamedColor::BrightYellow,
|
|
|
|
NamedColor::Blue => NamedColor::BrightBlue,
|
|
|
|
NamedColor::Magenta => NamedColor::BrightMagenta,
|
|
|
|
NamedColor::Cyan => NamedColor::BrightCyan,
|
|
|
|
NamedColor::White => NamedColor::BrightWhite,
|
|
|
|
val => val
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-04 19:14:27 +00:00
|
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
|
|
|
pub enum Color {
|
|
|
|
Named(NamedColor),
|
|
|
|
Spec(Rgb),
|
|
|
|
Indexed(u8),
|
|
|
|
}
|
|
|
|
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
/// Terminal character attributes
|
|
|
|
#[derive(Debug, Eq, PartialEq)]
|
|
|
|
pub enum Attr {
|
|
|
|
/// Clear all special abilities
|
|
|
|
Reset,
|
|
|
|
/// Bold text
|
|
|
|
Bold,
|
|
|
|
/// Dim or secondary color
|
|
|
|
Dim,
|
|
|
|
/// Italic text
|
|
|
|
Italic,
|
|
|
|
/// Underscore text
|
|
|
|
Underscore,
|
|
|
|
/// Blink cursor slowly
|
|
|
|
BlinkSlow,
|
|
|
|
/// Blink cursor fast
|
|
|
|
BlinkFast,
|
|
|
|
/// Invert colors
|
|
|
|
Reverse,
|
|
|
|
/// Do not display characters
|
|
|
|
Hidden,
|
|
|
|
/// Strikethrough text
|
|
|
|
Strike,
|
|
|
|
/// Cancel bold and dim
|
|
|
|
CancelBoldDim,
|
|
|
|
/// Cancel italic
|
|
|
|
CancelItalic,
|
|
|
|
/// Cancel underline
|
|
|
|
CancelUnderline,
|
|
|
|
/// Cancel blink
|
|
|
|
CancelBlink,
|
|
|
|
/// Cancel inversion
|
|
|
|
CancelReverse,
|
|
|
|
/// Cancel text hiding
|
|
|
|
CancelHidden,
|
|
|
|
/// Cancel strike through
|
|
|
|
CancelStrike,
|
|
|
|
/// Set indexed foreground color
|
|
|
|
Foreground(Color),
|
|
|
|
/// Set indexed background color
|
|
|
|
Background(Color),
|
|
|
|
}
|
|
|
|
|
2016-12-04 23:48:30 +00:00
|
|
|
impl<'a, H, W> vte::Perform for Performer<'a, H, W>
|
|
|
|
where H: Handler + TermInfo + 'a,
|
|
|
|
W: io::Write + 'a
|
|
|
|
{
|
2016-09-18 18:17:44 +00:00
|
|
|
#[inline]
|
|
|
|
fn print(&mut self, c: char) {
|
|
|
|
self.handler.input(c);
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
}
|
|
|
|
|
2016-09-18 18:17:44 +00:00
|
|
|
#[inline]
|
|
|
|
fn execute(&mut self, byte: u8) {
|
|
|
|
match byte {
|
|
|
|
C0::HT => self.handler.put_tab(1),
|
|
|
|
C0::BS => self.handler.backspace(),
|
|
|
|
C0::CR => self.handler.carriage_return(),
|
|
|
|
C0::LF | C0::VT | C0::FF => self.handler.linefeed(),
|
|
|
|
C0::BEL => self.handler.bell(),
|
|
|
|
C0::SUB => self.handler.substitute(),
|
|
|
|
C1::NEL => self.handler.newline(),
|
|
|
|
C1::HTS => self.handler.set_horizontal_tabstop(),
|
2016-12-04 23:48:30 +00:00
|
|
|
C1::DECID => self.handler.identify_terminal(self.writer),
|
2016-09-23 16:24:26 +00:00
|
|
|
_ => err_println!("[unhandled] execute byte={:02x}", byte)
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-18 18:17:44 +00:00
|
|
|
#[inline]
|
|
|
|
fn hook(&mut self, params: &[i64], intermediates: &[u8], ignore: bool, byte: u8) {
|
|
|
|
err_println!("[unhandled hook] params={:?}, ints: {:?}, ignore: {:?}, byte={:?}",
|
|
|
|
params, intermediates, ignore, byte as char);
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
}
|
|
|
|
|
2016-09-18 18:17:44 +00:00
|
|
|
#[inline]
|
|
|
|
fn put(&mut self, byte: u8) {
|
|
|
|
err_println!("[unhandled put] byte={:?}", byte);
|
2016-06-07 00:41:03 +00:00
|
|
|
}
|
|
|
|
|
2016-09-18 18:17:44 +00:00
|
|
|
#[inline]
|
|
|
|
fn unhook(&mut self, byte: u8) {
|
|
|
|
err_println!("[unhandled unhook] byte={:?}", byte);
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
}
|
|
|
|
|
2016-09-18 18:17:44 +00:00
|
|
|
#[inline]
|
|
|
|
fn osc_start(&mut self) {
|
|
|
|
err_println!("[unhandled osc_start]");
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
}
|
|
|
|
|
2016-09-18 18:17:44 +00:00
|
|
|
#[inline]
|
|
|
|
fn osc_put(&mut self, byte: u8) {
|
|
|
|
err_println!("[unhandled osc_put] byte={:?}", byte as char);
|
|
|
|
}
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
|
2016-09-18 18:17:44 +00:00
|
|
|
#[inline]
|
|
|
|
fn osc_end(&mut self, byte: u8) {
|
|
|
|
err_println!("[unhandled osc_end] byte={:?}", byte);
|
|
|
|
}
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
|
2016-09-18 18:17:44 +00:00
|
|
|
#[inline]
|
2016-12-04 23:48:30 +00:00
|
|
|
fn csi_dispatch(
|
|
|
|
&mut self,
|
|
|
|
args: &[i64],
|
|
|
|
intermediates: &[u8],
|
|
|
|
_ignore: bool,
|
|
|
|
action: char
|
|
|
|
) {
|
2016-09-18 18:17:44 +00:00
|
|
|
let private = intermediates.get(0).map(|b| *b == b'?').unwrap_or(false);
|
|
|
|
let handler = &mut self.handler;
|
2016-12-04 23:48:30 +00:00
|
|
|
let writer = &mut self.writer;
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
|
|
|
|
|
2016-05-31 03:44:37 +00:00
|
|
|
macro_rules! unhandled {
|
|
|
|
() => {{
|
2016-09-18 18:17:44 +00:00
|
|
|
err_println!("[Unhandled CSI] action={:?}, args={:?}, intermediates={:?}",
|
|
|
|
action, args, intermediates);
|
2016-05-31 03:44:37 +00:00
|
|
|
return;
|
|
|
|
}}
|
|
|
|
}
|
|
|
|
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
macro_rules! arg_or_default {
|
2016-09-18 18:17:44 +00:00
|
|
|
(idx: $idx:expr, default: $default:expr) => {
|
|
|
|
args.get($idx).and_then(|v| {
|
|
|
|
if *v == 0 {
|
|
|
|
None
|
|
|
|
} else {
|
|
|
|
Some(*v)
|
|
|
|
}
|
|
|
|
}).unwrap_or($default)
|
2016-05-31 03:44:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-18 18:17:44 +00:00
|
|
|
match action {
|
2016-10-10 15:29:51 +00:00
|
|
|
'@' => handler.insert_blank(Column(arg_or_default!(idx: 0, default: 1) as usize)),
|
2016-05-31 03:44:37 +00:00
|
|
|
'A' => {
|
2016-09-18 18:17:44 +00:00
|
|
|
handler.move_up(Line(arg_or_default!(idx: 0, default: 1) as usize));
|
2016-05-31 03:44:37 +00:00
|
|
|
},
|
2016-09-18 18:17:44 +00:00
|
|
|
'B' | 'e' => handler.move_down(Line(arg_or_default!(idx: 0, default: 1) as usize)),
|
2016-12-17 06:13:51 +00:00
|
|
|
'c' | 'n' => handler.identify_terminal(writer),
|
2016-09-18 18:17:44 +00:00
|
|
|
'C' | 'a' => handler.move_forward(Column(arg_or_default!(idx: 0, default: 1) as usize)),
|
|
|
|
'D' => handler.move_backward(Column(arg_or_default!(idx: 0, default: 1) as usize)),
|
|
|
|
'E' => handler.move_down_and_cr(Line(arg_or_default!(idx: 0, default: 1) as usize)),
|
|
|
|
'F' => handler.move_up_and_cr(Line(arg_or_default!(idx: 0, default: 1) as usize)),
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
'g' => {
|
2016-09-18 18:17:44 +00:00
|
|
|
let mode = match arg_or_default!(idx: 0, default: 0) {
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
0 => TabulationClearMode::Current,
|
|
|
|
3 => TabulationClearMode::All,
|
2016-09-18 18:17:44 +00:00
|
|
|
_ => unhandled!(),
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
};
|
|
|
|
|
2016-05-31 03:44:37 +00:00
|
|
|
handler.clear_tabs(mode);
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
},
|
2016-09-18 18:17:44 +00:00
|
|
|
'G' | '`' => handler.goto_col(Column(arg_or_default!(idx: 0, default: 1) as usize - 1)),
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
'H' | 'f' => {
|
2016-09-18 18:17:44 +00:00
|
|
|
let y = arg_or_default!(idx: 0, default: 1) as usize;
|
|
|
|
let x = arg_or_default!(idx: 1, default: 1) as usize;
|
2016-07-04 15:28:14 +00:00
|
|
|
handler.goto(Line(y - 1), Column(x - 1));
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
},
|
2016-09-18 18:17:44 +00:00
|
|
|
'I' => handler.move_forward_tabs(arg_or_default!(idx: 0, default: 1)),
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
'J' => {
|
2016-09-18 18:17:44 +00:00
|
|
|
let mode = match arg_or_default!(idx: 0, default: 0) {
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
0 => ClearMode::Below,
|
|
|
|
1 => ClearMode::Above,
|
|
|
|
2 => ClearMode::All,
|
2016-09-18 18:17:44 +00:00
|
|
|
_ => unhandled!(),
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
};
|
|
|
|
|
2016-05-31 03:44:37 +00:00
|
|
|
handler.clear_screen(mode);
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
},
|
|
|
|
'K' => {
|
2016-09-18 18:17:44 +00:00
|
|
|
let mode = match arg_or_default!(idx: 0, default: 0) {
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
0 => LineClearMode::Right,
|
|
|
|
1 => LineClearMode::Left,
|
|
|
|
2 => LineClearMode::All,
|
2016-09-18 18:17:44 +00:00
|
|
|
_ => unhandled!(),
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
};
|
|
|
|
|
2016-05-31 03:44:37 +00:00
|
|
|
handler.clear_line(mode);
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
},
|
2016-09-18 18:17:44 +00:00
|
|
|
'S' => handler.scroll_up(Line(arg_or_default!(idx: 0, default: 1) as usize)),
|
|
|
|
'T' => handler.scroll_down(Line(arg_or_default!(idx: 0, default: 1) as usize)),
|
|
|
|
'L' => handler.insert_blank_lines(Line(arg_or_default!(idx: 0, default: 1) as usize)),
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
'l' => {
|
2016-09-18 18:17:44 +00:00
|
|
|
let mode = Mode::from_primitive(private, arg_or_default!(idx: 0, default: 0));
|
2016-05-31 03:44:37 +00:00
|
|
|
match mode {
|
2016-06-23 16:42:00 +00:00
|
|
|
Some(mode) => handler.unset_mode(mode),
|
2016-05-31 03:44:37 +00:00
|
|
|
None => unhandled!(),
|
|
|
|
}
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
},
|
2016-09-18 18:17:44 +00:00
|
|
|
'M' => handler.delete_lines(Line(arg_or_default!(idx: 0, default: 1) as usize)),
|
|
|
|
'X' => handler.erase_chars(Column(arg_or_default!(idx: 0, default: 1) as usize)),
|
|
|
|
'P' => handler.delete_chars(Column(arg_or_default!(idx: 0, default: 1) as usize)),
|
|
|
|
'Z' => handler.move_backward_tabs(arg_or_default!(idx: 0, default: 1)),
|
|
|
|
'd' => handler.goto_line(Line(arg_or_default!(idx: 0, default: 1) as usize - 1)),
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
'h' => {
|
2016-09-18 18:17:44 +00:00
|
|
|
let mode = Mode::from_primitive(private, arg_or_default!(idx: 0, default: 0));
|
2016-05-31 03:44:37 +00:00
|
|
|
match mode {
|
2016-06-23 16:42:00 +00:00
|
|
|
Some(mode) => handler.set_mode(mode),
|
2016-05-31 03:44:37 +00:00
|
|
|
None => unhandled!(),
|
|
|
|
}
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
},
|
|
|
|
'm' => {
|
|
|
|
// Sometimes a C-style for loop is just what you need
|
|
|
|
let mut i = 0; // C-for initializer
|
2016-09-18 18:17:44 +00:00
|
|
|
if args.len() == 0 {
|
|
|
|
handler.terminal_attribute(Attr::Reset);
|
|
|
|
return;
|
|
|
|
}
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
loop {
|
2016-09-18 18:17:44 +00:00
|
|
|
// println!("args.len = {}; i={}", args.len(), i);
|
|
|
|
if i >= args.len() { // C-for condition
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2016-09-18 18:17:44 +00:00
|
|
|
let attr = match args[i] {
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
0 => Attr::Reset,
|
|
|
|
1 => Attr::Bold,
|
|
|
|
2 => Attr::Dim,
|
|
|
|
3 => Attr::Italic,
|
|
|
|
4 => Attr::Underscore,
|
|
|
|
5 => Attr::BlinkSlow,
|
|
|
|
6 => Attr::BlinkFast,
|
|
|
|
7 => Attr::Reverse,
|
|
|
|
8 => Attr::Hidden,
|
|
|
|
9 => Attr::Strike,
|
|
|
|
22 => Attr::CancelBoldDim,
|
|
|
|
23 => Attr::CancelItalic,
|
|
|
|
24 => Attr::CancelUnderline,
|
|
|
|
25 => Attr::CancelBlink,
|
|
|
|
27 => Attr::CancelReverse,
|
|
|
|
28 => Attr::CancelHidden,
|
|
|
|
29 => Attr::CancelStrike,
|
2016-12-04 19:14:27 +00:00
|
|
|
30 => Attr::Foreground(Color::Named(NamedColor::Black)),
|
|
|
|
31 => Attr::Foreground(Color::Named(NamedColor::Red)),
|
|
|
|
32 => Attr::Foreground(Color::Named(NamedColor::Green)),
|
|
|
|
33 => Attr::Foreground(Color::Named(NamedColor::Yellow)),
|
|
|
|
34 => Attr::Foreground(Color::Named(NamedColor::Blue)),
|
|
|
|
35 => Attr::Foreground(Color::Named(NamedColor::Magenta)),
|
|
|
|
36 => Attr::Foreground(Color::Named(NamedColor::Cyan)),
|
|
|
|
37 => Attr::Foreground(Color::Named(NamedColor::White)),
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
38 => {
|
2016-12-04 19:14:27 +00:00
|
|
|
if let Some(color) = parse_color(&args[i..], &mut i) {
|
|
|
|
Attr::Foreground(color)
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
} else {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
},
|
2016-12-04 19:14:27 +00:00
|
|
|
39 => Attr::Foreground(Color::Named(NamedColor::Foreground)),
|
|
|
|
40 => Attr::Background(Color::Named(NamedColor::Black)),
|
|
|
|
41 => Attr::Background(Color::Named(NamedColor::Red)),
|
|
|
|
42 => Attr::Background(Color::Named(NamedColor::Green)),
|
|
|
|
43 => Attr::Background(Color::Named(NamedColor::Yellow)),
|
|
|
|
44 => Attr::Background(Color::Named(NamedColor::Blue)),
|
|
|
|
45 => Attr::Background(Color::Named(NamedColor::Magenta)),
|
|
|
|
46 => Attr::Background(Color::Named(NamedColor::Cyan)),
|
|
|
|
47 => Attr::Background(Color::Named(NamedColor::White)),
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
48 => {
|
2016-12-04 19:14:27 +00:00
|
|
|
if let Some(color) = parse_color(&args[i..], &mut i) {
|
|
|
|
Attr::Background(color)
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
} else {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
},
|
2016-12-04 19:14:27 +00:00
|
|
|
49 => Attr::Background(Color::Named(NamedColor::Background)),
|
|
|
|
90 => Attr::Foreground(Color::Named(NamedColor::BrightBlack)),
|
|
|
|
91 => Attr::Foreground(Color::Named(NamedColor::BrightRed)),
|
|
|
|
92 => Attr::Foreground(Color::Named(NamedColor::BrightGreen)),
|
|
|
|
93 => Attr::Foreground(Color::Named(NamedColor::BrightYellow)),
|
|
|
|
94 => Attr::Foreground(Color::Named(NamedColor::BrightBlue)),
|
|
|
|
95 => Attr::Foreground(Color::Named(NamedColor::BrightMagenta)),
|
|
|
|
96 => Attr::Foreground(Color::Named(NamedColor::BrightCyan)),
|
|
|
|
97 => Attr::Foreground(Color::Named(NamedColor::BrightWhite)),
|
2016-12-17 06:13:51 +00:00
|
|
|
100 => Attr::Background(Color::Named(NamedColor::BrightBlack)),
|
|
|
|
101 => Attr::Background(Color::Named(NamedColor::BrightRed)),
|
|
|
|
102 => Attr::Background(Color::Named(NamedColor::BrightGreen)),
|
|
|
|
103 => Attr::Background(Color::Named(NamedColor::BrightYellow)),
|
|
|
|
104 => Attr::Background(Color::Named(NamedColor::BrightBlue)),
|
|
|
|
105 => Attr::Background(Color::Named(NamedColor::BrightMagenta)),
|
|
|
|
106 => Attr::Background(Color::Named(NamedColor::BrightCyan)),
|
|
|
|
107 => Attr::Background(Color::Named(NamedColor::BrightWhite)),
|
2016-09-18 18:17:44 +00:00
|
|
|
_ => unhandled!(),
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
};
|
|
|
|
|
2016-05-31 03:44:37 +00:00
|
|
|
handler.terminal_attribute(attr);
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
|
|
|
|
i += 1; // C-for expr
|
|
|
|
}
|
|
|
|
}
|
2016-12-17 06:13:51 +00:00
|
|
|
// TODO this should be a device status report
|
|
|
|
// 'n' => handler.identify_terminal(writer),
|
2016-06-08 17:39:49 +00:00
|
|
|
'r' => {
|
|
|
|
if private {
|
2016-09-18 18:17:44 +00:00
|
|
|
unhandled!();
|
2016-06-08 17:39:49 +00:00
|
|
|
}
|
2016-09-18 18:17:44 +00:00
|
|
|
let arg0 = arg_or_default!(idx: 0, default: 1) as usize;
|
|
|
|
let top = Line(arg0 - 1);
|
2016-07-04 04:58:35 +00:00
|
|
|
// Bottom should be included in the range, but range end is not
|
|
|
|
// usually included. One option would be to use an inclusive
|
|
|
|
// range, but instead we just let the open range end be 1
|
|
|
|
// higher.
|
2016-09-18 18:17:44 +00:00
|
|
|
let arg1 = arg_or_default!(idx: 1, default: handler.lines().0 as _) as usize;
|
|
|
|
let bottom = Line(arg1);
|
2016-07-04 04:58:35 +00:00
|
|
|
|
|
|
|
handler.set_scrolling_region(top..bottom);
|
2016-06-08 17:39:49 +00:00
|
|
|
},
|
2016-05-31 03:44:37 +00:00
|
|
|
's' => handler.save_cursor_position(),
|
|
|
|
'u' => handler.restore_cursor_position(),
|
2016-09-18 18:17:44 +00:00
|
|
|
_ => unhandled!(),
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-18 18:17:44 +00:00
|
|
|
#[inline]
|
2016-12-17 06:48:04 +00:00
|
|
|
fn esc_dispatch(
|
|
|
|
&mut self,
|
|
|
|
params: &[i64],
|
|
|
|
intermediates: &[u8],
|
|
|
|
_ignore: bool,
|
|
|
|
byte: u8
|
|
|
|
) {
|
2016-09-18 18:17:44 +00:00
|
|
|
match byte {
|
|
|
|
b'D' => self.handler.linefeed(),
|
|
|
|
b'E' => self.handler.newline(),
|
|
|
|
b'H' => self.handler.set_horizontal_tabstop(),
|
|
|
|
b'M' => self.handler.reverse_index(),
|
2016-12-04 23:48:30 +00:00
|
|
|
b'Z' => self.handler.identify_terminal(self.writer),
|
2016-09-18 18:17:44 +00:00
|
|
|
b'c' => self.handler.reset_state(),
|
|
|
|
b'7' => self.handler.save_cursor_position(),
|
|
|
|
b'8' => self.handler.restore_cursor_position(),
|
|
|
|
b'=' => self.handler.set_keypad_application_mode(),
|
|
|
|
b'>' => self.handler.unset_keypad_application_mode(),
|
2016-09-23 16:21:51 +00:00
|
|
|
_ => err_println!("[unhandled] esc_dispatch params={:?}, ints={:?}, byte={:?} ({:02x})",
|
|
|
|
params, intermediates, byte as char, byte),
|
2016-09-18 18:17:44 +00:00
|
|
|
}
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Parse a color specifier from list of attributes
|
2016-12-04 19:14:27 +00:00
|
|
|
fn parse_color(attrs: &[i64], i: &mut usize) -> Option<Color> {
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
if attrs.len() < 2 {
|
|
|
|
return None;
|
|
|
|
}
|
|
|
|
|
|
|
|
match attrs[*i+1] {
|
|
|
|
2 => {
|
|
|
|
// RGB color spec
|
|
|
|
if attrs.len() < 5 {
|
|
|
|
err_println!("Expected RGB color spec; got {:?}", attrs);
|
|
|
|
return None;
|
|
|
|
}
|
|
|
|
|
|
|
|
let r = attrs[*i+2];
|
|
|
|
let g = attrs[*i+3];
|
|
|
|
let b = attrs[*i+4];
|
|
|
|
|
2016-12-17 06:13:51 +00:00
|
|
|
*i += 4;
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
|
|
|
|
let range = 0...255;
|
|
|
|
if !range.contains(r) || !range.contains(g) || !range.contains(b) {
|
|
|
|
err_println!("Invalid RGB color spec: ({}, {}, {})", r, g, b);
|
|
|
|
return None;
|
|
|
|
}
|
|
|
|
|
2016-12-04 19:14:27 +00:00
|
|
|
Some(Color::Spec(Rgb {
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
r: r as u8,
|
|
|
|
g: g as u8,
|
|
|
|
b: b as u8
|
2016-12-04 19:14:27 +00:00
|
|
|
}))
|
|
|
|
},
|
|
|
|
5 => {
|
|
|
|
if attrs.len() < 3 {
|
|
|
|
err_println!("Expected color index; got {:?}", attrs);
|
|
|
|
None
|
|
|
|
} else {
|
2016-12-17 06:13:51 +00:00
|
|
|
*i += 2;
|
2016-12-04 19:14:27 +00:00
|
|
|
let idx = attrs[*i];
|
|
|
|
match idx {
|
|
|
|
0 ... 255 => {
|
|
|
|
Some(Color::Indexed(idx as u8))
|
|
|
|
},
|
|
|
|
_ => {
|
|
|
|
err_println!("Invalid color index: {}", idx);
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
},
|
|
|
|
_ => {
|
|
|
|
err_println!("Unexpected color attr: {}", attrs[*i+1]);
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// C0 set of 7-bit control characters (from ANSI X3.4-1977).
|
2016-06-09 15:30:55 +00:00
|
|
|
#[allow(non_snake_case)]
|
|
|
|
pub mod C0 {
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
/// Null filler, terminal should ignore this character
|
2016-09-18 18:17:44 +00:00
|
|
|
pub const NUL: u8 = 0x00;
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
/// Start of Header
|
2016-09-18 18:17:44 +00:00
|
|
|
pub const SOH: u8 = 0x01;
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
/// Start of Text, implied end of header
|
2016-09-18 18:17:44 +00:00
|
|
|
pub const STX: u8 = 0x02;
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
/// End of Text, causes some terminal to respond with ACK or NAK
|
2016-09-18 18:17:44 +00:00
|
|
|
pub const ETX: u8 = 0x03;
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
/// End of Transmission
|
2016-09-18 18:17:44 +00:00
|
|
|
pub const EOT: u8 = 0x04;
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
/// Enquiry, causes terminal to send ANSWER-BACK ID
|
2016-09-18 18:17:44 +00:00
|
|
|
pub const ENQ: u8 = 0x05;
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
/// Acknowledge, usually sent by terminal in response to ETX
|
2016-09-18 18:17:44 +00:00
|
|
|
pub const ACK: u8 = 0x06;
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
/// Bell, triggers the bell, buzzer, or beeper on the terminal
|
2016-09-18 18:17:44 +00:00
|
|
|
pub const BEL: u8 = 0x07;
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
/// Backspace, can be used to define overstruck characters
|
2016-09-18 18:17:44 +00:00
|
|
|
pub const BS: u8 = 0x08;
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
/// Horizontal Tabulation, move to next predetermined position
|
2016-09-18 18:17:44 +00:00
|
|
|
pub const HT: u8 = 0x09;
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
/// Linefeed, move to same position on next line (see also NL)
|
2016-09-18 18:17:44 +00:00
|
|
|
pub const LF: u8 = 0x0A;
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
/// Vertical Tabulation, move to next predetermined line
|
2016-09-18 18:17:44 +00:00
|
|
|
pub const VT: u8 = 0x0B;
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
/// Form Feed, move to next form or page
|
2016-09-18 18:17:44 +00:00
|
|
|
pub const FF: u8 = 0x0C;
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
/// Carriage Return, move to first character of current line
|
2016-09-18 18:17:44 +00:00
|
|
|
pub const CR: u8 = 0x0D;
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
/// Shift Out, switch to G1 (other half of character set)
|
2016-09-18 18:17:44 +00:00
|
|
|
pub const SO: u8 = 0x0E;
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
/// Shift In, switch to G0 (normal half of character set)
|
2016-09-18 18:17:44 +00:00
|
|
|
pub const SI: u8 = 0x0F;
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
/// Data Link Escape, interpret next control character specially
|
2016-09-18 18:17:44 +00:00
|
|
|
pub const DLE: u8 = 0x10;
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
/// (DC1) Terminal is allowed to resume transmitting
|
2016-09-18 18:17:44 +00:00
|
|
|
pub const XON: u8 = 0x11;
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
/// Device Control 2, causes ASR-33 to activate paper-tape reader
|
2016-09-18 18:17:44 +00:00
|
|
|
pub const DC2: u8 = 0x12;
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
/// (DC2) Terminal must pause and refrain from transmitting
|
2016-09-18 18:17:44 +00:00
|
|
|
pub const XOFF: u8 = 0x13;
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
/// Device Control 4, causes ASR-33 to deactivate paper-tape reader
|
2016-09-18 18:17:44 +00:00
|
|
|
pub const DC4: u8 = 0x14;
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
/// Negative Acknowledge, used sometimes with ETX and ACK
|
2016-09-18 18:17:44 +00:00
|
|
|
pub const NAK: u8 = 0x15;
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
/// Synchronous Idle, used to maintain timing in Sync communication
|
2016-09-18 18:17:44 +00:00
|
|
|
pub const SYN: u8 = 0x16;
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
/// End of Transmission block
|
2016-09-18 18:17:44 +00:00
|
|
|
pub const ETB: u8 = 0x17;
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
/// Cancel (makes VT100 abort current escape sequence if any)
|
2016-09-18 18:17:44 +00:00
|
|
|
pub const CAN: u8 = 0x18;
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
/// End of Medium
|
2016-09-18 18:17:44 +00:00
|
|
|
pub const EM: u8 = 0x19;
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
/// Substitute (VT100 uses this to display parity errors)
|
2016-09-18 18:17:44 +00:00
|
|
|
pub const SUB: u8 = 0x1A;
|
2016-12-17 06:13:51 +00:00
|
|
|
/// Prefix to an escape sequence
|
2016-09-18 18:17:44 +00:00
|
|
|
pub const ESC: u8 = 0x1B;
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
/// File Separator
|
2016-09-18 18:17:44 +00:00
|
|
|
pub const FS: u8 = 0x1C;
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
/// Group Separator
|
2016-09-18 18:17:44 +00:00
|
|
|
pub const GS: u8 = 0x1D;
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
/// Record Separator (sent by VT132 in block-transfer mode)
|
2016-09-18 18:17:44 +00:00
|
|
|
pub const RS: u8 = 0x1E;
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
/// Unit Separator
|
2016-09-18 18:17:44 +00:00
|
|
|
pub const US: u8 = 0x1F;
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
/// Delete, should be ignored by terminal
|
2016-09-18 18:17:44 +00:00
|
|
|
pub const DEL: u8 = 0x7f;
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// C1 set of 8-bit control characters (from ANSI X3.64-1979)
|
|
|
|
///
|
|
|
|
/// 0x80 (@), 0x81 (A), 0x82 (B), 0x83 (C) are reserved
|
|
|
|
/// 0x98 (X), 0x99 (Y) are reserved
|
|
|
|
/// 0x9a (Z) is resezved, but causes DEC terminals to respond with DA codes
|
2016-06-09 15:30:55 +00:00
|
|
|
#[allow(non_snake_case)]
|
|
|
|
pub mod C1 {
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
/// Reserved
|
2016-09-18 18:17:44 +00:00
|
|
|
pub const PAD: u8 = 0x80;
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
/// Reserved
|
2016-09-18 18:17:44 +00:00
|
|
|
pub const HOP: u8 = 0x81;
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
/// Reserved
|
2016-09-18 18:17:44 +00:00
|
|
|
pub const BPH: u8 = 0x82;
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
/// Reserved
|
2016-09-18 18:17:44 +00:00
|
|
|
pub const NBH: u8 = 0x83;
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
/// Index, moves down one line same column regardless of NL
|
2016-09-18 18:17:44 +00:00
|
|
|
pub const IND: u8 = 0x84;
|
2016-12-17 06:13:51 +00:00
|
|
|
/// New line, moves done one line and to first column (CR+LF)
|
2016-09-18 18:17:44 +00:00
|
|
|
pub const NEL: u8 = 0x85;
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
/// Start of Selected Area to be as charsent to auxiliary output device
|
2016-09-18 18:17:44 +00:00
|
|
|
pub const SSA: u8 = 0x86;
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
/// End of Selected Area to be sent to auxiliary output device
|
2016-09-18 18:17:44 +00:00
|
|
|
pub const ESA: u8 = 0x87;
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
/// Horizontal Tabulation Set at current position
|
2016-09-18 18:17:44 +00:00
|
|
|
pub const HTS: u8 = 0x88;
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
/// Hor Tab Justify, moves string to next tab position
|
2016-09-18 18:17:44 +00:00
|
|
|
pub const HTJ: u8 = 0x89;
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
/// Vertical Tabulation Set at current line
|
2016-09-18 18:17:44 +00:00
|
|
|
pub const VTS: u8 = 0x8A;
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
/// Partial Line Down (subscript)
|
2016-09-18 18:17:44 +00:00
|
|
|
pub const PLD: u8 = 0x8B;
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
/// Partial Line Up (superscript)
|
2016-09-18 18:17:44 +00:00
|
|
|
pub const PLU: u8 = 0x8C;
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
/// Reverse Index, go up one line, reverse scroll if necessary
|
2016-09-18 18:17:44 +00:00
|
|
|
pub const RI: u8 = 0x8D;
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
/// Single Shift to G2
|
2016-09-18 18:17:44 +00:00
|
|
|
pub const SS2: u8 = 0x8E;
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
/// Single Shift to G3 (VT100 uses this for sending PF keys)
|
2016-09-18 18:17:44 +00:00
|
|
|
pub const SS3: u8 = 0x8F;
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
/// Device Control String, terminated by ST (VT125 enters graphics)
|
2016-09-18 18:17:44 +00:00
|
|
|
pub const DCS: u8 = 0x90;
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
/// Private Use 1
|
2016-09-18 18:17:44 +00:00
|
|
|
pub const PU1: u8 = 0x91;
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
/// Private Use 2
|
2016-09-18 18:17:44 +00:00
|
|
|
pub const PU2: u8 = 0x92;
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
/// Set Transmit State
|
2016-09-18 18:17:44 +00:00
|
|
|
pub const STS: u8 = 0x93;
|
2016-12-17 06:13:51 +00:00
|
|
|
/// Cancel character, ignore previous character
|
2016-09-18 18:17:44 +00:00
|
|
|
pub const CCH: u8 = 0x94;
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
/// Message Waiting, turns on an indicator on the terminal
|
2016-09-18 18:17:44 +00:00
|
|
|
pub const MW: u8 = 0x95;
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
/// Start of Protected Area
|
2016-09-18 18:17:44 +00:00
|
|
|
pub const SPA: u8 = 0x96;
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
/// End of Protected Area
|
2016-09-18 18:17:44 +00:00
|
|
|
pub const EPA: u8 = 0x97;
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
/// SOS
|
2016-09-18 18:17:44 +00:00
|
|
|
pub const SOS: u8 = 0x98;
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
/// SGCI
|
2016-09-18 18:17:44 +00:00
|
|
|
pub const SGCI: u8 = 0x99;
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
/// DECID - Identify Terminal
|
2016-09-18 18:17:44 +00:00
|
|
|
pub const DECID: u8 = 0x9a;
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
/// Control Sequence Introducer (described in a seperate table)
|
2016-09-18 18:17:44 +00:00
|
|
|
pub const CSI: u8 = 0x9B;
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
/// String Terminator (VT125 exits graphics)
|
2016-09-18 18:17:44 +00:00
|
|
|
pub const ST: u8 = 0x9C;
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
/// Operating System Command (reprograms intelligent terminal)
|
2016-09-18 18:17:44 +00:00
|
|
|
pub const OSC: u8 = 0x9D;
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
/// Privacy Message (password verification), terminated by ST
|
2016-09-18 18:17:44 +00:00
|
|
|
pub const PM: u8 = 0x9E;
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
/// Application Program Command (to word processor), term by ST
|
2016-09-18 18:17:44 +00:00
|
|
|
pub const APC: u8 = 0x9F;
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
}
|
|
|
|
|
2016-07-30 01:01:10 +00:00
|
|
|
// Tests for parsing escape sequences
|
|
|
|
//
|
|
|
|
// Byte sequences used in these tests are recording of pty stdout.
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
#[cfg(test)]
|
|
|
|
mod tests {
|
2016-12-04 23:48:30 +00:00
|
|
|
use std::io;
|
2016-07-04 04:12:43 +00:00
|
|
|
use index::{Line, Column};
|
2016-12-04 19:14:27 +00:00
|
|
|
use super::{Processor, Handler, Attr, TermInfo, Color};
|
2016-05-31 03:44:37 +00:00
|
|
|
use ::Rgb;
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
|
2016-12-04 23:48:30 +00:00
|
|
|
/// The /dev/null of io::Write
|
|
|
|
struct Void;
|
|
|
|
|
|
|
|
impl io::Write for Void {
|
|
|
|
fn write(&mut self, bytes: &[u8]) -> io::Result<usize> {
|
|
|
|
Ok(bytes.len())
|
|
|
|
}
|
|
|
|
|
|
|
|
fn flush(&mut self) -> io::Result<()> {
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-08 17:39:49 +00:00
|
|
|
#[derive(Default)]
|
|
|
|
struct AttrHandler {
|
|
|
|
attr: Option<Attr>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Handler for AttrHandler {
|
|
|
|
fn terminal_attribute(&mut self, attr: Attr) {
|
|
|
|
self.attr = Some(attr);
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
}
|
2016-06-08 17:39:49 +00:00
|
|
|
}
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
|
2016-06-08 17:39:49 +00:00
|
|
|
impl TermInfo for AttrHandler {
|
2016-07-04 04:12:43 +00:00
|
|
|
fn lines(&self) -> Line {
|
|
|
|
Line(24)
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
}
|
|
|
|
|
2016-07-04 04:12:43 +00:00
|
|
|
fn cols(&self) -> Column {
|
|
|
|
Column(80)
|
2016-06-08 17:39:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn parse_control_attribute() {
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
static BYTES: &'static [u8] = &[
|
|
|
|
0x1b, 0x5b, 0x31, 0x6d
|
|
|
|
];
|
|
|
|
|
2016-09-18 18:17:44 +00:00
|
|
|
let mut parser = Processor::new();
|
2016-06-08 17:39:49 +00:00
|
|
|
let mut handler = AttrHandler::default();
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
|
2016-09-18 18:17:44 +00:00
|
|
|
for byte in &BYTES[..] {
|
2016-12-04 23:48:30 +00:00
|
|
|
parser.advance(&mut handler, *byte, &mut Void);
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
}
|
|
|
|
|
2016-05-31 03:44:37 +00:00
|
|
|
assert_eq!(handler.attr, Some(Attr::Bold));
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn parse_truecolor_attr() {
|
|
|
|
static BYTES: &'static [u8] = &[
|
|
|
|
0x1b, 0x5b, 0x33, 0x38, 0x3b, 0x32, 0x3b, 0x31, 0x32,
|
|
|
|
0x38, 0x3b, 0x36, 0x36, 0x3b, 0x32, 0x35, 0x35, 0x6d
|
|
|
|
];
|
|
|
|
|
2016-09-18 18:17:44 +00:00
|
|
|
let mut parser = Processor::new();
|
2016-06-08 17:39:49 +00:00
|
|
|
let mut handler = AttrHandler::default();
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
|
2016-09-18 18:17:44 +00:00
|
|
|
for byte in &BYTES[..] {
|
2016-12-04 23:48:30 +00:00
|
|
|
parser.advance(&mut handler, *byte, &mut Void);
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
}
|
|
|
|
|
2016-05-31 03:44:37 +00:00
|
|
|
let spec = Rgb {
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
r: 128,
|
|
|
|
g: 66,
|
|
|
|
b: 255
|
|
|
|
};
|
|
|
|
|
2016-12-04 19:14:27 +00:00
|
|
|
assert_eq!(handler.attr, Some(Attr::Foreground(Color::Spec(spec))));
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// No exactly a test; useful for debugging
|
|
|
|
#[test]
|
|
|
|
fn parse_zsh_startup() {
|
|
|
|
static BYTES: &'static [u8] = &[
|
2016-12-17 06:48:04 +00:00
|
|
|
0x1b, 0x5b, 0x31, 0x6d, 0x1b, 0x5b, 0x37, 0x6d, 0x25, 0x1b, 0x5b,
|
|
|
|
0x32, 0x37, 0x6d, 0x1b, 0x5b, 0x31, 0x6d, 0x1b, 0x5b, 0x30, 0x6d,
|
|
|
|
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
|
|
|
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
|
|
|
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
|
|
|
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
|
|
|
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
|
|
|
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
|
|
|
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
|
|
|
0x20, 0x20, 0x0d, 0x20, 0x0d, 0x0d, 0x1b, 0x5b, 0x30, 0x6d, 0x1b,
|
|
|
|
0x5b, 0x32, 0x37, 0x6d, 0x1b, 0x5b, 0x32, 0x34, 0x6d, 0x1b, 0x5b,
|
|
|
|
0x4a, 0x6a, 0x77, 0x69, 0x6c, 0x6d, 0x40, 0x6a, 0x77, 0x69, 0x6c,
|
|
|
|
0x6d, 0x2d, 0x64, 0x65, 0x73, 0x6b, 0x20, 0x1b, 0x5b, 0x30, 0x31,
|
|
|
|
0x3b, 0x33, 0x32, 0x6d, 0xe2, 0x9e, 0x9c, 0x20, 0x1b, 0x5b, 0x30,
|
|
|
|
0x31, 0x3b, 0x33, 0x32, 0x6d, 0x20, 0x1b, 0x5b, 0x33, 0x36, 0x6d,
|
|
|
|
0x7e, 0x2f, 0x63, 0x6f, 0x64, 0x65
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
];
|
|
|
|
|
2016-07-04 04:14:56 +00:00
|
|
|
let mut handler = AttrHandler::default();
|
2016-09-18 18:17:44 +00:00
|
|
|
let mut parser = Processor::new();
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
|
2016-09-18 18:17:44 +00:00
|
|
|
for byte in &BYTES[..] {
|
2016-12-04 23:48:30 +00:00
|
|
|
parser.advance(&mut handler, *byte, &mut Void);
|
Initial ANSI parser implementation
This is the initial terminal stream parsing implementation for
Alacritty. There are currently several TODOs, FIXMEs, and unimplemented!
things scattered about still, but what's here is good enough to
correctly parse my zsh startup.
The `Parser` implementation is largely based on the suck-less _simple
terminal_ parser. Because this is Rust and Rust has a fantastic type
system, some improvements are possible. First, `Parser` is a struct, and
its data is stored internally instead of statically. Second, there's no
terminal updates hard-coded into the parser. Instead, `Parser` is
generic over a `Handler` type which has methods for all of the actions
supported by the parser. Because Parser is generic, it should be
possible (with proper inlining) to have equivalent performance to the
hard-coded version.
In addition to using _simple terminal_ as a reference, there's a doc in
Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI
terminal protocol, which has been referenced extensively.
There's probably a large number escapes we don't handle, and that's ok.
There's a lot that aren't necessary for everyday terminal usage. If you
feel like something that's not supported should be, feel free to add it.
Please try not to become overzealous and adding support for sequences
only used by folks trapped in 1988.
2016-05-29 05:09:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|