ht icon indicating copy to clipboard operation
ht copied to clipboard

Escape sequences - current state of support

Open pzmarzly opened this issue 1 year ago • 2 comments

Does ht interpret ANSI escape codes? There are many protocols that I think ht could interpret and transform into JSON messages. Or if not, then explicitly forward them further over getView API (or a new getUnsanitizedView / getRawView).

Some protocols that are somewhat important for modern terminal experience:

  • colors,
  • clickable links,
  • mouse integration,
  • clipboard copy/paste,
  • setting title and cwd

pzmarzly avatar Jun 04 '24 15:06 pzmarzly

Yeah, @ku1ik and I have discussed this this as a future feature to add. Agree that supporting this will be useful!

andyk avatar Jun 04 '24 17:06 andyk

@pzmarzly ht interprets most ANSI escape codes/sequences, however most of the protocols you listed are not yet supported.

By "colors", what do you mean specifically? ht supports all colors specifications (indexed/palette, 8-bit, 24-bit). Currently takeSnapshot returns text field, which is plain text (no color), and seq field, which is a string of escape sequences that in addition to fast-forwarding a blank terminal into the snapshotted state it also includes whole screen contents with color sequences. I understand that seq is not useful in most cases, especially if you just want to get a rich view of the screen buffer. My guess is you're after the rich view, right? This we have discussed with @andyk and it makes total sense to implement 👍

Re clickable links, mouse integration and clipboard: I don't see usefulness of those for a headless terminal. I guess if you want to build a real non-headless terminal with ht then you'd need those, but then I'm not sure ht is the best underlying terminal emulation tool for this task. We may expand scope in the future, but the original (and current) idea for it is to be first and foremost a useful headless terminal (as the name implies) :)

ku1ik avatar Jul 22 '25 11:07 ku1ik