Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
fuchsia.googlesource.com-third_party-rust-mirrors-rustyline
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
fuchsia-mirror
fuchsia.googlesource.com-third_party-rust-mirrors-rustyline
Commits
d1fa71c9
Commit
d1fa71c9
authored
8 years ago
by
gwenn
Browse files
Options
Downloads
Patches
Plain Diff
Use libc winsize and TIOCGWINSZ
parent
1ae47dcd
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/tty/unix.rs
+2
-20
2 additions, 20 deletions
src/tty/unix.rs
with
2 additions
and
20 deletions
src/tty/unix.rs
+
2
−
20
View file @
d1fa71c9
...
...
@@ -21,30 +21,12 @@ const STDOUT_FILENO: libc::c_int = libc::STDOUT_FILENO;
/// Unsupported Terminals that don't support RAW mode
static
UNSUPPORTED_TERM
:
[
&
'static
str
;
3
]
=
[
"dumb"
,
"cons25"
,
"emacs"
];
#[cfg(any(target_os
=
"macos"
,
target_os
=
"freebsd"
))]
const
TIOCGWINSZ
:
libc
::
c_ulong
=
0x40087468
;
#[cfg(any(all(target_os
=
"linux"
,
target_env
=
"gnu"
),
target_os
=
"android"
))]
const
TIOCGWINSZ
:
libc
::
c_ulong
=
0x5413
;
#[cfg(all(target_os
=
"linux"
,
target_env
=
"musl"
))]
const
TIOCGWINSZ
:
libc
::
c_int
=
0x5413
;
fn
get_win_size
()
->
(
usize
,
usize
)
{
use
std
::
mem
::
zeroed
;
use
libc
::
c_ushort
;
unsafe
{
#[repr(C)]
struct
winsize
{
ws_row
:
c_ushort
,
ws_col
:
c_ushort
,
ws_xpixel
:
c_ushort
,
ws_ypixel
:
c_ushort
,
}
let
mut
size
:
winsize
=
zeroed
();
match
libc
::
ioctl
(
STDOUT_FILENO
,
TIOCGWINSZ
,
&
mut
size
)
{
let
mut
size
:
libc
::
winsize
=
zeroed
();
match
libc
::
ioctl
(
STDOUT_FILENO
,
libc
::
TIOCGWINSZ
,
&
mut
size
)
{
0
=>
(
size
.ws_col
as
usize
,
size
.ws_row
as
usize
),
// TODO getCursorPosition
_
=>
(
80
,
24
),
}
...
...
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