2020-02-03 05:00:36 +01:00
|
|
|
// Copyright (c) 2019-2020 Alexander Medvednikov. All rights reserved.
|
2019-10-15 08:04:22 +02:00
|
|
|
// Use of this source code is governed by an MIT license
|
|
|
|
// that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
// Will serve as more advanced input method
|
|
|
|
// Based on the work of https://github.com/AmokHuginnsson/replxx
|
|
|
|
|
|
|
|
module readline
|
|
|
|
|
|
|
|
// Linux
|
|
|
|
// 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
|
|
|
|
}
|
|
|
|
|
|
|
|
// Linux
|
|
|
|
// Used to collect the screen information
|
|
|
|
struct Winsize {
|
|
|
|
ws_row u16
|
|
|
|
ws_col u16
|
|
|
|
ws_xpixel u16
|
|
|
|
ws_ypixel u16
|
|
|
|
}
|
|
|
|
|
2019-10-31 17:01:04 +01:00
|
|
|
pub struct Readline {
|
2019-10-15 08:04:22 +02:00
|
|
|
mut:
|
|
|
|
is_raw bool
|
|
|
|
orig_termios Termios // Linux
|
|
|
|
current ustring // Line being edited
|
|
|
|
cursor int // Cursor position
|
|
|
|
overwrite bool
|
|
|
|
cursor_row_offset int
|
|
|
|
prompt string
|
2019-11-10 17:33:21 +01:00
|
|
|
prompt_offset int
|
2019-10-15 08:04:22 +02:00
|
|
|
previous_lines []ustring
|
|
|
|
search_index int
|
|
|
|
is_tty bool
|
2019-11-10 01:08:53 +01:00
|
|
|
}
|