When I was making it, I used the KEY_UP and KEY_DOWN constants, and nothing happened. So I had the program output the value of keyboard when I pressed the up and down key, and got 2 for the down key and 3 for the up. If I add those numbers, it works fine. Why is it that KEY_UP and KEY_DOWN do not work?
If it's worth anything I'm compiling it using g++ -lncurses less-clone.cpp -o less2.
i know what ur problem is. i had the same myself. there is a a datatype called wchar_t which is a bigger version of char. key_anything is too big for char so use that instead
Yeah, I didn't realise it was a char and got confused because I read it had to be at least a short int. Changed it to int and now it is fine. Thanks!
EDIT: Still having issues I'm afraid. Now KEY_ENTER doesn't seem to be working. Again, has_key reports it as true but I press enter and it's not recognised.
no, getch returns the ascii int equivalent which when printed turns out the ascii char. the key_anything are escape chars. they are characters. if you make a non ncurses program and ask for input, then hit key_up, you will see its ascii code
yes any key on the keyboard is (with some exceptions like alternate fn buttons) a character and thus has an ascii key code. the only reasn ncurses uses key_fn(int), key_enter, key_up, key_down etc etc, is because the ascii characters for each of those are diffrent between operating systems. ncurses is the attempt to make code involving stuff like that cross-compatible
how do you know i didn't. and as i said, its os dependent
Whether or not ascii is used is O/S dependent. Ascii values are not. Which set of extended ascii is present may depend on the locale, but again, there are no representations there for arrow keys.
How do I know you didn't google it? Because you said "yes i do. why would you say that." I know you can read, so it seems pretty obvious you didn't and apparently didn't bother visiting the links supplied. I'm out.
sorry i made a mistake. the tutorials i looked at for ncurses said they were ascii, but i searched under ascii keyboard constants and read an explination of how they were ascii sounding. so once again sorry, i was going off improper tutorials