Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
termion
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
redox-os
termion
Commits
7da5fbf3
Commit
7da5fbf3
authored
9 years ago
by
Ticki
Browse files
Options
Downloads
Patches
Plain Diff
Clean up imports in raw module
parent
12e08141
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/raw.rs
+9
-9
9 additions, 9 deletions
src/raw.rs
with
9 additions
and
9 deletions
src/raw.rs
+
9
−
9
View file @
7da5fbf3
use
std
::
io
::{
Write
,
Error
,
ErrorKind
,
Result
as
IoResult
};
use
std
::
io
::{
self
,
Write
};
use
std
::
ops
::{
Deref
,
DerefMut
};
/// A terminal restorer, which keeps the previous state of the terminal, and restores it, when
...
...
@@ -12,7 +12,7 @@ pub struct RawTerminal<W: Write> {
impl
<
W
:
Write
>
Drop
for
RawTerminal
<
W
>
{
fn
drop
(
&
mut
self
)
{
use
control
::
TermWrite
;
self
.csi
(
b"R"
);
let
_
=
self
.csi
(
b"R"
);
}
}
...
...
@@ -48,11 +48,11 @@ impl<W: Write> DerefMut for RawTerminal<W> {
}
impl
<
W
:
Write
>
Write
for
RawTerminal
<
W
>
{
fn
write
(
&
mut
self
,
buf
:
&
[
u8
])
->
Io
Result
<
usize
>
{
fn
write
(
&
mut
self
,
buf
:
&
[
u8
])
->
io
::
Result
<
usize
>
{
self
.output
.write
(
buf
)
}
fn
flush
(
&
mut
self
)
->
Io
Result
<
()
>
{
fn
flush
(
&
mut
self
)
->
io
::
Result
<
()
>
{
self
.output
.flush
()
}
}
...
...
@@ -64,18 +64,18 @@ pub trait IntoRawMode: Write + Sized {
/// Raw mode means that stdin won't be printed (it will instead have to be written manually by the
/// program). Furthermore, the input isn't canonicalised or buffered (that is, you can read from
/// stdin one byte of a time). The output is neither modified in any way.
fn
into_raw_mode
(
self
)
->
Io
Result
<
RawTerminal
<
Self
>>
;
fn
into_raw_mode
(
self
)
->
io
::
Result
<
RawTerminal
<
Self
>>
;
}
impl
<
W
:
Write
>
IntoRawMode
for
W
{
#[cfg(not(target_os
=
"redox"
))]
fn
into_raw_mode
(
self
)
->
Io
Result
<
RawTerminal
<
W
>>
{
fn
into_raw_mode
(
self
)
->
io
::
Result
<
RawTerminal
<
W
>>
{
use
termios
::{
cfmakeraw
,
get_terminal_attr
,
set_terminal_attr
};
let
(
mut
ios
,
exit
)
=
get_terminal_attr
();
let
prev_ios
=
ios
.clone
();
if
exit
!=
0
{
return
Err
(
Error
::
new
(
ErrorKind
::
Other
,
"Unable to get Termios attribute."
));
return
Err
(
io
::
Error
::
new
(
io
::
ErrorKind
::
Other
,
"Unable to get Termios attribute."
));
}
unsafe
{
...
...
@@ -83,7 +83,7 @@ impl<W: Write> IntoRawMode for W {
}
if
set_terminal_attr
(
&
mut
ios
as
*
mut
_
)
!=
0
{
Err
(
Error
::
new
(
ErrorKind
::
Other
,
"Unable to set Termios attribute."
))
Err
(
io
::
Error
::
new
(
io
::
ErrorKind
::
Other
,
"Unable to set Termios attribute."
))
}
else
{
Ok
(
RawTerminal
{
prev_ios
:
prev_ios
,
...
...
@@ -92,7 +92,7 @@ impl<W: Write> IntoRawMode for W {
}
}
#[cfg(target_os
=
"redox"
)]
fn
into_raw_mode
(
mut
self
)
->
Io
Result
<
RawTerminal
<
W
>>
{
fn
into_raw_mode
(
mut
self
)
->
io
::
Result
<
RawTerminal
<
W
>>
{
use
control
::
TermWrite
;
self
.csi
(
b"r"
)
.map
(|
_
|
RawTerminal
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment