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

os: fixes for os.input(), os.get_raw_stdin(), os.get_raw_line() in case of stdin EOF

This commit is contained in:
Delyan Angelov
2021-02-27 12:50:15 +02:00
parent e6b4f9ff09
commit 20f9bdfa8e
4 changed files with 42 additions and 21 deletions

View File

@@ -22,15 +22,18 @@ fn main() {
term.set_cursor_position(x: width / 2, y: height / 2) // now we point the cursor to the middle of the terminal
println(term.strikethrough(term.bright_green('hello world'))) // Print green text
term.set_cursor_position(x: 0, y: height) // Sets the position of the cursor to the bottom of the terminal
mut var := os.input('press q to quit: ')
// Keep prompting until the user presses the q key
for {
if var == 'q' {
if var := os.input_opt('press q to quit: ') {
if var != 'q' {
continue
}
break
} else {
var = os.input('press q to quit: ')
}
println('')
break
}
println('Goodbye.')
}
```