mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
db, json, time, term: change optional to result (#16201)
This commit is contained in:
@@ -30,7 +30,7 @@ pub fn get_terminal_size() (int, int) {
|
||||
}
|
||||
|
||||
// get_cursor_position returns a Coord containing the current cursor position
|
||||
pub fn get_cursor_position() ?Coord {
|
||||
pub fn get_cursor_position() !Coord {
|
||||
if os.is_atty(1) <= 0 || os.getenv('TERM') == 'dumb' {
|
||||
return Coord{0, 0}
|
||||
}
|
||||
|
||||
@@ -58,8 +58,8 @@ fn test_header() {
|
||||
}
|
||||
|
||||
fn test_get_cursor_position() {
|
||||
original_position := term.get_cursor_position()?
|
||||
cursor_position_1 := term.get_cursor_position()?
|
||||
original_position := term.get_cursor_position()!
|
||||
cursor_position_1 := term.get_cursor_position()!
|
||||
assert original_position.x == cursor_position_1.x
|
||||
assert original_position.y == cursor_position_1.y
|
||||
//
|
||||
@@ -67,13 +67,13 @@ fn test_get_cursor_position() {
|
||||
x: 10
|
||||
y: 11
|
||||
)
|
||||
cursor_position_2 := term.get_cursor_position()?
|
||||
cursor_position_2 := term.get_cursor_position()!
|
||||
//
|
||||
term.set_cursor_position(
|
||||
x: 5
|
||||
y: 6
|
||||
)
|
||||
cursor_position_3 := term.get_cursor_position()?
|
||||
cursor_position_3 := term.get_cursor_position()!
|
||||
//
|
||||
term.set_cursor_position(original_position)
|
||||
eprintln('original_position: $original_position')
|
||||
|
||||
@@ -69,7 +69,7 @@ pub fn get_terminal_size() (int, int) {
|
||||
}
|
||||
|
||||
// get_cursor_position returns a Coord containing the current cursor position
|
||||
pub fn get_cursor_position() ?Coord {
|
||||
pub fn get_cursor_position() !Coord {
|
||||
mut res := Coord{}
|
||||
if os.is_atty(1) > 0 && os.getenv('TERM') != 'dumb' {
|
||||
info := C.CONSOLE_SCREEN_BUFFER_INFO{}
|
||||
|
||||
@@ -47,7 +47,7 @@ pub fn (mut ctx Context) run() ? {
|
||||
ctx.fail('error: x11 backend not implemented yet')
|
||||
exit(1)
|
||||
} else {
|
||||
ctx.termios_setup()?
|
||||
ctx.termios_setup() or { panic(err) }
|
||||
ctx.termios_loop()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ fn restore_terminal_state() {
|
||||
os.flush()
|
||||
}
|
||||
|
||||
fn (mut ctx Context) termios_setup() ? {
|
||||
fn (mut ctx Context) termios_setup() ! {
|
||||
// store the current title, so restore_terminal_state can get it back
|
||||
save_title()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user