ErichDonGubler / termion

A bindless library for controlling terminals/TTY.
MIT License
4 stars 1 forks source link

Implement Windows support #1

Open ErichDonGubler opened 6 years ago

ErichDonGubler commented 6 years ago
forbjok commented 6 years ago

Any progress on this?

ErichDonGubler commented 6 years ago

@forbjok: Yes indeed! I've updated the comments with a checklist of what I see needs to happen before this is ready for PR.

forbjok commented 6 years ago

I tried building your windows branch yesterday with "cargo test", but it's failing with a bunch of "Could not find attr in sys" errors in lib.rs, since there currently isn't an attr module in the windows version of sys. Do you have a newer one that compiles?

ErichDonGubler commented 6 years ago

@forbjok: Just pushed some fixes with commit https://github.com/ErichDonGubler/termion/commit/65cc96cb3ac3dd826166546fb0e781e6737dd0e9 -- I rebased onto latest upstream changed, so you'll need to force the update.

Some tests are broken or missing, as noted in the edited OP -- but everything SHOULD compile and run just fine now. Let me know if you find anything strange.

mattmccarty commented 6 years ago

Hi @ErichDonGubler I'll be ready to start working with you on this early next week. I got pulled onto a huge project after new years at work (which I was expecting), so it has taken me some time to get back to this. I have already pulled down your branch and started doing research. Lets start a discussion.

ErichDonGubler commented 6 years ago

@mattmccarty: Sure! What's your preferred medium for collaboration? :)

mattmccarty commented 6 years ago

Telepathy, but not everyone has that ability yet :(

It doesn't matter. I suppose we can use gitter or IRC, so if others want to jump in on the convo they can do so easily. I'll let you set it up. Just let me know.

mattmccarty commented 6 years ago

Still with me?

ErichDonGubler commented 6 years ago

@mattmccarty: Sorry, life got busy -- here is a Riot room to join. :)

VladimirMarkelov commented 6 years ago

What Windows versions are termion going to support? As far as I know, ANSI is Window 10 only feature. No termion Windows 7?

ErichDonGubler commented 6 years ago

@VladimirMarkelov: As an initial PR, we'll want to make the leap from no Windows support as small as possible, so at least the initial work will only support Windows 10. @ticki will have to comment on whether or not he is willing to support implementation(s) of non-ANSI terminals.

ErichDonGubler commented 6 years ago

Good news -- commit bf1bf13 knocked out the panicking issues with keyboard/mouse input being too fast from my testing on Windows 10! Now @mattmccarty and I just need to fix the other issues, which I'm far less worried about. :)

EDIT: Also fixed the is_tty example. Woot!

ErichDonGubler commented 6 years ago

Everyone, I've updated the information in this issue to track the status of the other issues that @mattmccarty took the initiative to create. Hopefully this gives much better visibility into the status of Windows support! :)

fasihrana commented 6 years ago

Any progress on this?

ErichDonGubler commented 6 years ago

@fasihrana: Life has been busy for me, @mattmccarty has disappeared, so none of the issues we've created have moved forward much. I've kept the windows and associated branches up-to-date with upstream, though!

fasihrana commented 6 years ago

I just cloned and did a compile of your repo on Windows 7 with git bash and I'm getting the same errors.

error[E0433]: failed to resolve. Maybe a missing `extern crate sys;`?
  --> src\lib.rs:22:9
   |
22 | pub use sys::size::terminal_size;
   |         ^^^ Maybe a missing `extern crate sys;`?

error[E0433]: failed to resolve. Maybe a missing `extern crate sys;`?
  --> src\lib.rs:23:9
   |
23 | pub use sys::tty::{is_tty, get_tty};
   |         ^^^ Maybe a missing `extern crate sys;`?

error[E0433]: failed to resolve. Maybe a missing `extern crate sys;`?
 --> src\async.rs:5:5
  |
5 | use sys::tty::get_tty;
  |     ^^^ Maybe a missing `extern crate sys;`?

error[E0432]: unresolved import `sys`
  --> src\raw.rs:28:5
   |
28 | use sys::Termios;
   |     ^^^ Maybe a missing `extern crate sys;`?

error[E0433]: failed to resolve. Maybe a missing `extern crate sys;`?
  --> src\raw.rs:29:5
   |
29 | use sys::attr::{get_terminal_attr, raw_terminal_attr, set_terminal_attr};
   |     ^^^ Maybe a missing `extern crate sys;`?

error[E0425]: cannot find function `get_tty` in this scope
  --> src\async.rs:20:36
   |
20 |     thread::spawn(move || for i in get_tty().unwrap().bytes() {
   |                                    ^^^^^^^ not found in this scope

error[E0425]: cannot find function `set_terminal_attr` in this scope
  --> src\raw.rs:45:9
   |
45 |         set_terminal_attr(&self.prev_ios).unwrap();
   |         ^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function `get_terminal_attr` in this scope
  --> src\raw.rs:90:23
   |
90 |         let mut ios = get_terminal_attr()?;
   |                       ^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function `raw_terminal_attr` in this scope
  --> src\raw.rs:93:9
   |
93 |         raw_terminal_attr(&mut ios);
   |         ^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function `set_terminal_attr` in this scope
  --> src\raw.rs:95:9
   |
95 |         set_terminal_attr(&ios)?;
   |         ^^^^^^^^^^^^^^^^^ not found in this scope
fasihrana commented 6 years ago

Aaah! nevermind. I checkedout windows branch. it compiles on git bash now.

fasihrana commented 6 years ago

I think you should try this with git-bash and you'll see that all examples work. Maybe this can be merged to redox-os/termion for git-bash support on windows?

Is there any other terminal/shell you want me to check this on? I've got a Windows 2008 server machine.

ErichDonGubler commented 6 years ago

@fasihrana: I don't think that the windows branch is ready for primetime yet. Most of the examples function, but not fully. There's also the design problem of enabling the ANSI functionality on Windows 10, which we kludge into working right now but I believe we should use typestate for. See the checklists above -- some things might be checkable based on how well things are already working, so if you see something specifically that isn't actually broken then please report it!

fasihrana commented 6 years ago

Conemu+PowerShell on Win Server 2008 R2:

Examples that work are:

  1. alternate_screen
  2. alternate_screen_raw
  3. async
  4. color
  5. commie
  6. detect_color
  7. is_tty
  8. keys
  9. read
  10. rustc_fun
  11. size
  12. truecolor (only works for certain colors, does not show all the shades changing)
fasihrana commented 6 years ago

Same result as above for plain Bash.exe found in Git-Windows installation.

ErichDonGubler commented 6 years ago

@fasihrana: If you're interested in continuing this discussion, let's take it to the Riot room I've made: https://riot.im/app/#/room/#erichdongubler-termion:matrix.org