survivor

graphical action game for the linux terminal
git clone https://git.ce9e.org/survivor.git

commit
92b42cac05422529b9335cc0e3e4236d4018b80c
parent
fbee65761413620270ecf1961f5d60004b98ef58
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2023-02-20 20:51
use winsize type for get_terminal_size

Diffstat

M src/term.rs 9 +++++++--

1 files changed, 7 insertions, 2 deletions


diff --git a/src/term.rs b/src/term.rs

@@ -1,11 +1,16 @@
    1     1 extern crate libc;
    2     2 
    3     3 fn get_terminal_size() -> (usize, usize) {
    4    -1     let w = [0u16; 4];
   -1     4     let w: libc::winsize = libc::winsize {
   -1     5         ws_col: 0,
   -1     6         ws_row: 0,
   -1     7         ws_ypixel: 0,
   -1     8         ws_xpixel: 0,
   -1     9     };
    5    10     unsafe {
    6    11         libc::ioctl(1, libc::TIOCGWINSZ, &w);
    7    12     }
    8    -1     return (w[1] as usize, w[0] as usize);
   -1    13     return (w.ws_col as usize, w.ws_row as usize);
    9    14 }
   10    15 
   11    16 mod ti {