From 81e99a2af3e53eb6d58e2ad83dd4fc486e17fead Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Mon, 31 Jul 2023 14:22:03 +0300 Subject: [PATCH] term: fix vlib/term/termios/termios_test.v on windows --- vlib/term/termios/termios_test.v | 15 +++++++++++++++ vlib/term/termios/termios_windows.c.v | 9 +++++++++ 2 files changed, 24 insertions(+) diff --git a/vlib/term/termios/termios_test.v b/vlib/term/termios/termios_test.v index 8fe37b8f19..e6f6e486e7 100644 --- a/vlib/term/termios/termios_test.v +++ b/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) diff --git a/vlib/term/termios/termios_windows.c.v b/vlib/term/termios/termios_windows.c.v index 632393e2dd..b262057a9d 100644 --- a/vlib/term/termios/termios_windows.c.v +++ b/vlib/term/termios/termios_windows.c.v @@ -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