Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrapping ansi escapes? #1

Open
joshtriplett opened this issue Apr 22, 2020 · 1 comment
Open

Wrapping ansi escapes? #1

joshtriplett opened this issue Apr 22, 2020 · 1 comment

Comments

@joshtriplett
Copy link

Given that this library already recognizes ansi escape sequences, could it offer a function to split out ansi escape sequences rather than stripping them? For instance, an iterator that alternates between Escapes(&str) and NormalStr(&str)? That would enable use cases like wrapping escapes in a control sequence (such as \[ and \] for the bash prompt).

@luser
Copy link
Owner

luser commented Apr 22, 2020

I'm open to suggestions as to how to make this work without complicating the API for the existing use case. Honestly all the real hard work is done in the vte crate so it might be easier to just use that? This crate just ignores most of the callbacks it gets from vte:

impl<W> Perform for Performer<W>
where W: Write,
{
fn print(&mut self, c: char) {
// Just print bytes to the inner writer.
self.err = write!(self.writer, "{}", c).err();
}
fn execute(&mut self, byte: u8) {
// We only care about executing linefeeds.
if byte == b'\n' {
self.err = writeln!(self.writer, "").err();
}
}
// Since we're not actually implementing a terminal, we just ignore everything else.
fn hook(&mut self, _params: &[i64], _intermediates: &[u8], _ignore: bool) {}
fn put(&mut self, _byte: u8) {}
fn unhook(&mut self) {}
fn osc_dispatch(&mut self, _params: &[&[u8]]) {}
fn csi_dispatch(
&mut self,
_params: &[i64],
_intermediates: &[u8],
_ignore: bool,
_: char
) {}
fn esc_dispatch(
&mut self,
_params: &[i64],
_intermediates: &[u8],
_ignore: bool,
_byte: u8
) {}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants