X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/95bbe1aee1557d56b0e61932b4267d7d0a81f587..01c034ad857128c51482a563befb374e38ebe668:/windlg.c diff --git a/windlg.c b/windlg.c index e6194699..6f3c35c8 100644 --- a/windlg.c +++ b/windlg.c @@ -43,6 +43,20 @@ static void MyGetDlgItemInt (HWND hwnd, int id, int *result) { *result = n; } +static void MyGetDlgItemFlt (HWND hwnd, int id, int *result, int scale) { + char text[80]; + BOOL ok; + ok = GetDlgItemText (hwnd, id, text, sizeof(text)-1); + if (ok && text[0]) + *result = (int) (scale * atof(text)); +} + +static void MySetDlgItemFlt (HWND hwnd, int id, double value) { + char text[80]; + sprintf(text, "%g", value); + SetDlgItemText (hwnd, id, text); +} + static int CALLBACK LogProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { int i; @@ -223,6 +237,7 @@ enum { IDCX_ABOUT = IDC_ABOUT, IDCX_TVSTATIC, IDCX_TREEVIEW, controlstartvalue, sessionpanelend, loggingpanelstart, + IDC_TITLE_LOGGING, IDC_BOX_LOGGING1, IDC_LSTATSTATIC, IDC_LSTATOFF, @@ -231,6 +246,10 @@ enum { IDCX_ABOUT = IDC_ABOUT, IDCX_TVSTATIC, IDCX_TREEVIEW, controlstartvalue, IDC_LGFSTATIC, IDC_LGFEDIT, IDC_LGFBUTTON, + IDC_LSTATXIST, + IDC_LSTATXOVR, + IDC_LSTATXAPN, + IDC_LSTATXASK, loggingpanelend, keyboardpanelstart, @@ -249,6 +268,8 @@ enum { IDCX_ABOUT = IDC_ABOUT, IDCX_TVSTATIC, IDCX_TREEVIEW, controlstartvalue, IDC_FUNCLINUX, IDC_FUNCXTERM, IDC_FUNCVT400, + IDC_FUNCVT100P, + IDC_FUNCSCO, IDC_KPSTATIC, IDC_KPNORMAL, IDC_KPAPPLIC, @@ -269,7 +290,6 @@ enum { IDCX_ABOUT = IDC_ABOUT, IDCX_TVSTATIC, IDCX_TREEVIEW, controlstartvalue, IDC_WRAPMODE, IDC_DECOM, IDC_LFHASCR, - IDC_BEEP, IDC_BCE, IDC_BLINKTEXT, IDC_ANSWERBACK, @@ -284,6 +304,28 @@ enum { IDCX_ABOUT = IDC_ABOUT, IDCX_TVSTATIC, IDCX_TREEVIEW, controlstartvalue, IDC_EDITNO, terminalpanelend, + bellpanelstart, + IDC_TITLE_BELL, + IDC_BOX_BELL1, + IDC_BOX_BELL2, + IDC_BELLSTATIC, + IDC_BELL_DISABLED, + IDC_BELL_DEFAULT, + IDC_BELL_WAVEFILE, + IDC_BELL_VISUAL, + IDC_BELL_WAVESTATIC, + IDC_BELL_WAVEEDIT, + IDC_BELL_WAVEBROWSE, + IDC_BELLOVL, + IDC_BELLOVLNSTATIC, + IDC_BELLOVLN, + IDC_BELLOVLTSTATIC, + IDC_BELLOVLT, + IDC_BELLOVLEXPLAIN, + IDC_BELLOVLSSTATIC, + IDC_BELLOVLS, + bellpanelend, + windowpanelstart, IDC_TITLE_WINDOW, IDC_BOX_WINDOW1, @@ -312,6 +354,7 @@ enum { IDCX_ABOUT = IDC_ABOUT, IDCX_TVSTATIC, IDCX_TREEVIEW, controlstartvalue, IDC_BOX_APPEARANCE2, IDC_BOX_APPEARANCE3, IDC_BOX_APPEARANCE4, + IDC_BOX_APPEARANCE5, IDC_CURSORSTATIC, IDC_CURBLOCK, IDC_CURUNDER, @@ -323,6 +366,7 @@ enum { IDCX_ABOUT = IDC_ABOUT, IDCX_TVSTATIC, IDCX_TREEVIEW, controlstartvalue, IDC_WINEDIT, IDC_WINNAME, IDC_HIDEMOUSE, + IDC_SUNKENEDGE, appearancepanelend, connectionpanelstart, @@ -510,11 +554,13 @@ static void init_dlg_ctrls(HWND hwnd) { cfg.bksp_is_delete ? IDC_DEL127 : IDC_DEL008); CheckRadioButton (hwnd, IDC_HOMETILDE, IDC_HOMERXVT, cfg.rxvt_homeend ? IDC_HOMERXVT : IDC_HOMETILDE); - CheckRadioButton (hwnd, IDC_FUNCTILDE, IDC_FUNCVT400, + CheckRadioButton (hwnd, IDC_FUNCTILDE, IDC_FUNCSCO, cfg.funky_type == 0 ? IDC_FUNCTILDE : cfg.funky_type == 1 ? IDC_FUNCLINUX : cfg.funky_type == 2 ? IDC_FUNCXTERM : cfg.funky_type == 3 ? IDC_FUNCVT400 : + cfg.funky_type == 4 ? IDC_FUNCVT100P : + cfg.funky_type == 5 ? IDC_FUNCSCO : IDC_FUNCTILDE ); CheckDlgButton (hwnd, IDC_NOAPPLICC, cfg.no_applic_c); CheckDlgButton (hwnd, IDC_NOAPPLICK, cfg.no_applic_k); @@ -547,13 +593,24 @@ static void init_dlg_ctrls(HWND hwnd) { SetDlgItemInt (hwnd, IDC_SAVEEDIT, cfg.savelines, FALSE); fmtfont (fontstatic); SetDlgItemText (hwnd, IDC_FONTSTATIC, fontstatic); - CheckDlgButton (hwnd, IDC_BEEP, cfg.beep); + CheckRadioButton (hwnd, IDC_BELL_DISABLED, IDC_BELL_VISUAL, + cfg.beep==BELL_DISABLED ? IDC_BELL_DISABLED : + cfg.beep==BELL_DEFAULT ? IDC_BELL_DEFAULT : + cfg.beep==BELL_WAVEFILE ? IDC_BELL_WAVEFILE : + cfg.beep==BELL_VISUAL ? IDC_BELL_VISUAL : IDC_BELL_DEFAULT); + SetDlgItemText (hwnd, IDC_BELL_WAVEEDIT, cfg.bell_wavefile); + CheckDlgButton (hwnd, IDC_BELLOVL, cfg.bellovl); + SetDlgItemInt (hwnd, IDC_BELLOVLN, cfg.bellovl_n, FALSE); + MySetDlgItemFlt (hwnd, IDC_BELLOVLT, cfg.bellovl_t / 1000.0); + MySetDlgItemFlt (hwnd, IDC_BELLOVLS, cfg.bellovl_s / 1000.0); + CheckDlgButton (hwnd, IDC_BCE, cfg.bce); CheckDlgButton (hwnd, IDC_BLINKTEXT, cfg.blinktext); SetDlgItemText (hwnd, IDC_WINEDIT, cfg.wintitle); CheckDlgButton (hwnd, IDC_WINNAME, cfg.win_name_always); CheckDlgButton (hwnd, IDC_HIDEMOUSE, cfg.hide_mouseptr); + CheckDlgButton (hwnd, IDC_SUNKENEDGE, cfg.sunken_edge); CheckRadioButton (hwnd, IDC_CURBLOCK, IDC_CURVERT, cfg.cursor_type==0 ? IDC_CURBLOCK : cfg.cursor_type==1 ? IDC_CURUNDER : IDC_CURVERT); @@ -575,6 +632,10 @@ static void init_dlg_ctrls(HWND hwnd) { cfg.logtype == 0 ? IDC_LSTATOFF : cfg.logtype == 1 ? IDC_LSTATASCII : IDC_LSTATRAW); + CheckRadioButton(hwnd, IDC_LSTATXOVR, IDC_LSTATXASK, + cfg.logxfovr == LGXF_OVR ? IDC_LSTATXOVR : + cfg.logxfovr == LGXF_ASK ? IDC_LSTATXASK : + IDC_LSTATXAPN); { char *p = cfg.environmt; while (*p) { @@ -734,11 +795,11 @@ static void create_controls(HWND hwnd, int dlgtype, int panel) { } if (panel == loggingpanelstart) { - /* The Logging panel. Accelerators used: [acgo] tplfw */ + /* The Logging panel. Accelerators used: [acgo] tplfwe */ struct ctlpos cp; ctlposinit(&cp, hwnd, 80, 3, 13); bartitle(&cp, "Options controlling session logging", - IDC_TITLE_TERMINAL); + IDC_TITLE_LOGGING); beginbox(&cp, NULL, IDC_BOX_LOGGING1); radiobig(&cp, "Session logging:", IDC_LSTATSTATIC, @@ -748,11 +809,16 @@ static void create_controls(HWND hwnd, int dlgtype, int panel) { editbutton(&cp, "Log &file name:", IDC_LGFSTATIC, IDC_LGFEDIT, "Bro&wse...", IDC_LGFBUTTON); + radiobig(&cp, + "What to do if the log file already &exists:", IDC_LSTATXIST, + "Always overwrite it", IDC_LSTATXOVR, + "Always append to the end of it", IDC_LSTATXAPN, + "Ask the user every time", IDC_LSTATXASK, NULL); endbox(&cp); } if (panel == terminalpanelstart) { - /* The Terminal panel. Accelerators used: [acgo] wdlben hts */ + /* The Terminal panel. Accelerators used: [acgo] wdlen hts */ struct ctlpos cp; ctlposinit(&cp, hwnd, 80, 3, 13); bartitle(&cp, "Options controlling the terminal emulation", @@ -762,7 +828,6 @@ static void create_controls(HWND hwnd, int dlgtype, int panel) { checkbox(&cp, "Auto &wrap mode initially on", IDC_WRAPMODE); checkbox(&cp, "&DEC Origin Mode initially on", IDC_DECOM); checkbox(&cp, "Implicit CR in every &LF", IDC_LFHASCR); - checkbox(&cp, "&Beep enabled", IDC_BEEP); checkbox(&cp, "Use background colour to &erase screen", IDC_BCE); checkbox(&cp, "Enable bli&nking text", IDC_BLINKTEXT); multiedit(&cp, @@ -783,41 +848,78 @@ static void create_controls(HWND hwnd, int dlgtype, int panel) { endbox(&cp); } + if (panel == bellpanelstart) { + /* The Bell panel. Accelerators used: [acgo] bdsm wt */ + struct ctlpos cp; + ctlposinit(&cp, hwnd, 80, 3, 13); + bartitle(&cp, "Options controlling the terminal bell", + IDC_TITLE_BELL); + beginbox(&cp, "Set the style of bell", + IDC_BOX_BELL1); + radiobig(&cp, + "Action to happen when a &bell occurs:", IDC_BELLSTATIC, + "None (bell disabled)", IDC_BELL_DISABLED, + "Play Windows Default Sound", IDC_BELL_DEFAULT, + "Play a custom sound file", IDC_BELL_WAVEFILE, + "Visual bell (flash window)", IDC_BELL_VISUAL, NULL); + editbutton(&cp, "Custom sound file to play as a bell:", + IDC_BELL_WAVESTATIC, IDC_BELL_WAVEEDIT, + "Bro&wse...", IDC_BELL_WAVEBROWSE); + endbox(&cp); + beginbox(&cp, "Control the bell overload behaviour", + IDC_BOX_BELL2); + checkbox(&cp, "Bell is temporarily &disabled when over-used", + IDC_BELLOVL); + staticedit(&cp, "Over-use means this &many bells...", + IDC_BELLOVLNSTATIC, IDC_BELLOVLN, 20); + staticedit(&cp, "... in &this many seconds", + IDC_BELLOVLTSTATIC, IDC_BELLOVLT, 20); + statictext(&cp, "The bell is re-enabled after a few seconds of silence.", + IDC_BELLOVLEXPLAIN); + staticedit(&cp, "Seconds of &silence required", + IDC_BELLOVLSSTATIC, IDC_BELLOVLS, 20); + endbox(&cp); + } + if (panel == keyboardpanelstart) { - /* The Keyboard panel. Accelerators used: [acgo] h?sr~lxvunpymietd */ + /* The Keyboard panel. Accelerators used: [acgo] bhf ruyntd */ struct ctlpos cp; ctlposinit(&cp, hwnd, 80, 3, 13); + /* bartitle(&cp, "Options controlling the effects of keys", IDC_TITLE_KEYBOARD); + */ beginbox(&cp, "Change the sequences sent by:", IDC_BOX_KEYBOARD1); - radioline(&cp, "The Backspace key", IDC_DELSTATIC, 2, - "Control-&H", IDC_DEL008, - "Control-&? (127)", IDC_DEL127, NULL); - radioline(&cp, "The Home and End keys", IDC_HOMESTATIC, 2, - "&Standard", IDC_HOMETILDE, - "&rxvt", IDC_HOMERXVT, NULL); - radioline(&cp, "The Function keys and keypad", IDC_FUNCSTATIC, 4, - "ESC[n&~", IDC_FUNCTILDE, - "&Linux", IDC_FUNCLINUX, - "&Xterm R6", IDC_FUNCXTERM, - "&VT400", IDC_FUNCVT400, NULL); + radioline(&cp, "The &Backspace key", IDC_DELSTATIC, 2, + "Control-H", IDC_DEL008, + "Control-? (127)", IDC_DEL127, NULL); + radioline(&cp, "The &Home and End keys", IDC_HOMESTATIC, 2, + "Standard", IDC_HOMETILDE, + "rxvt", IDC_HOMERXVT, NULL); + radioline(&cp, "The &Function keys and keypad", IDC_FUNCSTATIC, 3, + "ESC[n~", IDC_FUNCTILDE, + "Linux", IDC_FUNCLINUX, + "Xterm R6", IDC_FUNCXTERM, + "VT400", IDC_FUNCVT400, + "VT100+", IDC_FUNCVT100P, + "SCO", IDC_FUNCSCO, NULL); endbox(&cp); beginbox(&cp, "Application keypad settings:", IDC_BOX_KEYBOARD2); checkbox(&cp, "Application c&ursor keys totally disabled", IDC_NOAPPLICC); - radioline(&cp, "Initial state of cursor keys:", IDC_CURSTATIC, 2, - "&Normal", IDC_CURNORMAL, - "A&pplication", IDC_CURAPPLIC, NULL); + radioline(&cp, "Initial state of cu&rsor keys:", IDC_CURSTATIC, 2, + "Normal", IDC_CURNORMAL, + "Application", IDC_CURAPPLIC, NULL); checkbox(&cp, "Application ke&ypad keys totally disabled", IDC_NOAPPLICK); - radioline(&cp, "Initial state of numeric keypad:", IDC_KPSTATIC, 3, - "Nor&mal", IDC_KPNORMAL, - "Appl&ication", IDC_KPAPPLIC, - "N&etHack", IDC_KPNH, NULL); + radioline(&cp, "Initial state of &numeric keypad:", IDC_KPSTATIC, 3, + "Normal", IDC_KPNORMAL, + "Application", IDC_KPAPPLIC, + "NetHack", IDC_KPNH, NULL); endbox(&cp); beginbox(&cp, "Enable extra keyboard features:", IDC_BOX_KEYBOARD3); @@ -861,7 +963,7 @@ static void create_controls(HWND hwnd, int dlgtype, int panel) { } if (panel == appearancepanelstart) { - /* The Appearance panel. Accelerators used: [acgo] luvb h ti p */ + /* The Appearance panel. Accelerators used: [acgo] luvb h ti p s */ struct ctlpos cp; ctlposinit(&cp, hwnd, 80, 3, 13); bartitle(&cp, "Options controlling PuTTY's appearance", @@ -891,6 +993,11 @@ static void create_controls(HWND hwnd, int dlgtype, int panel) { checkbox(&cp, "Hide mouse &pointer when typing in window", IDC_HIDEMOUSE); endbox(&cp); + beginbox(&cp, "Adjust the window border", + IDC_BOX_APPEARANCE5); + checkbox(&cp, "&Sunken-edge border (slightly thicker)", + IDC_SUNKENEDGE); + endbox(&cp); } if (panel == translationpanelstart) { @@ -1165,6 +1272,7 @@ static int GenericMainDlgProc (HWND hwnd, UINT msg, treeview_insert(&tvfaff, 1, "Logging"); treeview_insert(&tvfaff, 0, "Terminal"); treeview_insert(&tvfaff, 1, "Keyboard"); + treeview_insert(&tvfaff, 1, "Bell"); treeview_insert(&tvfaff, 0, "Window"); treeview_insert(&tvfaff, 1, "Appearance"); treeview_insert(&tvfaff, 1, "Translation"); @@ -1232,6 +1340,8 @@ static int GenericMainDlgProc (HWND hwnd, UINT msg, create_controls(hwnd, dlgtype, keyboardpanelstart); if (!strcmp(buffer, "Terminal")) create_controls(hwnd, dlgtype, terminalpanelstart); + if (!strcmp(buffer, "Bell")) + create_controls(hwnd, dlgtype, bellpanelstart); if (!strcmp(buffer, "Window")) create_controls(hwnd, dlgtype, windowpanelstart); if (!strcmp(buffer, "Appearance")) @@ -1420,21 +1530,22 @@ static int GenericMainDlgProc (HWND hwnd, UINT msg, HIWORD(wParam) == BN_DOUBLECLICKED) cfg.rxvt_homeend = IsDlgButtonChecked (hwnd, IDC_HOMERXVT); break; - case IDC_FUNCXTERM: - if (HIWORD(wParam) == BN_CLICKED || - HIWORD(wParam) == BN_DOUBLECLICKED) - cfg.funky_type = 2; - break; - case IDC_FUNCVT400: - if (HIWORD(wParam) == BN_CLICKED || - HIWORD(wParam) == BN_DOUBLECLICKED) - cfg.funky_type = 3; - break; case IDC_FUNCTILDE: case IDC_FUNCLINUX: + case IDC_FUNCXTERM: + case IDC_FUNCVT400: + case IDC_FUNCVT100P: + case IDC_FUNCSCO: if (HIWORD(wParam) == BN_CLICKED || HIWORD(wParam) == BN_DOUBLECLICKED) - cfg.funky_type = IsDlgButtonChecked (hwnd, IDC_FUNCLINUX); + switch (LOWORD(wParam)) { + case IDC_FUNCTILDE: cfg.funky_type = 0; break; + case IDC_FUNCLINUX: cfg.funky_type = 1; break; + case IDC_FUNCXTERM: cfg.funky_type = 2; break; + case IDC_FUNCVT400: cfg.funky_type = 3; break; + case IDC_FUNCVT100P: cfg.funky_type = 4; break; + case IDC_FUNCSCO: cfg.funky_type = 5; break; + } break; case IDC_KPNORMAL: case IDC_KPAPPLIC: @@ -1588,11 +1699,62 @@ static int GenericMainDlgProc (HWND hwnd, UINT msg, SetDlgItemText (hwnd, IDC_FONTSTATIC, fontstatic); } break; - case IDC_BEEP: + case IDC_BELL_DISABLED: + case IDC_BELL_DEFAULT: + case IDC_BELL_WAVEFILE: + case IDC_BELL_VISUAL: + if (HIWORD(wParam) == BN_CLICKED || + HIWORD(wParam) == BN_DOUBLECLICKED) { + if (LOWORD(wParam)==IDC_BELL_DISABLED) cfg.beep = BELL_DISABLED; + if (LOWORD(wParam)==IDC_BELL_DEFAULT) cfg.beep = BELL_DEFAULT; + if (LOWORD(wParam)==IDC_BELL_WAVEFILE) cfg.beep = BELL_WAVEFILE; + if (LOWORD(wParam)==IDC_BELL_VISUAL) cfg.beep = BELL_VISUAL; + } + break; + case IDC_BELL_WAVEBROWSE: + memset(&of, 0, sizeof(of)); +#ifdef OPENFILENAME_SIZE_VERSION_400 + of.lStructSize = OPENFILENAME_SIZE_VERSION_400; +#else + of.lStructSize = sizeof(of); +#endif + of.hwndOwner = hwnd; + of.lpstrFilter = "Wave Files\0*.WAV\0AllFiles\0*\0\0\0"; + of.lpstrCustomFilter = NULL; + of.nFilterIndex = 1; + of.lpstrFile = filename; strcpy(filename, cfg.bell_wavefile); + of.nMaxFile = sizeof(filename); + of.lpstrFileTitle = NULL; + of.lpstrInitialDir = NULL; + of.lpstrTitle = "Select Bell Sound File"; + of.Flags = 0; + if (GetOpenFileName(&of)) { + strcpy(cfg.bell_wavefile, filename); + SetDlgItemText (hwnd, IDC_BELL_WAVEEDIT, cfg.bell_wavefile); + } + break; + case IDC_BELL_WAVEEDIT: + if (HIWORD(wParam) == EN_CHANGE) + GetDlgItemText (hwnd, IDC_BELL_WAVEEDIT, cfg.bell_wavefile, + sizeof(cfg.bell_wavefile)-1); + break; + case IDC_BELLOVL: if (HIWORD(wParam) == BN_CLICKED || HIWORD(wParam) == BN_DOUBLECLICKED) - cfg.beep = IsDlgButtonChecked (hwnd, IDC_BEEP); + cfg.bellovl = IsDlgButtonChecked (hwnd, IDC_BELLOVL); break; + case IDC_BELLOVLN: + if (HIWORD(wParam) == EN_CHANGE) + MyGetDlgItemInt (hwnd, IDC_BELLOVLN, &cfg.bellovl_n); + break; + case IDC_BELLOVLT: + if (HIWORD(wParam) == EN_CHANGE) + MyGetDlgItemFlt (hwnd, IDC_BELLOVLT, &cfg.bellovl_t, 1000); + break; + case IDC_BELLOVLS: + if (HIWORD(wParam) == EN_CHANGE) + MyGetDlgItemFlt (hwnd, IDC_BELLOVLS, &cfg.bellovl_s, 1000); + break; case IDC_BLINKTEXT: if (HIWORD(wParam) == BN_CLICKED || HIWORD(wParam) == BN_DOUBLECLICKED) @@ -1613,6 +1775,11 @@ static int GenericMainDlgProc (HWND hwnd, UINT msg, HIWORD(wParam) == BN_DOUBLECLICKED) cfg.hide_mouseptr = IsDlgButtonChecked (hwnd, IDC_HIDEMOUSE); break; + case IDC_SUNKENEDGE: + if (HIWORD(wParam) == BN_CLICKED || + HIWORD(wParam) == BN_DOUBLECLICKED) + cfg.sunken_edge = IsDlgButtonChecked (hwnd, IDC_SUNKENEDGE); + break; case IDC_CURBLOCK: if (HIWORD(wParam) == BN_CLICKED || HIWORD(wParam) == BN_DOUBLECLICKED) @@ -1705,6 +1872,16 @@ static int GenericMainDlgProc (HWND hwnd, UINT msg, if (IsDlgButtonChecked (hwnd, IDC_LSTATRAW)) cfg.logtype = 2; } break; + case IDC_LSTATXASK: + case IDC_LSTATXAPN: + case IDC_LSTATXOVR: + if (HIWORD(wParam) == BN_CLICKED || + HIWORD(wParam) == BN_DOUBLECLICKED) { + if (IsDlgButtonChecked (hwnd, IDC_LSTATXASK)) cfg.logxfovr = LGXF_ASK; + if (IsDlgButtonChecked (hwnd, IDC_LSTATXAPN)) cfg.logxfovr = LGXF_APN; + if (IsDlgButtonChecked (hwnd, IDC_LSTATXOVR)) cfg.logxfovr = LGXF_OVR; + } + break; case IDC_TSEDIT: case IDC_R_TSEDIT: if (HIWORD(wParam) == EN_CHANGE) @@ -2207,6 +2384,9 @@ int askappend(char *filename) { "or Cancel to disable logging."; char message[sizeof(msgtemplate) + FILENAME_MAX]; int mbret; + if ( cfg.logxfovr != LGXF_ASK ) { + return ( (cfg.logxfovr==LGXF_OVR) ? 2 : 1); + } sprintf(message, msgtemplate, FILENAME_MAX, filename); mbret = MessageBox(NULL, message, mbtitle,