Commit Graph

4 Commits

Author SHA1 Message Date
Daniel Bertalan
282d0ebbec LibVT: Fix UTF-8 handling in OSC sequences
Previously, we would ignore bytes in the `0x80..0xff` range when parsing
OSC strings. This caused terminal titles and hyperlinks containing
non-ASCII characters to fail. Also added is extending the UTF-8 fail
functionality for C1 control codes, since we do not handle those.

Fixes #7377
2021-05-22 23:23:08 +02:00
Daniel Bertalan
7b9051afe5 LibVT: Fix 8-bit control codes clobbering UTF-8
Bytes in the 0x80..0x9F range were treated as C1 control codes,
which prevented them from being parsed as UTF-8 bytes.

This caused some characters (like U+DF, encoded as 0xC3 0x9F)
from being recognized as printable characters.
2021-05-16 14:17:04 +02:00
Daniel Bertalan
be519022c3 LibVT: Implement new ANSI escape sequence parser
This commit replaces the former, hand-written parser with a new one that
can be generated automatically according to a state change diagram.

The new `EscapeSequenceParser` class provides a more ergonomic interface
to dealing with escape sequences. This interface has been inspired by
Alacritty's [vte library](https://github.com/alacritty/vte/).

I tried to avoid changing the application logic inside the `Terminal`
class. While this code has not been thoroughly tested, I can't find
regressions in the basic command line utilities or `vttest`.

`Terminal` now displays nicer debug messages when it encounters an
unknown escape sequence. Defensive programming and bounds checks have
been added where we access parameters, and as a result, we can now
endure 4-5 seconds of `cat /dev/urandom`. :D

We generate EscapeSequenceStateMachine.h when building the in-kernel
LibVT, and we assume that the file is already in place when the userland
library is being built. This will probably cause problems later on, but
I can't find a way to do it nicely.
2021-05-16 11:50:56 +02:00
Daniel Bertalan
1b347298f1 LibVT: Add state machine file for the new parser
The parser itself will be included in a later commit.
2021-05-16 11:50:56 +02:00