Skip to content

Commit

Permalink
term: fix vlib/term/termios/termios_test.v on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
spytheman committed Jul 31, 2023
1 parent 367289a commit 81e99a2
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
15 changes: 15 additions & 0 deletions vlib/term/termios/termios_test.v
@@ -1,5 +1,20 @@
module termios

fn test_portable() {
assert 123 == int(flag(123))
o := Termios{
c_lflag: flag(0xFFFF)
} // assume c_lflag exists everywhere
// dump( o.c_lflag )
mut n := o
n.c_lflag &= invert(1)
// dump( n.c_lflag )
assert n.c_lflag != o.c_lflag
n.disable_echo() // just assume it exists, and can be called everywhere
assert true
}

[if !windows]
fn test_termios() {
mut original_term := Termios{}
tcgetattr(0, mut original_term)
Expand Down
9 changes: 9 additions & 0 deletions vlib/term/termios/termios_windows.c.v
Expand Up @@ -27,6 +27,15 @@ pub fn invert(value TcFlag) TcFlag {
}

pub struct Termios {
pub mut:
c_iflag TcFlag
c_oflag TcFlag
c_cflag TcFlag
c_lflag TcFlag
c_line Cc
c_cc [32]Cc
c_ispeed Speed
c_ospeed Speed
}

// tcgetattr is an unsafe wrapper around C.termios and keeps its semantic
Expand Down

0 comments on commit 81e99a2

Please sign in to comment.