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
45b1136f
Commit
45b1136f
authored
9 years ago
by
Ticki
Browse files
Options
Downloads
Patches
Plain Diff
get_passwd(), new example, update README
parent
098ce66b
No related branches found
No related tags found
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
README.md
+18
-1
18 additions, 1 deletion
README.md
examples/read.rs
+22
-0
22 additions, 0 deletions
examples/read.rs
examples/simple.rs
+4
-3
4 additions, 3 deletions
examples/simple.rs
src/extra.rs
+29
-0
29 additions, 0 deletions
src/extra.rs
src/lib.rs
+5
-0
5 additions, 0 deletions
src/lib.rs
with
78 additions
and
4 deletions
README.md
+
18
−
1
View file @
45b1136f
libterm
=======
A Rust Termios wrapper, providing various useful abstractions for dealing with terminals.
A pure Rust library for handling, manipulating and reading information about terminals. This provides a full-featured alternative to Termbox.
Features
--------
-
Raw mode.
-
Cursor movement.
-
Color output.
-
Text formatting.
-
Console size.
-
Control sequences.
-
Termios control.
-
Password input.
TODO
----
-
Mouse input
Usage
-----
...
...
This diff is collapsed.
Click to expand it.
examples/read.rs
0 → 100644
+
22
−
0
View file @
45b1136f
extern
crate
libterm
;
use
libterm
::
ReadExt
;
use
std
::
io
::{
Write
,
stdout
,
stdin
};
fn
main
()
{
let
stdout
=
stdout
();
let
mut
stdout
=
stdout
.lock
();
let
mut
stdin
=
stdin
();
stdout
.write
(
b"password: "
)
.unwrap
();
stdout
.flush
()
.unwrap
();
let
pass
=
stdin
.read_passwd
();
if
let
Some
(
pass
)
=
pass
{
stdout
.write
(
pass
.as_bytes
())
.unwrap
();
stdout
.write
(
b"
\n
"
)
.unwrap
();
}
else
{
stdout
.write
(
b"Error
\n
"
)
.unwrap
();
}
}
This diff is collapsed.
Click to expand it.
examples/simple.rs
+
4
−
3
View file @
45b1136f
extern
crate
libterm
;
use
libterm
::{
TermControl
,
raw_mode
,
Color
,
Mode
};
use
libterm
::{
TermControl
,
raw_mode
,
Color
,
Mode
,
ReadExt
};
use
std
::
io
::{
Read
,
Write
,
stdout
,
stdin
};
fn
main
()
{
let
_raw
=
raw_mode
();
let
mut
stdout
=
stdout
();
let
stdin
=
stdin
();
let
stdout
=
stdout
();
let
mut
stdout
=
stdout
.lock
();
let
mut
stdin
=
stdin
();
stdout
.goto
(
5
,
5
)
.unwrap
();
stdout
.clear
()
.unwrap
();
...
...
This diff is collapsed.
Click to expand it.
src/extra.rs
0 → 100644
+
29
−
0
View file @
45b1136f
use
std
::
io
::
Read
;
use
raw_mode
;
/// Extension to `Read` trait.
pub
trait
ReadExt
{
/// Read a password.
fn
read_passwd
(
&
mut
self
)
->
Option
<
String
>
;
}
impl
<
R
:
Read
>
ReadExt
for
R
{
fn
read_passwd
(
&
mut
self
)
->
Option
<
String
>
{
let
_raw
=
raw_mode
();
let
mut
string
=
String
::
with_capacity
(
30
);
for
c
in
self
.chars
()
{
match
if
let
Ok
(
c
)
=
c
{
c
}
else
{
return
None
;
}
{
'\x00'
|
'\x03'
|
'\x04'
=>
return
None
,
'\r'
=>
return
Some
(
string
),
b
=>
string
.push
(
b
),
}
}
Some
(
string
)
}
}
This diff is collapsed.
Click to expand it.
src/lib.rs
+
5
−
0
View file @
45b1136f
#![feature(io)]
#![feature(libc)]
#[warn(missing_docs)]
extern
crate
libc
;
...
...
@@ -19,3 +21,6 @@ pub use color::Color;
mod
mode
;
pub
use
mode
::
Mode
;
mod
extra
;
pub
use
extra
::
ReadExt
;
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