• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

.cargo/H03-May-2022-86

.github/H03-May-2022-21

docs/H03-May-2022-1610

examples/H03-May-2022-165103

src/H03-May-2022-1,308809

.cargo-checksum.jsonH A D03-May-202289 11

.cargo_vcs_info.jsonH A D01-Jan-197074 65

.gitignoreH A D01-Jan-197063 65

.travis.ymlH A D01-Jan-1970517 3124

CHANGELOG.mdH A D01-Jan-19701.4 KiB4329

Cargo.lockH A D01-Jan-1970872 3127

Cargo.tomlH A D01-Jan-19701.2 KiB3028

Cargo.toml.orig-cargoH A D01-Jan-1970714 1916

LICENSEH A D01-Jan-19701.1 KiB2217

README.mdH A D01-Jan-19702.6 KiB7351

README.md

1![Lines of Code][s7] [![Latest Version][s1]][l1] [![MIT][s2]][l2] [![docs][s3]][l3]
2
3# Crossterm Windows API Abstractions
4
5This crate provides some wrappers aground common used WinAPI functions.
6
7The purpose of this library is originally meant for the [crossterm](https://github.com/crossterm-rs/crossterm),
8but could be used apart from it. Although, notice that it unstable right because some changes to the
9API could be expected.
10
11# Features
12
13This crate provides some abstractions over reading input, console screen buffer, and handle.
14
15The following WinAPI calls:
16
17- CONSOLE_SCREEN_BUFFER_INFO (used to extract information like cursor pos, terminal size etc.)
18- HANDLE (the handle needed to run functions from WinAPI)
19- SetConsoleActiveScreenBuffer (activate an other screen buffer)
20- Set/GetConsoleMode (e.g. console modes like disabling output)
21- SetConsoleTextAttribute (eg. coloring)
22- SetConsoleWindowInfo (changing the buffer location e.g. scrolling)
23- FillConsoleOutputAttribute, FillConsoleOutputCharacter (used to replace some block of cells with a color or character.)
24- SetConsoleInfo
25- ReadConsoleW
26- Semaphore object handling
27
28# Example
29
30The [examples](https://github.com/crossterm-rs/examples) repository has more complete and verbose examples.
31
32## Screen buffer information
33
34```rust
35use crossterm_winapi::{ScreenBuffer, Handle};
36
37fn print_screen_buffer_information() {
38    let screen_buffer = ScreenBuffer::current().unwrap();
39
40    // get console screen buffer information
41    let csbi = screen_buffer.info().unwrap();
42
43    println!("cursor post: {:?}", csbi.cursor_pos());
44    println!("attributes: {:?}", csbi.attributes());
45    println!("terminal window dimentions {:?}", csbi.terminal_window());
46    println!("terminal size {:?}", csbi.terminal_size());
47}
48```
49
50## Handle
51
52```rust
53use crossterm_winapi::{HandleType, Handle};
54
55fn get_different_handle_types() {
56    let out_put_handle = Handle::new(HandleType::OutputHandle).unwrap();
57    let out_put_handle = Handle::new(HandleType::InputHandle).unwrap();
58    let curr_out_put_handle = Handle::new(HandleType::CurrentOutputHandle).unwrap();
59    let curr_out_put_handle = Handle::new(HandleType::CurrentInputHandle).unwrap();
60}
61```
62
63[s1]: https://img.shields.io/crates/v/crossterm_winapi.svg
64[l1]: https://crates.io/crates/crossterm_winapi
65
66[s2]: https://img.shields.io/badge/license-MIT-blue.svg
67[l2]: LICENSE
68
69[s3]: https://docs.rs/crossterm_winapi/badge.svg
70[l3]: https://docs.rs/crossterm_winapi/
71
72[s7]: https://travis-ci.org/crossterm-rs/crossterm.svg?branch=master
73