Skip to content

added CSI (\x9b) as additionally allowable escape#2521

Closed
Qix- wants to merge 1 commit into
nodejs:masterfrom
Qix-:patch-1
Closed

added CSI (\x9b) as additionally allowable escape#2521
Qix- wants to merge 1 commit into
nodejs:masterfrom
Qix-:patch-1

Conversation

@Qix-

@Qix- Qix- commented Aug 24, 2015

Copy link
Copy Markdown

Added \x9b as an additionally allowable ANSI escape code. It's pretty phased out, but can still be used.

The difference between the two is that \x1b requires a following [. Together, both of those characters combined form the CSI. There is the single character alternative, \x9b, that doesn't require the [. It is less common, I speculate, because faulty ANSI implementations will output [37;1m which is more distinct than just 37;1m - don't quote me on that though. All I know is that it has to do with C0 and C1 control codes and a bunch of unicode voodoo.

I doubt many terminal emulators even support it nowadays but it is something you should probably be checking for and should be innocuous to those not using it.

Brought to my attention from chalk/ansi-regex#5 cc @sindresorhus

@ChALkeR ChALkeR added the readline Issues and PRs related to the built-in readline module. label Aug 24, 2015
@Fishrock123

Copy link
Copy Markdown
Contributor

I think you'd also need to add it on lines such as this? https://github.com/nodejs/node/pull/2521/files#diff-d2acee21faac11dc676c3e4570bad979R998

@Qix-

Qix- commented Aug 24, 2015

Copy link
Copy Markdown
Author

You're correct. Will update here in a bit.

Added `\x9b` as an additionally allowable ANSI escape code. It's pretty phased out, but can still be used.

The difference between the two is that `\x1b` requires a following `[`. Together, both of those characters combined form the CSI. There is the single character alternative, `\x9b`, that doesn't require the `[`. It is less common, I speculate, because faulty ANSI implementations will output `[37;1m` which is more distinct than just `37;1m` - don't quote me on that though. All I know is that it has to do with [C0 and C1 control codes](https://en.wikipedia.org/wiki/C0_and_C1_control_codes) and a bunch of unicode voodoo.

I doubt many terminal emulators even support it nowadays but it *is* something you should probably be checking for.
@Qix-

Qix- commented Aug 24, 2015

Copy link
Copy Markdown
Author

@Fishrock123 done and done.

@silverwind

Copy link
Copy Markdown
Contributor

cc @rlidwka who has been around these parts recently.

@rlidwka

rlidwka commented Sep 6, 2015

Copy link
Copy Markdown
Contributor

I doubt many terminal emulators even support it nowadays

Can you name at least one so we can check it and reference it in the comments?

Also, if you're changing that generator, it'd be nice to add a test.

PS: I have a feeling that this PR adds \x9b[37;1m-like stuff only, where [ is required, which is contrary to what you described. Does the regexp work with \x9b37;1m? Should it?

@Qix-

Qix- commented Sep 6, 2015

Copy link
Copy Markdown
Author

Can you name at least one so we can check it and reference it in the comments?

Well it's any ecma-48 compliant terminal. That means it has to support 8-bit sequences. Unfortunately, I can't find a specific list of one.

Also, if you're changing that generator, it'd be nice to add a test.

I can do that 💃

PS: I have a feeling that this PR adds \x9b[37;1m-like stuff only, where [ is required, which is contrary to what you described. Does the regexp work with \x9b37;1m? Should it?

Yes it should, good catch. Not sure why I didn't see that before. I'll make the appropriate edits and whatnot.

@jasnell

jasnell commented Nov 16, 2015

Copy link
Copy Markdown
Member

@Qix- ... any updates on this one?

@jasnell jasnell added the stalled Issues and PRs that are stalled. label Nov 16, 2015
@Qix-

Qix- commented Nov 16, 2015

Copy link
Copy Markdown
Author

@jasnell would you be opposed to using ansi-regex? There has been a considerable amount of research and work put into it (check the tests). As it stands, making the current implementation of Node's regex complete would require quite a bit of rewriting.

I know the usage of modules is kind of a pain in a proper node release, but the module is pretty stable and hasn't had to be changed in quite a while. It is simple and could easily be used in a static manner.

@jasnell

jasnell commented Nov 16, 2015

Copy link
Copy Markdown
Member

opposed to using it how?

@Qix-

Qix- commented Nov 16, 2015

Copy link
Copy Markdown
Author

In lieu of the existing regex strings that I attempted to update in this PR.

@jasnell

jasnell commented Nov 16, 2015

Copy link
Copy Markdown
Member

hmm... using the same regex would likely make sense but pulling that module into core might be problematic. Would love to get the thoughts of other @nodejs/ctc folks

@Qix-

Qix- commented Nov 16, 2015

Copy link
Copy Markdown
Author

cc @sindresorhus again.

@sindresorhus

Copy link
Copy Markdown

Feel free to take whatever from that module. Anything to make Node.js core better.

@silverwind

Copy link
Copy Markdown
Contributor

It's a single regex, I think it hardly qualifies as 'pulling a module in', so I'd say go ahead.

@jasnell

jasnell commented Nov 17, 2015

Copy link
Copy Markdown
Member

@sindresorhus ... appreciate it!

@jasnell

jasnell commented Apr 22, 2016

Copy link
Copy Markdown
Member

@Qix- ... is this still something you'd like to do? If so, would you mind rebasing and updating this to perhaps use the regex from ansi-regex?

@Qix-

Qix- commented Apr 22, 2016

Copy link
Copy Markdown
Author

@jasnell is doing that approved? Since it wasn't ever officially stated as "yes, pull in the regex" I didn't bother continuing with anything.

@jasnell

jasnell commented Apr 22, 2016

Copy link
Copy Markdown
Member

See #2521 (comment)

@Qix-

Qix- commented Apr 23, 2016

Copy link
Copy Markdown
Author

No I know, I mean is it approved by the Node.js team to use it ;) Referring to #2521 (comment).

@jasnell

jasnell commented Apr 23, 2016

Copy link
Copy Markdown
Member

As long as @sindresorhus is credited and mention of it is added to our LICENSE file then it should be fine. Basically, just append the contents of https://github.com/chalk/ansi-regex/blob/master/license to https://github.com/nodejs/node/blob/master/LICENSE with a header indicating the source https://github.com/chalk/ansi-regex/. Then add a comment to the source crediting where the regex came from. If others from the @nodejs/ctc have concerns I'm sure they'll bring it up :-)

@Qix-

Qix- commented Apr 23, 2016

Copy link
Copy Markdown
Author

Hehe I'm also a collaborator on that repo as well and basically wrote what the regex is currently. IIRC (this is an old pull) Sindre was the one to suggest pulling in the regex since it's better tested anyway.

But yeah I can amend this PR :) Give me a little though!

@jasnell

jasnell commented Apr 23, 2016

Copy link
Copy Markdown
Member

:-) ok, make sure to give yourself credit then! :-)

@estliberitas estliberitas force-pushed the master branch 2 times, most recently from 7da4fd4 to c7066fb Compare April 26, 2016 05:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

readline Issues and PRs related to the built-in readline module. stalled Issues and PRs that are stalled.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants