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

all: require calling optfn() ? / optfn() or {...} for fn optfn() ? {}

This commit is contained in:
Delyan Angelov
2021-01-26 16:43:10 +02:00
parent 97103f680a
commit e5a84719ca
90 changed files with 1994 additions and 1832 deletions

View File

@ -11,29 +11,35 @@ fn event(e &tui.Event, x voidptr) {
app.tui.set_cursor_position(0, 0)
app.tui.write('V term.input event viewer (press `esc` to exit)\n\n')
app.tui.write('$e')
app.tui.write('\n\nRaw event bytes: "${e.utf8.bytes().hex()}" = ${e.utf8.bytes()}')
app.tui.write('\n\nRaw event bytes: "$e.utf8.bytes().hex()" = $e.utf8.bytes()')
if e.modifiers != 0 {
app.tui.write('\nModifiers: $e.modifiers = ')
if e.modifiers & tui.ctrl != 0 { app.tui.write('ctrl. ') }
if e.modifiers & tui.shift != 0 { app.tui.write('shift ') }
if e.modifiers & tui.alt != 0 { app.tui.write('alt. ') }
if e.modifiers & tui.ctrl != 0 {
app.tui.write('ctrl. ')
}
if e.modifiers & tui.shift != 0 {
app.tui.write('shift ')
}
if e.modifiers & tui.alt != 0 {
app.tui.write('alt. ')
}
}
app.tui.flush()
if e.typ == .key_down && e.code == .escape { exit(0) }
if e.typ == .key_down && e.code == .escape {
exit(0)
}
}
mut app := &App{}
app.tui = tui.init(
user_data: app,
user_data: app
event_fn: event
window_title: 'V term.ui event viewer'
hide_cursor: true
capture_events: true
frame_rate: 60
use_alternate_buffer: false
)
println('V term.ui event viewer (press `esc` to exit)\n\n')
app.tui.run()
app.tui.run() ?