From 95bbe1aee1557d56b0e61932b4267d7d0a81f587 Mon Sep 17 00:00:00 2001 From: simon Date: Mon, 9 Apr 2001 12:52:43 +0000 Subject: [PATCH] Keyboard handling patch from RDB: the Windows Application key is now always Compose (we have no better use for it), and Ctrl-Alt can be made to act like AltGr (but it's never Compose even when AltGr is). git-svn-id: svn://svn.tartarus.org/sgt/putty@1033 cda61777-01e9-0310-a592-d414129be87e --- putty.h | 1 + settings.c | 2 ++ windlg.c | 13 +++++++++++-- window.c | 63 ++++++++++++++++++++++++++++++++++++-------------------------- 4 files changed, 51 insertions(+), 28 deletions(-) diff --git a/putty.h b/putty.h index 5e881e1e..061074b4 100644 --- a/putty.h +++ b/putty.h @@ -205,6 +205,7 @@ typedef struct { int scroll_on_key; int scroll_on_disp; int compose_key; + int ctrlaltkeys; char wintitle[256]; /* initial window title */ /* Terminal options */ int savelines; diff --git a/settings.c b/settings.c index 3eec545c..559d4813 100644 --- a/settings.c +++ b/settings.c @@ -95,6 +95,7 @@ void save_settings (char *section, int do_host, Config *cfg) { write_setting_i (sesskey, "AltSpace", cfg->alt_space); write_setting_i (sesskey, "AltOnly", cfg->alt_only); write_setting_i (sesskey, "ComposeKey", cfg->compose_key); + write_setting_i (sesskey, "CtrlAltKeys", cfg->ctrlaltkeys); write_setting_i (sesskey, "LocalEcho", cfg->localecho); write_setting_i (sesskey, "LocalEdit", cfg->localedit); write_setting_s (sesskey, "Answerback", cfg->answerback); @@ -246,6 +247,7 @@ void load_settings (char *section, int do_host, Config *cfg) { gppi (sesskey, "AltSpace", 0, &cfg->alt_space); gppi (sesskey, "AltOnly", 0, &cfg->alt_only); gppi (sesskey, "ComposeKey", 0, &cfg->compose_key); + gppi (sesskey, "CtrlAltKeys", 1, &cfg->ctrlaltkeys); gppi (sesskey, "LocalEcho", LD_BACKEND, &cfg->localecho); gppi (sesskey, "LocalEdit", LD_BACKEND, &cfg->localedit); gpps (sesskey, "Answerback", "PuTTY", cfg->answerback, sizeof(cfg->answerback)); diff --git a/windlg.c b/windlg.c index c57dee92..e6194699 100644 --- a/windlg.c +++ b/windlg.c @@ -259,6 +259,7 @@ enum { IDCX_ABOUT = IDC_ABOUT, IDCX_TVSTATIC, IDCX_TREEVIEW, controlstartvalue, IDC_CURNORMAL, IDC_CURAPPLIC, IDC_COMPOSEKEY, + IDC_CTRLALTKEYS, keyboardpanelend, terminalpanelstart, @@ -526,6 +527,7 @@ static void init_dlg_ctrls(HWND hwnd) { CheckDlgButton (hwnd, IDC_ALTSPACE, cfg.alt_space); CheckDlgButton (hwnd, IDC_ALTONLY, cfg.alt_only); CheckDlgButton (hwnd, IDC_COMPOSEKEY, cfg.compose_key); + CheckDlgButton (hwnd, IDC_CTRLALTKEYS, cfg.ctrlaltkeys); CheckRadioButton (hwnd, IDC_ECHOBACKEND, IDC_ECHONO, cfg.localecho == LD_BACKEND ? IDC_ECHOBACKEND: cfg.localecho == LD_YES ? IDC_ECHOYES : IDC_ECHONO); @@ -782,7 +784,7 @@ static void create_controls(HWND hwnd, int dlgtype, int panel) { } if (panel == keyboardpanelstart) { - /* The Keyboard panel. Accelerators used: [acgo] h?sr~lxv unpymie t */ + /* The Keyboard panel. Accelerators used: [acgo] h?sr~lxvunpymietd */ struct ctlpos cp; ctlposinit(&cp, hwnd, 80, 3, 13); bartitle(&cp, "Options controlling the effects of keys", @@ -819,8 +821,10 @@ static void create_controls(HWND hwnd, int dlgtype, int panel) { endbox(&cp); beginbox(&cp, "Enable extra keyboard features:", IDC_BOX_KEYBOARD3); - checkbox(&cp, "Application and AltGr ac&t as Compose key", + checkbox(&cp, "AltGr ac&ts as Compose key", IDC_COMPOSEKEY); + checkbox(&cp, "Control-Alt is &different from AltGr", + IDC_CTRLALTKEYS); endbox(&cp); } @@ -1523,6 +1527,11 @@ static int GenericMainDlgProc (HWND hwnd, UINT msg, HIWORD(wParam) == BN_DOUBLECLICKED) cfg.compose_key = IsDlgButtonChecked (hwnd, IDC_COMPOSEKEY); break; + case IDC_CTRLALTKEYS: + if (HIWORD(wParam) == BN_CLICKED || + HIWORD(wParam) == BN_DOUBLECLICKED) + cfg.ctrlaltkeys = IsDlgButtonChecked (hwnd, IDC_CTRLALTKEYS); + break; case IDC_WRAPMODE: if (HIWORD(wParam) == BN_CLICKED || HIWORD(wParam) == BN_DOUBLECLICKED) diff --git a/window.c b/window.c index 127036ab..08559493 100644 --- a/window.c +++ b/window.c @@ -2018,29 +2018,6 @@ static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam, keystate[VK_RMENU] = keystate[VK_MENU]; } - /* Note if AltGr was pressed and if it was used as a compose key */ - if (cfg.compose_key) { - if (wParam == VK_MENU && (HIWORD(lParam)&KF_EXTENDED)) - { - if (!compose_state) compose_key = wParam; - } - if (wParam == VK_APPS && !compose_state) - compose_key = wParam; - - if (wParam == compose_key) - { - if (compose_state == 0 && (HIWORD(lParam)&(KF_UP|KF_REPEAT))==0) - compose_state = 1; - else if (compose_state == 1 && (HIWORD(lParam)&KF_UP)) - compose_state = 2; - else - compose_state = 0; - } - else if (compose_state==1 && wParam != VK_CONTROL) - compose_state = 0; - } else { - compose_state = 0; - } /* Nastyness with NUMLock - Shift-NUMLock is left alone though */ if ( (cfg.funky_type == 3 || @@ -2067,14 +2044,43 @@ static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam, key_down = ((HIWORD(lParam)&KF_UP)==0); - /* Make sure Ctrl-ALT is not the same as AltGr for ToAscii */ - if (left_alt && (keystate[VK_CONTROL]&0x80)) - keystate[VK_MENU] = 0; + /* Make sure Ctrl-ALT is not the same as AltGr for ToAscii unless told. */ + if (left_alt && (keystate[VK_CONTROL]&0x80)) { + if (cfg.ctrlaltkeys) + keystate[VK_MENU] = 0; + else { + keystate[VK_RMENU] = 0x80; + left_alt = 0; + } + } scan = (HIWORD(lParam) & (KF_UP | KF_EXTENDED | 0xFF)); shift_state = ((keystate[VK_SHIFT]&0x80)!=0) + ((keystate[VK_CONTROL]&0x80)!=0)*2; + /* Note if AltGr was pressed and if it was used as a compose key */ + if (!compose_state) { + compose_key = -1; + if (cfg.compose_key) { + if (wParam == VK_MENU && (HIWORD(lParam)&KF_EXTENDED)) + compose_key = wParam; + } + if (wParam == VK_APPS) + compose_key = wParam; + } + + if (wParam == compose_key) + { + if (compose_state == 0 && (HIWORD(lParam)&(KF_UP|KF_REPEAT))==0) + compose_state = 1; + else if (compose_state == 1 && (HIWORD(lParam)&KF_UP)) + compose_state = 2; + else + compose_state = 0; + } + else if (compose_state==1 && wParam != VK_CONTROL) + compose_state = 0; + /* * Record that we pressed key so the scroll window can be reset, but * be careful to avoid Shift-UP/Down @@ -2245,6 +2251,10 @@ static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam, { *p++ = 3; return p - output; } + if (wParam == VK_PAUSE) /* Break/Pause */ + { + *p++ = 26; *p++ = 0; return -2; + } /* Control-2 to Control-8 are special */ if (shift_state == 2 && wParam >= '2' && wParam <= '8') { @@ -2428,6 +2438,7 @@ static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam, } else return 0; } + else alt_state = 0; return -1; } -- 2.11.0