Skip to content

Commit

Permalink
examples: cleanup examples/term.ui/event_viewer.v
Browse files Browse the repository at this point in the history
  • Loading branch information
spytheman committed Dec 15, 2024
1 parent 3d5f81b commit c9542a2
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions examples/term.ui/event_viewer.v
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,15 @@ mut:
tui &tui.Context = unsafe { nil }
}

fn event(e &tui.Event, mut app App) {
fn (mut app App) show_header() {
app.tui.clear()
app.tui.set_cursor_position(0, 0)
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('\n\nRaw event bytes: "${e.utf8.bytes().hex()}" = ${e.utf8.bytes()}')
if !e.modifiers.is_empty() {
Expand All @@ -24,8 +29,8 @@ fn event(e &tui.Event, mut app App) {
}
}
app.tui.flush()

if e.typ == .key_down && e.code == .escape {
println('\nGood bye.')
exit(0)
}
}
Expand All @@ -43,6 +48,6 @@ fn main() {
frame_rate: 60
use_alternate_buffer: false
)
println('V term.ui event viewer (press `esc` to exit)\n\n')
app.show_header()
app.tui.run()!
}

0 comments on commit c9542a2

Please sign in to comment.