readline: make some functions public
parent
db59c621e8
commit
bee8972632
|
@ -39,9 +39,10 @@ fn C.tcsetattr() int
|
||||||
//fn C.ioctl() int
|
//fn C.ioctl() int
|
||||||
fn C.raise()
|
fn C.raise()
|
||||||
|
|
||||||
// Toggle raw mode of the terminal by changing its attributes
|
// Enable the raw mode of the terminal
|
||||||
// Catches SIGUSER (CTRL+C) Signal to reset tty
|
// In raw mode all keypresses are directly sent to the program and no interpretation is done
|
||||||
fn (r mut Readline) enable_raw_mode() {
|
// Catches the SIGUSER (CTRL+C) Signal
|
||||||
|
pub fn (r mut Readline) enable_raw_mode() {
|
||||||
if C.tcgetattr(0, &r.orig_termios) == -1 {
|
if C.tcgetattr(0, &r.orig_termios) == -1 {
|
||||||
r.is_tty = false
|
r.is_tty = false
|
||||||
r.is_raw = false
|
r.is_raw = false
|
||||||
|
@ -58,8 +59,9 @@ fn (r mut Readline) enable_raw_mode() {
|
||||||
r.is_tty = true
|
r.is_tty = true
|
||||||
}
|
}
|
||||||
|
|
||||||
// Not catching the SIGUSER (CTRL+C) Signal
|
// Enable the raw mode of the terminal
|
||||||
fn (r mut Readline) enable_raw_mode_nosig() {
|
// Does not catch the SIGUSER (CTRL+C) Signal
|
||||||
|
pub fn (r mut Readline) enable_raw_mode_nosig() {
|
||||||
if ( C.tcgetattr(0, &r.orig_termios) == -1 ) {
|
if ( C.tcgetattr(0, &r.orig_termios) == -1 ) {
|
||||||
r.is_tty = false
|
r.is_tty = false
|
||||||
r.is_raw = false
|
r.is_raw = false
|
||||||
|
@ -76,16 +78,16 @@ fn (r mut Readline) enable_raw_mode_nosig() {
|
||||||
r.is_tty = true
|
r.is_tty = true
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset back the terminal to its default value
|
// Disable the raw mode of the terminal
|
||||||
fn (r mut Readline) disable_raw_mode() {
|
pub fn (r mut Readline) disable_raw_mode() {
|
||||||
if r.is_raw {
|
if r.is_raw {
|
||||||
C.tcsetattr(0, C.TCSADRAIN, &r.orig_termios)
|
C.tcsetattr(0, C.TCSADRAIN, &r.orig_termios)
|
||||||
r.is_raw = false
|
r.is_raw = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read single char
|
// Read a single char
|
||||||
fn (r Readline) read_char() int {
|
pub fn (r Readline) read_char() int {
|
||||||
return utf8_getchar()
|
return utf8_getchar()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue