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;
41 mousemask(ALL_MOUSE_EVENTS | REPORT_MOUSE_POSITION | BUTTON_SHIFT |
42 BUTTON_CTRL | BUTTON_ALT,
53 wattron(win, WA_REVERSE);
54 mvwaddstr(win, lines - 1, 0,
" <ALT>END to exit ");
55 wattroff(win, WA_REVERSE);
57 mvwaddstr(win, 1, 4,
"Press a key or activate the mouse:");
68 if (c ==
'q' || c == KEY_F(9))
78 strnz__cpy(kstr
, "KEY_CODE_YES A wchar_t contains a key code",
151 strnz__cpy(kstr
, "KEY_EIC sent by rmir or smir in insert mode",
159 strnz__cpy(kstr
, "KEY_EOS clear - to - end - of - screen key",
194 strnz__cpy(kstr
, "KEY_SRESET Soft(partial) reset(unreliable)",
198 strnz__cpy(kstr
, "KEY_RESET Reset or hard reset(unreliable)",
327 "KEY_SEOL shifted clear - to - end - of - line key",
463 if (getmouse(&event) == OK) {
464 switch (event.bstate) {
465 case BUTTON1_PRESSED:
468 case BUTTON1_RELEASED:
471 case BUTTON1_CLICKED:
474 case BUTTON1_DOUBLE_CLICKED:
477 case BUTTON2_PRESSED:
480 case BUTTON2_RELEASED:
483 case BUTTON2_CLICKED:
486 case BUTTON2_DOUBLE_CLICKED:
489 case BUTTON3_PRESSED:
492 case BUTTON3_RELEASED:
495 case BUTTON3_CLICKED:
498 case BUTTON3_DOUBLE_CLICKED:
501 case BUTTON4_PRESSED:
504 case BUTTON4_RELEASED:
507 case BUTTON4_CLICKED:
510 case BUTTON4_DOUBLE_CLICKED:
513 case BUTTON5_PRESSED:
519 mvwaddstr(win, 6, 3,
" Action:");
520 mvwaddstr(win, 6, 16, action);
524 if (event.bstate & BUTTON_SHIFT)
526 if (event.bstate & BUTTON_CTRL)
528 if (event.bstate & BUTTON_ALT)
530 mvwaddstr(win, 3, 4, tmp);
532 if (wenclose(win, event.y, event.x)) {
533 sprintf(tmp,
" Inside Win: y: %3d, x: %3d",
534 event.y - begy, event.x - begx);
536 sprintf(tmp,
" Outside Win: y: %3d, x: %3d",
537 event.y - begy, event.x - begx);
539 mvwaddstr(win, 4, 4, tmp);
550 if (c != KEY_MOUSE) {
552 sprintf(tmp,
" Octal: %3o", c);
553 mvwaddstr(win, 3, 4, tmp);
556 sprintf(tmp,
" Decimal: %3d", c);
557 mvwaddstr(win, 4, 4, tmp);
560 sprintf(tmp,
" Hex: %3x", c);
561 mvwaddstr(win, 5, 4, tmp);
565 sprintf(tmp,
"Description: %s", kstr);
567 sprintf(tmp,
" ASCII: %c", c);
569 mvwaddstr(win, 6, 3, tmp);
571 mvwaddstr(win, 7, 2,
"Key bound To: ");
573 mvwaddstr(win, 7, 16, s ? s :
"Not Bound");
volatile sig_atomic_t sig_received
bool handle_signal(sig_atomic_t)
int popup_ckeys()
Display Curses Keys Responds to curses keys and mouse events, displaying the key code and description...
int win_new(int, int, int, int, char *, int)
Create a new window with optional box and title.
WINDOW * win_del()
Delete the current window and its associated box window.
int Perror(char *)
Display a simple error message window or print to stderr.
int display_error(char *em0, char *em1, char *em2, char *em3)
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