1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
// This file is part of file-descriptors. It is subject to the license terms in the COPYRIGHT file found in the top-level directory of this distribution and at https://raw.githubusercontent.com/lemonrock/file-descriptors/master/COPYRIGHT. No part of file-descriptors, including this file, may be copied, modified, propagated, or distributed except according to the terms contained in the COPYRIGHT file.
// Copyright © 2019 The developers of file-descriptors. See the COPYRIGHT file in the top-level directory of this distribution and at https://raw.githubusercontent.com/lemonrock/file-descriptors/master/COPYRIGHT.
/// Current terminal settings.
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct CurrentTerminalSettings(pub(crate) termios);
impl CurrentTerminalSettings
{
/// Input mode flag settings.
#[inline(always)]
pub fn input_mode_flag_settings(&self) -> InputModeFlagSettings
{
InputModeFlagSettings::from_mode_flags(self.0.c_iflag)
}
/// Backspace delay.
#[inline(always)]
pub fn backspace_delay(&self) -> BackspaceDelay
{
BackspaceDelay::from_mode_flags(self.0.c_oflag)
}
/// Carriage Return delay.
#[inline(always)]
pub fn carriage_return_delay(&self) -> CarriageReturnDelay
{
CarriageReturnDelay::from_mode_flags(self.0.c_oflag)
}
/// Form Feed delay.
#[inline(always)]
pub fn form_feed_delay(&self) -> FormFeedDelay
{
FormFeedDelay::from_mode_flags(self.0.c_oflag)
}
/// Horizontal Tab delay.
#[inline(always)]
pub fn horizontal_tab_delay(&self) -> HorizontalTabDelay
{
HorizontalTabDelay::from_mode_flags(self.0.c_oflag)
}
/// New Line delay.
#[inline(always)]
pub fn new_line_delay(&self) -> NewLineDelay
{
NewLineDelay::from_mode_flags(self.0.c_oflag)
}
/// Vertical Tab delay.
#[inline(always)]
pub fn vertical_tab_delay(&self) -> VerticalTabDelay
{
VerticalTabDelay::from_mode_flags(self.0.c_oflag)
}
/// Miscellaneous output mode flag settings.
#[inline(always)]
pub fn miscellaneous_output_mode_flag_settings(&self) -> MiscellaneousOutputModeFlagSettings
{
MiscellaneousOutputModeFlagSettings::from_mode_flags(self.0.c_oflag)
}
/// Bits per byte.
#[inline(always)]
pub fn bits_per_byte(&self) -> BitsPerByte
{
BitsPerByte::from_mode_flags(self.0.c_cflag)
}
/// How many stop bits?
#[inline(always)]
pub fn stop_bits(&self) -> StopBits
{
StopBits::from_mode_flags(self.0.c_cflag)
}
/// Parity.
#[inline(always)]
pub fn parity(&self) -> Parity
{
Parity::from_mode_flags(self.0.c_cflag)
}
/// Miscellaneous control mode flag settings.
#[inline(always)]
pub fn miscellaneous_control_mode_flag_settings(&self) -> MiscellaneousControlModeFlagSettings
{
MiscellaneousControlModeFlagSettings::from_mode_flags(self.0.c_cflag)
}
/// Miscellaneous local mode flag settings.
#[inline(always)]
pub fn miscellaneous_local_mode_flag_settings(&self) -> MiscellaneousLocalModeFlagSettings
{
MiscellaneousLocalModeFlagSettings::from_mode_flags(self.0.c_lflag)
}
/// Is flushing occurring?
#[inline(always)]
pub fn is_flushing_occurring(&self) -> bool
{
self.0.c_lflag & FLUSHO != 0
}
/// Terminal Mode.
#[inline(always)]
pub fn terminal_mode(&self) -> TerminalMode
{
TerminalMode::interpret_terminal_mode(self.0.c_lflag)
}
/// Echo.
#[inline(always)]
pub fn echo(&self) -> Echo
{
Echo::from_mode_flags(self.0.c_lflag)
}
/// Signal raising behaviour.
#[inline(always)]
pub fn signal_raising(&self) -> SignalRaising
{
SignalRaising::from_mode_flags(self.0.c_lflag)
}
/// Character settings.
#[inline(always)]
pub fn character_settings(&self) -> CharacterSettings
{
CharacterSettings::from_terminal_options(&self.0)
}
/// Baud rate.
#[inline(always)]
pub fn baud_rate(&self) -> BaudRate
{
unsafe { transmute(cfgetospeed(&self.0)) }
}
}