Hi, I use ncurses and pdcurses (pdcurses 3.9 self compiled with TDM mingw64 10.3.0) for my development environment under Windows 10, mainly for a modified version of my console favorite text editors (nano, fte) and other TUI programs.
I found that the ncurses mingw-w64 version 6.5 (and older versions) of the library and DLL, downloaded from https://invisible-island.net/datafiles/release/mingw64.zip does not report the Ctrl and Alt modifier for the F1-F12 keys. Ctrl and Alt modifiers with PDcurses and ncurses under native linux are ok, but are not reported on a Windows console. The small example below compiled and run with mingw64 gcc in a up to date Windows 10 console, with TERM not set, does not report the modifiers. Best regards Fabio ------------ // test key codes #include <stdio.h> #include <string.h> #include <ncurses.h> static void print_help(WINDOW *menu_win) { static const char helptext[] = "Press a key. Press F10 to exit"; box(menu_win, 0, 0); mvwprintw(menu_win, 1, 1, "%s", helptext); wrefresh(menu_win); } int main() { WINDOW *menu_win; int byebye = 0; int c; initscr(); start_color(); clear(); noecho(); cbreak(); init_pair(8, COLOR_RED, COLOR_BLACK); menu_win = newwin(3, 40, 1, 1); keypad(menu_win, TRUE); print_help(menu_win); while (1) { const char *kname; int fk; const char *mod; c = wgetch(menu_win); switch (c) { case KEY_F(10): byebye = 1; break; default: kname = keyname(c); // fk in 0..11 if (c >= KEY_F(1) && c <= KEY_F(12)) { fk = (c - KEY_F(1)); mod = "none "; } else if (c >= KEY_F(13) && c <= KEY_F(24)) { fk = (c - KEY_F(1)) - 12; mod = "shift "; } else if (c >= KEY_F(25) && c <= KEY_F(36)) { fk = (c - KEY_F(1)) - 24; mod = "ctrl "; } else if (c >= KEY_F(37) && c <= KEY_F(48)) { fk = (c - KEY_F(1)) - 36; mod = "sh+ct "; } else if (c >= KEY_F(49) && c <= KEY_F(60)) { fk = (c - KEY_F(1)) - 48; mod = "alt "; } else { fk = -1; mod = " "; } mvprintw(8, 0, "Character pressed is = %3d (%#x) (%#o) %-8s", c, c, c, kname ? kname : "--- "); if (fk >= 0) mvprintw(9, 0, "Function key F%d mod=%s", fk + 1, mod); refresh(); break; } print_help(menu_win); if (byebye == 1) break; } endwin(); return 0; }
