2
3
4
5
6
7
8
11#include <ncursesw/ncurses.h>
19
20
21
22
26 char Title[] =
"TEST CURSES KEYS";
37 getmaxyx(stdscr, maxy, maxx);
38 int begy = (maxy - lines) / 3;
39 int begx = (maxx - cols) / 2;
40 mousemask(ALL_MOUSE_EVENTS | REPORT_MOUSE_POSITION | BUTTON_SHIFT |
41 BUTTON_CTRL | BUTTON_ALT,
53 mvwaddstr(win, lines - 1, 0,
" <ALT>END to exit ");
54 wbkgrndset(win, &
CC_NT);
56 mvwaddstr(win, 1, 4,
"Press a key or activate the mouse:");
69 if (c ==
'q' || c == KEY_F(9))
79 strnz__cpy(kstr
, "KEY_CODE_YES A wchar_t contains a key code",
152 strnz__cpy(kstr
, "KEY_EIC sent by rmir or smir in insert mode",
160 strnz__cpy(kstr
, "KEY_EOS clear - to - end - of - screen key",
195 strnz__cpy(kstr
, "KEY_SRESET Soft(partial) reset(unreliable)",
199 strnz__cpy(kstr
, "KEY_RESET Reset or hard reset(unreliable)",
328 "KEY_SEOL shifted clear - to - end - of - line key",
464 if (getmouse(&event) == OK) {
465 switch (event.bstate) {
466 case BUTTON1_PRESSED:
469 case BUTTON1_RELEASED:
472 case BUTTON1_CLICKED:
475 case BUTTON1_DOUBLE_CLICKED:
478 case BUTTON2_PRESSED:
481 case BUTTON2_RELEASED:
484 case BUTTON2_CLICKED:
487 case BUTTON2_DOUBLE_CLICKED:
490 case BUTTON3_PRESSED:
493 case BUTTON3_RELEASED:
496 case BUTTON3_CLICKED:
499 case BUTTON3_DOUBLE_CLICKED:
502 case BUTTON4_PRESSED:
505 case BUTTON4_RELEASED:
508 case BUTTON4_CLICKED:
511 case BUTTON4_DOUBLE_CLICKED:
514 case BUTTON5_PRESSED:
520 mvwaddstr(win, 6, 3,
" Action:");
521 mvwaddstr(win, 6, 16, action);
525 if (event.bstate & BUTTON_SHIFT)
527 if (event.bstate & BUTTON_CTRL)
529 if (event.bstate & BUTTON_ALT)
531 mvwaddstr(win, 3, 4, tmp);
533 if (wenclose(win, event.y, event.x)) {
534 sprintf(tmp,
" Inside Win: y: %3d, x: %3d",
535 event.y - begy, event.x - begx);
537 sprintf(tmp,
" Outside Win: y: %3d, x: %3d",
538 event.y - begy, event.x - begx);
540 mvwaddstr(win, 4, 4, tmp);
551 if (c != KEY_MOUSE) {
553 sprintf(tmp,
" Octal: %3o", c);
554 mvwaddstr(win, 3, 4, tmp);
557 sprintf(tmp,
" Decimal: %3d", c);
558 mvwaddstr(win, 4, 4, tmp);
561 sprintf(tmp,
" Hex: %3x", c);
562 mvwaddstr(win, 5, 4, tmp);
566 sprintf(tmp,
"Description: %s", kstr);
568 sprintf(tmp,
" ASCII: %c", c);
570 mvwaddstr(win, 6, 3, tmp);
572 mvwaddstr(win, 7, 2,
"Key bound To: ");
574 mvwaddstr(win, 7, 16, s ? s :
"Not Bound");
int popup_ckeys()
Display Curses Keys Responds to curses keys and mouse events, displaying the key code and description...
volatile sig_atomic_t sig_received
bool handle_signal(sig_atomic_t)
void win_del()
Delete the current window and its associated box window.
int box_new(int, int, int, int, char *)
Create a new window with optional box and title.
int Perror(char *)
Display a simple error message window or print to stderr.
int display_error(char *, char *, char *, char *)
Display an error message window or print to stderr.
size_t strnz__cpy(char *, const char *, size_t)
safer alternative to strncpy
size_t strnz__cat(char *, const char *, size_t)
safer alternative to strncat