mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
readline: added suspend handling and dont print special characters
This commit is contained in:
parent
c12d4d1bd2
commit
f83bc9528d
@ -63,6 +63,7 @@ enum Action {
|
|||||||
history_next
|
history_next
|
||||||
overwrite
|
overwrite
|
||||||
clear_screen
|
clear_screen
|
||||||
|
suspend
|
||||||
}
|
}
|
||||||
|
|
||||||
// Toggle raw mode of the terminal by changing its attributes
|
// Toggle raw mode of the terminal by changing its attributes
|
||||||
@ -150,7 +151,8 @@ fn (r Readline) analyse(c byte) Action {
|
|||||||
case 27 : return r.analyse_control() // ESC
|
case 27 : return r.analyse_control() // ESC
|
||||||
case 1 : return Action.move_cursor_begining // ^A
|
case 1 : return Action.move_cursor_begining // ^A
|
||||||
case 5 : return Action.move_cursor_end // ^E
|
case 5 : return Action.move_cursor_end // ^E
|
||||||
default : return Action.insert_character
|
case 26 : return Action.suspend // CTRL + Z, SUB
|
||||||
|
default : return if c >= ` ` { Action.insert_character } else { Action.nothing }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -215,6 +217,7 @@ fn (r mut Readline) execute(a Action, c byte) bool {
|
|||||||
case Action.history_next: r.history_next()
|
case Action.history_next: r.history_next()
|
||||||
case Action.overwrite: r.switch_overwrite()
|
case Action.overwrite: r.switch_overwrite()
|
||||||
case Action.clear_screen: r.clear_screen()
|
case Action.clear_screen: r.clear_screen()
|
||||||
|
case Action.suspend: r.suspend()
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@ -404,3 +407,8 @@ fn (r mut Readline) history_next() {
|
|||||||
r.cursor = r.current.len
|
r.cursor = r.current.len
|
||||||
r.refresh_line()
|
r.refresh_line()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn (r mut Readline) suspend() {
|
||||||
|
C.raise(C.SIGSTOP)
|
||||||
|
r.refresh_line()
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user