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

readline: basic mac and windows version using os.getline

This commit is contained in:
Henrixounez
2019-10-15 08:04:22 +02:00
committed by Alexander Medvednikov
parent 195da8ef3f
commit bb1eca3564
4 changed files with 175 additions and 34 deletions

View File

@@ -13,39 +13,6 @@ import term
#include <termios.h>
#include <sys/ioctl.h>
// Used to change the terminal options
struct Termios {
mut:
c_iflag int
c_oflag int
c_cflag int
c_lflag int
c_cc [12]int //NCCS == 12. Cant use the defined value here
}
// Used to collect the screen information
struct Winsize {
ws_row u16
ws_col u16
ws_xpixel u16
ws_ypixel u16
}
struct Readline {
mut:
is_raw bool
orig_termios Termios
current ustring // Line being edited
cursor int // Cursor position
overwrite bool
cursor_row_offset int
prompt string
previous_lines []ustring
search_index int
is_tty bool
}
// Defines actions to execute
enum Action {
eof
@@ -104,7 +71,7 @@ fn (r mut Readline) enable_raw_mode2() {
}
// Reset back the terminal to its default value
pub fn (r mut Readline) disable_raw_mode() {
fn (r mut Readline) disable_raw_mode() {
if r.is_raw {
C.tcsetattr(0, C.TCSADRAIN, &r.orig_termios)
r.is_raw = false