mirror of
https://github.com/vlang/v.git
synced 2025-08-04 02:07:28 -04:00
examples: cleanup examples/term.ui/event_viewer.v
This commit is contained in:
parent
3d5f81b0e6
commit
c9542a2553
@ -5,10 +5,15 @@ mut:
|
|||||||
tui &tui.Context = unsafe { nil }
|
tui &tui.Context = unsafe { nil }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn event(e &tui.Event, mut app App) {
|
fn (mut app App) show_header() {
|
||||||
app.tui.clear()
|
app.tui.clear()
|
||||||
app.tui.set_cursor_position(0, 0)
|
app.tui.set_cursor_position(0, 0)
|
||||||
app.tui.write('V term.input event viewer (press `esc` to exit)\n\n')
|
app.tui.write('V term.input event viewer (press `esc` to exit)\n\n')
|
||||||
|
app.tui.flush()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn event(e &tui.Event, mut app App) {
|
||||||
|
app.show_header()
|
||||||
app.tui.write('${e}')
|
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.is_empty() {
|
if !e.modifiers.is_empty() {
|
||||||
@ -24,8 +29,8 @@ fn event(e &tui.Event, mut app App) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
app.tui.flush()
|
app.tui.flush()
|
||||||
|
|
||||||
if e.typ == .key_down && e.code == .escape {
|
if e.typ == .key_down && e.code == .escape {
|
||||||
|
println('\nGood bye.')
|
||||||
exit(0)
|
exit(0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -43,6 +48,6 @@ fn main() {
|
|||||||
frame_rate: 60
|
frame_rate: 60
|
||||||
use_alternate_buffer: false
|
use_alternate_buffer: false
|
||||||
)
|
)
|
||||||
println('V term.ui event viewer (press `esc` to exit)\n\n')
|
app.show_header()
|
||||||
app.tui.run()!
|
app.tui.run()!
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user