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
akitsu-sanae
termion
Commits
2335596a
Commit
2335596a
authored
9 years ago
by
Ticki
Browse files
Options
Downloads
Patches
Plain Diff
TerminalRestorer -> RawTerminal
parent
9efbb4e2
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/control.rs
+3
-1
3 additions, 1 deletion
src/control.rs
src/lib.rs
+1
-1
1 addition, 1 deletion
src/lib.rs
src/raw.rs
+11
-11
11 additions, 11 deletions
src/raw.rs
with
15 additions
and
13 deletions
src/control.rs
+
3
−
1
View file @
2335596a
...
...
@@ -44,7 +44,9 @@ pub trait TermWrite {
self
.csi
(
b"?25l"
)
}
// TODO insert mode
// TODO
// fn mode
/// Reset the rendition mode.
///
...
...
This diff is collapsed.
Click to expand it.
src/lib.rs
+
1
−
1
View file @
2335596a
...
...
@@ -28,7 +28,7 @@ mod error;
pub
use
error
::
TerminalError
;
mod
raw
;
pub
use
raw
::{
IntoRawMode
,
Terminal
Restorer
};
pub
use
raw
::{
IntoRawMode
,
Raw
Terminal
};
mod
size
;
pub
use
size
::
terminal_size
;
...
...
This diff is collapsed.
Click to expand it.
src/raw.rs
+
11
−
11
View file @
2335596a
...
...
@@ -6,12 +6,12 @@ use TerminalError;
/// A terminal restorer, which keeps the previous state of the terminal, and restores it, when
/// dropped.
#[cfg(target_os
=
"redox"
)]
pub
struct
Terminal
Restorer
<
W
>
{
pub
struct
Raw
Terminal
<
W
>
{
output
:
W
,
}
#[cfg(target_os
=
"redox"
)]
impl
<
W
:
Write
>
Drop
for
Terminal
Restorer
<
W
>
{
impl
<
W
:
Write
>
Drop
for
Raw
Terminal
<
W
>
{
fn
drop
(
&
mut
self
)
{
use
TermControl
;
self
.csi
(
b"R"
);
...
...
@@ -23,27 +23,27 @@ use termios::Termios;
/// A terminal restorer, which keeps the previous state of the terminal, and restores it, when
/// dropped.
#[cfg(not(target_os
=
"redox"
))]
pub
struct
Terminal
Restorer
<
W
>
{
pub
struct
Raw
Terminal
<
W
>
{
prev_ios
:
Termios
,
output
:
W
,
}
#[cfg(not(target_os
=
"redox"
))]
impl
<
W
>
Drop
for
Terminal
Restorer
<
W
>
{
impl
<
W
>
Drop
for
Raw
Terminal
<
W
>
{
fn
drop
(
&
mut
self
)
{
use
termios
::
set_terminal_attr
;
set_terminal_attr
(
&
mut
self
.prev_ios
as
*
mut
_
);
}
}
impl
<
W
>
Deref
for
Terminal
Restorer
<
W
>
{
impl
<
W
>
Deref
for
Raw
Terminal
<
W
>
{
type
Target
=
W
;
fn
deref
(
&
self
)
->
&
W
{
&
self
.output
}
}
impl
<
W
>
DerefMut
for
Terminal
Restorer
<
W
>
{
impl
<
W
>
DerefMut
for
Raw
Terminal
<
W
>
{
fn
deref_mut
(
&
mut
self
)
->
&
mut
W
{
&
mut
self
.output
}
...
...
@@ -56,12 +56,12 @@ pub trait IntoRawMode: 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
)
->
Result
<
Terminal
Restorer
<
Self
>
,
TerminalError
>
;
fn
into_raw_mode
(
self
)
->
Result
<
Raw
Terminal
<
Self
>
,
TerminalError
>
;
}
impl
<
W
:
Write
>
IntoRawMode
for
W
{
#[cfg(not(target_os
=
"redox"
))]
fn
into_raw_mode
(
self
)
->
Result
<
Terminal
Restorer
<
W
>
,
TerminalError
>
{
fn
into_raw_mode
(
self
)
->
Result
<
Raw
Terminal
<
W
>
,
TerminalError
>
{
use
termios
::{
cfmakeraw
,
get_terminal_attr
,
set_terminal_attr
};
let
(
mut
ios
,
err
)
=
get_terminal_attr
();
...
...
@@ -77,20 +77,20 @@ impl<W: Write> IntoRawMode for W {
if
set_terminal_attr
(
&
mut
ios
as
*
mut
_
)
!=
0
{
Err
(
TerminalError
::
SetAttrError
)
}
else
{
Ok
(
Terminal
Restorer
{
Ok
(
Raw
Terminal
{
prev_ios
:
prev_ios
,
output
:
self
,
})
}
}
#[cfg(target_os
=
"redox"
)]
fn
into_raw_mode
(
self
)
->
Result
<
Terminal
Restorer
<
W
>
,
TerminalError
>
{
fn
into_raw_mode
(
self
)
->
Result
<
Raw
Terminal
<
W
>
,
TerminalError
>
{
use
TermControl
;
if
let
Err
(
_
)
=
self
.csi
(
"r"
)
{
Err
(
TerminalError
::
StdoutError
)
}
else
{
Ok
(
Terminal
Restorer
{
Ok
(
Raw
Terminal
{
output
:
self
,
})
}
...
...
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