ocaml-tui / tty Goto Github PK
View Code? Open in Web Editor NEWA pure OCaml library for working with terminals
License: MIT License
A pure OCaml library for working with terminals
License: MIT License
As it stands now, there's a few flags that are always false in profile.ml
(* TODO(@leostera): String.contains "256color" "color" "ansi" *)
let is_256color = false in
let is_color = false in
let is_ansi = false in
The checks for these are essentially String.contains
checks, and need to be done based on the env variables available.
I've been trying to figure out a way to get the dimensions of the current terminal in a sensible (somewhat) cross-platform way. I thought it'd be a fairly easy thing to do and I could try submitting a PR once I have something working, but it's proving to be beyond my skill/knowledge level with OCaml and terminals in general.
However, it seems like a very common thing that people would expect to see in a library like this, so I figured it could merit some discussion at the very least?
AFAIK there's a bunch of ways it could be done, but they all have downsides:
\x1b[6n
) should cause a status message ESC[n;mR
to be 'printed' to STDIN. I got this kind of working1, but this only seems to work for certain terminals. Foot, Alacritty, URXVT and the linux console worked for me while Kitty, Wezterm, xfce-terminal and, surprisingly, xterm didnt.libc
constants in OCaml, so I had to hardcode the value of TIOCGWINSZ
, so it's the furthest thing from cross platform.with this hacky monstrosity. I had Base and Stdio opened in these experiments, in case some functions look odd. ↩
https://gist.github.com/rchog/ac9303c0d6b4d0deb74b006534749722 ↩
I think the Stdin module should read from /dev/tty
instead of stdin (or else the user should be able to choose). Otherwise writing interactive programs that read input from stdin (e.g. fzf in cat ... | fzf
) will have problems.
Specifically, when I tried doing that with minttea, I got an ENOTTY error message (although the program still seemed to function as expected). Changing the stdin module to start with let stdin_fd = Unix.descr_of_in_channel (In_channel.open_bin "/dev/tty")
got rid of it.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.