-
Notifications
You must be signed in to change notification settings - Fork 4
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
Initial support for Win32 #35
Conversation
@@ -994,7 +994,7 @@ let down_readline p = | |||
external sigwinch : unit -> int = "ocaml_down_sigwinch" | |||
let install_sigwinch_interrupt () = | |||
(* Sufficient to interrupt the event loop on window size changes. *) | |||
Sys.set_signal (sigwinch ()) (Sys.Signal_handle (fun _ -> ())) | |||
if Sys.unix then Sys.set_signal (sigwinch ()) (Sys.Signal_handle (fun _ -> ())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are no signals on Windows. But there is a way to receive windows resize events which could be piped back up to the OCaml code; it would just need a bit of work.
let mkdir_posix dir = ["mkdir"; "-p"; dir] | ||
let mkdir = if Sys.win32 then mkdir_win32 else mkdir_posix | ||
let create dir = Result.map_error snd @@ cmd_run (mkdir dir) | ||
let mkdir_p dir = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mkdir -p
does not exist in cmd.exe
. But Sys.mkdir
exists in the standard library, so perhaps some version of the code below could be used instead.
BTW, you will notice there is a lot of flickering at the moment; I'm not sure what to do about it. I found https://stackoverflow.com/questions/73800269/flicker-free-console-updates-with-virtual-terminal-sequences after some random googling, but am not sure it is applicable. |
I pushed 9bc5120 to fix the flickering (it is not perfect but it gets rid of most of it). |
It turns out that when pressing TAB, Down invokes Before the fix: After the fix: |
Completion and doc lookup (using I think this makes Down usable on Windows (there are still things to improve of course, but it is a start). @dbuenzli let me know if you would like me to do any changes, or feel free to pick the fixes and integrate them directly after massaging them into a shape that you are happy with :) |
Altogether that looks quite an unintrusive Windows support to me which makes me happy. If you want to stop here (please confirm) I'm happy to merge this and make a release. If you have in your head things that can be improved for other people to grab, please don't hesitate to open more specific issues. |
More precisely it would be nice to have an issue that records exactly what doesn't work as expected to avoid too much bug reporting noise and so that I can refer to it to warn people appropriately somewhere from the docs. |
Yes, I confirm. I think this is a good check point.
I played with it a bit more today and I couldn't find any obvious problems. I will open an issue if I come across anything. Looking forward, if you agree, I propose the following: whenever a Windows issue is reported here, assign it to me or just ping me, and I will take care of both triaging it and investigating possible fixes. |
Wow. Thanks @nojb ! |
That's fine with me. Could you perhaps just make an issue about the status of window resize on windows. |
Your patches are in, thanks. |
I will take a closer look at resizing later and open an issue, thanks! |
See the discussion in #34.
The list of things that do not work is long: resize events, mouse events, completion (tab) makes it go completely haywire, etc. But the bare minimum works. I did it before @jonahbeckford revealed his previous work, so things are done somewhat differently and/or in an overly naïve way (but note that with this simple patch arrows keys do work).
I don't think this patch is good enough to claim that Down works on Windows, but may serve as a stepping stone for further improvements.
I leave some comments inline below.