1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-04-10 15:48:06 -05:00

Since neither I nor Owen know why the IDM_ values for the saved-sessions

submenu were going up in steps of 16, I've changed to steps of 1, thus
increasing the possible number of sessions from ~256 to 4096, since a
recent report seemed to indicate that the previous limit might not be
enough for someone (!)
I can't find any documentation that puts an upper limit on the number of
menu items, and it seems to work on Win98, which is where I'd expect it to
break if anywhere.
Also a number of other tweaks to this code.

[originally from svn r4731]
This commit is contained in:
Jacob Nevins 2004-11-02 17:44:06 +00:00
parent 352bca5b1e
commit 8a4be1fe2f

View File

@ -45,6 +45,8 @@
#define IDM_SAVED_MIN 0x1000
#define IDM_SAVED_MAX 0x2000
/* Maximum number of sessions on saved-session submenu */
#define MENU_SAVED_MAX (IDM_SAVED_MAX-IDM_SAVED_MIN)
#define WM_IGNORE_CLIP (WM_XUSER + 2)
#define WM_FULLSCR_ON_MAX (WM_XUSER + 3)
@ -708,10 +710,12 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
s = CreateMenu();
get_sesslist(&sesslist, TRUE);
/* skip sesslist.sessions[0] == Default Settings */
for (i = 1;
i < ((sesslist.nsessions < 256) ? sesslist.nsessions : 256);
i < ((sesslist.nsessions <= MENU_SAVED_MAX+1) ? sesslist.nsessions
: MENU_SAVED_MAX+1);
i++)
AppendMenu(s, MF_ENABLED, IDM_SAVED_MIN + (16 * i),
AppendMenu(s, MF_ENABLED, IDM_SAVED_MIN + i-1,
sesslist.sessions[i]);
for (j = 0; j < lenof(popup_menus); j++) {
@ -1883,18 +1887,12 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
sprintf(c, "putty &%p", filemap);
cl = c;
} else if (wParam == IDM_SAVEDSESS) {
if ((lParam - IDM_SAVED_MIN) / 16 < sesslist.nsessions) {
char *session =
sesslist.sessions[(lParam - IDM_SAVED_MIN) / 16];
cl = snewn(16 + strlen(session), char);
/* 8, but play safe */
if (!cl)
cl = NULL;
/* not a very important failure mode */
else {
sprintf(cl, "putty @%s", session);
freecl = TRUE;
}
unsigned int sessno = lParam - IDM_SAVED_MIN + 1;
if (sessno < sesslist.nsessions) {
char *session = sesslist.sessions[sessno];
/* XXX spaces? quotes? "-load"? */
cl = dupprintf("putty @%s", session);
freecl = TRUE;
} else
break;
} else
@ -2112,7 +2110,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
flip_full_screen();
break;
default:
if (wParam >= IDM_SAVED_MIN && wParam <= IDM_SAVED_MAX) {
if (wParam >= IDM_SAVED_MIN && wParam < IDM_SAVED_MAX) {
SendMessage(hwnd, WM_SYSCOMMAND, IDM_SAVEDSESS, wParam);
}
if (wParam >= IDM_SPECIAL_MIN && wParam <= IDM_SPECIAL_MAX) {