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

Add support for unix_isatty #913

Closed
bandersongit opened this issue Nov 8, 2019 · 2 comments
Closed

Add support for unix_isatty #913

bandersongit opened this issue Nov 8, 2019 · 2 comments

Comments

@bandersongit
Copy link
Contributor

bandersongit commented Nov 8, 2019

The Pastel text highlighting library uses Unix.isatty as part of the logic to determine whether the host terminal supports color. There aren't currently stubs for this so compiling with JSOO requires consumers to provide an implementation. You can see reasonml/reason-native#207 for an an example of this.

I see a couple possible naive approaches:
a) bind Unix.stdin, Unix.stdout, Unix.stderr to NodeJS's process.stdin, process.stdout, Process.stderr and implement unix_isatty as `stream => stream. isTTY)
b) use NodeJS's tty.isatty( ) along with numeric file descriptors

However I have noticed that runtime's fs implementation has both node based and a non non based (fake) modules that it uses, so I could see doing something like that as well to have different behavior in a browser environment (for example I've verified that ansi escape sequences work in chrome's developer console, however none of the node js modules/functions I described are available in that environment)

@hhugo
Copy link
Member

hhugo commented Nov 9, 2019

ansi escape sequences work in chrome's developer console

Is that true ? I was not able to make this work.

I would probably go for (b), PR welcome

@bandersongit
Copy link
Contributor Author

ansi escape sequences work in chrome's developer console

Is that true ? I was not able to make this work.

When I was first playing with Rely and JSOO a few months ago in chrome I was able to get this colorized output
image
(the weird unicode character thing was fixed by #798, but I had the screenshot lying around).

Also for a simpler example
image

I would probably go for (b), PR welcome

Sounds good, I'll make some time for this in the next several days.

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

No branches or pull requests

2 participants