v / vlib / readline
Raw file | 36 loc (33 sloc) | 988 bytes | Latest commit hash bf11df40e
1// Copyright (c) 2019-2023 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// Serves as a more advanced input method
6// based on the work of https://github.com/AmokHuginnsson/replxx
7//
8module readline
9
10import term.termios
11
12// Winsize stores the screen information on Linux.
13struct Winsize {
14 ws_row u16
15 ws_col u16
16 ws_xpixel u16
17 ws_ypixel u16
18}
19
20// Readline is the key struct for reading and holding user input via a terminal.
21// Example: import readline { Readline }
22pub struct Readline {
23mut:
24 is_raw bool
25 orig_termios termios.Termios // Linux
26 current []rune // Line being edited
27 cursor int // Cursor position
28 overwrite bool
29 cursor_row_offset int
30 prompt string
31 prompt_offset int
32 previous_lines [][]rune
33 skip_empty bool // skip the empty lines when calling .history_previous()
34 search_index int
35 is_tty bool
36}