} und_mode;
static int descent;
-#define NCFGCOLOURS 24
+#define NCFGCOLOURS 22
#define NEXTCOLOURS 240
#define NALLCOLOURS (NCFGCOLOURS + NEXTCOLOURS)
static COLORREF colours[NALLCOLOURS];
static LPLOGPALETTE logpal;
static RGBTRIPLE defpal[NALLCOLOURS];
-static HWND hwnd;
-
static HBITMAP caretbm;
static int dbltime, lasttime, lastact;
static int send_raw_mouse = 0;
static int wheel_accumulator = 0;
+static int busy_status = BUSY_NOT;
+
static char *window_name, *icon_name;
static int compose_state = 0;
int guess_width, guess_height;
hinst = inst;
+ hwnd = NULL;
flags = FLAG_VERBOSE | FLAG_INTERACTIVE;
sk_init();
if (p && p >= r) r = p+1;
q = strrchr(b, ':');
if (q && q >= r) r = q+1;
- strcpy(r, "putty.hlp");
+ strcpy(r, PUTTY_HELP_FILE);
if ( (fp = fopen(b, "r")) != NULL) {
help_path = dupstr(b);
fclose(fp);
} else
help_path = NULL;
- strcpy(r, "putty.cnt");
+ strcpy(r, PUTTY_HELP_CONTENTS);
if ( (fp = fopen(b, "r")) != NULL) {
help_has_contents = TRUE;
fclose(fp);
i++; /* skip next argument */
} else if (ret == 1) {
continue; /* nothing further needs doing */
- } else if (!strcmp(p, "-cleanup")) {
+ } else if (!strcmp(p, "-cleanup") ||
+ !strcmp(p, "-cleanup-during-uninstall")) {
/*
* `putty -cleanup'. Remove all registry
* entries associated with PuTTY, and also find
* and delete the random seed file.
*/
char *s1, *s2;
- s1 = dupprintf("This procedure will remove ALL Registry\n"
- "entries associated with %s, and will\n"
- "also remove the random seed file.\n"
- "\n"
- "THIS PROCESS WILL DESTROY YOUR SAVED\n"
- "SESSIONS. Are you really sure you want\n"
- "to continue?", appname);
- s2 = dupprintf("%s Warning", appname);
- if (MessageBox(NULL, s1, s2,
- MB_YESNO | MB_ICONWARNING) == IDYES) {
+ /* Are we being invoked from an uninstaller? */
+ if (!strcmp(p, "-cleanup-during-uninstall")) {
+ s1 = dupprintf("Remove saved sessions and random seed file?\n"
+ "\n"
+ "If you hit Yes, ALL Registry entries associated\n"
+ "with %s will be removed, as well as the\n"
+ "random seed file. THIS PROCESS WILL\n"
+ "DESTROY YOUR SAVED SESSIONS.\n"
+ "(This only affects the currently logged-in user.)\n"
+ "\n"
+ "If you hit No, uninstallation will proceed, but\n"
+ "saved sessions etc will be left on the machine.",
+ appname);
+ s2 = dupprintf("%s Uninstallation", appname);
+ } else {
+ s1 = dupprintf("This procedure will remove ALL Registry entries\n"
+ "associated with %s, and will also remove\n"
+ "the random seed file. (This only affects the\n"
+ "currently logged-in user.)\n"
+ "\n"
+ "THIS PROCESS WILL DESTROY YOUR SAVED SESSIONS.\n"
+ "Are you really sure you want to continue?",
+ appname);
+ s2 = dupprintf("%s Warning", appname);
+ }
+ if (message_box(s1, s2,
+ MB_YESNO | MB_ICONWARNING | MB_DEFBUTTON2,
+ HELPCTXID(option_cleanup)) == IDYES) {
cleanup_all();
}
sfree(s1);
}
/*
- * Trim a colon suffix off the hostname if it's there.
+ * Trim a colon suffix off the hostname if it's there. In
+ * order to protect IPv6 address literals against this
+ * treatment, we do not do this if there's _more_ than one
+ * colon.
*/
- cfg.host[strcspn(cfg.host, ":")] = '\0';
+ {
+ char *c = strchr(cfg.host, ':');
+
+ if (c) {
+ char *d = strchr(c+1, ':');
+ if (!d)
+ *c = '\0';
+ }
+ }
/*
* Remove any remaining whitespace from the hostname.
RegisterClass(&wndclass);
}
- hwnd = NULL;
-
memset(&ucsdata, 0, sizeof(ucsdata));
cfgtopalette();
}
}
+static void update_mouse_pointer(void)
+{
+ LPTSTR curstype;
+ int force_visible = FALSE;
+ static int forced_visible = FALSE;
+ switch (busy_status) {
+ case BUSY_NOT:
+ if (send_raw_mouse)
+ curstype = IDC_ARROW;
+ else
+ curstype = IDC_IBEAM;
+ break;
+ case BUSY_WAITING:
+ curstype = IDC_APPSTARTING; /* this may be an abuse */
+ force_visible = TRUE;
+ break;
+ case BUSY_CPU:
+ curstype = IDC_WAIT;
+ force_visible = TRUE;
+ break;
+ default:
+ assert(0);
+ }
+ {
+ HCURSOR cursor = LoadCursor(NULL, curstype);
+ SetClassLong(hwnd, GCL_HCURSOR, (LONG)cursor);
+ SetCursor(cursor); /* force redraw of cursor at current posn */
+ }
+ if (force_visible != forced_visible) {
+ /* We want some cursor shapes to be visible always.
+ * Along with show_mouseptr(), this manages the ShowCursor()
+ * counter such that if we switch back to a non-force_visible
+ * cursor, the previous visibility state is restored. */
+ ShowCursor(force_visible);
+ forced_visible = force_visible;
+ }
+}
+
+void set_busy_status(void *frontend, int status)
+{
+ busy_status = status;
+ update_mouse_pointer();
+}
+
/*
* set or clear the "raw mouse message" mode
*/
{
activate = activate && !cfg.no_mouse_rep;
send_raw_mouse = activate;
- SetCursor(LoadCursor(NULL, activate ? IDC_ARROW : IDC_IBEAM));
+ update_mouse_pointer();
}
/*
static void show_mouseptr(int show)
{
+ /* NB that the counter in ShowCursor() is also frobbed by
+ * update_mouse_pointer() */
static int cursor_visible = 1;
if (!cfg.hide_mouseptr) /* override if this feature disabled */
show = 1;
if (!cfg.warn_on_close || session_closed ||
MessageBox(hwnd,
"Are you sure you want to close this session?",
- str, MB_ICONWARNING | MB_OKCANCEL) == IDOK)
+ str, MB_ICONWARNING | MB_OKCANCEL | MB_DEFBUTTON1)
+ == IDOK)
DestroyWindow(hwnd);
sfree(str);
}
GetWindowText(hwnd, cfg.wintitle, sizeof(cfg.wintitle));
prev_cfg = cfg;
- if (!do_reconfig(hwnd))
+ if (!do_reconfig(hwnd, back ? back->cfg_info(backhandle) : 0))
break;
{
HBRUSH fillcolour, oldbrush;
HPEN edge, oldpen;
fillcolour = CreateSolidBrush (
- colours[(ATTR_DEFBG>>ATTR_BGSHIFT)*2]);
+ colours[ATTR_DEFBG>>ATTR_BGSHIFT]);
oldbrush = SelectObject(hdc, fillcolour);
edge = CreatePen(PS_SOLID, 0,
- colours[(ATTR_DEFBG>>ATTR_BGSHIFT)*2]);
+ colours[ATTR_DEFBG>>ATTR_BGSHIFT]);
oldpen = SelectObject(hdc, edge);
/*
Rectangle(hdc, p.rcPaint.left, p.rcPaint.top,
p.rcPaint.right, p.rcPaint.bottom);
- // SelectClipRgn(hdc, NULL);
+ /* SelectClipRgn(hdc, NULL); */
SelectObject(hdc, oldbrush);
DeleteObject(fillcolour);
lpage_send(ldisc, CP_ACP, &c, 1, 1);
}
return 0;
- case WM_SETCURSOR:
- if (send_raw_mouse && LOWORD(lParam) == HTCLIENT) {
- SetCursor(LoadCursor(NULL, IDC_ARROW));
- return TRUE;
- }
- break;
case WM_SYSCOLORCHANGE:
if (cfg.system_colour) {
/* Refresh palette from system colours. */