Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
termion
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
akitsu-sanae
termion
Commits
8388d564
Commit
8388d564
authored
Jul 21, 2019
by
akitsu-sanae
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feature: window manipulation
parent
c27678ef
Pipeline
#5357
failed with stages
in 23 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
59 additions
and
0 deletions
+59
-0
src/lib.rs
src/lib.rs
+1
-0
src/window.rs
src/window.rs
+58
-0
No files found.
src/lib.rs
View file @
8388d564
...
...
@@ -40,6 +40,7 @@ pub mod raw;
pub
mod
screen
;
pub
mod
scroll
;
pub
mod
style
;
pub
mod
window
;
#[cfg(test)]
mod
test
{
...
...
src/window.rs
0 → 100644
View file @
8388d564
//! Window manipulation
use
std
::
fmt
;
use
numtoa
::
NumToA
;
// TODO: add restoring for minimization and maximization respectively
derive_csi_sequence!
(
"Minimize the terminal window."
,
Minimize
,
"2t"
);
derive_csi_sequence!
(
"Minimize the terminal window."
,
Maxmize
,
"9;1t"
);
/// Resize the terminal text area in character size unit
#[derive(Copy,
Clone,
PartialEq,
Eq)]
pub
struct
Resize
(
pub
u16
,
pub
u16
);
impl
From
<
Resize
>
for
String
{
fn
from
(
this
:
Resize
)
->
String
{
let
(
mut
x
,
mut
y
)
=
([
0u8
;
20
],
[
0u8
;
20
]);
[
"
\x1B
[8;"
,
this
.1
.numtoa_str
(
10
,
&
mut
x
),
";"
,
this
.0
.numtoa_str
(
10
,
&
mut
y
),
"t"
]
.concat
()
}
}
impl
Default
for
Resize
{
fn
default
()
->
Resize
{
use
sys
::
size
::
terminal_size
;
let
(
col
,
row
)
=
terminal_size
()
.unwrap
();
Resize
(
col
,
row
)
}
}
impl
fmt
::
Display
for
Resize
{
fn
fmt
(
&
self
,
f
:
&
mut
fmt
::
Formatter
)
->
fmt
::
Result
{
f
.write_str
(
&
String
::
from
(
*
self
))
}
}
/// Move the terminal window
#[derive(Copy,
Clone,
PartialEq,
Eq)]
pub
struct
Move
(
pub
u16
,
pub
u16
);
impl
From
<
Move
>
for
String
{
fn
from
(
this
:
Move
)
->
String
{
let
(
mut
x
,
mut
y
)
=
([
0u8
;
20
],
[
0u8
;
20
]);
[
"
\x1B
[3;"
,
this
.0
.numtoa_str
(
10
,
&
mut
x
),
";"
,
this
.1
.numtoa_str
(
10
,
&
mut
y
),
"t"
]
.concat
()
}
}
impl
Default
for
Move
{
fn
default
()
->
Move
{
Move
(
0
,
0
)
// TODO: use current terminal size
}
}
impl
fmt
::
Display
for
Move
{
fn
fmt
(
&
self
,
f
:
&
mut
fmt
::
Formatter
)
->
fmt
::
Result
{
f
.write_str
(
&
String
::
from
(
*
self
))
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment