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
098ce66b
Commit
098ce66b
authored
9 years ago
by
Ticki
Browse files
Options
Downloads
Patches
Plain Diff
Rendition modes
parent
6f9addc4
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
examples/simple.rs
+3
-1
3 additions, 1 deletion
examples/simple.rs
src/control.rs
+7
-3
7 additions, 3 deletions
src/control.rs
src/lib.rs
+3
-0
3 additions, 0 deletions
src/lib.rs
src/mode.rs
+21
-0
21 additions, 0 deletions
src/mode.rs
with
34 additions
and
4 deletions
examples/simple.rs
+
3
−
1
View file @
098ce66b
extern
crate
libterm
;
use
libterm
::{
TermControl
,
raw_mode
,
Color
};
use
libterm
::{
TermControl
,
raw_mode
,
Color
,
Mode
};
use
std
::
io
::{
Read
,
Write
,
stdout
,
stdin
};
fn
main
()
{
...
...
@@ -10,7 +10,9 @@ fn main() {
stdout
.goto
(
5
,
5
)
.unwrap
();
stdout
.clear
()
.unwrap
();
stdout
.mode
(
Mode
::
Bold
)
.unwrap
();
stdout
.write
(
b"yo, 'q' will exit."
)
.unwrap
();
stdout
.reset
()
.unwrap
();
stdout
.flush
()
.unwrap
();
stdout
.goto
(
20
,
10
)
.unwrap
();
...
...
This diff is collapsed.
Click to expand it.
src/control.rs
+
7
−
3
View file @
098ce66b
use
std
::
io
::{
Write
,
Result
as
IoResult
};
use
Color
;
use
{
Color
,
Mode
}
;
/// Controlling terminals.
pub
trait
TermControl
{
...
...
@@ -21,8 +21,8 @@ pub trait TermControl {
fn
hide
(
&
mut
self
)
->
IoResult
<
usize
>
{
self
.csi
(
b"?25l"
)
}
/// Reset the
style of the cursor
.
fn
reset
_style
(
&
mut
self
)
->
IoResult
<
usize
>
{
/// Reset the
rendition mode
.
fn
reset
(
&
mut
self
)
->
IoResult
<
usize
>
{
self
.csi
(
b"m"
)
}
/// Go to a given position.
...
...
@@ -71,6 +71,10 @@ pub trait TermControl {
b'm'
,
])
}
/// Set rendition mode (SGR).
fn
mode
(
&
mut
self
,
mode
:
Mode
)
->
IoResult
<
usize
>
{
self
.rendition
(
mode
as
u8
)
}
}
impl
<
W
:
Write
>
TermControl
for
W
{
...
...
This diff is collapsed.
Click to expand it.
src/lib.rs
+
3
−
0
View file @
098ce66b
...
...
@@ -16,3 +16,6 @@ pub use size::termsize;
mod
color
;
pub
use
color
::
Color
;
mod
mode
;
pub
use
mode
::
Mode
;
This diff is collapsed.
Click to expand it.
src/mode.rs
0 → 100644
+
21
−
0
View file @
098ce66b
/// A SGR parameter (rendition mode).
pub
enum
Mode
{
/// Reset SGR parameters.
Reset
=
0
,
/// Bold text.
Bold
=
1
,
/// Fainted text (not widely supported).
Faint
=
2
,
/// Italic text.
Italic
=
3
,
/// Underlined text.
Underline
=
4
,
/// Blinking text (not widely supported).
Blink
=
5
,
/// Inverted colors (negative mode).
Invert
=
7
,
/// Crossed out text (not widely supported).
CrossedOut
=
9
,
/// Framed text (not widely supported).
Framed
=
51
,
}
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