minicrossterm/crossterm_winapi
Timon 1e332daaed
Refactor and API stabilization (#115)
- Major refactor and cleanup.
- Improved performance; 
    - No locking when writing to stdout. 
    - UNIX doesn't have any dynamic dispatch anymore. 
    - Windows has improved the way to check if ANSI modes are enabled.
    - Removed lot's of complex API calls: `from_screen`, `from_output`
    - Removed `Arc<TerminalOutput>` from all internal Api's. 
- Removed termios dependency for UNIX systems.
- Upgraded deps.
- Removed about 1000 lines of code
    - `TerminalOutput` 
    - `Screen`
    - unsafe code
    - Some duplicated code introduced by a previous refactor.
- Raw modes UNIX systems improved     
- Added `NoItalic` attribute
2019-04-10 23:46:30 +02:00
..
examples Introduced: Crossterm Workspace and feature flags. (#84) 2019-01-27 21:16:14 +01:00
src Adds support for mouse and keyboard events. 2019-04-02 21:38:34 +02:00
.gitignore Introduced: Crossterm Workspace and feature flags. (#84) 2019-01-27 21:16:14 +01:00
.travis.yml Introduced: Crossterm Workspace and feature flags. (#84) 2019-01-27 21:16:14 +01:00
Cargo.toml Refactor and API stabilization (#115) 2019-04-10 23:46:30 +02:00
LICENSE Bug fix reading sync, updated licenses. 2019-04-05 15:44:39 +02:00
README.md Refactor and API stabilization (#115) 2019-04-10 23:46:30 +02:00

Crossterm Winapi | Common WinApi Abstractions

Lines of Code Latest Version MIT docs

This crate provides some wrappers aground common used WinApi functions. The purpose of this library is originally meant for crossterm, but could be used apart from it. Although, notice that it unstable right because some changes to the API could be expected.

Features

This crate provides some abstractions over reading input, console screen buffer, and handle.

The following WinApi calls

  • CONSOLE_SCREEN_BUFFER_INFO (used to extract information like cursor pos, terminal size etc.)
  • HANDLE (the handle needed to run functions from WinApi)
  • SetConsoleActiveScreenBuffer (activate an other screen buffer)
  • Set/GetConsoleMode (e.g. console modes like disabling output)
  • SetConsoleTextAttribute (eg. coloring)
  • SetConsoleWindowInfo (changing the buffer location e.g. scrolling)
  • FillConsoleOutputAttribute, FillConsoleOutputCharacter (used to replace some block of cells with a color or character.)
  • SetConsoleInfo
  • ReadConsoleW

Example

The examples folder has more complete and verbose examples.

Screenbuffer information

use crossterm_winapi::{ScreenBuffer, Handle};

fn print_screen_buffer_information() {
    let screen_buffer = ScreenBuffer::current().unwrap();

    // get console screen buffer information
    let csbi = screen_buffer.info().unwrap();

    println!("cursor post: {:?}", csbi.cursor_pos());
    println!("attributes: {:?}", csbi.attributes());
    println!("terminal window dimentions {:?}", csbi.terminal_window());
    println!("terminal size {:?}", csbi.terminal_size());
}

Handle

use crossterm_winapi::{HandleType, Handle};

fn get_different_handle_types() {
    let out_put_handle = Handle::new(HandleType::OutputHandle).unwrap();
    let out_put_handle = Handle::new(HandleType::InputHandle).unwrap();
    let curr_out_put_handle = Handle::new(HandleType::CurrentOutputHandle).unwrap();
    let curr_out_put_handle = Handle::new(HandleType::CurrentInputHandle).unwrap();
}