mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
term.ui: allow setting the terminal title (#6809)
This commit is contained in:
@ -6,15 +6,13 @@ mut:
|
||||
}
|
||||
|
||||
fn event(e &tui.Event, x voidptr) {
|
||||
print('\x1b[0;0H\x1b[2J\x1b[3J') // Clear everything
|
||||
println('V term.input event viewer (press `esc` to exit)\n\n')
|
||||
|
||||
println(e)
|
||||
println('Raw event bytes: "${e.utf8.bytes().hex()}" = ${e.utf8.bytes()}')
|
||||
|
||||
if e.modifiers == tui.ctrl | tui.alt {
|
||||
println('CTRL + ALT')
|
||||
}
|
||||
mut app := &App(x)
|
||||
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.write('$e')
|
||||
app.tui.write('\n\nRaw event bytes: "${e.utf8.bytes().hex()}" = ${e.utf8.bytes()}')
|
||||
app.tui.flush()
|
||||
|
||||
if e.typ == .key_down && e.code == .escape { exit(0) }
|
||||
}
|
||||
@ -24,6 +22,7 @@ app.tui = tui.init(
|
||||
user_data: app,
|
||||
event_fn: event
|
||||
|
||||
window_title: 'V term.ui event viewer'
|
||||
hide_cursor: true
|
||||
capture_events: true
|
||||
frame_rate: 60
|
||||
|
@ -116,6 +116,7 @@ fn main() {
|
||||
event_fn: event
|
||||
frame_rate: frame_rate
|
||||
hide_cursor: true
|
||||
window_title: 'V terminal pixelart drawing app'
|
||||
})
|
||||
app.mouse_pos.x = 40
|
||||
app.mouse_pos.y = 15
|
||||
@ -398,11 +399,13 @@ fn (mut app App) draw_footer() {
|
||||
app.tui.bold()
|
||||
app.tui.draw_text(3, wh - 1, '$select_size $app.size')
|
||||
app.tui.reset()
|
||||
if ww >= 90 {
|
||||
app.tui.draw_text(80, wh - 3, help_1)
|
||||
app.tui.draw_text(80, wh - 2, help_2)
|
||||
app.tui.draw_text(80, wh - 1, help_3)
|
||||
}
|
||||
|
||||
// TODO: help button
|
||||
// if ww >= 90 {
|
||||
// app.tui.draw_text(80, wh - 3, help_1)
|
||||
// app.tui.draw_text(80, wh - 2, help_2)
|
||||
// app.tui.draw_text(80, wh - 1, help_3)
|
||||
// }
|
||||
}
|
||||
|
||||
[inline]
|
||||
@ -436,6 +439,7 @@ fn (mut app App) footer_click(event &tui.Event) {
|
||||
return
|
||||
}
|
||||
idx := footer_y * 19 - 6 + event.x / 3
|
||||
if idx < 0 || idx > 56 { return }
|
||||
color := colors[idx / 19][idx % 19]
|
||||
if event.button == .primary {
|
||||
app.primary_color = color
|
||||
|
Reference in New Issue
Block a user