k_board/
lib.rs

1/***************************************************************************************
2 *   lib.rs  --  This file is part of k_board.                                         *
3 *                                                                                     *
4 *   Copyright (C) 2024 Mateo Lafalce                                                  *
5 *                                                                                     *
6 *   k_board is free software: you can redistribute it and/or modify                   *
7 *   it under the terms of the GNU General Public License as published                 *
8 *   by the Free Software Foundation, either version 3 of the License,                 *
9 *   or (at your option) any later version.                                            *
10 *                                                                                     *
11 *   k_board is distributed in the hope that it will be useful,                        *
12 *   but WITHOUT ANY WARRANTY; without even the implied warranty                       *
13 *   of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                           *
14 *   See the GNU General Public License for more details.                              *
15 *                                                                                     *
16 *   You should have received a copy of the GNU General Public License                 *
17 *   along with this program.  If not, see http://www.gnu.org/licenses/.               *
18 *                                                                                     *
19 **************************************************************************************/
20
21//!
22//! [<img alt="crates.io" src="https://img.shields.io/crates/v/k_board.svg?style=for-the-badge&color=fc8d62&logo=rust" height="20">](https://crates.io/crates/k_board)
23//! [<img alt="github" src="https://img.shields.io/badge/github-mateolafalce/k__board-8da0cb?style=for-the-badge&labelColor=555555&logo=github" height="20">](https://github.com/mateolafalce/k_board)
24//! [<img alt="docs.rs" src="https://img.shields.io/badge/docs.rs-k__board-66c2a5?style=for-the-badge&labelColor=555555&logo=docs.rs" height="20">](https://docs.rs/k_board)
25//!
26//! A lightweight keyboard mannager developed for dynamic programs by listening to keyboard events in raw mode (without the need to press enter). The handler has all the standard events of a western keyboard.
27//!
28//! - Gnu/Linux
29//!
30//! # Examples
31//!
32//! ```rust,ignore
33//! use k_board::{keyboard::Keyboard, keys::Keys};
34//!
35//!fn main() {
36//!    menu(0);
37//!    for key in Keyboard::new() {
38//!        match key {
39//!            Keys::Up => menu(0),
40//!            Keys::Down => menu(1),
41//!            Keys::Enter => break,
42//!            _ => {}
43//!        }
44//!    }
45//!}
46//!
47//!fn menu(operation: u8) {
48//!    std::process::Command::new("clear").status().unwrap();
49//!    let mut op: Vec<char> = vec!['*', ' '];
50//!    if operation == 1 {
51//!        op[0] = ' ';
52//!        op[1] = '*';
53//!    }
54//!    println!(
55//!        "[{}] I use k_board lightweight software\n[{}] I use heavyweight software",
56//!        op[0], op[1]
57//!    );
58//!}
59//! ```
60//!
61
62/// Keyboard struct & impls
63pub mod keyboard;
64/// All keys tables
65pub mod keys;
66/// Termios raw ops (linux kernel)
67pub mod termio;