~mdw
/
sgt
/
putty
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Miscellaneous fixes to try to make other compilers happier
[sgt/putty]
/
window.c
diff --git
a/window.c
b/window.c
index
4c83e9b
..
7b7dee1
100644
(file)
--- a/
window.c
+++ b/
window.c
@@
-83,6
+83,8
@@
static RGBTRIPLE defpal[NCOLOURS];
static HWND hwnd;
static HWND hwnd;
+static HBITMAP caretbm;
+
static int dbltime, lasttime, lastact;
static Mouse_Button lastbtn;
static int dbltime, lasttime, lastact;
static Mouse_Button lastbtn;
@@
-130,7
+132,7
@@
int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show) {
default_protocol = DEFAULT_PROTOCOL;
default_port = DEFAULT_PORT;
default_protocol = DEFAULT_PROTOCOL;
default_port = DEFAULT_PORT;
- do_defaults(NULL);
+ do_defaults(NULL
, &cfg
);
p = cmdline;
while (*p && isspace(*p)) p++;
p = cmdline;
while (*p && isspace(*p)) p++;
@@
-188,7
+190,7
@@
int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show) {
* An initial @ means to activate a saved session.
*/
if (*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;
if (!*cfg.host && !do_config()) {
WSACleanup();
return 0;
@@
-383,6
+385,17
@@
int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show) {
SWP_NOMOVE | SWP_NOREDRAW | SWP_NOZORDER);
/*
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.
*/
{
* Initialise the scroll bar.
*/
{
@@
-402,7
+415,7
@@
int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show) {
*/
{
char *error;
*/
{
char *error;
- char msg[1024];
+ char msg[1024]
, *title
;
char *realhost;
error = back->init (hwnd, cfg.host, cfg.port, &realhost);
char *realhost;
error = back->init (hwnd, cfg.host, cfg.port, &realhost);
@@
-412,9
+425,14
@@
int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show) {
return 0;
}
window_name = icon_name = NULL;
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;
}
session_closed = FALSE;
@@
-536,9
+554,11
@@
int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show) {
KillTimer(hwnd, timer_id);
timer_id = 0;
}
KillTimer(hwnd, timer_id);
timer_id = 0;
}
+ HideCaret(hwnd);
if (inbuf_head)
term_out();
term_update();
if (inbuf_head)
term_out();
term_update();
+ ShowCaret(hwnd);
if (!has_focus)
timer_id = SetTimer(hwnd, 1, 2000, NULL);
else if (cfg.blinktext)
if (!has_focus)
timer_id = SetTimer(hwnd, 1, 2000, NULL);
else if (cfg.blinktext)
@@
-725,7
+745,7
@@
font_messup:
if (cfg.fontisbold) {
fw_dontcare = FW_BOLD;
if (cfg.fontisbold) {
fw_dontcare = FW_BOLD;
- fw_bold = FW_
BLACK
;
+ fw_bold = FW_
HEAVY
;
} else {
fw_dontcare = FW_DONTCARE;
fw_bold = FW_BOLD;
} else {
fw_dontcare = FW_DONTCARE;
fw_bold = FW_BOLD;
@@
-990,7
+1010,9
@@
static LRESULT CALLBACK WndProc (HWND hwnd, UINT message,
enact_pending_netevent();
if (inbuf_head)
term_out();
enact_pending_netevent();
if (inbuf_head)
term_out();
+ HideCaret(hwnd);
term_update();
term_update();
+ ShowCaret(hwnd);
return 0;
case WM_CREATE:
break;
return 0;
case WM_CREATE:
break;
@@
-1243,6
+1265,7
@@
static LRESULT CALLBACK WndProc (HWND hwnd, UINT message,
case WM_PAINT:
{
PAINTSTRUCT p;
case WM_PAINT:
{
PAINTSTRUCT p;
+ HideCaret(hwnd);
hdc = BeginPaint (hwnd, &p);
if (pal) {
SelectPalette (hdc, pal, TRUE);
hdc = BeginPaint (hwnd, &p);
if (pal) {
SelectPalette (hdc, pal, TRUE);
@@
-1253,6
+1276,7
@@
static LRESULT CALLBACK WndProc (HWND hwnd, UINT message,
SelectObject (hdc, GetStockObject(SYSTEM_FONT));
SelectObject (hdc, GetStockObject(WHITE_PEN));
EndPaint (hwnd, &p);
SelectObject (hdc, GetStockObject(SYSTEM_FONT));
SelectObject (hdc, GetStockObject(WHITE_PEN));
EndPaint (hwnd, &p);
+ ShowCaret(hwnd);
}
return 0;
case WM_NETEVENT:
}
return 0;
case WM_NETEVENT:
@@
-1269,7
+1293,8
@@
static LRESULT CALLBACK WndProc (HWND hwnd, UINT message,
return 0;
case WM_SETFOCUS:
has_focus = TRUE;
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;
term_out();
term_update();
break;
@@
-1733,10
+1758,10
@@
static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam, unsigned cha
int r, i, code;
unsigned char * p = output;
int r, i, code;
unsigned char * p = output;
-static WORD keys[3];
-static int compose_state = 0;
-static int compose_char = 0;
-static WPARAM compose_key = 0;
+
static WORD keys[3];
+
static int compose_state = 0;
+
static int compose_char = 0;
+
static WPARAM compose_key = 0;
r = GetKeyboardState(keystate);
if (!r) memset(keystate, 0, sizeof(keystate));
r = GetKeyboardState(keystate);
if (!r) memset(keystate, 0, sizeof(keystate));
@@
-2047,6
+2072,16
@@
static WPARAM compose_key = 0;
return p - output;
}
}
return p - output;
}
}
+
+ /*
+ * Finally, deal with Return ourselves. (Win95 seems to
+ * foul it up when Alt is pressed, for some reason.)
+ */
+ if (wParam == VK_RETURN) /* Return */
+ {
+ *p++ = 0x0D;
+ return p-output;
+ }
}
/* Okay we've done everything interesting; let windows deal with
}
/* Okay we've done everything interesting; let windows deal with
@@
-2217,7
+2252,7
@@
void palette_reset (void) {
}
}
}
}
-void write_clip (void *data, int len) {
+void write_clip (void *data, int len
, int must_deselect
) {
HGLOBAL clipdata;
void *lock;
HGLOBAL clipdata;
void *lock;
@@
-2231,14
+2266,18
@@
void write_clip (void *data, int len) {
((unsigned char *) lock) [len] = 0;
GlobalUnlock (clipdata);
((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);
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) {
}
void get_clip (void **p, int *len) {