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
451cb95e
Commit
451cb95e
authored
8 years ago
by
Ticki
Browse files
Options
Downloads
Patches
Plain Diff
Add colors example
parent
99db72b3
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
examples/colors.rs
+137
-0
137 additions, 0 deletions
examples/colors.rs
with
137 additions
and
0 deletions
examples/colors.rs
0 → 100644
+
137
−
0
View file @
451cb95e
extern
crate
termion
;
use
termion
::{
TermWrite
,
Color
,
Style
};
use
std
::
io
::{
self
,
Write
};
const
LINE_NUM_BG
:
Color
=
Color
::
Grayscale
(
5
);
const
LINE_NUM_FG
:
Color
=
Color
::
Grayscale
(
18
);
const
ERROR_FG
:
Color
=
Color
::
Grayscale
(
17
);
const
INFO_LINE
:
&
'static
str
=
"│ "
;
fn
main
()
{
let
stdout
=
io
::
stdout
();
let
mut
stdout
=
stdout
.lock
();
stdout
.color
(
Color
::
LightGreen
)
.unwrap
();
stdout
.write
(
"—— src/test/ui/borrow-errors.rs at 82:18 ——
\n
"
.as_bytes
())
.unwrap
();
stdout
.reset
()
.unwrap
();
stdout
.color
(
Color
::
Red
)
.unwrap
();
stdout
.style
(
Style
::
Bold
)
.unwrap
();
stdout
.write
(
b"error: "
)
.unwrap
();
stdout
.reset
()
.unwrap
();
stdout
.style
(
Style
::
Bold
)
.unwrap
();
stdout
.write
(
b"two closures require unique access to `vec` at the same time"
)
.unwrap
();
stdout
.reset
()
.unwrap
();
stdout
.style
(
Style
::
Bold
)
.unwrap
();
stdout
.color
(
Color
::
Magenta
)
.unwrap
();
stdout
.write
(
b" [E0524]
\n
"
)
.unwrap
();
stdout
.reset
()
.unwrap
();
stdout
.color
(
LINE_NUM_FG
)
.unwrap
();
stdout
.bg_color
(
LINE_NUM_BG
)
.unwrap
();
stdout
.write
(
b"79 "
)
.unwrap
();
stdout
.reset
()
.unwrap
();
stdout
.write
(
b" let append = |e| {
\n
"
)
.unwrap
();
stdout
.color
(
LINE_NUM_FG
)
.unwrap
();
stdout
.bg_color
(
LINE_NUM_BG
)
.unwrap
();
stdout
.write
(
INFO_LINE
.as_bytes
())
.unwrap
();
stdout
.reset
()
.unwrap
();
stdout
.color
(
Color
::
Red
)
.unwrap
();
stdout
.write
(
" ━━━ "
.as_bytes
())
.unwrap
();
stdout
.reset
()
.unwrap
();
stdout
.color
(
ERROR_FG
)
.unwrap
();
stdout
.write
(
b"first closure is constructed here
\n
"
)
.unwrap
();
stdout
.reset
()
.unwrap
();
stdout
.color
(
LINE_NUM_FG
)
.unwrap
();
stdout
.bg_color
(
LINE_NUM_BG
)
.unwrap
();
stdout
.write
(
b"80 "
)
.unwrap
();
stdout
.reset
()
.unwrap
();
stdout
.write
(
b" vec.push(e)
\n
"
)
.unwrap
();
stdout
.color
(
LINE_NUM_FG
)
.unwrap
();
stdout
.bg_color
(
LINE_NUM_BG
)
.unwrap
();
stdout
.write
(
INFO_LINE
.as_bytes
())
.unwrap
();
stdout
.reset
()
.unwrap
();
stdout
.color
(
Color
::
Red
)
.unwrap
();
stdout
.write
(
" ━━━ "
.as_bytes
())
.unwrap
();
stdout
.reset
()
.unwrap
();
stdout
.color
(
ERROR_FG
)
.unwrap
();
stdout
.write
(
b"previous borrow occurs due to use of `vec` in closure
\n
"
)
.unwrap
();
stdout
.reset
()
.unwrap
();
stdout
.color
(
LINE_NUM_FG
)
.unwrap
();
stdout
.bg_color
(
LINE_NUM_BG
)
.unwrap
();
stdout
.write
(
b"81 "
)
.unwrap
();
stdout
.reset
()
.unwrap
();
stdout
.write
(
b" };
\n
"
)
.unwrap
();
stdout
.color
(
LINE_NUM_FG
)
.unwrap
();
stdout
.bg_color
(
LINE_NUM_BG
)
.unwrap
();
stdout
.write
(
b"82 "
)
.unwrap
();
stdout
.reset
()
.unwrap
();
stdout
.write
(
b" let append = |e| {
\n
"
)
.unwrap
();
stdout
.color
(
LINE_NUM_FG
)
.unwrap
();
stdout
.bg_color
(
LINE_NUM_BG
)
.unwrap
();
stdout
.write
(
INFO_LINE
.as_bytes
())
.unwrap
();
stdout
.reset
()
.unwrap
();
stdout
.color
(
Color
::
Red
)
.unwrap
();
stdout
.write
(
" ━━━ "
.as_bytes
())
.unwrap
();
stdout
.reset
()
.unwrap
();
stdout
.color
(
ERROR_FG
)
.unwrap
();
stdout
.write
(
b"second closure is constructed here
\n
"
)
.unwrap
();
stdout
.reset
()
.unwrap
();
stdout
.color
(
LINE_NUM_FG
)
.unwrap
();
stdout
.bg_color
(
LINE_NUM_BG
)
.unwrap
();
stdout
.write
(
b"83 "
)
.unwrap
();
stdout
.reset
()
.unwrap
();
stdout
.write
(
b" vec.push(e)
\n
"
)
.unwrap
();
stdout
.color
(
LINE_NUM_FG
)
.unwrap
();
stdout
.bg_color
(
LINE_NUM_BG
)
.unwrap
();
stdout
.write
(
INFO_LINE
.as_bytes
())
.unwrap
();
stdout
.reset
()
.unwrap
();
stdout
.color
(
Color
::
Red
)
.unwrap
();
stdout
.write
(
" ━━━ "
.as_bytes
())
.unwrap
();
stdout
.reset
()
.unwrap
();
stdout
.color
(
ERROR_FG
)
.unwrap
();
stdout
.write
(
b"borrow occurs due to use of `vec` in closure
\n
"
)
.unwrap
();
stdout
.reset
()
.unwrap
();
stdout
.color
(
LINE_NUM_FG
)
.unwrap
();
stdout
.bg_color
(
LINE_NUM_BG
)
.unwrap
();
stdout
.write
(
b"84 "
)
.unwrap
();
stdout
.reset
()
.unwrap
();
stdout
.write
(
b" };
\n
"
)
.unwrap
();
stdout
.color
(
LINE_NUM_FG
)
.unwrap
();
stdout
.bg_color
(
LINE_NUM_BG
)
.unwrap
();
stdout
.write
(
b"85 "
)
.unwrap
();
stdout
.reset
()
.unwrap
();
stdout
.write
(
b" }
\n
"
)
.unwrap
();
stdout
.color
(
LINE_NUM_FG
)
.unwrap
();
stdout
.bg_color
(
LINE_NUM_BG
)
.unwrap
();
stdout
.write
(
INFO_LINE
.as_bytes
())
.unwrap
();
stdout
.reset
()
.unwrap
();
stdout
.color
(
Color
::
Red
)
.unwrap
();
stdout
.write
(
" ━ "
.as_bytes
())
.unwrap
();
stdout
.reset
()
.unwrap
();
stdout
.color
(
ERROR_FG
)
.unwrap
();
stdout
.write
(
b"borrow from first closure ends here
\n
"
)
.unwrap
();
stdout
.reset
()
.unwrap
();
}
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