Initial commit
This commit is contained in:
commit
be3963718a
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/target
|
7
Cargo.lock
generated
Normal file
7
Cargo.lock
generated
Normal file
@ -0,0 +1,7 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "termios"
|
||||
version = "0.1.0"
|
6
Cargo.toml
Normal file
6
Cargo.toml
Normal file
@ -0,0 +1,6 @@
|
||||
[package]
|
||||
name = "termios"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
200
src/lib.rs
Normal file
200
src/lib.rs
Normal file
@ -0,0 +1,200 @@
|
||||
pub struct Iflags {
|
||||
pub brkint: bool,
|
||||
pub icrnl: bool,
|
||||
pub ignbrk: bool,
|
||||
pub igncr: bool,
|
||||
pub ignpar: bool,
|
||||
pub inlcr: bool,
|
||||
pub inpck: bool,
|
||||
pub istrip: bool,
|
||||
pub ixany: bool,
|
||||
pub ixoff: bool,
|
||||
pub ixon: bool,
|
||||
pub parmark: bool,
|
||||
}
|
||||
|
||||
impl Default for Iflags {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
brkint: false,
|
||||
icrnl: true,
|
||||
ignbrk: false,
|
||||
igncr: false,
|
||||
ignpar: true,
|
||||
inlcr: false,
|
||||
inpck: true,
|
||||
istrip: false,
|
||||
ixany: false,
|
||||
ixoff: false,
|
||||
ixon: true,
|
||||
parmark: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Oflags {
|
||||
pub opost: bool,
|
||||
pub onlcr: bool,
|
||||
pub ocrnl: bool,
|
||||
pub onocr: bool,
|
||||
pub onlret: bool,
|
||||
pub ofdel: bool,
|
||||
pub nldly: NlDelay,
|
||||
pub crdly: CrDelay,
|
||||
pub tabdly: TabDelay,
|
||||
pub bsdly: BsDelay,
|
||||
pub vtdly: VtDelay,
|
||||
pub ffdly: FfDelay,
|
||||
}
|
||||
|
||||
impl Default for Oflags {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
opost: true,
|
||||
onlcr: true,
|
||||
ocrnl: false,
|
||||
onocr: false,
|
||||
onlret: false,
|
||||
ofdel: false,
|
||||
nldly: NlDelay::Nl0,
|
||||
crdly: CrDelay::Cr0,
|
||||
tabdly: TabDelay::Tab0,
|
||||
bsdly: BsDelay::Bs0,
|
||||
vtdly: VtDelay::Vt0,
|
||||
ffdly: FfDelay::Ff0,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub enum NlDelay {
|
||||
Nl0,
|
||||
Nl1,
|
||||
}
|
||||
|
||||
pub enum CrDelay {
|
||||
Cr0,
|
||||
Cr1,
|
||||
Cr2,
|
||||
Cr3,
|
||||
}
|
||||
|
||||
pub enum TabDelay {
|
||||
Tab0,
|
||||
Tab1,
|
||||
Tab2,
|
||||
Tab3,
|
||||
}
|
||||
|
||||
pub enum BsDelay {
|
||||
Bs0,
|
||||
Bs1,
|
||||
}
|
||||
|
||||
pub enum VtDelay {
|
||||
Vt0,
|
||||
Vt1,
|
||||
}
|
||||
|
||||
pub enum FfDelay {
|
||||
Ff0,
|
||||
Ff1,
|
||||
}
|
||||
|
||||
pub struct Cflags {
|
||||
pub csize: CharSize,
|
||||
pub cstopb: bool,
|
||||
pub cread: bool,
|
||||
pub parenb: bool,
|
||||
pub parodd: bool,
|
||||
pub hupcl: bool,
|
||||
pub clocal: bool,
|
||||
}
|
||||
|
||||
impl Default for Cflags {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
csize: CharSize::Cs8,
|
||||
cstopb: false,
|
||||
cread: true,
|
||||
parenb: false,
|
||||
parodd: false,
|
||||
hupcl: true,
|
||||
clocal: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub enum CharSize {
|
||||
Cs5,
|
||||
Cs6,
|
||||
Cs7,
|
||||
Cs8,
|
||||
}
|
||||
|
||||
pub struct Lflags {
|
||||
pub echo: bool,
|
||||
pub echoe: bool,
|
||||
pub echok: bool,
|
||||
pub echonl: bool,
|
||||
pub icanon: bool,
|
||||
pub iexten: bool,
|
||||
pub isig: bool,
|
||||
pub noflsh: bool,
|
||||
pub tostop: bool,
|
||||
}
|
||||
|
||||
impl Default for Lflags {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
echo: true,
|
||||
echoe: true,
|
||||
echok: true,
|
||||
echonl: false,
|
||||
icanon: true,
|
||||
iexten: true,
|
||||
isig: true,
|
||||
noflsh: false,
|
||||
tostop: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Termios {
|
||||
pub iflags: Iflags,
|
||||
pub oflags: Oflags,
|
||||
pub cflags: Cflags,
|
||||
pub lflags: Lflags,
|
||||
pub veof: char,
|
||||
pub veol: char,
|
||||
pub verase: char,
|
||||
pub vintr: char,
|
||||
pub vkill: char,
|
||||
pub vmin: u32,
|
||||
pub vquit: char,
|
||||
pub vstart: char,
|
||||
pub vstop: char,
|
||||
pub vsusp: char,
|
||||
pub vtime: u32,
|
||||
}
|
||||
|
||||
impl Default for Termios {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
iflags: Iflags::default(),
|
||||
oflags: Oflags::default(),
|
||||
cflags: Cflags::default(),
|
||||
lflags: Lflags::default(),
|
||||
veof: '\u{4}', //ctrl-D (EOT)
|
||||
veol: '\n',
|
||||
verase: '\u{8}', //ctrl-H (BS)
|
||||
vintr: '\u{3}', //ctrl-C (ETX)
|
||||
vkill: '\u{15}', //ctrl-U (NAK)
|
||||
vmin: 0,
|
||||
vquit: '\u{1C}', //ctrl-\
|
||||
vstart: '\u{11}', // ctrl-S (XONN)
|
||||
vstop: '\u{13}', // ctrl-Q (XOFF)
|
||||
vsusp: '\u{1A}', // ctrl-Z (SUB)
|
||||
vtime: 0,
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user