Hopson97 / Asciimon

Pokemon-inspired game created using Rust for terminals which support ANSI escape commands.
124 stars 11 forks source link

Use termion #32

Closed dmitmel closed 6 years ago

dmitmel commented 6 years ago

In this PR I have added the termion crates to dependencies. Crates are the essential part of the Rust ecosystem, so I've decided to use a crate to handle ANSI control sequences instead of doing that manually. Feel free to ask any questions!

Hopson97 commented 6 years ago

I'll need to test if this works on windows, I'll get back to you on this. Thanks!

Hopson97 commented 6 years ago

Yeah this doesn't work on windows :(

dmitmel commented 6 years ago

Yeah this doesn't work on windows :(

Do you mean cmd.exe? I don't see any reason to support it, because there are many other terminals for Windows that support ANSI and I don't think that many people would play this game inside cmd.exe.

P. S. When I just started programming, I worked on Windows and I used irb (interactive Ruby shell) inside cmd.exe to run my programs (then I discovered Notepad and copied my programs to irb instead of searching for them through the shell history, but this is a whole another story). And back then, I didn't know how to resize that window horizontally!

dmitmel commented 6 years ago

If you really want Windows support, I'm searching for terminal crates for non-ANSI terminals.

Hopson97 commented 6 years ago

Eh, not sure if it is needed. Current system is already set up and works fine, so why change it?

Hopson97 commented 6 years ago

and it failed on compilation, something do with it being unable to find "sys" modules, which I believe is Unix thing.

I have been using Powershell, which does suppot ANSI :p

dmitmel commented 6 years ago

Eh, not sure if it is needed

But why did you remove termion in f693f9?

Hopson97 commented 6 years ago

Because it didn't work

dmitmel commented 6 years ago

But it only supports ANSI terminals

dmitmel commented 6 years ago

and it failed on compilation, something do with it being unable to find "sys" modules, which I believe is Unix thing.

Can you show compiler output, please?

Hopson97 commented 6 years ago

"But it only supports ANSI terminals" Yeah? Windows Powershell is an ANSI terminal lol

Hopson97 commented 6 years ago
error[E0433]: failed to resolve. Maybe a missing `extern crate sys;`?
  --> C:\Users\mhops\.cargo\registry\src\github.com-1ecc6299db9ec823\termion-1.5.1\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;`?
  --> C:\Users\mhops\.cargo\registry\src\github.com-1ecc6299db9ec823\termion-1.5.1\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;`?
 --> C:\Users\mhops\.cargo\registry\src\github.com-1ecc6299db9ec823\termion-1.5.1\src\async.rs:5:5
  |
5 | use sys::tty::get_tty;
  |     ^^^ Maybe a missing `extern crate sys;`?

error[E0432]: unresolved import `sys`
  --> C:\Users\mhops\.cargo\registry\src\github.com-1ecc6299db9ec823\termion-1.5.1\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;`?
  --> C:\Users\mhops\.cargo\registry\src\github.com-1ecc6299db9ec823\termion-1.5.1\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
  --> C:\Users\mhops\.cargo\registry\src\github.com-1ecc6299db9ec823\termion-1.5.1\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
  --> C:\Users\mhops\.cargo\registry\src\github.com-1ecc6299db9ec823\termion-1.5.1\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\mhops\.cargo\registry\src\github.com-1ecc6299db9ec823\termion-1.5.1\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
  --> C:\Users\mhops\.cargo\registry\src\github.com-1ecc6299db9ec823\termion-1.5.1\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
  --> C:\Users\mhops\.cargo\registry\src\github.com-1ecc6299db9ec823\termion-1.5.1\src\raw.rs:95:9
   |
95 |         set_terminal_attr(&ios)?;
   |         ^^^^^^^^^^^^^^^^^ not found in this scope

error: aborting due to 10 previous errors

Some errors occurred: E0425, E0432, E0433.
For more information about an error, try `rustc --explain E0425`.
error: Could not compile `termion`.
dmitmel commented 6 years ago

Can you print this string in Powershell and send a screenshot of the result:

\u001b[31mred text\u001b[39m normal text

?

Hopson97 commented 6 years ago

Why?

dmitmel commented 6 years ago

I want to test if Powershell really supports ANSI because I've found that it requires enabling ANSI

Hopson97 commented 6 years ago

I literally have been making Asciimon by testing it on Powershell, it definitely works lol

dmitmel commented 6 years ago

Ok then

dmitmel commented 6 years ago

I'll try to remake this PR but with the termcolor crate (this is what Cargo uses for coloring output)

Hopson97 commented 6 years ago

Really is not needed