Add configurable option to disable application keypad/cursor keys totally
authorsimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Tue, 24 Oct 2000 13:49:23 +0000 (13:49 +0000)
committersimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Tue, 24 Oct 2000 13:49:23 +0000 (13:49 +0000)
git-svn-id: svn://svn.tartarus.org/sgt/putty@760 cda61777-01e9-0310-a592-d414129be87e

putty.h
settings.c
windlg.c
window.c

diff --git a/putty.h b/putty.h
index 6b49379..0d1c932 100644 (file)
--- a/putty.h
+++ b/putty.h
@@ -156,6 +156,7 @@ typedef struct {
     int bksp_is_delete;
     int rxvt_homeend;
     int funky_type;
+    int no_applic;                     /* totally disable application modes */
     int app_cursor;
     int app_keypad;
     int nethack_keypad;
index fdea968..afb54a1 100644 (file)
@@ -79,6 +79,7 @@ void save_settings (char *section, int do_host, Config *cfg) {
     write_setting_i (sesskey, "BackspaceIsDelete", cfg->bksp_is_delete);
     write_setting_i (sesskey, "RXVTHomeEnd", cfg->rxvt_homeend);
     write_setting_i (sesskey, "LinuxFunctionKeys", cfg->funky_type);
+    write_setting_i (sesskey, "NoApplicationKeys", cfg->no_applic);
     write_setting_i (sesskey, "ApplicationCursorKeys", cfg->app_cursor);
     write_setting_i (sesskey, "ApplicationKeypad", cfg->app_keypad);
     write_setting_i (sesskey, "NetHackKeypad", cfg->nethack_keypad);
@@ -205,6 +206,7 @@ void load_settings (char *section, int do_host, Config *cfg) {
     gppi (sesskey, "BackspaceIsDelete", 1, &cfg->bksp_is_delete);
     gppi (sesskey, "RXVTHomeEnd", 0, &cfg->rxvt_homeend);
     gppi (sesskey, "LinuxFunctionKeys", 0, &cfg->funky_type);
+    gppi (sesskey, "NoApplicationKeys", 0, &cfg->no_applic);
     gppi (sesskey, "ApplicationCursorKeys", 0, &cfg->app_cursor);
     gppi (sesskey, "ApplicationKeypad", 0, &cfg->app_keypad);
     gppi (sesskey, "NetHackKeypad", 0, &cfg->nethack_keypad);
index d9e42e3..97114a5 100644 (file)
--- a/windlg.c
+++ b/windlg.c
@@ -219,6 +219,7 @@ enum { IDCX_ABOUT = IDC_ABOUT, IDCX_TVSTATIC, IDCX_TREEVIEW, controlstartvalue,
     IDC_KPNORMAL,
     IDC_KPAPPLIC,
     IDC_KPNH,
+    IDC_NOAPPLIC,
     IDC_CURSTATIC,
     IDC_CURNORMAL,
     IDC_CURAPPLIC,
@@ -430,6 +431,7 @@ static void init_dlg_ctrls(HWND hwnd) {
                       cfg.funky_type == 2 ? IDC_FUNCXTERM :
                       cfg.funky_type == 3 ? IDC_FUNCVT400 :
                       IDC_FUNCTILDE );
+    CheckDlgButton (hwnd, IDC_NOAPPLIC, cfg.no_applic);
     CheckRadioButton (hwnd, IDC_CURNORMAL, IDC_CURAPPLIC,
                      cfg.app_cursor ? IDC_CURAPPLIC : IDC_CURNORMAL);
     CheckRadioButton (hwnd, IDC_KPNORMAL, IDC_KPNH,
@@ -730,8 +732,11 @@ static int GenericMainDlgProc (HWND hwnd, UINT msg,
                      "&Xterm R6", IDC_FUNCXTERM,
                       "&VT400", IDC_FUNCVT400, NULL);
             endbox(&cp);
-            beginbox(&cp, "Change the initial state of:",
+            beginbox(&cp, "Application keypad settings:",
                      IDC_BOX_KEYBOARD2, IDC_BOXT_KEYBOARD2);
+            checkbox(&cp,
+                     "Application ke&ypad and cursor keys totally disabled",
+                     IDC_NOAPPLIC);
            radioline(&cp, "Initial state of cursor keys:", IDC_CURSTATIC, 2,
                      "&Normal", IDC_CURNORMAL,
                      "A&pplication", IDC_CURAPPLIC, NULL);
@@ -1235,6 +1240,11 @@ static int GenericMainDlgProc (HWND hwnd, UINT msg,
                HIWORD(wParam) == BN_DOUBLECLICKED)
                cfg.app_cursor = IsDlgButtonChecked (hwnd, IDC_CURAPPLIC);
            break;
+         case IDC_NOAPPLIC:
+           if (HIWORD(wParam) == BN_CLICKED ||
+               HIWORD(wParam) == BN_DOUBLECLICKED)
+               cfg.no_applic = IsDlgButtonChecked (hwnd, IDC_NOAPPLIC);
+           break;
          case IDC_ALTF4:
            if (HIWORD(wParam) == BN_CLICKED ||
                HIWORD(wParam) == BN_DOUBLECLICKED)
index f2e4e7f..98dd9a5 100644 (file)
--- a/window.c
+++ b/window.c
@@ -1903,7 +1903,8 @@ static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam,
            compose_state = 0;
 
        /* Nastyness with NUMLock - Shift-NUMLock is left alone though */
-       if ( (cfg.funky_type == 3 || (cfg.funky_type <= 1 && app_keypad_keys))
+       if ( (cfg.funky_type == 3 ||
+              (cfg.funky_type <= 1 && app_keypad_keys && !cfg.no_applic))
              && wParam==VK_NUMLOCK && !(keystate[VK_SHIFT]&0x80)) {
 
            wParam = VK_EXECUTE;
@@ -1948,7 +1949,7 @@ static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam,
     if (compose_state>1 && left_alt) compose_state = 0;
 
     /* Sanitize the number pad if not using a PC NumPad */
-    if( left_alt || (app_keypad_keys && cfg.funky_type != 2)
+    if( left_alt || (app_keypad_keys && !cfg.no_applic && cfg.funky_type != 2)
        || cfg.funky_type == 3 || cfg.nethack_keypad || compose_state )
     {
        if ((HIWORD(lParam)&KF_EXTENDED) == 0)
@@ -2030,13 +2031,14 @@ static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam,
           int xkey = 0;
 
           if ( cfg.funky_type == 3 ||
-             ( cfg.funky_type <= 1 && app_keypad_keys)) switch(wParam) {
+             ( cfg.funky_type <= 1 &&
+               app_keypad_keys && !cfg.no_applic)) switch(wParam) {
               case VK_EXECUTE: xkey = 'P'; break;
               case VK_DIVIDE:  xkey = 'Q'; break;
               case VK_MULTIPLY:xkey = 'R'; break;
               case VK_SUBTRACT:xkey = 'S'; break;
           }
-          if(app_keypad_keys) switch(wParam) {
+          if(app_keypad_keys && !cfg.no_applic) switch(wParam) {
               case VK_NUMPAD0: xkey = 'p'; break;
               case VK_NUMPAD1: xkey = 'q'; break;
               case VK_NUMPAD2: xkey = 'r'; break;
@@ -2198,7 +2200,7 @@ static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam,
            {
                if (vt52_mode)
                    p += sprintf((char *)p, "\x1B%c", xkey);
-               else if (app_cursor_keys)
+               else if (app_cursor_keys && !cfg.no_applic)
                    p += sprintf((char *)p, "\x1BO%c", xkey);
                else
                    p += sprintf((char *)p, "\x1B[%c", xkey);