mirror of
https://github.com/vlang/v.git
synced 2025-09-13 14:32:26 +03:00
fmt: fix alignment of struct init fields (#22025)
This commit is contained in:
parent
99da5726db
commit
c51d30bf53
671 changed files with 18817 additions and 18787 deletions
|
@ -34,9 +34,9 @@ fn frame(x voidptr) {
|
|||
fn main() {
|
||||
mut app := &App{}
|
||||
app.tui = tui.init(
|
||||
user_data: app
|
||||
event_fn: event
|
||||
frame_fn: frame
|
||||
user_data: app
|
||||
event_fn: event
|
||||
frame_fn: frame
|
||||
hide_cursor: true
|
||||
)
|
||||
app.tui.run()!
|
||||
|
@ -96,4 +96,4 @@ and by only painting frames when your app's content has actually changed.
|
|||
Q: Why does the module only emit `keydown` events, and not `keyup` like `sokol`/`gg`?
|
||||
A: It's because of the way terminals emit events. Every key event is received as a keypress,
|
||||
and there isn't a way of telling terminals to send keyboard events differently,
|
||||
nor a reliable way of converting these into `keydown` / `keyup` events.
|
||||
nor a reliable way of converting these into `keydown` / `keyup` events.
|
|
@ -184,13 +184,13 @@ fn (mut ctx Context) parse_events() {
|
|||
}
|
||||
|
||||
mut event := &Event{
|
||||
typ: .key_down
|
||||
typ: .key_down
|
||||
modifiers: modifiers
|
||||
code: code
|
||||
ascii: ascii
|
||||
width: int(e.dwControlKeyState)
|
||||
height: int(e.wVirtualKeyCode)
|
||||
utf8: unsafe { e.uChar.UnicodeChar.str() }
|
||||
code: code
|
||||
ascii: ascii
|
||||
width: int(e.dwControlKeyState)
|
||||
height: int(e.wVirtualKeyCode)
|
||||
utf8: unsafe { e.uChar.UnicodeChar.str() }
|
||||
}
|
||||
ctx.event(event)
|
||||
}
|
||||
|
@ -233,36 +233,36 @@ fn (mut ctx Context) parse_events() {
|
|||
EventType.mouse_drag
|
||||
}
|
||||
ctx.event(&Event{
|
||||
typ: typ
|
||||
x: x
|
||||
y: y
|
||||
button: button
|
||||
typ: typ
|
||||
x: x
|
||||
y: y
|
||||
button: button
|
||||
modifiers: modifiers
|
||||
})
|
||||
}
|
||||
C.MOUSE_WHEELED {
|
||||
ctx.event(&Event{
|
||||
typ: .mouse_scroll
|
||||
typ: .mouse_scroll
|
||||
direction: if i16(e.dwButtonState >> 16) < 0 {
|
||||
Direction.up
|
||||
} else {
|
||||
Direction.down
|
||||
}
|
||||
x: x
|
||||
y: y
|
||||
x: x
|
||||
y: y
|
||||
modifiers: modifiers
|
||||
})
|
||||
}
|
||||
0x0008 { // C.MOUSE_HWHEELED
|
||||
ctx.event(&Event{
|
||||
typ: .mouse_scroll
|
||||
typ: .mouse_scroll
|
||||
direction: if i16(e.dwButtonState >> 16) < 0 {
|
||||
Direction.right
|
||||
} else {
|
||||
Direction.left
|
||||
}
|
||||
x: x
|
||||
y: y
|
||||
x: x
|
||||
y: y
|
||||
modifiers: modifiers
|
||||
})
|
||||
}
|
||||
|
@ -275,10 +275,10 @@ fn (mut ctx Context) parse_events() {
|
|||
}
|
||||
ctx.mouse_down = button
|
||||
ctx.event(&Event{
|
||||
typ: .mouse_down
|
||||
x: x
|
||||
y: y
|
||||
button: button
|
||||
typ: .mouse_down
|
||||
x: x
|
||||
y: y
|
||||
button: button
|
||||
modifiers: modifiers
|
||||
})
|
||||
}
|
||||
|
@ -297,10 +297,10 @@ fn (mut ctx Context) parse_events() {
|
|||
if w != ctx.window_width || h != ctx.window_height {
|
||||
ctx.window_width, ctx.window_height = w, h
|
||||
mut event := &Event{
|
||||
typ: .resized
|
||||
width: ctx.window_width
|
||||
typ: .resized
|
||||
width: ctx.window_width
|
||||
height: ctx.window_height
|
||||
utf8: utf8
|
||||
utf8: utf8
|
||||
}
|
||||
ctx.event(event)
|
||||
}
|
||||
|
|
|
@ -123,8 +123,8 @@ fn (mut ctx Context) termios_setup() ! {
|
|||
c.termios_setup() or { panic(err) }
|
||||
c.window_height, c.window_width = get_terminal_size()
|
||||
mut event := &Event{
|
||||
typ: .resized
|
||||
width: c.window_width
|
||||
typ: .resized
|
||||
width: c.window_width
|
||||
height: c.window_height
|
||||
}
|
||||
c.paused = false
|
||||
|
@ -147,8 +147,8 @@ fn (mut ctx Context) termios_setup() ! {
|
|||
c.window_height, c.window_width = get_terminal_size()
|
||||
|
||||
mut event := &Event{
|
||||
typ: .resized
|
||||
width: c.window_width
|
||||
typ: .resized
|
||||
width: c.window_width
|
||||
height: c.window_height
|
||||
}
|
||||
c.event(event)
|
||||
|
@ -281,10 +281,10 @@ fn single_char(buf string) &Event {
|
|||
ch := buf[0]
|
||||
|
||||
mut event := &Event{
|
||||
typ: .key_down
|
||||
typ: .key_down
|
||||
ascii: ch
|
||||
code: unsafe { KeyCode(ch) }
|
||||
utf8: ch.ascii_str()
|
||||
code: unsafe { KeyCode(ch) }
|
||||
utf8: ch.ascii_str()
|
||||
}
|
||||
|
||||
match ch {
|
||||
|
@ -296,19 +296,19 @@ fn single_char(buf string) &Event {
|
|||
// don't treat tab, enter as ctrl+i, ctrl+j
|
||||
1...8, 11...26 {
|
||||
event = &Event{
|
||||
typ: event.typ
|
||||
ascii: event.ascii
|
||||
utf8: event.utf8
|
||||
code: unsafe { KeyCode(96 | ch) }
|
||||
typ: event.typ
|
||||
ascii: event.ascii
|
||||
utf8: event.utf8
|
||||
code: unsafe { KeyCode(96 | ch) }
|
||||
modifiers: .ctrl
|
||||
}
|
||||
}
|
||||
65...90 {
|
||||
event = &Event{
|
||||
typ: event.typ
|
||||
ascii: event.ascii
|
||||
utf8: event.utf8
|
||||
code: unsafe { KeyCode(32 | ch) }
|
||||
typ: event.typ
|
||||
ascii: event.ascii
|
||||
utf8: event.utf8
|
||||
code: unsafe { KeyCode(32 | ch) }
|
||||
modifiers: .shift
|
||||
}
|
||||
}
|
||||
|
@ -322,10 +322,10 @@ fn multi_char(buf string) (&Event, int) {
|
|||
ch := buf[0]
|
||||
|
||||
mut event := &Event{
|
||||
typ: .key_down
|
||||
typ: .key_down
|
||||
ascii: ch
|
||||
code: unsafe { KeyCode(ch) }
|
||||
utf8: buf
|
||||
code: unsafe { KeyCode(ch) }
|
||||
utf8: buf
|
||||
}
|
||||
|
||||
match ch {
|
||||
|
@ -337,19 +337,19 @@ fn multi_char(buf string) (&Event, int) {
|
|||
// don't treat tab, enter as ctrl+i, ctrl+j
|
||||
1...8, 11...26 {
|
||||
event = &Event{
|
||||
typ: event.typ
|
||||
ascii: event.ascii
|
||||
utf8: event.utf8
|
||||
code: unsafe { KeyCode(96 | ch) }
|
||||
typ: event.typ
|
||||
ascii: event.ascii
|
||||
utf8: event.utf8
|
||||
code: unsafe { KeyCode(96 | ch) }
|
||||
modifiers: .ctrl
|
||||
}
|
||||
}
|
||||
65...90 {
|
||||
event = &Event{
|
||||
typ: event.typ
|
||||
ascii: event.ascii
|
||||
utf8: event.utf8
|
||||
code: unsafe { KeyCode(32 | ch) }
|
||||
typ: event.typ
|
||||
ascii: event.ascii
|
||||
utf8: event.utf8
|
||||
code: unsafe { KeyCode(32 | ch) }
|
||||
modifiers: .shift
|
||||
}
|
||||
}
|
||||
|
@ -394,10 +394,10 @@ fn escape_sequence(buf_ string) (&Event, int) {
|
|||
|
||||
if buf.len == 0 {
|
||||
return &Event{
|
||||
typ: .key_down
|
||||
typ: .key_down
|
||||
ascii: 27
|
||||
code: .escape
|
||||
utf8: single
|
||||
code: .escape
|
||||
utf8: single
|
||||
}, 1
|
||||
}
|
||||
|
||||
|
@ -406,10 +406,10 @@ fn escape_sequence(buf_ string) (&Event, int) {
|
|||
mut modifiers := c.modifiers
|
||||
modifiers.set(.alt)
|
||||
return &Event{
|
||||
typ: c.typ
|
||||
ascii: c.ascii
|
||||
code: c.code
|
||||
utf8: single
|
||||
typ: c.typ
|
||||
ascii: c.ascii
|
||||
code: c.code
|
||||
utf8: single
|
||||
modifiers: modifiers
|
||||
}, 2
|
||||
}
|
||||
|
@ -449,12 +449,12 @@ fn escape_sequence(buf_ string) (&Event, int) {
|
|||
}
|
||||
|
||||
return &Event{
|
||||
typ: event
|
||||
x: x
|
||||
y: y
|
||||
button: button
|
||||
typ: event
|
||||
x: x
|
||||
y: y
|
||||
button: button
|
||||
modifiers: modifiers
|
||||
utf8: single
|
||||
utf8: single
|
||||
}, end
|
||||
}
|
||||
32...63 {
|
||||
|
@ -465,28 +465,28 @@ fn escape_sequence(buf_ string) (&Event, int) {
|
|||
}
|
||||
|
||||
return &Event{
|
||||
typ: event
|
||||
x: x
|
||||
y: y
|
||||
button: button
|
||||
typ: event
|
||||
x: x
|
||||
y: y
|
||||
button: button
|
||||
modifiers: modifiers
|
||||
utf8: single
|
||||
utf8: single
|
||||
}, end
|
||||
}
|
||||
64...95 {
|
||||
direction := if typ & 1 == 0 { Direction.down } else { Direction.up }
|
||||
return &Event{
|
||||
typ: .mouse_scroll
|
||||
x: x
|
||||
y: y
|
||||
typ: .mouse_scroll
|
||||
x: x
|
||||
y: y
|
||||
direction: direction
|
||||
modifiers: modifiers
|
||||
utf8: single
|
||||
utf8: single
|
||||
}, end
|
||||
}
|
||||
else {
|
||||
return &Event{
|
||||
typ: .unknown
|
||||
typ: .unknown
|
||||
utf8: single
|
||||
}, end
|
||||
}
|
||||
|
@ -563,9 +563,9 @@ fn escape_sequence(buf_ string) (&Event, int) {
|
|||
}
|
||||
|
||||
return &Event{
|
||||
typ: .key_down
|
||||
code: code
|
||||
utf8: single
|
||||
typ: .key_down
|
||||
code: code
|
||||
utf8: single
|
||||
modifiers: modifiers
|
||||
}, end
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue