YS-L / csvlens

Command line csv viewer
MIT License
2.49k stars 40 forks source link

Windows support #4

Closed jqnatividad closed 1 year ago

jqnatividad commented 2 years ago

Great stuff! However, it doesn't seem to work on Windows.

When I do cargo install csvlens on Windows, I get several errors:

error[E0433]: failed to resolve: maybe a missing crate `sys`?
  --> C:\Users\jsmith\.cargo\registry\src\github.com-1ecc6299db9ec823\termion-1.5.6\src\lib.rs:24:9
   |
24 | pub use sys::size::terminal_size;
   |         ^^^ maybe a missing crate `sys`?

error[E0433]: failed to resolve: maybe a missing crate `sys`?
  --> C:\Users\jsmith\.cargo\registry\src\github.com-1ecc6299db9ec823\termion-1.5.6\src\lib.rs:27:9
   |
27 | pub use sys::tty::{is_tty, get_tty};
   |         ^^^ maybe a missing crate `sys`?

error[E0433]: failed to resolve: maybe a missing crate `sys`?
 --> C:\Users\jsmith\.cargo\registry\src\github.com-1ecc6299db9ec823\termion-1.5.6\src\async.rs:5:5
  |
5 | use sys::tty::get_tty;
  |     ^^^ maybe a missing crate `sys`?

error[E0433]: failed to resolve: maybe a missing crate `sys`?
  --> C:\Users\jsmith\.cargo\registry\src\github.com-1ecc6299db9ec823\termion-1.5.6\src\raw.rs:28:5
   |
28 | use sys::attr::{get_terminal_attr, raw_terminal_attr, set_terminal_attr};
   |     ^^^ maybe a missing crate `sys`?

error[E0432]: unresolved import `sys`
  --> C:\Users\jsmith\.cargo\registry\src\github.com-1ecc6299db9ec823\termion-1.5.6\src\raw.rs:29:5
   |
29 | use sys::Termios;
   |     ^^^ maybe a missing crate `sys`?

error[E0425]: cannot find function `get_tty` in this scope
  --> C:\Users\jsmith\.cargo\registry\src\github.com-1ecc6299db9ec823\termion-1.5.6\src\async.rs:14:36
   |
14 |     thread::spawn(move || for i in get_tty().unwrap().bytes() {
   |                                    ^^^^^^^ not found in this scope

error[E0425]: cannot find function `get_tty` in this scope
  --> C:\Users\jsmith\.cargo\registry\src\github.com-1ecc6299db9ec823\termion-1.5.6\src\async.rs:43:36
   |
43 |     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
  --> C:\Users\jsmith\.cargo\registry\src\github.com-1ecc6299db9ec823\termion-1.5.6\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
   --> C:\Users\jsmith\.cargo\registry\src\github.com-1ecc6299db9ec823\termion-1.5.6\src\raw.rs:102:23
    |
102 |         let mut ios = get_terminal_attr()?;
    |                       ^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function `raw_terminal_attr` in this scope
   --> C:\Users\jsmith\.cargo\registry\src\github.com-1ecc6299db9ec823\termion-1.5.6\src\raw.rs:105:9
    |
105 |         raw_terminal_attr(&mut ios);
    |         ^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function `set_terminal_attr` in this scope
   --> C:\Users\jsmith\.cargo\registry\src\github.com-1ecc6299db9ec823\termion-1.5.6\src\raw.rs:107:9
    |
107 |         set_terminal_attr(&ios)?;
    |         ^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function `set_terminal_attr` in this scope
   --> C:\Users\jsmith\.cargo\registry\src\github.com-1ecc6299db9ec823\termion-1.5.6\src\raw.rs:119:9
    |
119 |         set_terminal_attr(&self.prev_ios)?;
    |         ^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function `get_terminal_attr` in this scope
   --> C:\Users\jsmith\.cargo\registry\src\github.com-1ecc6299db9ec823\termion-1.5.6\src\raw.rs:125:23
    |
125 |         let mut ios = get_terminal_attr()?;
    |                       ^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function `raw_terminal_attr` in this scope
   --> C:\Users\jsmith\.cargo\registry\src\github.com-1ecc6299db9ec823\termion-1.5.6\src\raw.rs:126:9
    |
126 |         raw_terminal_attr(&mut ios);
    |         ^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function `set_terminal_attr` in this scope
   --> C:\Users\jsmith\.cargo\registry\src\github.com-1ecc6299db9ec823\termion-1.5.6\src\raw.rs:127:9
    |
127 |         set_terminal_attr(&ios)?;
    |         ^^^^^^^^^^^^^^^^^ not found in this scope
jqnatividad commented 2 years ago

I guess this is because Termion doesn't support Windows.

Would it be possible to use crossterm instead, especially now that it's the default backend of tui-rs? https://github.com/fdehau/tui-rs/blob/master/CHANGELOG.md#v0170---2022-01-22

With the justification why https://github.com/fdehau/tui-rs/pull/553

YS-L commented 2 years ago

Thanks for reporting! Yes, I think moving to crossterm is needed to support Windows. Other than that, the code currently relies on reading /dev/tty and we would need to find an equivalent on Windows.

I don't have easy access to a Windows machine though, so this might take some time.

YS-L commented 2 years ago

I updated the implementation to use crossterm in v0.1.6. Appreciate any feedback on whether it works on Windows. Thanks!

jqnatividad commented 1 year ago

I installed csvlens on Windows 11 and it works!