static HWND hwnd;
+static HBITMAP caretbm;
+
static int dbltime, lasttime, lastact;
static Mouse_Button lastbtn;
default_protocol = DEFAULT_PROTOCOL;
default_port = DEFAULT_PORT;
- do_defaults(NULL);
+ do_defaults(NULL, &cfg);
p = cmdline;
while (*p && isspace(*p)) p++;
* An initial @ means to activate a saved session.
*/
if (*p == '@') {
- do_defaults (p+1);
+ do_defaults (p+1, &cfg);
if (!*cfg.host && !do_config()) {
WSACleanup();
return 0;
SWP_NOMOVE | SWP_NOREDRAW | SWP_NOZORDER);
/*
+ * Set up a caret bitmap, with no content.
+ */
+ {
+ char *bits;
+ int size = (font_width+15)/16 * 2 * font_height;
+ bits = calloc(size, 1);
+ caretbm = CreateBitmap(font_width, font_height, 1, 1, bits);
+ free(bits);
+ }
+
+ /*
* Initialise the scroll bar.
*/
{
*/
{
char *error;
- char msg[1024];
+ char msg[1024], *title;
char *realhost;
error = back->init (hwnd, cfg.host, cfg.port, &realhost);
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;
KillTimer(hwnd, timer_id);
timer_id = 0;
}
+ HideCaret(hwnd);
if (inbuf_head)
term_out();
term_update();
+ ShowCaret(hwnd);
if (!has_focus)
timer_id = SetTimer(hwnd, 1, 2000, NULL);
else if (cfg.blinktext)
enact_pending_netevent();
if (inbuf_head)
term_out();
+ HideCaret(hwnd);
term_update();
+ ShowCaret(hwnd);
return 0;
case WM_CREATE:
break;
case WM_PAINT:
{
PAINTSTRUCT p;
+ HideCaret(hwnd);
hdc = BeginPaint (hwnd, &p);
if (pal) {
SelectPalette (hdc, pal, TRUE);
SelectObject (hdc, GetStockObject(SYSTEM_FONT));
SelectObject (hdc, GetStockObject(WHITE_PEN));
EndPaint (hwnd, &p);
+ ShowCaret(hwnd);
}
return 0;
case WM_NETEVENT:
return 0;
case WM_SETFOCUS:
has_focus = TRUE;
- CreateCaret(hwnd, NULL, font_width, font_height);
+ CreateCaret(hwnd, caretbm, 0, 0);
+ ShowCaret(hwnd);
term_out();
term_update();
break;
}
}
-void write_clip (void *data, int len) {
+void write_clip (void *data, int len, int must_deselect) {
HGLOBAL clipdata;
void *lock;
((unsigned char *) lock) [len] = 0;
GlobalUnlock (clipdata);
- SendMessage (hwnd, WM_IGNORE_CLIP, TRUE, 0);
+ if (!must_deselect)
+ SendMessage (hwnd, WM_IGNORE_CLIP, TRUE, 0);
+
if (OpenClipboard (hwnd)) {
EmptyClipboard();
SetClipboardData (CF_TEXT, clipdata);
CloseClipboard();
} else
GlobalFree (clipdata);
- SendMessage (hwnd, WM_IGNORE_CLIP, FALSE, 0);
+
+ if (!must_deselect)
+ SendMessage (hwnd, WM_IGNORE_CLIP, FALSE, 0);
}
void get_clip (void **p, int *len) {