v / vlib / term / termios / termios_windows.c.v
65 lines · 56 sloc · 1.82 KB · 37255767290c243b71f0e78d77c3bd5e875748e6
Raw
1// Copyright (c) 2019-2024 Alexander Medvednikov. All rights reserved.
2// Use of this source code is governed by an MIT license
3// that can be found in the LICENSE file.
4//
5// TODO: Windows version needs to be implemented.
6// Will serve as more advanced input method
7// based on the work of https://github.com/AmokHuginnsson/replxx
8//
9module termios
10
11type TcFlag = int
12type Speed = int
13type Cc = u8
14
15// flag provides a termios flag of the correct size for the underlying C.termios structure.
16// It is only implemented for Unix like OSes.
17pub fn flag(value int) TcFlag {
18 return int(value)
19}
20
21// invert is a platform dependant way to bitwise NOT (~) TcFlag, as its length varies across platforms.
22// It is only implemented for Unix like OSes.
23pub fn invert(value TcFlag) TcFlag {
24 return ~int(value)
25}
26
27pub struct Termios {
28pub mut:
29 c_iflag TcFlag
30 c_oflag TcFlag
31 c_cflag TcFlag
32 c_lflag TcFlag
33 c_line Cc
34 c_cc [32]Cc
35 c_ispeed Speed
36 c_ospeed Speed
37}
38
39// tcgetattr is an unsafe wrapper around C.termios and keeps its semantic.
40// It is only implemented for Unix like OSes.
41pub fn tcgetattr(fd int, mut termios_p Termios) int {
42 return -1
43}
44
45// tcsetattr is an unsafe wrapper around C.termios and keeps its semantic.
46// It is only implemented for Unix like OSes.
47pub fn tcsetattr(fd int, optional_actions int, mut termios_p Termios) int {
48 return -1
49}
50
51// ioctl is an unsafe wrapper around C.ioctl and keeps its semantic.
52// It is only implemented for Unix like OSes.
53@[inline]
54pub fn ioctl(fd int, request u64, arg voidptr) int {
55 return -1
56}
57
58// set_state applies the flags in the `new_state` to the descriptor `fd`.
59pub fn set_state(fd int, new_state Termios) int {
60 return -1
61}
62
63// disable_echo disables echoing characters as they are typed, when that Termios state is later set with termios.set_state(fd,t).
64pub fn (mut t Termios) disable_echo() {
65}
66