Skip to content
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

Make kibi compatible with Windows 10 #9

Closed
codingonHP opened this issue Feb 19, 2020 · 2 comments · Fixed by #26
Closed

Make kibi compatible with Windows 10 #9

codingonHP opened this issue Feb 19, 2020 · 2 comments · Fixed by #26
Assignees
Labels
enhancement New feature or request

Comments

@codingonHP
Copy link

Hi,
I am trying to build kibi for Windows 10 but it fails with compilation errors.
Can you please help.

Rust Info

  • cargo 1.43.0-nightly (3c53211c3 2020-02-07)
  • rustc 1.43.0-nightly (e620d0f33 2020-02-18)

Windows Info

OS Name: Microsoft Windows 10 Enterprise
OS Version: 10.0.19041 N/A Build 19041
OS Manufacturer: Microsoft Corporation
OS Configuration: Standalone Workstation

Compiler output

$ cargo build --release --locked --all-features

   Compiling kibi v0.1.2 (C:\Users\vanand\kibi\kibi)
error[E0433]: failed to resolve: could not find `sys` in `nix`
 --> src\editor.rs:6:10
  |
6 | use nix::sys::termios::Termios;
  |          ^^^ could not find `sys` in `nix`

error[E0432]: unresolved imports `signal_hook::iterator`, `signal_hook::SIGWINCH`
 --> src\editor.rs:7:19
  |
7 | use signal_hook::{iterator::Signals, SIGWINCH};
  |                   ^^^^^^^^           ^^^^^^^^ no `SIGWINCH` in the root
  |                   |
  |                   could not find `iterator` in `signal_hook`

error[E0432]: unresolved imports `libc::STDIN_FILENO`, `libc::STDOUT_FILENO`, `libc::TIOCGWINSZ`, `libc::VMIN`, `libc::VTIME`
 --> src\terminal.rs:3:12
  |
3 | use libc::{STDIN_FILENO, STDOUT_FILENO, TIOCGWINSZ, VMIN, VTIME};
  |            ^^^^^^^^^^^^  ^^^^^^^^^^^^^  ^^^^^^^^^^  ^^^^  ^^^^^
  |            |             |              |           |     |
  |            |             |              |           |     no `VTIME` in the root
  |            |             |              |           |     help: a similar name exists in the module: `ETIME`
  |            |             |              |           no `VMIN` in the root
  |            |             |              no `TIOCGWINSZ` in the root
  |            |             no `STDOUT_FILENO` in the root
  |            no `STDIN_FILENO` in the root

error[E0432]: unresolved imports `nix::pty`, `nix::sys`
 --> src\terminal.rs:4:11
  |
4 | use nix::{pty::Winsize, sys::termios};
  |           ^^^           ^^^ could not find `sys` in `nix`
  |           |
  |           could not find `pty` in `nix`

error[E0433]: failed to resolve: could not find `ioctl_read_bad` in `nix`
  --> src\terminal.rs:35:10
   |
35 |     nix::ioctl_read_bad!(get_ws, TIOCGWINSZ, Winsize);
   |          ^^^^^^^^^^^^^^ could not find `ioctl_read_bad` in `nix`

error[E0412]: cannot find type `Termios` in this scope
   --> src\editor.rs:109:19
    |
109 |     orig_termios: Termios,
    |                   ^^^^^^^ not found in this scope

error[E0412]: cannot find type `Error` in crate `nix`
 --> src\error.rs:8:14
  |
8 |     Nix(nix::Error),
  |              ^^^^^ not found in `nix`
  |
help: possible candidates are found in other modules, you can import them into scope
  |
3 | use core::fmt::Error;
  |
3 | use crate::error::Error;
  |
3 | use std::error::Error;
  |
3 | use std::fmt::Error;
  |
    and 1 other candidate

error[E0412]: cannot find type `Error` in crate `nix`
  --> src\error.rs:33:16
   |
33 | impl From<nix::Error> for Error {
   |                ^^^^^ not found in `nix`
   |
help: possible candidates are found in other modules, you can import them into scope
   |
3  | use core::fmt::Error;
   |
3  | use crate::error::Error;
   |
3  | use std::error::Error;
   |
3  | use std::fmt::Error;
   |
     and 1 other candidate

error[E0412]: cannot find type `Error` in crate `nix`
  --> src\error.rs:35:23
   |
35 |     fn from(err: nix::Error) -> Self { Self::Nix(err) }
   |                       ^^^^^ not found in `nix`
   |
help: possible candidates are found in other modules, you can import them into scope
   |
3  | use core::fmt::Error;
   |
3  | use crate::error::Error;
   |
3  | use std::error::Error;
   |
3  | use std::fmt::Error;
   |
     and 1 other candidate

error[E0412]: cannot find type `Error` in crate `nix`
 --> src\terminal.rs:8:71
  |
8 | pub(crate) fn set_termios(term: &termios::Termios) -> Result<(), nix::Error> {
  |                                                                       ^^^^^ not found in `nix`
  |
help: possible candidates are found in other modules, you can import them into scope
  |
1 | use core::fmt::Error;
  |
1 | use crate::error::Error;
  |
1 | use std::error::Error;
  |
1 | use std::fmt::Error;
  |
    and 1 other candidate

error[E0425]: cannot find function `get_ws` in this scope
  --> src\terminal.rs:43:14
   |
43 |     unsafe { get_ws(STDOUT_FILENO, maybe_ws.as_mut_ptr()).ok().map(|_| maybe_ws.assume_init()) }
   |              ^^^^^^ not found in this scope

error: aborting due to 11 previous errors

@ilai-deutel
Copy link
Owner

Hi there,

Currently, kibi is not compatible with Windows because system calls specific to *nix platform (Linux, MacOS, ...) are made:

  1. POSIX terminal library calls (termios) to enable and disable terminal raw mode (enable_raw_mode())
  2. Obtaining the terminal size (get_window_size()):
    • via ioctl
    • using ANSI escape sequences if the ioctl method fails
  3. Signal handling for SIGWINCH to know when the terminal has been resized

Windows 10

Enabling / disabling raw mode (1.) is necessary to be able to use a text editor. I think one of the crates that safely wrap winapi::um::consoleapi::SetConsoleMode could be used.

Obtaining the terminal size (2.) could potentially work using ANSI escape sequences with recent versions of Windows 10 that support them (since version 1511, released in November 2015). This method is currently implemented in kibi as get_window_size_v2.

Automatic resize of the terminal window (3.) is nice, but it could be disabled for Windows until an alternative is implemented.

Windows 7

If I understand correctly, Windows 7 cannot handle ANSI escape sequences, so I'm not sure if it could work without a major change.

@ilai-deutel ilai-deutel added the enhancement New feature or request label Feb 24, 2020
@ilai-deutel ilai-deutel changed the title kibi fails to build on Windows 10 Make kibi compatible with Windows 10 Feb 24, 2020
@ilai-deutel ilai-deutel self-assigned this Mar 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants
@codingonHP @ilai-deutel and others