KEY_* definitions?
jchimene opened this issue · 5 comments
Hi - Probably my error, but I notice that KEY_LEFT is 0x104, which collides with lowercase 'h'. In ncurses.h, it looks like 0x404.
I just checked in #201 , and the issue is still there.
From /usr/include/curses.h
#define KEY_LEFT 0404 /* left-arrow key */
where it's defined as 104 in whatever code ncurses-rs generates. I can't seem to find the actual definition. It looks like it should be working, but I don't fully understand genconstants.c
Finally built #201 , and KEY_LEFT is now outside ASCII code range in raw_constants.rs
. Life is good.
premature success
This
let control = vec![
vec!['w', 'W', (KEY_UP as u8) as char],
vec!['e', 'E', (KEY_PPAGE as u8) as char],
vec!['d', 'D', (KEY_RIGHT as u8) as char],
vec!['c', 'C', (KEY_NPAGE as u8) as char],
vec!['x', 'X', (KEY_DOWN as u8) as char],
vec!['z', 'Z', (KEY_END as u8) as char],
vec!['a', 'A', (KEY_LEFT as u8) as char],
vec!['q', 'Q', (KEY_HOME as u8) as char],
];
yields
(3) vec!['w', 'W', '\u{3}']
(3) vec!['e', 'E', 'S']
(3) vec!['d', 'D', '\u{5}']
(3) vec!['c', 'C', 'R']
(3) vec!['x', 'X', '\u{2}']
(3) vec!['z', 'Z', 'h']
(3) vec!['a', 'A', '\u{4}']
(3) vec!['q', 'Q', '\u{6}']
I think I'll just hardcode the correct constant values for KEY_PPAGE
,KEY_NPAGE
,KEY_END
I think I'll just hardcode the correct constant values for
KEY_PPAGE
,KEY_NPAGE
,KEY_END
As far as i can see, these constants are being generated correctly.
pub const KEY_PPAGE: i32 = 339;
pub const KEY_NPAGE: i32 = 338;
pub const KEY_END: i32 = 360;
I think the issue here is KEY_PPAGE as u8
. You might want to take a look at char::from_u32
Yeah, that was it. Duh. Thanks! I changed the array to a tuple (char,char,u32)
It's still broken . getch() returns i32. It's just not worth the trouble to support the keypad.