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
efcc232d
Commit
efcc232d
authored
9 years ago
by
Ticki
Browse files
Options
Downloads
Patches
Plain Diff
32-bit support
parent
22ef2409
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/size.rs
+14
-2
14 additions, 2 deletions
src/size.rs
src/termios.rs
+2
-2
2 additions, 2 deletions
src/termios.rs
with
16 additions
and
4 deletions
src/size.rs
+
14
−
2
View file @
efcc232d
...
...
@@ -12,18 +12,30 @@ struct TermSize {
_y
:
c_ushort
,
}
// Since attributes on non-item statements is not stable yet, we use a function.
#[cfg(target_pointer_width
=
"64"
)]
fn
tiocgwinsz
()
->
u64
{
use
termios
::
TIOCGWINSZ
;
TIOCGWINSZ
as
u64
}
#[cfg(target_pointer_width
=
"32"
)]
fn
tiocgwinsz
()
->
u32
{
use
termios
::
TIOCGWINSZ
;
TIOCGWINSZ
as
u32
}
/// Get the size of the terminal.
#[cfg(not(target_os
=
"redox"
))]
pub
fn
terminal_size
()
->
Result
<
(
usize
,
usize
),
TerminalError
>
{
use
libc
::
ioctl
;
use
libc
::
STDOUT_FILENO
;
use
termios
::
TIOCGWINSZ
;
use
std
::
mem
;
unsafe
{
let
mut
size
:
TermSize
=
mem
::
zeroed
();
if
ioctl
(
STDOUT_FILENO
,
TIOCGWINSZ
,
&
mut
size
as
*
mut
_
)
==
0
{
if
ioctl
(
STDOUT_FILENO
,
tiocgwinsz
()
,
&
mut
size
as
*
mut
_
)
==
0
{
Ok
((
size
.col
as
usize
,
size
.row
as
usize
))
}
else
{
Err
(
TerminalError
::
TermSizeError
)
...
...
This diff is collapsed.
Click to expand it.
src/termios.rs
+
2
−
2
View file @
efcc232d
use
libc
::{
c_int
,
c_uint
,
c_uchar
};
#[cfg(not(target_os
=
"macos"
))]
pub
const
TIOCGWINSZ
:
u
64
=
0x00005413
;
pub
const
TIOCGWINSZ
:
u
size
=
0x00005413
;
#[cfg(target_os
=
"macos"
)]
pub
const
TIOCGWINSZ
:
u
64
=
0x40087468
;
pub
const
TIOCGWINSZ
:
u
size
=
0x40087468
;
extern
{
pub
fn
tcgetattr
(
filedes
:
c_int
,
termptr
:
*
mut
Termios
)
->
c_int
;
...
...
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