Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • termion termion
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 65
    • Issues 65
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 10
    • Merge requests 10
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Container Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • redox-osredox-os
  • termiontermion
  • Merge requests
  • !174

Add Windows 10 support

  • Review changes

  • Download
  • Email patches
  • Plain diff
Open kankri requested to merge kankri/termion:windows-support into master Aug 28, 2020
  • Overview 3
  • Commits 20
  • Pipelines 1
  • Changes 17

I tried the merge request !151 but found it wasn't really working. This MR adds commits to that.

Running e.g. the keys example seemed to be somewhat working when started with cargo run --example keys, but wasn't working if started directly as target\debug\examples\keys.exe: escape sequences were just printed on the screen instead of controlling the output. It seems cargo leaves the console in the Virtual Terminal mode, thus hiding the fact that termion didn't properly set up the console. Even when started from cargo, keyboard input was not handled properly.

I fixed the problems I noticed in the original MR:

  • Fix unused imports.
  • Fix "termion::sys::tty::is_tty()".
  • Add support for using escape sequences and reading special keys on Windows 10.

Then I changed some of the examples to make it easier to test the various features:

  • Print keys using Debug trait in examples/keys.rs.
  • Show more color and style features in examples/color.rs.
  • Print mouse events in examples/mouse.rs.

Finally I added some tests for parse_csi() and fixed the panics those tests discovered:

  • Fix a comment.
  • Normalize indentation in "event::parse_csi()".
  • Simplify pattern matching in "event::parse_csi()".
  • Simplify pattern matching in "event::parse_csi()" with "ok()?".
  • Add tests for "CSI <" and fix "event::parse_csi()" not to panic.
  • Add tests for "CSI M" and fix "event::parse_csi()" not to panic.
  • Fix invalid tests.
  • Simplify matching "CSI M" in "event::parse_csi()".
  • Add tests for "CSI ... M" and fix "event::parse_csi()" not to panic.
  • Add tests for "CSI ... ~" and fix "event::parse_csi()" not to panic.

There are still some shortcomings in Windows support:

  • Control-j, control-m and Enter are all reported as Char('\n')
  • Control-z ends the input iterator (because of CTRL_Z_MASK in std::sys::windows::stdio::read_u16s())
  • Control-arrow keys are not supported (termion doesn't parse multiple arguments)
  • Window resize events are not received
  • Only Windows 10.0.10586 and later is supported (some features starting from 10.0.14393)

All of these problems could be avoided by using the Windows Console API to get key and windows size events directly.

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: windows-support