Skip to content

Commit

Permalink
term.ui,os.notify: fix .ctrl being stuck in examples/term.ui/event_vi…
Browse files Browse the repository at this point in the history
…ewer.v (regression happened in e9a3817 from 2023-02-20)
  • Loading branch information
spytheman committed Oct 9, 2023
1 parent 169a6b5 commit 121fa0e
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion vlib/os/notify/backend_darwin.c.v
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ fn (mut kn KqueueNotifier) close() ! {
// event_mask_to_flag is a helper function that converts a bitmask
// returned by kevent() wait to FdEventType
fn event_mask_to_flag(filter i16, flags u16) FdEventType {
mut res := FdEventType.read
mut res := unsafe { FdEventType(0) }

if filter & notify.kqueue_read != 0 {
res.set(.read)
Expand Down
2 changes: 1 addition & 1 deletion vlib/os/notify/backend_linux.c.v
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ fn (mut en EpollNotifier) close() ! {
// event_mask_to_flag is a helper function that converts a bitmask
// returned by epoll_wait to FdEventType
fn event_mask_to_flag(mask u32) FdEventType {
mut flags := FdEventType.read
mut flags := unsafe { FdEventType(0) }

if mask & notify.epoll_read != 0 {
flags.set(.read)
Expand Down
4 changes: 2 additions & 2 deletions vlib/term/ui/input_windows.c.v
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ fn (mut ctx Context) parse_events() {
else { unsafe { KeyCode(ascii) } }
}

mut modifiers := Modifiers.ctrl
mut modifiers := unsafe { Modifiers(0) }
if e.dwControlKeyState & (0x1 | 0x2) != 0 {
modifiers.set(.alt)
}
Expand Down Expand Up @@ -204,7 +204,7 @@ fn (mut ctx Context) parse_events() {
}
x := e.dwMousePosition.X + 1
y := int(e.dwMousePosition.Y) - sb_info.srWindow.Top + 1
mut modifiers := Modifiers.ctrl
mut modifiers := unsafe { Modifiers(0) }
if e.dwControlKeyState & (0x1 | 0x2) != 0 {
modifiers.set(.alt)
}
Expand Down
4 changes: 2 additions & 2 deletions vlib/term/ui/termios_nix.c.v
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ fn escape_sequence(buf_ string) (&Event, int) {
lo := typ & 0b00011
hi := typ & 0b11100

mut modifiers := Modifiers.ctrl
mut modifiers := unsafe { Modifiers(0) }
if hi & 4 != 0 {
modifiers.set(.shift)
}
Expand Down Expand Up @@ -497,7 +497,7 @@ fn escape_sequence(buf_ string) (&Event, int) {
// ----------------------------

mut code := KeyCode.null
mut modifiers := Modifiers.ctrl
mut modifiers := unsafe { Modifiers(0) }
match buf {
'[A', 'OA' { code = .up }
'[B', 'OB' { code = .down }
Expand Down
5 changes: 3 additions & 2 deletions vlib/v/checker/tests/enum_cast.out
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ vlib/v/checker/tests/enum_cast.vv:21:19: warning: 10 does not represent a value
21 | println(unsafe { Permissions(0b1010) })
| ~~~~~~~~~~~~~~~~~~~
22 | println(unsafe { Permissions(-1) })
23 | }
23 | println(unsafe { Permissions(0) })
vlib/v/checker/tests/enum_cast.vv:22:19: warning: -1 does not represent a value of enum Permissions
20 | println(unsafe { Permissions(0b101) })
21 | println(unsafe { Permissions(0b1010) })
22 | println(unsafe { Permissions(-1) })
| ~~~~~~~~~~~~~~~
23 | }
23 | println(unsafe { Permissions(0) })
24 | }
1 change: 1 addition & 0 deletions vlib/v/checker/tests/enum_cast.vv
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ fn main() {
println(unsafe { Permissions(0b101) })
println(unsafe { Permissions(0b1010) })
println(unsafe { Permissions(-1) })
println(unsafe { Permissions(0) })
}

0 comments on commit 121fa0e

Please sign in to comment.