1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

termios: new termios module (#17792)

* termio: new termio module

move the tcgetattr and tcsetattr functions in a new termio module.
The code needed refactoring as different OS have different fields
size, position and number for the C.termios structure, which
could not be correctly expressed consitently otherwise.

It has the positive side effect to reduce the number of unsafe calls.
New testing code was also added for the readline module as it is
relying of the feature.

* apply 2023 copyright to the new files too
This commit is contained in:
Thomas Mangin
2023-03-30 06:58:52 +01:00
committed by GitHub
parent 0826102e0a
commit 580d9cedc7
25 changed files with 921 additions and 723 deletions

View File

@ -7,6 +7,8 @@
//
module readline
import term.termios
// Winsize stores the screen information on Linux.
struct Winsize {
ws_row u16
@ -20,9 +22,9 @@ struct Winsize {
pub struct Readline {
mut:
is_raw bool
orig_termios Termios // Linux
current []rune // Line being edited
cursor int // Cursor position
orig_termios termios.Termios // Linux
current []rune // Line being edited
cursor int // Cursor position
overwrite bool
cursor_row_offset int
prompt string