dbuenzli / down

An OCaml toplevel (REPL) upgrade
http://erratique.ch/software/down
ISC License
81 stars 3 forks source link

Down does not work on Windows #34

Closed nojb closed 4 months ago

nojb commented 4 months ago

The package does not even compile at the moment:

$ dune build
Compilateur d'optimisation Microsoft (R) C/C++ version 19.39.33522 pour x64
Copyright (C) Microsoft Corporation. Tous droits réservés.

header_check.h
File "src/dune", line 7, characters 9-19:
7 |   (names down_stubs))
             ^^^^^^^^^^
down_stubs.c
down_stubs.c(8): fatal error C1083: Impossible d'ouvrir le fichier include : 'termios.h' : No such file or directory

Of course, this is a just a surface issue. The deeper issue is that Down is based on ANSI escape codes which are specific to UNIX. The Windows console is conceptually different and is controlled using system calls. Making Down work with on Windows would require, as far as I understand, a complete rewrite of anything that uses ANSI codes to make API calls instead (a fair amount of work).

I'm opening the issue following the discussion at https://discuss.ocaml.org/t/ann-down-0-2-0-and-omod-0-4-0/14380/5.

jonahbeckford commented 4 months ago

I did get 75% of the way porting down to run on Windows but ran out of time (and still don't have the time). The patches are available at ~https://gitlab.com/diskuv/DkHelloWorldActor/-/tree/main/dependencies/down~ https://gitlab.com/diskuv/share/down-win32.git

My git comment says: "Printable characters works, but not up and down arrows."

dbuenzli commented 4 months ago

I don't know what @jonahbeckford did (there's a login screen).

But:

The deeper issue is that Down is based on ANSI escape codes which are specific to UNIX.

Following a few links here and there it seems there is some kind of compatibility built in window. E.g.

https://learn.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences

Not sure if all sequences I use are supported but there is e.g. cursor movement.

jonahbeckford commented 4 months ago

Oops. Edited the link.

nojb commented 4 months ago

Following a few links here and there it seems there is some kind of compatibility built in window. E.g.

Indeed, thanks for the link. Could not resist using this to give it a shot after @jonahbeckford claimed that he had it almost working (but before he revealed his patch). It is not much, but I got something bare bones working: #35.

dbuenzli commented 4 months ago

Release 0.3.0 with Windows support is on the way to opam. Thank you all !