X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/a094ae434ec1d6a0f69af9b3ef6fbeb40fa96d92..126ea1abe12d4f9e771d7148b4d8aa11b0c40282:/windlg.c diff --git a/windlg.c b/windlg.c index 6a45a31a..dbccb372 100644 --- a/windlg.c +++ b/windlg.c @@ -1,13 +1,6 @@ #include #include #include -#ifndef AUTO_WINSOCK -#ifdef WINSOCK_TWO -#include -#else -#include -#endif -#endif #include #include @@ -24,7 +17,7 @@ static HWND logbox = NULL, abtbox = NULL; static int readytogo; -static void force_normal(HWND hwnd) +void force_normal(HWND hwnd) { static int recurse = 0; @@ -34,7 +27,7 @@ static void force_normal(HWND hwnd) recurse = 1; wp.length = sizeof(wp); - if (GetWindowPlacement(hwnd, &wp)) + if (GetWindowPlacement(hwnd, &wp) && wp.showCmd == SW_SHOWMAXIMIZED) { wp.showCmd = SW_SHOWNORMAL; SetWindowPlacement(hwnd, &wp); @@ -73,7 +66,7 @@ static int CALLBACK LogProc (HWND hwnd, UINT msg, int *selitems; selcount = SendDlgItemMessage(hwnd, IDN_LIST, LB_GETSELCOUNT, 0, 0); - selitems = malloc(selcount * sizeof(int)); + selitems = smalloc(selcount * sizeof(int)); if (selitems) { int count = SendDlgItemMessage(hwnd, IDN_LIST, LB_GETSELITEMS, @@ -92,7 +85,7 @@ static int CALLBACK LogProc (HWND hwnd, UINT msg, for (i = 0; i < count; i++) size += strlen(events[selitems[i]]) + sizeof(sel_nl); - clipdata = malloc(size); + clipdata = smalloc(size); if (clipdata) { char *p = clipdata; for (i = 0; i < count; i++) { @@ -104,9 +97,9 @@ static int CALLBACK LogProc (HWND hwnd, UINT msg, p += sizeof(sel_nl); } write_clip(clipdata, size, TRUE); - free(clipdata); + sfree(clipdata); } - free(selitems); + sfree(selitems); for (i = 0; i < nevents; i++) SendDlgItemMessage(hwnd, IDN_LIST, LB_SETSEL, @@ -226,6 +219,8 @@ enum { IDCX_ABOUT = IDC_ABOUT, IDCX_TVSTATIC, IDCX_TREEVIEW, controlstartvalue, IDC_KPNORMAL, IDC_KPAPPLIC, IDC_KPNH, + IDC_NOAPPLICK, + IDC_NOAPPLICC, IDC_CURSTATIC, IDC_CURNORMAL, IDC_CURAPPLIC, @@ -236,35 +231,33 @@ enum { IDCX_ABOUT = IDC_ABOUT, IDCX_TVSTATIC, IDCX_TREEVIEW, controlstartvalue, IDC_TITLE_TERMINAL, IDC_BOX_TERMINAL1, IDC_BOXT_TERMINAL1, IDC_BOX_TERMINAL2, IDC_BOXT_TERMINAL2, - IDC_BOX_TERMINAL3, IDC_BOXT_TERMINAL3, IDC_WRAPMODE, IDC_DECOM, - IDC_DIMSTATIC, - IDC_ROWSSTATIC, - IDC_ROWSEDIT, - IDC_COLSSTATIC, - IDC_COLSEDIT, - IDC_LOCKSIZE, - IDC_FONTSTATIC, - IDC_CHOOSEFONT, IDC_LFHASCR, IDC_BEEP, IDC_BCE, IDC_BLINKTEXT, IDC_LDISCTERM, + IDC_LSTATSTATIC, + IDC_LSTATOFF, + IDC_LSTATASCII, + IDC_LSTATRAW, + IDC_LGFSTATIC, + IDC_LGFEDIT, + IDC_LGFBUTTON, terminalpanelend, windowpanelstart, IDC_TITLE_WINDOW, IDC_BOX_WINDOW1, IDC_BOXT_WINDOW1, IDC_BOX_WINDOW2, IDC_BOXT_WINDOW2, - IDC_BOX_WINDOW3, IDC_BOXT_WINDOW3, - IDC_BOX_WINDOW4, - IDC_WINNAME, - IDC_BLINKCUR, + IDC_BOX_WINDOW3, + IDC_ROWSSTATIC, + IDC_ROWSEDIT, + IDC_COLSSTATIC, + IDC_COLSEDIT, + IDC_LOCKSIZE, IDC_SCROLLBAR, - IDC_WINTITLE, - IDC_WINEDIT, IDC_CLOSEWARN, IDC_SAVESTATIC, IDC_SAVEEDIT, @@ -273,8 +266,26 @@ enum { IDCX_ABOUT = IDC_ABOUT, IDCX_TVSTATIC, IDCX_TREEVIEW, controlstartvalue, IDC_ALTONLY, IDC_SCROLLKEY, IDC_SCROLLDISP, + IDC_ALWAYSONTOP, windowpanelend, + appearancepanelstart, + IDC_TITLE_APPEARANCE, + IDC_BOX_APPEARANCE1, IDC_BOXT_APPEARANCE1, + IDC_BOX_APPEARANCE2, IDC_BOXT_APPEARANCE2, + IDC_BOX_APPEARANCE3, IDC_BOXT_APPEARANCE3, + IDC_CURSORSTATIC, + IDC_CURBLOCK, + IDC_CURUNDER, + IDC_CURVERT, + IDC_BLINKCUR, + IDC_FONTSTATIC, + IDC_CHOOSEFONT, + IDC_WINTITLE, + IDC_WINEDIT, + IDC_WINNAME, + appearancepanelend, + connectionpanelstart, IDC_TITLE_CONNECTION, IDC_BOX_CONNECTION1, IDC_BOXT_CONNECTION1, @@ -327,6 +338,7 @@ enum { IDCX_ABOUT = IDC_ABOUT, IDCX_TVSTATIC, IDCX_TREEVIEW, controlstartvalue, IDC_AGENTFWD, IDC_CMDSTATIC, IDC_CMDEDIT, + IDC_COMPRESS, sshpanelend, selectionpanelstart, @@ -434,6 +446,8 @@ static void init_dlg_ctrls(HWND hwnd) { cfg.funky_type == 2 ? IDC_FUNCXTERM : cfg.funky_type == 3 ? IDC_FUNCVT400 : IDC_FUNCTILDE ); + CheckDlgButton (hwnd, IDC_NOAPPLICC, cfg.no_applic_c); + CheckDlgButton (hwnd, IDC_NOAPPLICK, cfg.no_applic_k); CheckRadioButton (hwnd, IDC_CURNORMAL, IDC_CURAPPLIC, cfg.app_cursor ? IDC_CURAPPLIC : IDC_CURNORMAL); CheckRadioButton (hwnd, IDC_KPNORMAL, IDC_KPNH, @@ -444,6 +458,7 @@ static void init_dlg_ctrls(HWND hwnd) { CheckDlgButton (hwnd, IDC_ALTONLY, cfg.alt_only); CheckDlgButton (hwnd, IDC_COMPOSEKEY, cfg.compose_key); CheckDlgButton (hwnd, IDC_LDISCTERM, cfg.ldisc_term); + CheckDlgButton (hwnd, IDC_ALWAYSONTOP, cfg.alwaysontop); CheckDlgButton (hwnd, IDC_SCROLLKEY, cfg.scroll_on_key); CheckDlgButton (hwnd, IDC_SCROLLDISP, cfg.scroll_on_disp); @@ -461,6 +476,9 @@ static void init_dlg_ctrls(HWND hwnd) { SetDlgItemText (hwnd, IDC_WINEDIT, cfg.wintitle); CheckDlgButton (hwnd, IDC_WINNAME, cfg.win_name_always); + CheckRadioButton (hwnd, IDC_CURBLOCK, IDC_CURVERT, + cfg.cursor_type==0 ? IDC_CURBLOCK : + cfg.cursor_type==1 ? IDC_CURUNDER : IDC_CURVERT); CheckDlgButton (hwnd, IDC_BLINKCUR, cfg.blink_cur); CheckDlgButton (hwnd, IDC_SCROLLBAR, cfg.scrollbar); CheckDlgButton (hwnd, IDC_LOCKSIZE, cfg.locksize); @@ -470,6 +488,11 @@ static void init_dlg_ctrls(HWND hwnd) { SetDlgItemText (hwnd, IDC_TTEDIT, cfg.termtype); SetDlgItemText (hwnd, IDC_TSEDIT, cfg.termspeed); SetDlgItemText (hwnd, IDC_LOGEDIT, cfg.username); + SetDlgItemText (hwnd, IDC_LGFEDIT, cfg.logfilename); + CheckRadioButton(hwnd, IDC_LSTATOFF, IDC_LSTATRAW, + cfg.logtype == 0 ? IDC_LSTATOFF : + cfg.logtype == 1 ? IDC_LSTATASCII : + IDC_LSTATRAW); { char *p = cfg.environmt; while (*p) { @@ -484,6 +507,7 @@ static void init_dlg_ctrls(HWND hwnd) { SetDlgItemText (hwnd, IDC_TTEDIT, cfg.termtype); SetDlgItemText (hwnd, IDC_LOGEDIT, cfg.username); CheckDlgButton (hwnd, IDC_NOPTY, cfg.nopty); + CheckDlgButton (hwnd, IDC_COMPRESS, cfg.compression); CheckDlgButton (hwnd, IDC_BUGGYMAC, cfg.buggymac); CheckDlgButton (hwnd, IDC_AGENTFWD, cfg.agentfwd); CheckRadioButton (hwnd, IDC_CIPHER3DES, IDC_CIPHERDES, @@ -515,7 +539,11 @@ static void init_dlg_ctrls(HWND hwnd) { CheckDlgButton (hwnd, IDC_BOLDCOLOUR, cfg.bold_colour); CheckDlgButton (hwnd, IDC_PALETTE, cfg.try_palette); { - int i; + int i, n; + n = SendDlgItemMessage (hwnd, IDC_COLOURLIST, LB_GETCOUNT, 0, 0); + for (i=n; i-- >0 ;) + SendDlgItemMessage (hwnd, IDC_COLOURLIST, + LB_DELETESTRING, i, 0); for (i=0; i<22; i++) if (cfg.bold_colour || permcolour[i]) SendDlgItemMessage (hwnd, IDC_COLOURLIST, LB_ADDSTRING, 0, @@ -590,6 +618,8 @@ static int GenericMainDlgProc (HWND hwnd, UINT msg, CHOOSEFONT cf; LOGFONT lf; char fontstatic[256]; + char portname[32]; + struct servent * service; int i; switch (msg) { @@ -629,7 +659,7 @@ static int GenericMainDlgProc (HWND hwnd, UINT msg, SendMessage(tvstatic, WM_SETFONT, font, MAKELPARAM(TRUE, 0)); r.left = 3; r.right = r.left + 75; - r.top = 13; r.bottom = r.top + 196; + r.top = 13; r.bottom = r.top + 206; MapDialogRect(hwnd, &r); treeview = CreateWindowEx(WS_EX_CLIENTEDGE, WC_TREEVIEW, "", WS_CHILD | WS_VISIBLE | @@ -694,39 +724,39 @@ static int GenericMainDlgProc (HWND hwnd, UINT msg, hsession = treeview_insert(&tvfaff, 0, "Session"); } - /* The Terminal panel. Accelerators used: [acgo] rmkh&dlbenu */ + /* The Terminal panel. Accelerators used: [acgo] &dflbenuw */ { struct ctlpos cp; ctlposinit(&cp, hwnd, 80, 3, 13); bartitle(&cp, "Options controlling the terminal emulation", IDC_TITLE_TERMINAL); - beginbox(&cp, "Set the size of the terminal window", - IDC_BOX_TERMINAL1, IDC_BOXT_TERMINAL1); - multiedit(&cp, - "&Rows", IDC_ROWSSTATIC, IDC_ROWSEDIT, 50, - "Colu&mns", IDC_COLSSTATIC, IDC_COLSEDIT, 50, - NULL); - checkbox(&cp, "Loc&k window size against resizing", IDC_LOCKSIZE); - endbox(&cp); - beginbox(&cp, "Set the font used in the terminal window", - IDC_BOX_TERMINAL2, IDC_BOXT_TERMINAL2); - staticbtn(&cp, "", IDC_FONTSTATIC, "C&hange...", IDC_CHOOSEFONT); - endbox(&cp); beginbox(&cp, "Set various terminal options", - IDC_BOX_TERMINAL3, IDC_BOXT_TERMINAL3); + IDC_BOX_TERMINAL1, IDC_BOXT_TERMINAL1); 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); - checkbox(&cp, "&Use local terminal line discipline", IDC_LDISCTERM); + checkbox(&cp, "&Use local terminal line discipline", IDC_LDISCTERM); endbox(&cp); + beginbox(&cp, "Control session logging", + IDC_BOX_TERMINAL2, IDC_BOXT_TERMINAL2); + radiobig(&cp, + "Session logging:", IDC_LSTATSTATIC, + "Logging turned &off completely", IDC_LSTATOFF, + "Log printable output only", IDC_LSTATASCII, + "Log all session output", IDC_LSTATRAW, NULL); + editbutton(&cp, "Log &file name:", + IDC_LGFSTATIC, IDC_LGFEDIT, "Bro&wse...", + IDC_LGFBUTTON); + endbox(&cp); + treeview_insert(&tvfaff, 0, "Terminal"); } - /* The Keyboard panel. Accelerators used: [acgo] h?srvlxvnpmiet */ + /* The Keyboard panel. Accelerators used: [acgo] h?srvlxvnpmietu */ { struct ctlpos cp; ctlposinit(&cp, hwnd, 80, 3, 13); @@ -746,11 +776,17 @@ 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 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); + 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, @@ -765,26 +801,22 @@ static int GenericMainDlgProc (HWND hwnd, UINT msg, treeview_insert(&tvfaff, 1, "Keyboard"); } - /* The Window panel. Accelerators used: [acgo] tibsdkw4ylp */ + /* The Window panel. Accelerators used: [acgo] bsdkw4ylpt */ { struct ctlpos cp; ctlposinit(&cp, hwnd, 80, 3, 13); bartitle(&cp, "Options controlling PuTTY's window", IDC_TITLE_WINDOW); - beginbox(&cp, "Adjust the use of the window title", + beginbox(&cp, "Set the size of the window", IDC_BOX_WINDOW1, IDC_BOXT_WINDOW1); - if (dlgtype == 0) - multiedit(&cp, - "Initial window &title:", IDC_WINTITLE, - IDC_WINEDIT, 100, NULL); - checkbox(&cp, "Avoid ever using &icon title", IDC_WINNAME); - endbox(&cp); - beginbox(&cp, "Adjust the use of the cursor", - IDC_BOX_WINDOW2, IDC_BOXT_WINDOW2); - checkbox(&cp, "Cursor &blinks", IDC_BLINKCUR); + multiedit(&cp, + "&Rows", IDC_ROWSSTATIC, IDC_ROWSEDIT, 50, + "Colu&mns", IDC_COLSSTATIC, IDC_COLSEDIT, 50, + NULL); + checkbox(&cp, "Loc&k window size against resizing", IDC_LOCKSIZE); endbox(&cp); beginbox(&cp, "Control the scrollback in the window", - IDC_BOX_WINDOW3, IDC_BOXT_WINDOW3); + IDC_BOX_WINDOW2, IDC_BOXT_WINDOW2); staticedit(&cp, "Lines of &scrollback", IDC_SAVESTATIC, IDC_SAVEEDIT, 50); checkbox(&cp, "&Display scrollbar", IDC_SCROLLBAR); @@ -792,16 +824,47 @@ static int GenericMainDlgProc (HWND hwnd, UINT msg, checkbox(&cp, "Reset scrollback on dis&play activity", IDC_SCROLLDISP); endbox(&cp); - beginbox(&cp, NULL, IDC_BOX_WINDOW4, 0); + beginbox(&cp, NULL, IDC_BOX_WINDOW3, 0); checkbox(&cp, "&Warn before closing window", IDC_CLOSEWARN); checkbox(&cp, "Window closes on ALT-F&4", IDC_ALTF4); checkbox(&cp, "S&ystem menu appears on ALT-Space", IDC_ALTSPACE); checkbox(&cp, "System menu appears on A< alone", IDC_ALTONLY); + checkbox(&cp, "Ensure window is always on &top", IDC_ALWAYSONTOP); endbox(&cp); treeview_insert(&tvfaff, 0, "Window"); } + /* The Appearance panel. Accelerators used: [acgo] rmkhtibluv */ + { + struct ctlpos cp; + ctlposinit(&cp, hwnd, 80, 3, 13); + bartitle(&cp, "Options controlling PuTTY's appearance", + IDC_TITLE_APPEARANCE); + beginbox(&cp, "Adjust the use of the cursor", + IDC_BOX_APPEARANCE1, IDC_BOXT_APPEARANCE1); + radioline(&cp, "Cursor appearance:", IDC_CURSORSTATIC, 3, + "B&lock", IDC_CURBLOCK, + "&Underline", IDC_CURUNDER, + "&Vertical line", IDC_CURVERT, + NULL); + checkbox(&cp, "Cursor &blinks", IDC_BLINKCUR); + endbox(&cp); + beginbox(&cp, "Set the font used in the terminal window", + IDC_BOX_APPEARANCE2, IDC_BOXT_APPEARANCE2); + staticbtn(&cp, "", IDC_FONTSTATIC, "C&hange...", IDC_CHOOSEFONT); + endbox(&cp); + beginbox(&cp, "Adjust the use of the window title", + IDC_BOX_APPEARANCE3, IDC_BOXT_APPEARANCE3); + multiedit(&cp, + "Window &title:", IDC_WINTITLE, + IDC_WINEDIT, 100, NULL); + checkbox(&cp, "Avoid ever using &icon title", IDC_WINNAME); + endbox(&cp); + + treeview_insert(&tvfaff, 1, "Appearance"); + } + /* The Translation panel. Accelerators used: [acgo] xbepnkis */ { struct ctlpos cp; @@ -953,6 +1016,7 @@ static int GenericMainDlgProc (HWND hwnd, UINT msg, beginbox(&cp, "Protocol options", IDC_BOX_SSH3, IDC_BOXT_SSH3); checkbox(&cp, "Don't allocate a &pseudo-terminal", IDC_NOPTY); + checkbox(&cp, "Enable compr&ession", IDC_COMPRESS); radioline(&cp, "Preferred SSH protocol version:", IDC_SSHPROTSTATIC, 2, "&1", IDC_SSHPROT1, "&2", IDC_SSHPROT2, NULL); @@ -1025,6 +1089,8 @@ static int GenericMainDlgProc (HWND hwnd, UINT msg, hide(hwnd, FALSE, terminalpanelstart, terminalpanelend); if (!strcmp(buffer, "Window")) hide(hwnd, FALSE, windowpanelstart, windowpanelend); + if (!strcmp(buffer, "Appearance")) + hide(hwnd, FALSE, appearancepanelstart, appearancepanelend); if (!strcmp(buffer, "Connection")) hide(hwnd, FALSE, connectionpanelstart, connectionpanelend); if (!strcmp(buffer, "Telnet")) @@ -1077,8 +1143,16 @@ static int GenericMainDlgProc (HWND hwnd, UINT msg, sizeof(cfg.host)-1); break; case IDC_PORT: - if (HIWORD(wParam) == EN_CHANGE) - MyGetDlgItemInt (hwnd, IDC_PORT, &cfg.port); + if (HIWORD(wParam) == EN_CHANGE) { + GetDlgItemText (hwnd, IDC_PORT, portname, 31); + if (isdigit(portname[0])) + MyGetDlgItemInt (hwnd, IDC_PORT, &cfg.port); + else { + service = getservbyname(portname, NULL); + if (service) cfg.port = ntohs(service->s_port); + else cfg.port = 0; + } + } break; case IDC_SESSEDIT: if (HIWORD(wParam) == EN_CHANGE) { @@ -1140,6 +1214,8 @@ static int GenericMainDlgProc (HWND hwnd, UINT msg, init_dlg_ctrls(hwnd); if (!isdef) SetDlgItemText(hwnd, IDC_SESSEDIT, sessions[n]); + else + SetDlgItemText(hwnd, IDC_SESSEDIT, ""); } if (LOWORD(wParam) == IDC_SESSLIST) { /* @@ -1227,6 +1303,16 @@ static int GenericMainDlgProc (HWND hwnd, UINT msg, HIWORD(wParam) == BN_DOUBLECLICKED) cfg.app_cursor = IsDlgButtonChecked (hwnd, IDC_CURAPPLIC); break; + case IDC_NOAPPLICC: + if (HIWORD(wParam) == BN_CLICKED || + HIWORD(wParam) == BN_DOUBLECLICKED) + cfg.no_applic_c = IsDlgButtonChecked (hwnd, IDC_NOAPPLICC); + break; + case IDC_NOAPPLICK: + if (HIWORD(wParam) == BN_CLICKED || + HIWORD(wParam) == BN_DOUBLECLICKED) + cfg.no_applic_k = IsDlgButtonChecked (hwnd, IDC_NOAPPLICK); + break; case IDC_ALTF4: if (HIWORD(wParam) == BN_CLICKED || HIWORD(wParam) == BN_DOUBLECLICKED) @@ -1247,6 +1333,11 @@ static int GenericMainDlgProc (HWND hwnd, UINT msg, HIWORD(wParam) == BN_DOUBLECLICKED) cfg.ldisc_term = IsDlgButtonChecked (hwnd, IDC_LDISCTERM); break; + case IDC_ALWAYSONTOP: + if (HIWORD(wParam) == BN_CLICKED || + HIWORD(wParam) == BN_DOUBLECLICKED) + cfg.alwaysontop = IsDlgButtonChecked (hwnd, IDC_ALWAYSONTOP); + break; case IDC_SCROLLKEY: if (HIWORD(wParam) == BN_CLICKED || HIWORD(wParam) == BN_DOUBLECLICKED) @@ -1338,6 +1429,21 @@ static int GenericMainDlgProc (HWND hwnd, UINT msg, HIWORD(wParam) == BN_DOUBLECLICKED) cfg.win_name_always = IsDlgButtonChecked (hwnd, IDC_WINNAME); break; + case IDC_CURBLOCK: + if (HIWORD(wParam) == BN_CLICKED || + HIWORD(wParam) == BN_DOUBLECLICKED) + cfg.cursor_type = 0; + break; + case IDC_CURUNDER: + if (HIWORD(wParam) == BN_CLICKED || + HIWORD(wParam) == BN_DOUBLECLICKED) + cfg.cursor_type = 1; + break; + case IDC_CURVERT: + if (HIWORD(wParam) == BN_CLICKED || + HIWORD(wParam) == BN_DOUBLECLICKED) + cfg.cursor_type = 2; + break; case IDC_BLINKCUR: if (HIWORD(wParam) == BN_CLICKED || HIWORD(wParam) == BN_DOUBLECLICKED) @@ -1373,6 +1479,43 @@ static int GenericMainDlgProc (HWND hwnd, UINT msg, GetDlgItemText (hwnd, IDC_TTEDIT, cfg.termtype, sizeof(cfg.termtype)-1); break; + case IDC_LGFEDIT: + if (HIWORD(wParam) == EN_CHANGE) + GetDlgItemText (hwnd, IDC_LGFEDIT, cfg.logfilename, + sizeof(cfg.logfilename)-1); + break; + case IDC_LGFBUTTON: + 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 = "All Files\0*\0\0\0"; + of.lpstrCustomFilter = NULL; + of.nFilterIndex = 1; + of.lpstrFile = filename; strcpy(filename, cfg.keyfile); + of.nMaxFile = sizeof(filename); + of.lpstrFileTitle = NULL; + of.lpstrInitialDir = NULL; + of.lpstrTitle = "Select session log file"; + of.Flags = 0; + if (GetSaveFileName(&of)) { + strcpy(cfg.keyfile, filename); + SetDlgItemText (hwnd, IDC_LGFEDIT, cfg.keyfile); + } + break; + case IDC_LSTATOFF: + case IDC_LSTATASCII: + case IDC_LSTATRAW: + if (HIWORD(wParam) == BN_CLICKED || + HIWORD(wParam) == BN_DOUBLECLICKED) { + if (IsDlgButtonChecked (hwnd, IDC_LSTATOFF)) cfg.logtype = 0; + if (IsDlgButtonChecked (hwnd, IDC_LSTATASCII)) cfg.logtype = 1; + if (IsDlgButtonChecked (hwnd, IDC_LSTATRAW)) cfg.logtype = 2; + } + break; case IDC_TSEDIT: if (HIWORD(wParam) == EN_CHANGE) GetDlgItemText (hwnd, IDC_TSEDIT, cfg.termspeed, @@ -1461,6 +1604,11 @@ static int GenericMainDlgProc (HWND hwnd, UINT msg, HIWORD(wParam) == BN_DOUBLECLICKED) cfg.nopty = IsDlgButtonChecked (hwnd, IDC_NOPTY); break; + case IDC_COMPRESS: + if (HIWORD(wParam) == BN_CLICKED || + HIWORD(wParam) == BN_DOUBLECLICKED) + cfg.compression = IsDlgButtonChecked (hwnd, IDC_COMPRESS); + break; case IDC_BUGGYMAC: if (HIWORD(wParam) == BN_CLICKED || HIWORD(wParam) == BN_DOUBLECLICKED) @@ -1567,17 +1715,15 @@ static int GenericMainDlgProc (HWND hwnd, UINT msg, int n, i; cfg.bold_colour = IsDlgButtonChecked (hwnd, IDC_BOLDCOLOUR); n = SendDlgItemMessage (hwnd, IDC_COLOURLIST, LB_GETCOUNT, 0, 0); - if (cfg.bold_colour && n!=22) { - for (i=0; i<22; i++) - if (!permcolour[i]) - SendDlgItemMessage (hwnd, IDC_COLOURLIST, - LB_INSERTSTRING, i, - (LPARAM) colours[i]); - } else if (!cfg.bold_colour && n!=12) { - for (i=22; i-- ;) - if (!permcolour[i]) - SendDlgItemMessage (hwnd, IDC_COLOURLIST, + if (n != 12+10*cfg.bold_colour) { + for (i=n; i-- >0 ;) + SendDlgItemMessage (hwnd, IDC_COLOURLIST, LB_DELETESTRING, i, 0); + for (i=0; i<22; i++) + if (cfg.bold_colour || permcolour[i]) + SendDlgItemMessage (hwnd, IDC_COLOURLIST, + LB_ADDSTRING, 0, + (LPARAM) colours[i]); } } break; @@ -1593,7 +1739,6 @@ static int GenericMainDlgProc (HWND hwnd, UINT msg, 0, 0); if (!cfg.bold_colour) i = (i < 3 ? i*2 : i == 3 ? 5 : i*2-2); -debug(("ooh\n")); SetDlgItemInt (hwnd, IDC_RVALUE, cfg.colours[i][0], FALSE); SetDlgItemInt (hwnd, IDC_GVALUE, cfg.colours[i][1], FALSE); SetDlgItemInt (hwnd, IDC_BVALUE, cfg.colours[i][2], FALSE); @@ -1730,8 +1875,6 @@ int do_reconfig (HWND hwnd) { ret = DialogBox (hinst, MAKEINTRESOURCE(IDD_RECONF), hwnd, ReconfDlgProc); if (!ret) cfg = backup_cfg; /* structure copy */ - else - force_normal(hwnd); return ret; } @@ -1836,3 +1979,30 @@ void verify_ssh_host_key(char *host, int port, char *keytype, store_host_key(host, port, keytype, keystr); } } + +/* + * Ask whether to wipe a session log file before writing to it. + * Returns 2 for wipe, 1 for append, 0 for cancel (don't log). + */ +int askappend(char *filename) { + static const char mbtitle[] = "PuTTY Log to File"; + static const char msgtemplate[] = + "The session log file \"%.*s\" already exists.\n" + "You can overwrite it with a new session log,\n" + "append your session log to the end of it,\n" + "or disable session logging for this session.\n" + "Hit Yes to wipe the file, No to append to it,\n" + "or Cancel to disable logging."; + char message[sizeof(msgtemplate) + FILENAME_MAX]; + int mbret; + sprintf(message, msgtemplate, FILENAME_MAX, filename); + + mbret = MessageBox(NULL, message, mbtitle, + MB_ICONQUESTION | MB_YESNOCANCEL); + if (mbret == IDYES) + return 2; + else if (mbret == IDNO) + return 1; + else + return 0; +}