From 9ca5da428c0113cced4401cc8c424eb6f485608a Mon Sep 17 00:00:00 2001 From: simon Date: Mon, 2 Oct 2000 12:24:58 +0000 Subject: [PATCH] Add ability to configure the initial window title git-svn-id: svn://svn.tartarus.org/sgt/putty@661 cda61777-01e9-0310-a592-d414129be87e --- putty.h | 1 + win_res.h | 12 ++++++--- win_res.inp | 23 +++++++++++++---- win_res.rc | 40 ++++++++++++++++++----------- windlg.c | 84 ++++++++++++++++++++++++++++++++++++++----------------------- window.c | 13 +++++++--- 6 files changed, 115 insertions(+), 58 deletions(-) diff --git a/putty.h b/putty.h index 4b64892e..791930ab 100644 --- a/putty.h +++ b/putty.h @@ -163,6 +163,7 @@ typedef struct { int alt_space; /* is it special? */ int ldisc_term; int scroll_on_key; + char wintitle[256]; /* initial window title */ /* Terminal options */ int savelines; int dec_om; diff --git a/win_res.h b/win_res.h index d9e50449..72804adc 100644 --- a/win_res.h +++ b/win_res.h @@ -7,6 +7,7 @@ #define IDD_PANEL0 103 #define IDD_PANEL1 104 #define IDD_PANEL2 105 +#define IDD_PANELW 115 #define IDD_PANEL3 106 #define IDD_PANEL35 107 #define IDD_PANEL4 108 @@ -70,7 +71,6 @@ #define IDC2_WRAPMODE 1001 #define IDC2_DECOM 1002 -#define IDC2_WINNAME 1003 #define IDC2_DIMSTATIC 1004 #define IDC2_ROWSSTATIC 1005 #define IDC2_ROWSEDIT 1006 @@ -81,13 +81,17 @@ #define IDC2_FONTSTATIC 1011 #define IDC2_CHOOSEFONT 1012 #define IDC2_LFHASCR 1018 -#define IDC1_BLINKCUR 1020 #define IDC1_BEEP 1021 -#define IDC2_SCROLLBAR 1022 -#define IDC2_LOCKSIZE 1023 #define IDC2_BCE 1024 #define IDC2_BLINKTEXT 1025 +#define IDCW_WINNAME 1001 +#define IDCW_BLINKCUR 1002 +#define IDCW_SCROLLBAR 1003 +#define IDCW_LOCKSIZE 1004 +#define IDCW_WINTITLE 1005 +#define IDCW_WINEDIT 1006 + #define IDC3_TTSTATIC 1001 #define IDC3_TTEDIT 1002 #define IDC3_TSSTATIC 1003 diff --git a/win_res.inp b/win_res.inp index 2f021785..eb302fe5 100644 --- a/win_res.inp +++ b/win_res.inp @@ -145,7 +145,7 @@ BEGIN AUTOCHECKBOX "Reset scrollback on &keypress", IDC1_SCROLLKEY, SCOL END -/* Accelerators used: [aco] bdghiklmnprswy */ +/* Accelerators used: [aco] dghlmnprsw */ IDD_PANEL2 DIALOG DISCARDABLE 6, 30, 168, 163 STYLE WS_CHILD | WS_VISIBLE | NOT WS_BORDER FONT 8, "MS Sans Serif" @@ -170,12 +170,8 @@ BEGIN GRID(1,8,10) AUTOCHECKBOX "Auto &wrap mode initially on", IDC2_WRAPMODE, SCOL AUTOCHECKBOX "&DEC Origin Mode initially on", IDC2_DECOM, SCOL - AUTOCHECKBOX "Avoid ever using &icon title", IDC2_WINNAME, SCOL AUTOCHECKBOX "Implicit CR in every &LF", IDC2_LFHASCR, SCOL - AUTOCHECKBOX "&Blinking cursor", IDC1_BLINKCUR, SCOL AUTOCHECKBOX "Bee&p enabled", IDC1_BEEP, SCOL - AUTOCHECKBOX "Displa&y scrollbar", IDC2_SCROLLBAR, SCOL - AUTOCHECKBOX "Loc&k Window size", IDC2_LOCKSIZE, SCOL AUTOCHECKBOX "Use Back&ground colour erase", IDC2_BCE, SCOL AUTOCHECKBOX "Enable bli&nking text", IDC2_BLINKTEXT, SCOL GAP(6) @@ -183,6 +179,23 @@ BEGIN GAP(6) END +/* Accelerators used: [aco] bikty */ +IDD_PANELW DIALOG DISCARDABLE 6, 30, 168, 163 +STYLE WS_CHILD | WS_VISIBLE | NOT WS_BORDER +FONT 8, "MS Sans Serif" +INIT(10,176,8,162) SPOS(3,3) +BEGIN + GRID(4,4,24) + LTEXT "Initial window &title:", IDCW_WINTITLE, COL(1), SS(3,2) + EDITTEXT IDCW_WINEDIT, ADJ(8) COL(1), SS(3,3), ES_AUTOHSCROLL + NEXT(2) + GRID(1,8,10) + AUTOCHECKBOX "Avoid ever using &icon title", IDCW_WINNAME, SCOL + AUTOCHECKBOX "&Blinking cursor", IDCW_BLINKCUR, SCOL + AUTOCHECKBOX "Displa&y scrollbar", IDCW_SCROLLBAR, SCOL + AUTOCHECKBOX "Loc&k Window size", IDCW_LOCKSIZE, SCOL +END + /* Accelerators used: [aco] bdflrstuv */ IDD_PANEL3 DIALOG DISCARDABLE 6, 30, 168, 163 STYLE WS_CHILD | WS_VISIBLE | NOT WS_BORDER diff --git a/win_res.rc b/win_res.rc index eb89218a..9ef425be 100644 --- a/win_res.rc +++ b/win_res.rc @@ -145,7 +145,7 @@ BEGIN AUTOCHECKBOX "Reset scrollback on &keypress", IDC1_SCROLLKEY, 3, 143, 162, 8 END -/* Accelerators used: [aco] bdghiklmnprswy */ +/* Accelerators used: [aco] dghlmnprsw */ IDD_PANEL2 DIALOG DISCARDABLE 6, 30, 168, 163 STYLE WS_CHILD | WS_VISIBLE | NOT WS_BORDER FONT 8, "MS Sans Serif" @@ -170,19 +170,32 @@ BEGIN AUTOCHECKBOX "Auto &wrap mode initially on", IDC2_WRAPMODE, 3, 62, 162, 8 AUTOCHECKBOX "&DEC Origin Mode initially on", IDC2_DECOM, 3, 72, 162, 8 - AUTOCHECKBOX "Avoid ever using &icon title", IDC2_WINNAME, 3, 82, 162, 8 - AUTOCHECKBOX "Implicit CR in every &LF", IDC2_LFHASCR, 3, 92, 162, 8 - AUTOCHECKBOX "&Blinking cursor", IDC1_BLINKCUR, 3, 102, 162, 8 - AUTOCHECKBOX "Bee&p enabled", IDC1_BEEP, 3, 112, 162, 8 - AUTOCHECKBOX "Displa&y scrollbar", IDC2_SCROLLBAR, 3, 122, 162, 8 - AUTOCHECKBOX "Loc&k Window size", IDC2_LOCKSIZE, 3, 132, 162, 8 - AUTOCHECKBOX "Use Back&ground colour erase", IDC2_BCE, 3, 142, 162, 8 - AUTOCHECKBOX "Enable bli&nking text", IDC2_BLINKTEXT, 3, 152, 162, 8 + AUTOCHECKBOX "Implicit CR in every &LF", IDC2_LFHASCR, 3, 82, 162, 8 + AUTOCHECKBOX "Bee&p enabled", IDC1_BEEP, 3, 92, 162, 8 + AUTOCHECKBOX "Use Back&ground colour erase", IDC2_BCE, 3, 102, 162, 8 + AUTOCHECKBOX "Enable bli&nking text", IDC2_BLINKTEXT, 3, 112, 162, 8 END +/* Accelerators used: [aco] bikty */ +IDD_PANELW DIALOG DISCARDABLE 6, 30, 168, 163 +STYLE WS_CHILD | WS_VISIBLE | NOT WS_BORDER +FONT 8, "MS Sans Serif" + +BEGIN + + LTEXT "Initial window &title:", IDCW_WINTITLE, 3, 3, 119, 8 + EDITTEXT IDCW_WINEDIT, 3, 11, 119, 12, ES_AUTOHSCROLL + + + AUTOCHECKBOX "Avoid ever using &icon title", IDCW_WINNAME, 3, 29, 162, 8 + AUTOCHECKBOX "&Blinking cursor", IDCW_BLINKCUR, 3, 39, 162, 8 + AUTOCHECKBOX "Displa&y scrollbar", IDCW_SCROLLBAR, 3, 49, 162, 8 + AUTOCHECKBOX "Loc&k Window size", IDCW_LOCKSIZE, 3, 59, 162, 8 +END + /* Accelerators used: [aco] bdflrstuv */ IDD_PANEL3 DIALOG DISCARDABLE 6, 30, 168, 163 STYLE WS_CHILD | WS_VISIBLE | NOT WS_BORDER @@ -340,15 +353,14 @@ BEGIN END -/* Accelerators used: co */ -IDD_LOGBOX DIALOG DISCARDABLE 100, 20, 260, 119 +/* Accelerators used: c */ +IDD_LOGBOX DIALOG DISCARDABLE 100, 20, 160, 119 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "PuTTY Event Log" FONT 8, "MS Sans Serif" BEGIN - DEFPUSHBUTTON "&Close", IDOK, 135, 102, 44, 14 - PUSHBUTTON "C&opy", IDN_COPY, 81, 102, 44, 14 - LISTBOX IDN_LIST, 3, 3, 254, 95, LBS_HASSTRINGS | LBS_USETABSTOPS | WS_VSCROLL | LBS_EXTENDEDSEL + DEFPUSHBUTTON "&Close", IDOK, 58, 102, 44, 14 + LISTBOX IDN_LIST, 3, 3, 154, 95, LBS_HASSTRINGS | LBS_USETABSTOPS | WS_VSCROLL END /* No accelerators used */ diff --git a/windlg.c b/windlg.c index 60d19052..3b973200 100644 --- a/windlg.c +++ b/windlg.c @@ -16,9 +16,9 @@ #include "win_res.h" #include "storage.h" -#define NPANELS 8 -#define MAIN_NPANELS 8 -#define RECONF_NPANELS 5 +#define NPANELS 9 +#define MAIN_NPANELS 9 +#define RECONF_NPANELS 6 static char **events = NULL; static int nevents = 0, negsize = 0; @@ -110,6 +110,7 @@ static void save_settings (char *section, int do_host) { write_setting_i (sesskey, "AutoWrapMode", cfg.wrap_mode); write_setting_i (sesskey, "LFImpliesCR", cfg.lfhascr); write_setting_i (sesskey, "WinNameAlways", cfg.win_name_always); + write_setting_s (sesskey, "WinTitle", cfg.wintitle); write_setting_i (sesskey, "TermWidth", cfg.width); write_setting_i (sesskey, "TermHeight", cfg.height); write_setting_s (sesskey, "Font", cfg.font); @@ -227,6 +228,7 @@ static void load_settings (char *section, int do_host) { gppi (sesskey, "AutoWrapMode", 1, &cfg.wrap_mode); gppi (sesskey, "LFImpliesCR", 0, &cfg.lfhascr); gppi (sesskey, "WinNameAlways", 0, &cfg.win_name_always); + gpps (sesskey, "WinTitle", "", cfg.wintitle, sizeof(cfg.wintitle)); gppi (sesskey, "TermWidth", 80, &cfg.width); gppi (sesskey, "TermHeight", 24, &cfg.height); gpps (sesskey, "Font", "Courier", cfg.font, sizeof(cfg.font)); @@ -726,7 +728,6 @@ static int CALLBACK TerminalProc (HWND hwnd, UINT msg, switch (msg) { case WM_INITDIALOG: CheckDlgButton (hwnd, IDC2_WRAPMODE, cfg.wrap_mode); - CheckDlgButton (hwnd, IDC2_WINNAME, cfg.win_name_always); CheckDlgButton (hwnd, IDC2_DECOM, cfg.dec_om); CheckDlgButton (hwnd, IDC2_LFHASCR, cfg.lfhascr); SetDlgItemInt (hwnd, IDC2_ROWSEDIT, cfg.height, FALSE); @@ -734,10 +735,7 @@ static int CALLBACK TerminalProc (HWND hwnd, UINT msg, SetDlgItemInt (hwnd, IDC2_SAVEEDIT, cfg.savelines, FALSE); fmtfont (fontstatic); SetDlgItemText (hwnd, IDC2_FONTSTATIC, fontstatic); - CheckDlgButton (hwnd, IDC1_BLINKCUR, cfg.blink_cur); CheckDlgButton (hwnd, IDC1_BEEP, cfg.beep); - CheckDlgButton (hwnd, IDC2_SCROLLBAR, cfg.scrollbar); - CheckDlgButton (hwnd, IDC2_LOCKSIZE, cfg.locksize); CheckDlgButton (hwnd, IDC2_BCE, cfg.bce); CheckDlgButton (hwnd, IDC2_BLINKTEXT, cfg.blinktext); break; @@ -748,11 +746,6 @@ static int CALLBACK TerminalProc (HWND hwnd, UINT msg, HIWORD(wParam) == BN_DOUBLECLICKED) cfg.wrap_mode = IsDlgButtonChecked (hwnd, IDC2_WRAPMODE); break; - case IDC2_WINNAME: - if (HIWORD(wParam) == BN_CLICKED || - HIWORD(wParam) == BN_DOUBLECLICKED) - cfg.win_name_always = IsDlgButtonChecked (hwnd, IDC2_WINNAME); - break; case IDC2_DECOM: if (HIWORD(wParam) == BN_CLICKED || HIWORD(wParam) == BN_DOUBLECLICKED) @@ -804,26 +797,11 @@ static int CALLBACK TerminalProc (HWND hwnd, UINT msg, SetDlgItemText (hwnd, IDC2_FONTSTATIC, fontstatic); } break; - case IDC1_BLINKCUR: - if (HIWORD(wParam) == BN_CLICKED || - HIWORD(wParam) == BN_DOUBLECLICKED) - cfg.blink_cur = IsDlgButtonChecked (hwnd, IDC1_BLINKCUR); - break; case IDC1_BEEP: if (HIWORD(wParam) == BN_CLICKED || HIWORD(wParam) == BN_DOUBLECLICKED) cfg.beep = IsDlgButtonChecked (hwnd, IDC1_BEEP); break; - case IDC2_SCROLLBAR: - if (HIWORD(wParam) == BN_CLICKED || - HIWORD(wParam) == BN_DOUBLECLICKED) - cfg.scrollbar = IsDlgButtonChecked (hwnd, IDC2_SCROLLBAR); - break; - case IDC2_LOCKSIZE: - if (HIWORD(wParam) == BN_CLICKED || - HIWORD(wParam) == BN_DOUBLECLICKED) - cfg.locksize = IsDlgButtonChecked (hwnd, IDC2_LOCKSIZE); - break; case IDC2_BLINKTEXT: if (HIWORD(wParam) == BN_CLICKED || HIWORD(wParam) == BN_DOUBLECLICKED) @@ -840,6 +818,49 @@ static int CALLBACK TerminalProc (HWND hwnd, UINT msg, return GeneralPanelProc (hwnd, msg, wParam, lParam); } +static int CALLBACK WindowProc (HWND hwnd, UINT msg, + WPARAM wParam, LPARAM lParam) { + switch (msg) { + case WM_INITDIALOG: + SetDlgItemText (hwnd, IDCW_WINEDIT, cfg.wintitle); + CheckDlgButton (hwnd, IDCW_WINNAME, cfg.win_name_always); + CheckDlgButton (hwnd, IDCW_BLINKCUR, cfg.blink_cur); + CheckDlgButton (hwnd, IDCW_SCROLLBAR, cfg.scrollbar); + CheckDlgButton (hwnd, IDCW_LOCKSIZE, cfg.locksize); + break; + case WM_COMMAND: + switch (LOWORD(wParam)) { + case IDCW_WINNAME: + if (HIWORD(wParam) == BN_CLICKED || + HIWORD(wParam) == BN_DOUBLECLICKED) + cfg.win_name_always = IsDlgButtonChecked (hwnd, IDCW_WINNAME); + break; + case IDCW_BLINKCUR: + if (HIWORD(wParam) == BN_CLICKED || + HIWORD(wParam) == BN_DOUBLECLICKED) + cfg.blink_cur = IsDlgButtonChecked (hwnd, IDCW_BLINKCUR); + break; + case IDCW_SCROLLBAR: + if (HIWORD(wParam) == BN_CLICKED || + HIWORD(wParam) == BN_DOUBLECLICKED) + cfg.scrollbar = IsDlgButtonChecked (hwnd, IDCW_SCROLLBAR); + break; + case IDCW_LOCKSIZE: + if (HIWORD(wParam) == BN_CLICKED || + HIWORD(wParam) == BN_DOUBLECLICKED) + cfg.locksize = IsDlgButtonChecked (hwnd, IDCW_LOCKSIZE); + break; + case IDCW_WINEDIT: + if (HIWORD(wParam) == EN_CHANGE) + GetDlgItemText (hwnd, IDCW_WINEDIT, cfg.wintitle, + sizeof(cfg.wintitle)-1); + break; + } + break; + } + return GeneralPanelProc (hwnd, msg, wParam, lParam); +} + static int CALLBACK TelnetProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { int i; @@ -1282,13 +1303,14 @@ static int CALLBACK TranslationProc (HWND hwnd, UINT msg, } static DLGPROC panelproc[NPANELS] = { - ConnectionProc, KeyboardProc, TerminalProc, + ConnectionProc, KeyboardProc, TerminalProc, WindowProc, TelnetProc, SshProc, SelectionProc, ColourProc, TranslationProc }; static char *panelids[NPANELS] = { MAKEINTRESOURCE(IDD_PANEL0), MAKEINTRESOURCE(IDD_PANEL1), MAKEINTRESOURCE(IDD_PANEL2), + MAKEINTRESOURCE(IDD_PANELW), MAKEINTRESOURCE(IDD_PANEL3), MAKEINTRESOURCE(IDD_PANEL35), MAKEINTRESOURCE(IDD_PANEL4), @@ -1297,12 +1319,12 @@ static char *panelids[NPANELS] = { }; static char *names[NPANELS] = { - "Connection", "Keyboard", "Terminal", "Telnet", + "Connection", "Keyboard", "Terminal", "Window", "Telnet", "SSH", "Selection", "Colours", "Translation" }; -static int mainp[MAIN_NPANELS] = { 0, 1, 2, 3, 4, 5, 6, 7}; -static int reconfp[RECONF_NPANELS] = { 1, 2, 5, 6, 7}; +static int mainp[MAIN_NPANELS] = { 0, 1, 2, 3, 4, 5, 6, 7, 8}; +static int reconfp[RECONF_NPANELS] = { 1, 2, 3, 6, 7, 8}; static int GenericMainDlgProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam, diff --git a/window.c b/window.c index 43e305f8..fe9d2e91 100644 --- a/window.c +++ b/window.c @@ -415,7 +415,7 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show) { */ { char *error; - char msg[1024]; + char msg[1024], *title; char *realhost; error = back->init (hwnd, cfg.host, cfg.port, &realhost); @@ -425,9 +425,14 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show) { return 0; } window_name = icon_name = NULL; - sprintf(msg, "%s - PuTTY", realhost); - set_title (msg); - set_icon (msg); + if (*cfg.wintitle) { + title = cfg.wintitle; + } else { + sprintf(msg, "%s - PuTTY", realhost); + title = msg; + } + set_title (title); + set_icon (title); } session_closed = FALSE; -- 2.11.0