mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-01 11:32:48 -05:00
Formatting change to braces around one case of a switch.
Sometimes, within a switch statement, you want to declare local variables specific to the handler for one particular case. Until now I've mostly been writing this in the form switch (discriminant) { case SIMPLE: do stuff; break; case COMPLICATED: { declare variables; do stuff; } break; } which is ugly because the two pieces of essentially similar code appear at different indent levels, and also inconvenient because you have less horizontal space available to write the complicated case handler in - particuarly undesirable because _complicated_ case handlers are the ones most likely to need all the space they can get! After encountering a rather nicer idiom in the LLVM source code, and after a bit of hackery this morning figuring out how to persuade Emacs's auto-indent to do what I wanted with it, I've decided to move to an idiom in which the open brace comes right after the case statement, and the code within it is indented the same as it would have been without the brace. Then the whole case handler (including the break) lives inside those braces, and you get something that looks more like this: switch (discriminant) { case SIMPLE: do stuff; break; case COMPLICATED: { declare variables; do stuff; break; } } This commit is a big-bang change that reformats all the complicated case handlers I could find into the new layout. This is particularly nice in the Pageant main function, in which almost _every_ case handler had a bundle of variables and was long and complicated. (In fact that's what motivated me to get round to this.) Some of the innermost parts of the terminal escape-sequence handling are also breathing a bit easier now the horizontal pressure on them is relieved. (Also, in a few cases, I was able to remove the extra braces completely, because the only variable local to the case handler was a loop variable which our new C99 policy allows me to move into the initialiser clause of its for statement.) Viewed with whitespace ignored, this is not too disruptive a change. Downstream patches that conflict with it may need to be reapplied using --ignore-whitespace or similar.
This commit is contained in:
@ -22,44 +22,43 @@ static LRESULT CALLBACK SizeTipWndProc(HWND hWnd, UINT nMsg,
|
||||
case WM_ERASEBKGND:
|
||||
return true;
|
||||
|
||||
case WM_PAINT:
|
||||
{
|
||||
HBRUSH hbr;
|
||||
HGDIOBJ holdbr;
|
||||
RECT cr;
|
||||
int wtlen;
|
||||
LPTSTR wt;
|
||||
HDC hdc;
|
||||
case WM_PAINT: {
|
||||
HBRUSH hbr;
|
||||
HGDIOBJ holdbr;
|
||||
RECT cr;
|
||||
int wtlen;
|
||||
LPTSTR wt;
|
||||
HDC hdc;
|
||||
|
||||
PAINTSTRUCT ps;
|
||||
hdc = BeginPaint(hWnd, &ps);
|
||||
PAINTSTRUCT ps;
|
||||
hdc = BeginPaint(hWnd, &ps);
|
||||
|
||||
SelectObject(hdc, tip_font);
|
||||
SelectObject(hdc, GetStockObject(BLACK_PEN));
|
||||
SelectObject(hdc, tip_font);
|
||||
SelectObject(hdc, GetStockObject(BLACK_PEN));
|
||||
|
||||
hbr = CreateSolidBrush(tip_bg);
|
||||
holdbr = SelectObject(hdc, hbr);
|
||||
hbr = CreateSolidBrush(tip_bg);
|
||||
holdbr = SelectObject(hdc, hbr);
|
||||
|
||||
GetClientRect(hWnd, &cr);
|
||||
Rectangle(hdc, cr.left, cr.top, cr.right, cr.bottom);
|
||||
GetClientRect(hWnd, &cr);
|
||||
Rectangle(hdc, cr.left, cr.top, cr.right, cr.bottom);
|
||||
|
||||
wtlen = GetWindowTextLength(hWnd);
|
||||
wt = (LPTSTR) snewn(wtlen + 1, TCHAR);
|
||||
GetWindowText(hWnd, wt, wtlen + 1);
|
||||
wtlen = GetWindowTextLength(hWnd);
|
||||
wt = (LPTSTR) snewn(wtlen + 1, TCHAR);
|
||||
GetWindowText(hWnd, wt, wtlen + 1);
|
||||
|
||||
SetTextColor(hdc, tip_text);
|
||||
SetBkColor(hdc, tip_bg);
|
||||
SetTextColor(hdc, tip_text);
|
||||
SetBkColor(hdc, tip_bg);
|
||||
|
||||
TextOut(hdc, cr.left + 3, cr.top + 3, wt, wtlen);
|
||||
TextOut(hdc, cr.left + 3, cr.top + 3, wt, wtlen);
|
||||
|
||||
sfree(wt);
|
||||
sfree(wt);
|
||||
|
||||
SelectObject(hdc, holdbr);
|
||||
DeleteObject(hbr);
|
||||
SelectObject(hdc, holdbr);
|
||||
DeleteObject(hbr);
|
||||
|
||||
EndPaint(hWnd, &ps);
|
||||
}
|
||||
EndPaint(hWnd, &ps);
|
||||
return 0;
|
||||
}
|
||||
|
||||
case WM_NCHITTEST:
|
||||
return HTTRANSPARENT;
|
||||
@ -69,22 +68,21 @@ static LRESULT CALLBACK SizeTipWndProc(HWND hWnd, UINT nMsg,
|
||||
tip_font = NULL;
|
||||
break;
|
||||
|
||||
case WM_SETTEXT:
|
||||
{
|
||||
LPCTSTR str = (LPCTSTR) lParam;
|
||||
SIZE sz;
|
||||
HDC hdc = CreateCompatibleDC(NULL);
|
||||
case WM_SETTEXT: {
|
||||
LPCTSTR str = (LPCTSTR) lParam;
|
||||
SIZE sz;
|
||||
HDC hdc = CreateCompatibleDC(NULL);
|
||||
|
||||
SelectObject(hdc, tip_font);
|
||||
GetTextExtentPoint32(hdc, str, _tcslen(str), &sz);
|
||||
SelectObject(hdc, tip_font);
|
||||
GetTextExtentPoint32(hdc, str, _tcslen(str), &sz);
|
||||
|
||||
SetWindowPos(hWnd, NULL, 0, 0, sz.cx + 6, sz.cy + 6,
|
||||
SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE);
|
||||
InvalidateRect(hWnd, NULL, false);
|
||||
SetWindowPos(hWnd, NULL, 0, 0, sz.cx + 6, sz.cy + 6,
|
||||
SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE);
|
||||
InvalidateRect(hWnd, NULL, false);
|
||||
|
||||
DeleteDC(hdc);
|
||||
}
|
||||
DeleteDC(hdc);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return DefWindowProc(hWnd, nMsg, wParam, lParam);
|
||||
|
@ -925,20 +925,18 @@ void prefslist(struct prefslist *hdl, struct ctlpos *cp, int lines,
|
||||
wid = xpos - left;
|
||||
|
||||
switch (i) {
|
||||
case 1:
|
||||
case 1: {
|
||||
/* The drag list box. */
|
||||
r.left = left; r.right = wid;
|
||||
r.top = cp->ypos; r.bottom = listheight;
|
||||
{
|
||||
HWND ctl;
|
||||
ctl = doctl(cp, r, "LISTBOX",
|
||||
WS_CHILD | WS_VISIBLE | WS_TABSTOP |
|
||||
WS_VSCROLL | LBS_HASSTRINGS | LBS_USETABSTOPS,
|
||||
WS_EX_CLIENTEDGE,
|
||||
"", listid);
|
||||
p_MakeDragList(ctl);
|
||||
}
|
||||
HWND ctl = doctl(cp, r, "LISTBOX",
|
||||
WS_CHILD | WS_VISIBLE | WS_TABSTOP |
|
||||
WS_VSCROLL | LBS_HASSTRINGS | LBS_USETABSTOPS,
|
||||
WS_EX_CLIENTEDGE,
|
||||
"", listid);
|
||||
p_MakeDragList(ctl);
|
||||
break;
|
||||
}
|
||||
|
||||
case 2:
|
||||
/* The "Up" and "Down" buttons. */
|
||||
@ -1496,19 +1494,18 @@ void winctrl_layout(struct dlgparam *dp, struct winctrls *wc,
|
||||
* switching on its type.
|
||||
*/
|
||||
switch (ctrl->generic.type) {
|
||||
case CTRL_TEXT:
|
||||
{
|
||||
char *wrapped, *escaped;
|
||||
int lines;
|
||||
num_ids = 1;
|
||||
wrapped = staticwrap(&pos, cp->hwnd,
|
||||
ctrl->generic.label, &lines);
|
||||
escaped = shortcut_escape(wrapped, NO_SHORTCUT);
|
||||
statictext(&pos, escaped, lines, base_id);
|
||||
sfree(escaped);
|
||||
sfree(wrapped);
|
||||
}
|
||||
case CTRL_TEXT: {
|
||||
char *wrapped, *escaped;
|
||||
int lines;
|
||||
num_ids = 1;
|
||||
wrapped = staticwrap(&pos, cp->hwnd,
|
||||
ctrl->generic.label, &lines);
|
||||
escaped = shortcut_escape(wrapped, NO_SHORTCUT);
|
||||
statictext(&pos, escaped, lines, base_id);
|
||||
sfree(escaped);
|
||||
sfree(wrapped);
|
||||
break;
|
||||
}
|
||||
case CTRL_EDITBOX:
|
||||
num_ids = 2; /* static, edit */
|
||||
escaped = shortcut_escape(ctrl->editbox.label,
|
||||
@ -1533,42 +1530,41 @@ void winctrl_layout(struct dlgparam *dp, struct winctrls *wc,
|
||||
}
|
||||
sfree(escaped);
|
||||
break;
|
||||
case CTRL_RADIO:
|
||||
case CTRL_RADIO: {
|
||||
num_ids = ctrl->radio.nbuttons + 1; /* label as well */
|
||||
{
|
||||
struct radio *buttons;
|
||||
int i;
|
||||
struct radio *buttons;
|
||||
int i;
|
||||
|
||||
escaped = shortcut_escape(ctrl->radio.label,
|
||||
ctrl->radio.shortcut);
|
||||
shortcuts[nshortcuts++] = ctrl->radio.shortcut;
|
||||
escaped = shortcut_escape(ctrl->radio.label,
|
||||
ctrl->radio.shortcut);
|
||||
shortcuts[nshortcuts++] = ctrl->radio.shortcut;
|
||||
|
||||
buttons = snewn(ctrl->radio.nbuttons, struct radio);
|
||||
buttons = snewn(ctrl->radio.nbuttons, struct radio);
|
||||
|
||||
for (i = 0; i < ctrl->radio.nbuttons; i++) {
|
||||
buttons[i].text =
|
||||
shortcut_escape(ctrl->radio.buttons[i],
|
||||
(char)(ctrl->radio.shortcuts ?
|
||||
ctrl->radio.shortcuts[i] :
|
||||
NO_SHORTCUT));
|
||||
buttons[i].id = base_id + 1 + i;
|
||||
if (ctrl->radio.shortcuts) {
|
||||
assert(nshortcuts < MAX_SHORTCUTS_PER_CTRL);
|
||||
shortcuts[nshortcuts++] = ctrl->radio.shortcuts[i];
|
||||
}
|
||||
}
|
||||
|
||||
radioline_common(&pos, escaped, base_id,
|
||||
ctrl->radio.ncolumns,
|
||||
buttons, ctrl->radio.nbuttons);
|
||||
|
||||
for (i = 0; i < ctrl->radio.nbuttons; i++) {
|
||||
sfree(buttons[i].text);
|
||||
}
|
||||
sfree(buttons);
|
||||
sfree(escaped);
|
||||
for (i = 0; i < ctrl->radio.nbuttons; i++) {
|
||||
buttons[i].text =
|
||||
shortcut_escape(ctrl->radio.buttons[i],
|
||||
(char)(ctrl->radio.shortcuts ?
|
||||
ctrl->radio.shortcuts[i] :
|
||||
NO_SHORTCUT));
|
||||
buttons[i].id = base_id + 1 + i;
|
||||
if (ctrl->radio.shortcuts) {
|
||||
assert(nshortcuts < MAX_SHORTCUTS_PER_CTRL);
|
||||
shortcuts[nshortcuts++] = ctrl->radio.shortcuts[i];
|
||||
}
|
||||
}
|
||||
|
||||
radioline_common(&pos, escaped, base_id,
|
||||
ctrl->radio.ncolumns,
|
||||
buttons, ctrl->radio.nbuttons);
|
||||
|
||||
for (i = 0; i < ctrl->radio.nbuttons; i++) {
|
||||
sfree(buttons[i].text);
|
||||
}
|
||||
sfree(buttons);
|
||||
sfree(escaped);
|
||||
break;
|
||||
}
|
||||
case CTRL_CHECKBOX:
|
||||
num_ids = 1;
|
||||
escaped = shortcut_escape(ctrl->checkbox.label,
|
||||
|
@ -88,17 +88,15 @@ static INT_PTR CALLBACK LogProc(HWND hwnd, UINT msg,
|
||||
int i;
|
||||
|
||||
switch (msg) {
|
||||
case WM_INITDIALOG:
|
||||
{
|
||||
char *str = dupprintf("%s Event Log", appname);
|
||||
SetWindowText(hwnd, str);
|
||||
sfree(str);
|
||||
}
|
||||
{
|
||||
static int tabs[4] = { 78, 108 };
|
||||
SendDlgItemMessage(hwnd, IDN_LIST, LB_SETTABSTOPS, 2,
|
||||
(LPARAM) tabs);
|
||||
}
|
||||
case WM_INITDIALOG: {
|
||||
char *str = dupprintf("%s Event Log", appname);
|
||||
SetWindowText(hwnd, str);
|
||||
sfree(str);
|
||||
|
||||
static int tabs[4] = { 78, 108 };
|
||||
SendDlgItemMessage(hwnd, IDN_LIST, LB_SETTABSTOPS, 2,
|
||||
(LPARAM) tabs);
|
||||
|
||||
for (i = 0; i < ninitial; i++)
|
||||
SendDlgItemMessage(hwnd, IDN_LIST, LB_ADDSTRING,
|
||||
0, (LPARAM) events_initial[i]);
|
||||
@ -106,6 +104,7 @@ static INT_PTR CALLBACK LogProc(HWND hwnd, UINT msg,
|
||||
SendDlgItemMessage(hwnd, IDN_LIST, LB_ADDSTRING,
|
||||
0, (LPARAM) events_circular[(circular_first + i) % LOGEVENT_CIRCULAR_MAX]);
|
||||
return 1;
|
||||
}
|
||||
case WM_COMMAND:
|
||||
switch (LOWORD(wParam)) {
|
||||
case IDOK:
|
||||
@ -184,14 +183,13 @@ static INT_PTR CALLBACK LicenceProc(HWND hwnd, UINT msg,
|
||||
WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (msg) {
|
||||
case WM_INITDIALOG:
|
||||
{
|
||||
char *str = dupprintf("%s Licence", appname);
|
||||
SetWindowText(hwnd, str);
|
||||
sfree(str);
|
||||
SetDlgItemText(hwnd, IDA_TEXT, LICENCE_TEXT("\r\n\r\n"));
|
||||
}
|
||||
case WM_INITDIALOG: {
|
||||
char *str = dupprintf("%s Licence", appname);
|
||||
SetWindowText(hwnd, str);
|
||||
sfree(str);
|
||||
SetDlgItemText(hwnd, IDA_TEXT, LICENCE_TEXT("\r\n\r\n"));
|
||||
return 1;
|
||||
}
|
||||
case WM_COMMAND:
|
||||
switch (LOWORD(wParam)) {
|
||||
case IDOK:
|
||||
@ -213,21 +211,20 @@ static INT_PTR CALLBACK AboutProc(HWND hwnd, UINT msg,
|
||||
char *str;
|
||||
|
||||
switch (msg) {
|
||||
case WM_INITDIALOG:
|
||||
case WM_INITDIALOG: {
|
||||
str = dupprintf("About %s", appname);
|
||||
SetWindowText(hwnd, str);
|
||||
sfree(str);
|
||||
{
|
||||
char *buildinfo_text = buildinfo("\r\n");
|
||||
char *text = dupprintf
|
||||
("%s\r\n\r\n%s\r\n\r\n%s\r\n\r\n%s",
|
||||
appname, ver, buildinfo_text,
|
||||
"\251 " SHORT_COPYRIGHT_DETAILS ". All rights reserved.");
|
||||
sfree(buildinfo_text);
|
||||
SetDlgItemText(hwnd, IDA_TEXT, text);
|
||||
sfree(text);
|
||||
}
|
||||
char *buildinfo_text = buildinfo("\r\n");
|
||||
char *text = dupprintf
|
||||
("%s\r\n\r\n%s\r\n\r\n%s\r\n\r\n%s",
|
||||
appname, ver, buildinfo_text,
|
||||
"\251 " SHORT_COPYRIGHT_DETAILS ". All rights reserved.");
|
||||
sfree(buildinfo_text);
|
||||
SetDlgItemText(hwnd, IDA_TEXT, text);
|
||||
sfree(text);
|
||||
return 1;
|
||||
}
|
||||
case WM_COMMAND:
|
||||
switch (LOWORD(wParam)) {
|
||||
case IDOK:
|
||||
|
910
windows/window.c
910
windows/window.c
@ -2180,20 +2180,19 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
|
||||
return 0;
|
||||
case WM_CREATE:
|
||||
break;
|
||||
case WM_CLOSE:
|
||||
{
|
||||
char *str;
|
||||
show_mouseptr(true);
|
||||
str = dupprintf("%s Exit Confirmation", appname);
|
||||
if (session_closed || !conf_get_bool(conf, CONF_warn_on_close) ||
|
||||
MessageBox(hwnd,
|
||||
"Are you sure you want to close this session?",
|
||||
str, MB_ICONWARNING | MB_OKCANCEL | MB_DEFBUTTON1)
|
||||
== IDOK)
|
||||
DestroyWindow(hwnd);
|
||||
sfree(str);
|
||||
}
|
||||
case WM_CLOSE: {
|
||||
char *str;
|
||||
show_mouseptr(true);
|
||||
str = dupprintf("%s Exit Confirmation", appname);
|
||||
if (session_closed || !conf_get_bool(conf, CONF_warn_on_close) ||
|
||||
MessageBox(hwnd,
|
||||
"Are you sure you want to close this session?",
|
||||
str, MB_ICONWARNING | MB_OKCANCEL | MB_DEFBUTTON1)
|
||||
== IDOK)
|
||||
DestroyWindow(hwnd);
|
||||
sfree(str);
|
||||
return 0;
|
||||
}
|
||||
case WM_DESTROY:
|
||||
show_mouseptr(true);
|
||||
PostQuitMessage(0);
|
||||
@ -2216,88 +2215,87 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
|
||||
break;
|
||||
case IDM_NEWSESS:
|
||||
case IDM_DUPSESS:
|
||||
case IDM_SAVEDSESS:
|
||||
{
|
||||
char b[2048];
|
||||
char *cl;
|
||||
const char *argprefix;
|
||||
bool inherit_handles;
|
||||
STARTUPINFO si;
|
||||
PROCESS_INFORMATION pi;
|
||||
HANDLE filemap = NULL;
|
||||
case IDM_SAVEDSESS: {
|
||||
char b[2048];
|
||||
char *cl;
|
||||
const char *argprefix;
|
||||
bool inherit_handles;
|
||||
STARTUPINFO si;
|
||||
PROCESS_INFORMATION pi;
|
||||
HANDLE filemap = NULL;
|
||||
|
||||
if (restricted_acl())
|
||||
argprefix = "&R";
|
||||
else
|
||||
argprefix = "";
|
||||
if (restricted_acl())
|
||||
argprefix = "&R";
|
||||
else
|
||||
argprefix = "";
|
||||
|
||||
if (wParam == IDM_DUPSESS) {
|
||||
/*
|
||||
* Allocate a file-mapping memory chunk for the
|
||||
* config structure.
|
||||
*/
|
||||
SECURITY_ATTRIBUTES sa;
|
||||
strbuf *serbuf;
|
||||
void *p;
|
||||
int size;
|
||||
if (wParam == IDM_DUPSESS) {
|
||||
/*
|
||||
* Allocate a file-mapping memory chunk for the
|
||||
* config structure.
|
||||
*/
|
||||
SECURITY_ATTRIBUTES sa;
|
||||
strbuf *serbuf;
|
||||
void *p;
|
||||
int size;
|
||||
|
||||
serbuf = strbuf_new();
|
||||
conf_serialise(BinarySink_UPCAST(serbuf), conf);
|
||||
size = serbuf->len;
|
||||
serbuf = strbuf_new();
|
||||
conf_serialise(BinarySink_UPCAST(serbuf), conf);
|
||||
size = serbuf->len;
|
||||
|
||||
sa.nLength = sizeof(sa);
|
||||
sa.lpSecurityDescriptor = NULL;
|
||||
sa.bInheritHandle = true;
|
||||
filemap = CreateFileMapping(INVALID_HANDLE_VALUE,
|
||||
&sa,
|
||||
PAGE_READWRITE,
|
||||
0, size, NULL);
|
||||
if (filemap && filemap != INVALID_HANDLE_VALUE) {
|
||||
p = MapViewOfFile(filemap, FILE_MAP_WRITE, 0, 0, size);
|
||||
if (p) {
|
||||
memcpy(p, serbuf->s, size);
|
||||
UnmapViewOfFile(p);
|
||||
}
|
||||
}
|
||||
|
||||
strbuf_free(serbuf);
|
||||
inherit_handles = true;
|
||||
cl = dupprintf("putty %s&%p:%u", argprefix,
|
||||
filemap, (unsigned)size);
|
||||
} else if (wParam == IDM_SAVEDSESS) {
|
||||
unsigned int sessno = ((lParam - IDM_SAVED_MIN)
|
||||
/ MENU_SAVED_STEP) + 1;
|
||||
if (sessno < (unsigned)sesslist.nsessions) {
|
||||
const char *session = sesslist.sessions[sessno];
|
||||
cl = dupprintf("putty %s@%s", argprefix, session);
|
||||
inherit_handles = false;
|
||||
} else
|
||||
break;
|
||||
} else /* IDM_NEWSESS */ {
|
||||
cl = dupprintf("putty%s%s",
|
||||
*argprefix ? " " : "",
|
||||
argprefix);
|
||||
inherit_handles = false;
|
||||
sa.nLength = sizeof(sa);
|
||||
sa.lpSecurityDescriptor = NULL;
|
||||
sa.bInheritHandle = true;
|
||||
filemap = CreateFileMapping(INVALID_HANDLE_VALUE,
|
||||
&sa,
|
||||
PAGE_READWRITE,
|
||||
0, size, NULL);
|
||||
if (filemap && filemap != INVALID_HANDLE_VALUE) {
|
||||
p = MapViewOfFile(filemap, FILE_MAP_WRITE, 0, 0, size);
|
||||
if (p) {
|
||||
memcpy(p, serbuf->s, size);
|
||||
UnmapViewOfFile(p);
|
||||
}
|
||||
}
|
||||
|
||||
GetModuleFileName(NULL, b, sizeof(b) - 1);
|
||||
si.cb = sizeof(si);
|
||||
si.lpReserved = NULL;
|
||||
si.lpDesktop = NULL;
|
||||
si.lpTitle = NULL;
|
||||
si.dwFlags = 0;
|
||||
si.cbReserved2 = 0;
|
||||
si.lpReserved2 = NULL;
|
||||
CreateProcess(b, cl, NULL, NULL, inherit_handles,
|
||||
NORMAL_PRIORITY_CLASS, NULL, NULL, &si, &pi);
|
||||
CloseHandle(pi.hProcess);
|
||||
CloseHandle(pi.hThread);
|
||||
|
||||
if (filemap)
|
||||
CloseHandle(filemap);
|
||||
sfree(cl);
|
||||
strbuf_free(serbuf);
|
||||
inherit_handles = true;
|
||||
cl = dupprintf("putty %s&%p:%u", argprefix,
|
||||
filemap, (unsigned)size);
|
||||
} else if (wParam == IDM_SAVEDSESS) {
|
||||
unsigned int sessno = ((lParam - IDM_SAVED_MIN)
|
||||
/ MENU_SAVED_STEP) + 1;
|
||||
if (sessno < (unsigned)sesslist.nsessions) {
|
||||
const char *session = sesslist.sessions[sessno];
|
||||
cl = dupprintf("putty %s@%s", argprefix, session);
|
||||
inherit_handles = false;
|
||||
} else
|
||||
break;
|
||||
} else /* IDM_NEWSESS */ {
|
||||
cl = dupprintf("putty%s%s",
|
||||
*argprefix ? " " : "",
|
||||
argprefix);
|
||||
inherit_handles = false;
|
||||
}
|
||||
|
||||
GetModuleFileName(NULL, b, sizeof(b) - 1);
|
||||
si.cb = sizeof(si);
|
||||
si.lpReserved = NULL;
|
||||
si.lpDesktop = NULL;
|
||||
si.lpTitle = NULL;
|
||||
si.dwFlags = 0;
|
||||
si.cbReserved2 = 0;
|
||||
si.lpReserved2 = NULL;
|
||||
CreateProcess(b, cl, NULL, NULL, inherit_handles,
|
||||
NORMAL_PRIORITY_CLASS, NULL, NULL, &si, &pi);
|
||||
CloseHandle(pi.hProcess);
|
||||
CloseHandle(pi.hThread);
|
||||
|
||||
if (filemap)
|
||||
CloseHandle(filemap);
|
||||
sfree(cl);
|
||||
break;
|
||||
}
|
||||
case IDM_RESTART:
|
||||
if (!backend) {
|
||||
lp_eventlog(&wgs.logpolicy, "----- Session restarted -----");
|
||||
@ -2306,193 +2304,192 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
|
||||
}
|
||||
|
||||
break;
|
||||
case IDM_RECONF:
|
||||
{
|
||||
Conf *prev_conf;
|
||||
int init_lvl = 1;
|
||||
bool reconfig_result;
|
||||
case IDM_RECONF: {
|
||||
Conf *prev_conf;
|
||||
int init_lvl = 1;
|
||||
bool reconfig_result;
|
||||
|
||||
if (reconfiguring)
|
||||
break;
|
||||
else
|
||||
reconfiguring = true;
|
||||
if (reconfiguring)
|
||||
break;
|
||||
else
|
||||
reconfiguring = true;
|
||||
|
||||
/*
|
||||
* Copy the current window title into the stored
|
||||
* previous configuration, so that doing nothing to
|
||||
* the window title field in the config box doesn't
|
||||
* reset the title to its startup state.
|
||||
*/
|
||||
conf_set_str(conf, CONF_wintitle, window_name);
|
||||
/*
|
||||
* Copy the current window title into the stored
|
||||
* previous configuration, so that doing nothing to
|
||||
* the window title field in the config box doesn't
|
||||
* reset the title to its startup state.
|
||||
*/
|
||||
conf_set_str(conf, CONF_wintitle, window_name);
|
||||
|
||||
prev_conf = conf_copy(conf);
|
||||
prev_conf = conf_copy(conf);
|
||||
|
||||
reconfig_result = do_reconfig(
|
||||
hwnd, conf, backend ? backend_cfg_info(backend) : 0);
|
||||
reconfiguring = false;
|
||||
if (!reconfig_result) {
|
||||
conf_free(prev_conf);
|
||||
break;
|
||||
}
|
||||
|
||||
conf_cache_data();
|
||||
|
||||
resize_action = conf_get_int(conf, CONF_resize_action);
|
||||
{
|
||||
/* Disable full-screen if resizing forbidden */
|
||||
int i;
|
||||
for (i = 0; i < lenof(popup_menus); i++)
|
||||
EnableMenuItem(popup_menus[i].menu, IDM_FULLSCREEN,
|
||||
MF_BYCOMMAND |
|
||||
(resize_action == RESIZE_DISABLED
|
||||
? MF_GRAYED : MF_ENABLED));
|
||||
/* Gracefully unzoom if necessary */
|
||||
if (IsZoomed(hwnd) && (resize_action == RESIZE_DISABLED))
|
||||
ShowWindow(hwnd, SW_RESTORE);
|
||||
}
|
||||
|
||||
/* Pass new config data to the logging module */
|
||||
log_reconfig(logctx, conf);
|
||||
|
||||
sfree(logpal);
|
||||
/*
|
||||
* Flush the line discipline's edit buffer in the
|
||||
* case where local editing has just been disabled.
|
||||
*/
|
||||
if (ldisc) {
|
||||
ldisc_configure(ldisc, conf);
|
||||
ldisc_echoedit_update(ldisc);
|
||||
}
|
||||
if (pal)
|
||||
DeleteObject(pal);
|
||||
logpal = NULL;
|
||||
pal = NULL;
|
||||
conftopalette();
|
||||
init_palette();
|
||||
|
||||
/* Pass new config data to the terminal */
|
||||
term_reconfig(term, conf);
|
||||
setup_clipboards(term, conf);
|
||||
|
||||
/* Pass new config data to the back end */
|
||||
if (backend)
|
||||
backend_reconfig(backend, conf);
|
||||
|
||||
/* Screen size changed ? */
|
||||
if (conf_get_int(conf, CONF_height) !=
|
||||
conf_get_int(prev_conf, CONF_height) ||
|
||||
conf_get_int(conf, CONF_width) !=
|
||||
conf_get_int(prev_conf, CONF_width) ||
|
||||
conf_get_int(conf, CONF_savelines) !=
|
||||
conf_get_int(prev_conf, CONF_savelines) ||
|
||||
resize_action == RESIZE_FONT ||
|
||||
(resize_action == RESIZE_EITHER && IsZoomed(hwnd)) ||
|
||||
resize_action == RESIZE_DISABLED)
|
||||
term_size(term, conf_get_int(conf, CONF_height),
|
||||
conf_get_int(conf, CONF_width),
|
||||
conf_get_int(conf, CONF_savelines));
|
||||
|
||||
/* Enable or disable the scroll bar, etc */
|
||||
{
|
||||
LONG nflg, flag = GetWindowLongPtr(hwnd, GWL_STYLE);
|
||||
LONG nexflag, exflag =
|
||||
GetWindowLongPtr(hwnd, GWL_EXSTYLE);
|
||||
|
||||
nexflag = exflag;
|
||||
if (conf_get_bool(conf, CONF_alwaysontop) !=
|
||||
conf_get_bool(prev_conf, CONF_alwaysontop)) {
|
||||
if (conf_get_bool(conf, CONF_alwaysontop)) {
|
||||
nexflag |= WS_EX_TOPMOST;
|
||||
SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0,
|
||||
SWP_NOMOVE | SWP_NOSIZE);
|
||||
} else {
|
||||
nexflag &= ~(WS_EX_TOPMOST);
|
||||
SetWindowPos(hwnd, HWND_NOTOPMOST, 0, 0, 0, 0,
|
||||
SWP_NOMOVE | SWP_NOSIZE);
|
||||
}
|
||||
}
|
||||
if (conf_get_bool(conf, CONF_sunken_edge))
|
||||
nexflag |= WS_EX_CLIENTEDGE;
|
||||
else
|
||||
nexflag &= ~(WS_EX_CLIENTEDGE);
|
||||
|
||||
nflg = flag;
|
||||
if (conf_get_bool(conf, is_full_screen() ?
|
||||
CONF_scrollbar_in_fullscreen :
|
||||
CONF_scrollbar))
|
||||
nflg |= WS_VSCROLL;
|
||||
else
|
||||
nflg &= ~WS_VSCROLL;
|
||||
|
||||
if (resize_action == RESIZE_DISABLED ||
|
||||
is_full_screen())
|
||||
nflg &= ~WS_THICKFRAME;
|
||||
else
|
||||
nflg |= WS_THICKFRAME;
|
||||
|
||||
if (resize_action == RESIZE_DISABLED)
|
||||
nflg &= ~WS_MAXIMIZEBOX;
|
||||
else
|
||||
nflg |= WS_MAXIMIZEBOX;
|
||||
|
||||
if (nflg != flag || nexflag != exflag) {
|
||||
if (nflg != flag)
|
||||
SetWindowLongPtr(hwnd, GWL_STYLE, nflg);
|
||||
if (nexflag != exflag)
|
||||
SetWindowLongPtr(hwnd, GWL_EXSTYLE, nexflag);
|
||||
|
||||
SetWindowPos(hwnd, NULL, 0, 0, 0, 0,
|
||||
SWP_NOACTIVATE | SWP_NOCOPYBITS |
|
||||
SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER |
|
||||
SWP_FRAMECHANGED);
|
||||
|
||||
init_lvl = 2;
|
||||
}
|
||||
}
|
||||
|
||||
/* Oops */
|
||||
if (resize_action == RESIZE_DISABLED && IsZoomed(hwnd)) {
|
||||
force_normal(hwnd);
|
||||
init_lvl = 2;
|
||||
}
|
||||
|
||||
win_set_title(wintw, conf_get_str(conf, CONF_wintitle));
|
||||
if (IsIconic(hwnd)) {
|
||||
SetWindowText(hwnd,
|
||||
conf_get_bool(conf, CONF_win_name_always) ?
|
||||
window_name : icon_name);
|
||||
}
|
||||
|
||||
{
|
||||
FontSpec *font = conf_get_fontspec(conf, CONF_font);
|
||||
FontSpec *prev_font = conf_get_fontspec(prev_conf,
|
||||
CONF_font);
|
||||
|
||||
if (!strcmp(font->name, prev_font->name) ||
|
||||
!strcmp(conf_get_str(conf, CONF_line_codepage),
|
||||
conf_get_str(prev_conf, CONF_line_codepage)) ||
|
||||
font->isbold != prev_font->isbold ||
|
||||
font->height != prev_font->height ||
|
||||
font->charset != prev_font->charset ||
|
||||
conf_get_int(conf, CONF_font_quality) !=
|
||||
conf_get_int(prev_conf, CONF_font_quality) ||
|
||||
conf_get_int(conf, CONF_vtmode) !=
|
||||
conf_get_int(prev_conf, CONF_vtmode) ||
|
||||
conf_get_int(conf, CONF_bold_style) !=
|
||||
conf_get_int(prev_conf, CONF_bold_style) ||
|
||||
resize_action == RESIZE_DISABLED ||
|
||||
resize_action == RESIZE_EITHER ||
|
||||
resize_action != conf_get_int(prev_conf,
|
||||
CONF_resize_action))
|
||||
init_lvl = 2;
|
||||
}
|
||||
|
||||
InvalidateRect(hwnd, NULL, true);
|
||||
reset_window(init_lvl);
|
||||
|
||||
conf_free(prev_conf);
|
||||
reconfig_result = do_reconfig(
|
||||
hwnd, conf, backend ? backend_cfg_info(backend) : 0);
|
||||
reconfiguring = false;
|
||||
if (!reconfig_result) {
|
||||
conf_free(prev_conf);
|
||||
break;
|
||||
}
|
||||
|
||||
conf_cache_data();
|
||||
|
||||
resize_action = conf_get_int(conf, CONF_resize_action);
|
||||
{
|
||||
/* Disable full-screen if resizing forbidden */
|
||||
int i;
|
||||
for (i = 0; i < lenof(popup_menus); i++)
|
||||
EnableMenuItem(popup_menus[i].menu, IDM_FULLSCREEN,
|
||||
MF_BYCOMMAND |
|
||||
(resize_action == RESIZE_DISABLED
|
||||
? MF_GRAYED : MF_ENABLED));
|
||||
/* Gracefully unzoom if necessary */
|
||||
if (IsZoomed(hwnd) && (resize_action == RESIZE_DISABLED))
|
||||
ShowWindow(hwnd, SW_RESTORE);
|
||||
}
|
||||
|
||||
/* Pass new config data to the logging module */
|
||||
log_reconfig(logctx, conf);
|
||||
|
||||
sfree(logpal);
|
||||
/*
|
||||
* Flush the line discipline's edit buffer in the
|
||||
* case where local editing has just been disabled.
|
||||
*/
|
||||
if (ldisc) {
|
||||
ldisc_configure(ldisc, conf);
|
||||
ldisc_echoedit_update(ldisc);
|
||||
}
|
||||
if (pal)
|
||||
DeleteObject(pal);
|
||||
logpal = NULL;
|
||||
pal = NULL;
|
||||
conftopalette();
|
||||
init_palette();
|
||||
|
||||
/* Pass new config data to the terminal */
|
||||
term_reconfig(term, conf);
|
||||
setup_clipboards(term, conf);
|
||||
|
||||
/* Pass new config data to the back end */
|
||||
if (backend)
|
||||
backend_reconfig(backend, conf);
|
||||
|
||||
/* Screen size changed ? */
|
||||
if (conf_get_int(conf, CONF_height) !=
|
||||
conf_get_int(prev_conf, CONF_height) ||
|
||||
conf_get_int(conf, CONF_width) !=
|
||||
conf_get_int(prev_conf, CONF_width) ||
|
||||
conf_get_int(conf, CONF_savelines) !=
|
||||
conf_get_int(prev_conf, CONF_savelines) ||
|
||||
resize_action == RESIZE_FONT ||
|
||||
(resize_action == RESIZE_EITHER && IsZoomed(hwnd)) ||
|
||||
resize_action == RESIZE_DISABLED)
|
||||
term_size(term, conf_get_int(conf, CONF_height),
|
||||
conf_get_int(conf, CONF_width),
|
||||
conf_get_int(conf, CONF_savelines));
|
||||
|
||||
/* Enable or disable the scroll bar, etc */
|
||||
{
|
||||
LONG nflg, flag = GetWindowLongPtr(hwnd, GWL_STYLE);
|
||||
LONG nexflag, exflag =
|
||||
GetWindowLongPtr(hwnd, GWL_EXSTYLE);
|
||||
|
||||
nexflag = exflag;
|
||||
if (conf_get_bool(conf, CONF_alwaysontop) !=
|
||||
conf_get_bool(prev_conf, CONF_alwaysontop)) {
|
||||
if (conf_get_bool(conf, CONF_alwaysontop)) {
|
||||
nexflag |= WS_EX_TOPMOST;
|
||||
SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0,
|
||||
SWP_NOMOVE | SWP_NOSIZE);
|
||||
} else {
|
||||
nexflag &= ~(WS_EX_TOPMOST);
|
||||
SetWindowPos(hwnd, HWND_NOTOPMOST, 0, 0, 0, 0,
|
||||
SWP_NOMOVE | SWP_NOSIZE);
|
||||
}
|
||||
}
|
||||
if (conf_get_bool(conf, CONF_sunken_edge))
|
||||
nexflag |= WS_EX_CLIENTEDGE;
|
||||
else
|
||||
nexflag &= ~(WS_EX_CLIENTEDGE);
|
||||
|
||||
nflg = flag;
|
||||
if (conf_get_bool(conf, is_full_screen() ?
|
||||
CONF_scrollbar_in_fullscreen :
|
||||
CONF_scrollbar))
|
||||
nflg |= WS_VSCROLL;
|
||||
else
|
||||
nflg &= ~WS_VSCROLL;
|
||||
|
||||
if (resize_action == RESIZE_DISABLED ||
|
||||
is_full_screen())
|
||||
nflg &= ~WS_THICKFRAME;
|
||||
else
|
||||
nflg |= WS_THICKFRAME;
|
||||
|
||||
if (resize_action == RESIZE_DISABLED)
|
||||
nflg &= ~WS_MAXIMIZEBOX;
|
||||
else
|
||||
nflg |= WS_MAXIMIZEBOX;
|
||||
|
||||
if (nflg != flag || nexflag != exflag) {
|
||||
if (nflg != flag)
|
||||
SetWindowLongPtr(hwnd, GWL_STYLE, nflg);
|
||||
if (nexflag != exflag)
|
||||
SetWindowLongPtr(hwnd, GWL_EXSTYLE, nexflag);
|
||||
|
||||
SetWindowPos(hwnd, NULL, 0, 0, 0, 0,
|
||||
SWP_NOACTIVATE | SWP_NOCOPYBITS |
|
||||
SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER |
|
||||
SWP_FRAMECHANGED);
|
||||
|
||||
init_lvl = 2;
|
||||
}
|
||||
}
|
||||
|
||||
/* Oops */
|
||||
if (resize_action == RESIZE_DISABLED && IsZoomed(hwnd)) {
|
||||
force_normal(hwnd);
|
||||
init_lvl = 2;
|
||||
}
|
||||
|
||||
win_set_title(wintw, conf_get_str(conf, CONF_wintitle));
|
||||
if (IsIconic(hwnd)) {
|
||||
SetWindowText(hwnd,
|
||||
conf_get_bool(conf, CONF_win_name_always) ?
|
||||
window_name : icon_name);
|
||||
}
|
||||
|
||||
{
|
||||
FontSpec *font = conf_get_fontspec(conf, CONF_font);
|
||||
FontSpec *prev_font = conf_get_fontspec(prev_conf,
|
||||
CONF_font);
|
||||
|
||||
if (!strcmp(font->name, prev_font->name) ||
|
||||
!strcmp(conf_get_str(conf, CONF_line_codepage),
|
||||
conf_get_str(prev_conf, CONF_line_codepage)) ||
|
||||
font->isbold != prev_font->isbold ||
|
||||
font->height != prev_font->height ||
|
||||
font->charset != prev_font->charset ||
|
||||
conf_get_int(conf, CONF_font_quality) !=
|
||||
conf_get_int(prev_conf, CONF_font_quality) ||
|
||||
conf_get_int(conf, CONF_vtmode) !=
|
||||
conf_get_int(prev_conf, CONF_vtmode) ||
|
||||
conf_get_int(conf, CONF_bold_style) !=
|
||||
conf_get_int(prev_conf, CONF_bold_style) ||
|
||||
resize_action == RESIZE_DISABLED ||
|
||||
resize_action == RESIZE_EITHER ||
|
||||
resize_action != conf_get_int(prev_conf,
|
||||
CONF_resize_action))
|
||||
init_lvl = 2;
|
||||
}
|
||||
|
||||
InvalidateRect(hwnd, NULL, true);
|
||||
reset_window(init_lvl);
|
||||
|
||||
conf_free(prev_conf);
|
||||
break;
|
||||
}
|
||||
case IDM_COPYALL:
|
||||
term_copyall(term, clips_system, lenof(clips_system));
|
||||
break;
|
||||
@ -2680,21 +2677,19 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
case WM_MOUSEMOVE:
|
||||
{
|
||||
/*
|
||||
* Windows seems to like to occasionally send MOUSEMOVE
|
||||
* events even if the mouse hasn't moved. Don't unhide
|
||||
* the mouse pointer in this case.
|
||||
*/
|
||||
static WPARAM wp = 0;
|
||||
static LPARAM lp = 0;
|
||||
if (wParam != wp || lParam != lp ||
|
||||
last_mousemove != WM_MOUSEMOVE) {
|
||||
show_mouseptr(true);
|
||||
wp = wParam; lp = lParam;
|
||||
last_mousemove = WM_MOUSEMOVE;
|
||||
}
|
||||
case WM_MOUSEMOVE: {
|
||||
/*
|
||||
* Windows seems to like to occasionally send MOUSEMOVE
|
||||
* events even if the mouse hasn't moved. Don't unhide
|
||||
* the mouse pointer in this case.
|
||||
*/
|
||||
static WPARAM wp = 0;
|
||||
static LPARAM lp = 0;
|
||||
if (wParam != wp || lParam != lp ||
|
||||
last_mousemove != WM_MOUSEMOVE) {
|
||||
show_mouseptr(true);
|
||||
wp = wParam; lp = lParam;
|
||||
last_mousemove = WM_MOUSEMOVE;
|
||||
}
|
||||
/*
|
||||
* Add the mouse position and message time to the random
|
||||
@ -2717,19 +2712,19 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
|
||||
wParam & MK_CONTROL, is_alt_pressed());
|
||||
}
|
||||
return 0;
|
||||
case WM_NCMOUSEMOVE:
|
||||
{
|
||||
static WPARAM wp = 0;
|
||||
static LPARAM lp = 0;
|
||||
if (wParam != wp || lParam != lp ||
|
||||
last_mousemove != WM_NCMOUSEMOVE) {
|
||||
show_mouseptr(true);
|
||||
wp = wParam; lp = lParam;
|
||||
last_mousemove = WM_NCMOUSEMOVE;
|
||||
}
|
||||
}
|
||||
case WM_NCMOUSEMOVE: {
|
||||
static WPARAM wp = 0;
|
||||
static LPARAM lp = 0;
|
||||
if (wParam != wp || lParam != lp ||
|
||||
last_mousemove != WM_NCMOUSEMOVE) {
|
||||
show_mouseptr(true);
|
||||
wp = wParam; lp = lParam;
|
||||
last_mousemove = WM_NCMOUSEMOVE;
|
||||
}
|
||||
noise_ultralight(NOISE_SOURCE_MOUSEPOS, lParam);
|
||||
break;
|
||||
}
|
||||
case WM_IGNORE_CLIP:
|
||||
ignore_clip = wParam; /* don't panic on DESTROYCLIPBOARD */
|
||||
break;
|
||||
@ -2738,122 +2733,120 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
|
||||
term_lost_clipboard_ownership(term, CLIP_SYSTEM);
|
||||
ignore_clip = false;
|
||||
return 0;
|
||||
case WM_PAINT:
|
||||
{
|
||||
PAINTSTRUCT p;
|
||||
case WM_PAINT: {
|
||||
PAINTSTRUCT p;
|
||||
|
||||
HideCaret(hwnd);
|
||||
hdc = BeginPaint(hwnd, &p);
|
||||
if (pal) {
|
||||
SelectPalette(hdc, pal, true);
|
||||
RealizePalette(hdc);
|
||||
}
|
||||
|
||||
/*
|
||||
* We have to be careful about term_paint(). It will
|
||||
* set a bunch of character cells to INVALID and then
|
||||
* call do_paint(), which will redraw those cells and
|
||||
* _then mark them as done_. This may not be accurate:
|
||||
* when painting in WM_PAINT context we are restricted
|
||||
* to the rectangle which has just been exposed - so if
|
||||
* that only covers _part_ of a character cell and the
|
||||
* rest of it was already visible, that remainder will
|
||||
* not be redrawn at all. Accordingly, we must not
|
||||
* paint any character cell in a WM_PAINT context which
|
||||
* already has a pending update due to terminal output.
|
||||
* The simplest solution to this - and many, many
|
||||
* thanks to Hung-Te Lin for working all this out - is
|
||||
* not to do any actual painting at _all_ if there's a
|
||||
* pending terminal update: just mark the relevant
|
||||
* character cells as INVALID and wait for the
|
||||
* scheduled full update to sort it out.
|
||||
*
|
||||
* I have a suspicion this isn't the _right_ solution.
|
||||
* An alternative approach would be to have terminal.c
|
||||
* separately track what _should_ be on the terminal
|
||||
* screen and what _is_ on the terminal screen, and
|
||||
* have two completely different types of redraw (one
|
||||
* for full updates, which syncs the former with the
|
||||
* terminal itself, and one for WM_PAINT which syncs
|
||||
* the latter with the former); yet another possibility
|
||||
* would be to have the Windows front end do what the
|
||||
* GTK one already does, and maintain a bitmap of the
|
||||
* current terminal appearance so that WM_PAINT becomes
|
||||
* completely trivial. However, this should do for now.
|
||||
*/
|
||||
assert(!wintw_hdc);
|
||||
wintw_hdc = hdc;
|
||||
term_paint(term,
|
||||
(p.rcPaint.left-offset_width)/font_width,
|
||||
(p.rcPaint.top-offset_height)/font_height,
|
||||
(p.rcPaint.right-offset_width-1)/font_width,
|
||||
(p.rcPaint.bottom-offset_height-1)/font_height,
|
||||
!term->window_update_pending);
|
||||
wintw_hdc = NULL;
|
||||
|
||||
if (p.fErase ||
|
||||
p.rcPaint.left < offset_width ||
|
||||
p.rcPaint.top < offset_height ||
|
||||
p.rcPaint.right >= offset_width + font_width*term->cols ||
|
||||
p.rcPaint.bottom>= offset_height + font_height*term->rows)
|
||||
{
|
||||
HBRUSH fillcolour, oldbrush;
|
||||
HPEN edge, oldpen;
|
||||
fillcolour = CreateSolidBrush (
|
||||
colours[ATTR_DEFBG>>ATTR_BGSHIFT]);
|
||||
oldbrush = SelectObject(hdc, fillcolour);
|
||||
edge = CreatePen(PS_SOLID, 0,
|
||||
colours[ATTR_DEFBG>>ATTR_BGSHIFT]);
|
||||
oldpen = SelectObject(hdc, edge);
|
||||
|
||||
/*
|
||||
* Jordan Russell reports that this apparently
|
||||
* ineffectual IntersectClipRect() call masks a
|
||||
* Windows NT/2K bug causing strange display
|
||||
* problems when the PuTTY window is taller than
|
||||
* the primary monitor. It seems harmless enough...
|
||||
*/
|
||||
IntersectClipRect(hdc,
|
||||
p.rcPaint.left, p.rcPaint.top,
|
||||
p.rcPaint.right, p.rcPaint.bottom);
|
||||
|
||||
ExcludeClipRect(hdc,
|
||||
offset_width, offset_height,
|
||||
offset_width+font_width*term->cols,
|
||||
offset_height+font_height*term->rows);
|
||||
|
||||
Rectangle(hdc, p.rcPaint.left, p.rcPaint.top,
|
||||
p.rcPaint.right, p.rcPaint.bottom);
|
||||
|
||||
/* SelectClipRgn(hdc, NULL); */
|
||||
|
||||
SelectObject(hdc, oldbrush);
|
||||
DeleteObject(fillcolour);
|
||||
SelectObject(hdc, oldpen);
|
||||
DeleteObject(edge);
|
||||
}
|
||||
SelectObject(hdc, GetStockObject(SYSTEM_FONT));
|
||||
SelectObject(hdc, GetStockObject(WHITE_PEN));
|
||||
EndPaint(hwnd, &p);
|
||||
ShowCaret(hwnd);
|
||||
HideCaret(hwnd);
|
||||
hdc = BeginPaint(hwnd, &p);
|
||||
if (pal) {
|
||||
SelectPalette(hdc, pal, true);
|
||||
RealizePalette(hdc);
|
||||
}
|
||||
return 0;
|
||||
case WM_NETEVENT:
|
||||
|
||||
/*
|
||||
* We have to be careful about term_paint(). It will
|
||||
* set a bunch of character cells to INVALID and then
|
||||
* call do_paint(), which will redraw those cells and
|
||||
* _then mark them as done_. This may not be accurate:
|
||||
* when painting in WM_PAINT context we are restricted
|
||||
* to the rectangle which has just been exposed - so if
|
||||
* that only covers _part_ of a character cell and the
|
||||
* rest of it was already visible, that remainder will
|
||||
* not be redrawn at all. Accordingly, we must not
|
||||
* paint any character cell in a WM_PAINT context which
|
||||
* already has a pending update due to terminal output.
|
||||
* The simplest solution to this - and many, many
|
||||
* thanks to Hung-Te Lin for working all this out - is
|
||||
* not to do any actual painting at _all_ if there's a
|
||||
* pending terminal update: just mark the relevant
|
||||
* character cells as INVALID and wait for the
|
||||
* scheduled full update to sort it out.
|
||||
*
|
||||
* I have a suspicion this isn't the _right_ solution.
|
||||
* An alternative approach would be to have terminal.c
|
||||
* separately track what _should_ be on the terminal
|
||||
* screen and what _is_ on the terminal screen, and
|
||||
* have two completely different types of redraw (one
|
||||
* for full updates, which syncs the former with the
|
||||
* terminal itself, and one for WM_PAINT which syncs
|
||||
* the latter with the former); yet another possibility
|
||||
* would be to have the Windows front end do what the
|
||||
* GTK one already does, and maintain a bitmap of the
|
||||
* current terminal appearance so that WM_PAINT becomes
|
||||
* completely trivial. However, this should do for now.
|
||||
*/
|
||||
assert(!wintw_hdc);
|
||||
wintw_hdc = hdc;
|
||||
term_paint(term,
|
||||
(p.rcPaint.left-offset_width)/font_width,
|
||||
(p.rcPaint.top-offset_height)/font_height,
|
||||
(p.rcPaint.right-offset_width-1)/font_width,
|
||||
(p.rcPaint.bottom-offset_height-1)/font_height,
|
||||
!term->window_update_pending);
|
||||
wintw_hdc = NULL;
|
||||
|
||||
if (p.fErase ||
|
||||
p.rcPaint.left < offset_width ||
|
||||
p.rcPaint.top < offset_height ||
|
||||
p.rcPaint.right >= offset_width + font_width*term->cols ||
|
||||
p.rcPaint.bottom>= offset_height + font_height*term->rows)
|
||||
{
|
||||
/*
|
||||
* To protect against re-entrancy when Windows's recv()
|
||||
* immediately triggers a new WSAAsyncSelect window
|
||||
* message, we don't call select_result directly from this
|
||||
* handler but instead wait until we're back out at the
|
||||
* top level of the message loop.
|
||||
*/
|
||||
struct wm_netevent_params *params =
|
||||
snew(struct wm_netevent_params);
|
||||
params->wParam = wParam;
|
||||
params->lParam = lParam;
|
||||
queue_toplevel_callback(wm_netevent_callback, params);
|
||||
HBRUSH fillcolour, oldbrush;
|
||||
HPEN edge, oldpen;
|
||||
fillcolour = CreateSolidBrush (
|
||||
colours[ATTR_DEFBG>>ATTR_BGSHIFT]);
|
||||
oldbrush = SelectObject(hdc, fillcolour);
|
||||
edge = CreatePen(PS_SOLID, 0,
|
||||
colours[ATTR_DEFBG>>ATTR_BGSHIFT]);
|
||||
oldpen = SelectObject(hdc, edge);
|
||||
|
||||
/*
|
||||
* Jordan Russell reports that this apparently
|
||||
* ineffectual IntersectClipRect() call masks a
|
||||
* Windows NT/2K bug causing strange display
|
||||
* problems when the PuTTY window is taller than
|
||||
* the primary monitor. It seems harmless enough...
|
||||
*/
|
||||
IntersectClipRect(hdc,
|
||||
p.rcPaint.left, p.rcPaint.top,
|
||||
p.rcPaint.right, p.rcPaint.bottom);
|
||||
|
||||
ExcludeClipRect(hdc,
|
||||
offset_width, offset_height,
|
||||
offset_width+font_width*term->cols,
|
||||
offset_height+font_height*term->rows);
|
||||
|
||||
Rectangle(hdc, p.rcPaint.left, p.rcPaint.top,
|
||||
p.rcPaint.right, p.rcPaint.bottom);
|
||||
|
||||
/* SelectClipRgn(hdc, NULL); */
|
||||
|
||||
SelectObject(hdc, oldbrush);
|
||||
DeleteObject(fillcolour);
|
||||
SelectObject(hdc, oldpen);
|
||||
DeleteObject(edge);
|
||||
}
|
||||
SelectObject(hdc, GetStockObject(SYSTEM_FONT));
|
||||
SelectObject(hdc, GetStockObject(WHITE_PEN));
|
||||
EndPaint(hwnd, &p);
|
||||
ShowCaret(hwnd);
|
||||
return 0;
|
||||
}
|
||||
case WM_NETEVENT: {
|
||||
/*
|
||||
* To protect against re-entrancy when Windows's recv()
|
||||
* immediately triggers a new WSAAsyncSelect window
|
||||
* message, we don't call select_result directly from this
|
||||
* handler but instead wait until we're back out at the
|
||||
* top level of the message loop.
|
||||
*/
|
||||
struct wm_netevent_params *params =
|
||||
snew(struct wm_netevent_params);
|
||||
params->wParam = wParam;
|
||||
params->lParam = lParam;
|
||||
queue_toplevel_callback(wm_netevent_callback, params);
|
||||
return 0;
|
||||
}
|
||||
case WM_SETFOCUS:
|
||||
term_set_focus(term, true);
|
||||
CreateCaret(hwnd, caretbm, font_width, font_height);
|
||||
@ -3137,21 +3130,20 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
|
||||
term_scroll(term, 0, -term->rows / 2);
|
||||
break;
|
||||
case SB_THUMBPOSITION:
|
||||
case SB_THUMBTRACK:
|
||||
case SB_THUMBTRACK: {
|
||||
/*
|
||||
* Use GetScrollInfo instead of HIWORD(wParam) to get
|
||||
* 32-bit scroll position.
|
||||
*/
|
||||
{
|
||||
SCROLLINFO si;
|
||||
SCROLLINFO si;
|
||||
|
||||
si.cbSize = sizeof(si);
|
||||
si.fMask = SIF_TRACKPOS;
|
||||
if (GetScrollInfo(hwnd, SB_VERT, &si) == 0)
|
||||
si.nTrackPos = HIWORD(wParam);
|
||||
term_scroll(term, 1, si.nTrackPos);
|
||||
}
|
||||
si.cbSize = sizeof(si);
|
||||
si.fMask = SIF_TRACKPOS;
|
||||
if (GetScrollInfo(hwnd, SB_VERT, &si) == 0)
|
||||
si.nTrackPos = HIWORD(wParam);
|
||||
term_scroll(term, 1, si.nTrackPos);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case WM_PALETTECHANGED:
|
||||
@ -3232,61 +3224,59 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
|
||||
set_input_locale((HKL)lParam);
|
||||
sys_cursor_update();
|
||||
break;
|
||||
case WM_IME_STARTCOMPOSITION:
|
||||
{
|
||||
HIMC hImc = ImmGetContext(hwnd);
|
||||
ImmSetCompositionFont(hImc, &lfont);
|
||||
ImmReleaseContext(hwnd, hImc);
|
||||
}
|
||||
case WM_IME_STARTCOMPOSITION: {
|
||||
HIMC hImc = ImmGetContext(hwnd);
|
||||
ImmSetCompositionFont(hImc, &lfont);
|
||||
ImmReleaseContext(hwnd, hImc);
|
||||
break;
|
||||
case WM_IME_COMPOSITION:
|
||||
{
|
||||
HIMC hIMC;
|
||||
int n;
|
||||
char *buff;
|
||||
}
|
||||
case WM_IME_COMPOSITION: {
|
||||
HIMC hIMC;
|
||||
int n;
|
||||
char *buff;
|
||||
|
||||
if (osPlatformId == VER_PLATFORM_WIN32_WINDOWS ||
|
||||
osPlatformId == VER_PLATFORM_WIN32s)
|
||||
break; /* no Unicode */
|
||||
if (osPlatformId == VER_PLATFORM_WIN32_WINDOWS ||
|
||||
osPlatformId == VER_PLATFORM_WIN32s)
|
||||
break; /* no Unicode */
|
||||
|
||||
if ((lParam & GCS_RESULTSTR) == 0) /* Composition unfinished. */
|
||||
break; /* fall back to DefWindowProc */
|
||||
if ((lParam & GCS_RESULTSTR) == 0) /* Composition unfinished. */
|
||||
break; /* fall back to DefWindowProc */
|
||||
|
||||
hIMC = ImmGetContext(hwnd);
|
||||
n = ImmGetCompositionStringW(hIMC, GCS_RESULTSTR, NULL, 0);
|
||||
hIMC = ImmGetContext(hwnd);
|
||||
n = ImmGetCompositionStringW(hIMC, GCS_RESULTSTR, NULL, 0);
|
||||
|
||||
if (n > 0) {
|
||||
int i;
|
||||
buff = snewn(n, char);
|
||||
ImmGetCompositionStringW(hIMC, GCS_RESULTSTR, buff, n);
|
||||
/*
|
||||
* Jaeyoun Chung reports that Korean character
|
||||
* input doesn't work correctly if we do a single
|
||||
* term_keyinputw covering the whole of buff. So
|
||||
* instead we send the characters one by one.
|
||||
*/
|
||||
/* don't divide SURROGATE PAIR */
|
||||
if (ldisc) {
|
||||
for (i = 0; i < n; i += 2) {
|
||||
WCHAR hs = *(unsigned short *)(buff+i);
|
||||
if (IS_HIGH_SURROGATE(hs) && i+2 < n) {
|
||||
WCHAR ls = *(unsigned short *)(buff+i+2);
|
||||
if (IS_LOW_SURROGATE(ls)) {
|
||||
term_keyinputw(
|
||||
term, (unsigned short *)(buff+i), 2);
|
||||
i += 2;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
term_keyinputw(
|
||||
term, (unsigned short *)(buff+i), 1);
|
||||
}
|
||||
if (n > 0) {
|
||||
int i;
|
||||
buff = snewn(n, char);
|
||||
ImmGetCompositionStringW(hIMC, GCS_RESULTSTR, buff, n);
|
||||
/*
|
||||
* Jaeyoun Chung reports that Korean character
|
||||
* input doesn't work correctly if we do a single
|
||||
* term_keyinputw covering the whole of buff. So
|
||||
* instead we send the characters one by one.
|
||||
*/
|
||||
/* don't divide SURROGATE PAIR */
|
||||
if (ldisc) {
|
||||
for (i = 0; i < n; i += 2) {
|
||||
WCHAR hs = *(unsigned short *)(buff+i);
|
||||
if (IS_HIGH_SURROGATE(hs) && i+2 < n) {
|
||||
WCHAR ls = *(unsigned short *)(buff+i+2);
|
||||
if (IS_LOW_SURROGATE(ls)) {
|
||||
term_keyinputw(
|
||||
term, (unsigned short *)(buff+i), 2);
|
||||
i += 2;
|
||||
continue;
|
||||
}
|
||||
free(buff);
|
||||
}
|
||||
term_keyinputw(
|
||||
term, (unsigned short *)(buff+i), 1);
|
||||
}
|
||||
ImmReleaseContext(hwnd, hIMC);
|
||||
return 1;
|
||||
}
|
||||
free(buff);
|
||||
}
|
||||
ImmReleaseContext(hwnd, hIMC);
|
||||
return 1;
|
||||
}
|
||||
|
||||
case WM_IME_CHAR:
|
||||
if (wParam & 0xFF00) {
|
||||
|
@ -1624,17 +1624,16 @@ void select_result(WPARAM wParam, LPARAM lParam)
|
||||
plug_receive(s->plug, 2, buf, ret);
|
||||
}
|
||||
break;
|
||||
case FD_WRITE:
|
||||
{
|
||||
int bufsize_before, bufsize_after;
|
||||
s->writable = true;
|
||||
bufsize_before = s->sending_oob + bufchain_size(&s->output_data);
|
||||
try_send(s);
|
||||
bufsize_after = s->sending_oob + bufchain_size(&s->output_data);
|
||||
if (bufsize_after < bufsize_before)
|
||||
plug_sent(s->plug, bufsize_after);
|
||||
}
|
||||
case FD_WRITE: {
|
||||
int bufsize_before, bufsize_after;
|
||||
s->writable = true;
|
||||
bufsize_before = s->sending_oob + bufchain_size(&s->output_data);
|
||||
try_send(s);
|
||||
bufsize_after = s->sending_oob + bufchain_size(&s->output_data);
|
||||
if (bufsize_after < bufsize_before)
|
||||
plug_sent(s->plug, bufsize_after);
|
||||
break;
|
||||
}
|
||||
case FD_CLOSE:
|
||||
/* Signal a close on the socket. First read any outstanding data. */
|
||||
do {
|
||||
@ -1652,42 +1651,42 @@ void select_result(WPARAM wParam, LPARAM lParam)
|
||||
}
|
||||
} while (ret > 0);
|
||||
return;
|
||||
case FD_ACCEPT:
|
||||
{
|
||||
case FD_ACCEPT: {
|
||||
#ifdef NO_IPV6
|
||||
struct sockaddr_in isa;
|
||||
struct sockaddr_in isa;
|
||||
#else
|
||||
struct sockaddr_storage isa;
|
||||
struct sockaddr_storage isa;
|
||||
#endif
|
||||
int addrlen = sizeof(isa);
|
||||
SOCKET t; /* socket of connection */
|
||||
accept_ctx_t actx;
|
||||
int addrlen = sizeof(isa);
|
||||
SOCKET t; /* socket of connection */
|
||||
accept_ctx_t actx;
|
||||
|
||||
memset(&isa, 0, sizeof(isa));
|
||||
err = 0;
|
||||
t = p_accept(s->s,(struct sockaddr *)&isa,&addrlen);
|
||||
if (t == INVALID_SOCKET)
|
||||
{
|
||||
err = p_WSAGetLastError();
|
||||
if (err == WSATRY_AGAIN)
|
||||
break;
|
||||
}
|
||||
memset(&isa, 0, sizeof(isa));
|
||||
err = 0;
|
||||
t = p_accept(s->s,(struct sockaddr *)&isa,&addrlen);
|
||||
if (t == INVALID_SOCKET)
|
||||
{
|
||||
err = p_WSAGetLastError();
|
||||
if (err == WSATRY_AGAIN)
|
||||
break;
|
||||
}
|
||||
|
||||
actx.p = (void *)t;
|
||||
actx.p = (void *)t;
|
||||
|
||||
#ifndef NO_IPV6
|
||||
if (isa.ss_family == AF_INET &&
|
||||
s->localhost_only &&
|
||||
!ipv4_is_local_addr(((struct sockaddr_in *)&isa)->sin_addr))
|
||||
if (isa.ss_family == AF_INET &&
|
||||
s->localhost_only &&
|
||||
!ipv4_is_local_addr(((struct sockaddr_in *)&isa)->sin_addr))
|
||||
#else
|
||||
if (s->localhost_only && !ipv4_is_local_addr(isa.sin_addr))
|
||||
if (s->localhost_only && !ipv4_is_local_addr(isa.sin_addr))
|
||||
#endif
|
||||
{
|
||||
p_closesocket(t); /* dodgy WinSock let nonlocal through */
|
||||
} else if (plug_accepting(s->plug, sk_net_accept, actx)) {
|
||||
p_closesocket(t); /* denied or error */
|
||||
}
|
||||
{
|
||||
p_closesocket(t); /* dodgy WinSock let nonlocal through */
|
||||
} else if (plug_accepting(s->plug, sk_net_accept, actx)) {
|
||||
p_closesocket(t); /* denied or error */
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -100,20 +100,19 @@ static void progress_update(void *param, int action, int phase, int iprogress)
|
||||
case PROGFN_PHASE_EXTENT:
|
||||
p->phases[phase-1].total = progress;
|
||||
break;
|
||||
case PROGFN_READY:
|
||||
{
|
||||
unsigned total = 0;
|
||||
int i;
|
||||
for (i = 0; i < p->nphases; i++) {
|
||||
p->phases[i].startpoint = total;
|
||||
total += p->phases[i].total;
|
||||
}
|
||||
p->total = total;
|
||||
p->divisor = ((p->total + PROGRESSRANGE - 1) / PROGRESSRANGE);
|
||||
p->range = p->total / p->divisor;
|
||||
SendMessage(p->progbar, PBM_SETRANGE, 0, MAKELPARAM(0, p->range));
|
||||
case PROGFN_READY: {
|
||||
unsigned total = 0;
|
||||
int i;
|
||||
for (i = 0; i < p->nphases; i++) {
|
||||
p->phases[i].startpoint = total;
|
||||
total += p->phases[i].total;
|
||||
}
|
||||
p->total = total;
|
||||
p->divisor = ((p->total + PROGRESSRANGE - 1) / PROGRESSRANGE);
|
||||
p->range = p->total / p->divisor;
|
||||
SendMessage(p->progbar, PBM_SETRANGE, 0, MAKELPARAM(0, p->range));
|
||||
break;
|
||||
}
|
||||
case PROGFN_PROGRESS:
|
||||
if (p->phases[phase-1].exponential) {
|
||||
while (p->phases[phase-1].n < progress) {
|
||||
@ -236,24 +235,23 @@ static INT_PTR CALLBACK LicenceProc(HWND hwnd, UINT msg,
|
||||
WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (msg) {
|
||||
case WM_INITDIALOG:
|
||||
case WM_INITDIALOG: {
|
||||
/*
|
||||
* Centre the window.
|
||||
*/
|
||||
{ /* centre the window */
|
||||
RECT rs, rd;
|
||||
HWND hw;
|
||||
RECT rs, rd;
|
||||
HWND hw;
|
||||
|
||||
hw = GetDesktopWindow();
|
||||
if (GetWindowRect(hw, &rs) && GetWindowRect(hwnd, &rd))
|
||||
MoveWindow(hwnd,
|
||||
(rs.right + rs.left + rd.left - rd.right) / 2,
|
||||
(rs.bottom + rs.top + rd.top - rd.bottom) / 2,
|
||||
rd.right - rd.left, rd.bottom - rd.top, true);
|
||||
}
|
||||
hw = GetDesktopWindow();
|
||||
if (GetWindowRect(hw, &rs) && GetWindowRect(hwnd, &rd))
|
||||
MoveWindow(hwnd,
|
||||
(rs.right + rs.left + rd.left - rd.right) / 2,
|
||||
(rs.bottom + rs.top + rd.top - rd.bottom) / 2,
|
||||
rd.right - rd.left, rd.bottom - rd.top, true);
|
||||
|
||||
SetDlgItemText(hwnd, 1000, LICENCE_TEXT("\r\n\r\n"));
|
||||
return 1;
|
||||
}
|
||||
case WM_COMMAND:
|
||||
switch (LOWORD(wParam)) {
|
||||
case IDOK:
|
||||
@ -1057,13 +1055,12 @@ static INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg,
|
||||
case IDC_KEYSSH2RSA:
|
||||
case IDC_KEYSSH2DSA:
|
||||
case IDC_KEYSSH2ECDSA:
|
||||
case IDC_KEYSSH2ED25519:
|
||||
{
|
||||
state = (struct MainDlgState *)
|
||||
GetWindowLongPtr(hwnd, GWLP_USERDATA);
|
||||
ui_set_key_type(hwnd, state, LOWORD(wParam));
|
||||
}
|
||||
case IDC_KEYSSH2ED25519: {
|
||||
state = (struct MainDlgState *)
|
||||
GetWindowLongPtr(hwnd, GWLP_USERDATA);
|
||||
ui_set_key_type(hwnd, state, LOWORD(wParam));
|
||||
break;
|
||||
}
|
||||
case IDC_QUIT:
|
||||
PostMessage(hwnd, WM_CLOSE, 0, 0);
|
||||
break;
|
||||
@ -1478,61 +1475,60 @@ static INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg,
|
||||
*/
|
||||
ui_set_state(hwnd, state, 2);
|
||||
break;
|
||||
case WM_HELP:
|
||||
{
|
||||
int id = ((LPHELPINFO)lParam)->iCtrlId;
|
||||
const char *topic = NULL;
|
||||
switch (id) {
|
||||
case IDC_GENERATING:
|
||||
case IDC_PROGRESS:
|
||||
case IDC_GENSTATIC:
|
||||
case IDC_GENERATE:
|
||||
topic = WINHELP_CTX_puttygen_generate; break;
|
||||
case IDC_PKSTATIC:
|
||||
case IDC_KEYDISPLAY:
|
||||
topic = WINHELP_CTX_puttygen_pastekey; break;
|
||||
case IDC_FPSTATIC:
|
||||
case IDC_FINGERPRINT:
|
||||
topic = WINHELP_CTX_puttygen_fingerprint; break;
|
||||
case IDC_COMMENTSTATIC:
|
||||
case IDC_COMMENTEDIT:
|
||||
topic = WINHELP_CTX_puttygen_comment; break;
|
||||
case IDC_PASSPHRASE1STATIC:
|
||||
case IDC_PASSPHRASE1EDIT:
|
||||
case IDC_PASSPHRASE2STATIC:
|
||||
case IDC_PASSPHRASE2EDIT:
|
||||
topic = WINHELP_CTX_puttygen_passphrase; break;
|
||||
case IDC_LOADSTATIC:
|
||||
case IDC_LOAD:
|
||||
topic = WINHELP_CTX_puttygen_load; break;
|
||||
case IDC_SAVESTATIC:
|
||||
case IDC_SAVE:
|
||||
topic = WINHELP_CTX_puttygen_savepriv; break;
|
||||
case IDC_SAVEPUB:
|
||||
topic = WINHELP_CTX_puttygen_savepub; break;
|
||||
case IDC_TYPESTATIC:
|
||||
case IDC_KEYSSH1:
|
||||
case IDC_KEYSSH2RSA:
|
||||
case IDC_KEYSSH2DSA:
|
||||
case IDC_KEYSSH2ECDSA:
|
||||
case IDC_KEYSSH2ED25519:
|
||||
topic = WINHELP_CTX_puttygen_keytype; break;
|
||||
case IDC_BITSSTATIC:
|
||||
case IDC_BITS:
|
||||
topic = WINHELP_CTX_puttygen_bits; break;
|
||||
case IDC_IMPORT:
|
||||
case IDC_EXPORT_OPENSSH_AUTO:
|
||||
case IDC_EXPORT_OPENSSH_NEW:
|
||||
case IDC_EXPORT_SSHCOM:
|
||||
topic = WINHELP_CTX_puttygen_conversions; break;
|
||||
}
|
||||
if (topic) {
|
||||
launch_help(hwnd, topic);
|
||||
} else {
|
||||
MessageBeep(0);
|
||||
}
|
||||
case WM_HELP: {
|
||||
int id = ((LPHELPINFO)lParam)->iCtrlId;
|
||||
const char *topic = NULL;
|
||||
switch (id) {
|
||||
case IDC_GENERATING:
|
||||
case IDC_PROGRESS:
|
||||
case IDC_GENSTATIC:
|
||||
case IDC_GENERATE:
|
||||
topic = WINHELP_CTX_puttygen_generate; break;
|
||||
case IDC_PKSTATIC:
|
||||
case IDC_KEYDISPLAY:
|
||||
topic = WINHELP_CTX_puttygen_pastekey; break;
|
||||
case IDC_FPSTATIC:
|
||||
case IDC_FINGERPRINT:
|
||||
topic = WINHELP_CTX_puttygen_fingerprint; break;
|
||||
case IDC_COMMENTSTATIC:
|
||||
case IDC_COMMENTEDIT:
|
||||
topic = WINHELP_CTX_puttygen_comment; break;
|
||||
case IDC_PASSPHRASE1STATIC:
|
||||
case IDC_PASSPHRASE1EDIT:
|
||||
case IDC_PASSPHRASE2STATIC:
|
||||
case IDC_PASSPHRASE2EDIT:
|
||||
topic = WINHELP_CTX_puttygen_passphrase; break;
|
||||
case IDC_LOADSTATIC:
|
||||
case IDC_LOAD:
|
||||
topic = WINHELP_CTX_puttygen_load; break;
|
||||
case IDC_SAVESTATIC:
|
||||
case IDC_SAVE:
|
||||
topic = WINHELP_CTX_puttygen_savepriv; break;
|
||||
case IDC_SAVEPUB:
|
||||
topic = WINHELP_CTX_puttygen_savepub; break;
|
||||
case IDC_TYPESTATIC:
|
||||
case IDC_KEYSSH1:
|
||||
case IDC_KEYSSH2RSA:
|
||||
case IDC_KEYSSH2DSA:
|
||||
case IDC_KEYSSH2ECDSA:
|
||||
case IDC_KEYSSH2ED25519:
|
||||
topic = WINHELP_CTX_puttygen_keytype; break;
|
||||
case IDC_BITSSTATIC:
|
||||
case IDC_BITS:
|
||||
topic = WINHELP_CTX_puttygen_bits; break;
|
||||
case IDC_IMPORT:
|
||||
case IDC_EXPORT_OPENSSH_AUTO:
|
||||
case IDC_EXPORT_OPENSSH_NEW:
|
||||
case IDC_EXPORT_SSHCOM:
|
||||
topic = WINHELP_CTX_puttygen_conversions; break;
|
||||
}
|
||||
if (topic) {
|
||||
launch_help(hwnd, topic);
|
||||
} else {
|
||||
MessageBeep(0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case WM_CLOSE:
|
||||
state = (struct MainDlgState *) GetWindowLongPtr(hwnd, GWLP_USERDATA);
|
||||
sfree(state);
|
||||
|
@ -133,18 +133,17 @@ static INT_PTR CALLBACK AboutProc(HWND hwnd, UINT msg,
|
||||
WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (msg) {
|
||||
case WM_INITDIALOG:
|
||||
{
|
||||
char *buildinfo_text = buildinfo("\r\n");
|
||||
char *text = dupprintf
|
||||
("Pageant\r\n\r\n%s\r\n\r\n%s\r\n\r\n%s",
|
||||
ver, buildinfo_text,
|
||||
"\251 " SHORT_COPYRIGHT_DETAILS ". All rights reserved.");
|
||||
sfree(buildinfo_text);
|
||||
SetDlgItemText(hwnd, 1000, text);
|
||||
sfree(text);
|
||||
}
|
||||
case WM_INITDIALOG: {
|
||||
char *buildinfo_text = buildinfo("\r\n");
|
||||
char *text = dupprintf
|
||||
("Pageant\r\n\r\n%s\r\n\r\n%s\r\n\r\n%s",
|
||||
ver, buildinfo_text,
|
||||
"\251 " SHORT_COPYRIGHT_DETAILS ". All rights reserved.");
|
||||
sfree(buildinfo_text);
|
||||
SetDlgItemText(hwnd, 1000, text);
|
||||
sfree(text);
|
||||
return 1;
|
||||
}
|
||||
case WM_COMMAND:
|
||||
switch (LOWORD(wParam)) {
|
||||
case IDOK:
|
||||
@ -186,22 +185,20 @@ static INT_PTR CALLBACK PassphraseProc(HWND hwnd, UINT msg,
|
||||
struct PassphraseProcStruct *p;
|
||||
|
||||
switch (msg) {
|
||||
case WM_INITDIALOG:
|
||||
case WM_INITDIALOG: {
|
||||
passphrase_box = hwnd;
|
||||
/*
|
||||
* Centre the window.
|
||||
*/
|
||||
{ /* centre the window */
|
||||
RECT rs, rd;
|
||||
HWND hw;
|
||||
RECT rs, rd;
|
||||
HWND hw;
|
||||
|
||||
hw = GetDesktopWindow();
|
||||
if (GetWindowRect(hw, &rs) && GetWindowRect(hwnd, &rd))
|
||||
MoveWindow(hwnd,
|
||||
(rs.right + rs.left + rd.left - rd.right) / 2,
|
||||
(rs.bottom + rs.top + rd.top - rd.bottom) / 2,
|
||||
rd.right - rd.left, rd.bottom - rd.top, true);
|
||||
}
|
||||
hw = GetDesktopWindow();
|
||||
if (GetWindowRect(hw, &rs) && GetWindowRect(hwnd, &rd))
|
||||
MoveWindow(hwnd,
|
||||
(rs.right + rs.left + rd.left - rd.right) / 2,
|
||||
(rs.bottom + rs.top + rd.top - rd.bottom) / 2,
|
||||
rd.right - rd.left, rd.bottom - rd.top, true);
|
||||
|
||||
SetForegroundWindow(hwnd);
|
||||
SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0,
|
||||
@ -214,6 +211,7 @@ static INT_PTR CALLBACK PassphraseProc(HWND hwnd, UINT msg,
|
||||
*passphrase = dupstr("");
|
||||
SetDlgItemText(hwnd, 102, *passphrase);
|
||||
return 0;
|
||||
}
|
||||
case WM_COMMAND:
|
||||
switch (LOWORD(wParam)) {
|
||||
case IDOK:
|
||||
@ -485,41 +483,40 @@ static INT_PTR CALLBACK KeyListProc(HWND hwnd, UINT msg,
|
||||
ssh2_userkey *skey;
|
||||
|
||||
switch (msg) {
|
||||
case WM_INITDIALOG:
|
||||
case WM_INITDIALOG: {
|
||||
/*
|
||||
* Centre the window.
|
||||
*/
|
||||
{ /* centre the window */
|
||||
RECT rs, rd;
|
||||
HWND hw;
|
||||
RECT rs, rd;
|
||||
HWND hw;
|
||||
|
||||
hw = GetDesktopWindow();
|
||||
if (GetWindowRect(hw, &rs) && GetWindowRect(hwnd, &rd))
|
||||
MoveWindow(hwnd,
|
||||
(rs.right + rs.left + rd.left - rd.right) / 2,
|
||||
(rs.bottom + rs.top + rd.top - rd.bottom) / 2,
|
||||
rd.right - rd.left, rd.bottom - rd.top, true);
|
||||
}
|
||||
hw = GetDesktopWindow();
|
||||
if (GetWindowRect(hw, &rs) && GetWindowRect(hwnd, &rd))
|
||||
MoveWindow(hwnd,
|
||||
(rs.right + rs.left + rd.left - rd.right) / 2,
|
||||
(rs.bottom + rs.top + rd.top - rd.bottom) / 2,
|
||||
rd.right - rd.left, rd.bottom - rd.top, true);
|
||||
|
||||
if (has_help())
|
||||
SetWindowLongPtr(hwnd, GWL_EXSTYLE,
|
||||
GetWindowLongPtr(hwnd, GWL_EXSTYLE) |
|
||||
WS_EX_CONTEXTHELP);
|
||||
else {
|
||||
HWND item = GetDlgItem(hwnd, 103); /* the Help button */
|
||||
if (item)
|
||||
DestroyWindow(item);
|
||||
HWND item = GetDlgItem(hwnd, 103); /* the Help button */
|
||||
if (item)
|
||||
DestroyWindow(item);
|
||||
}
|
||||
|
||||
keylist = hwnd;
|
||||
{
|
||||
static int tabs[] = { 35, 75, 250 };
|
||||
SendDlgItemMessage(hwnd, 100, LB_SETTABSTOPS,
|
||||
sizeof(tabs) / sizeof(*tabs),
|
||||
(LPARAM) tabs);
|
||||
static int tabs[] = { 35, 75, 250 };
|
||||
SendDlgItemMessage(hwnd, 100, LB_SETTABSTOPS,
|
||||
sizeof(tabs) / sizeof(*tabs),
|
||||
(LPARAM) tabs);
|
||||
}
|
||||
keylist_update();
|
||||
return 0;
|
||||
}
|
||||
case WM_COMMAND:
|
||||
switch (LOWORD(wParam)) {
|
||||
case IDOK:
|
||||
@ -607,22 +604,21 @@ static INT_PTR CALLBACK KeyListProc(HWND hwnd, UINT msg,
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
case WM_HELP:
|
||||
{
|
||||
int id = ((LPHELPINFO)lParam)->iCtrlId;
|
||||
const char *topic = NULL;
|
||||
switch (id) {
|
||||
case 100: topic = WINHELP_CTX_pageant_keylist; break;
|
||||
case 101: topic = WINHELP_CTX_pageant_addkey; break;
|
||||
case 102: topic = WINHELP_CTX_pageant_remkey; break;
|
||||
}
|
||||
if (topic) {
|
||||
launch_help(hwnd, topic);
|
||||
} else {
|
||||
MessageBeep(0);
|
||||
}
|
||||
case WM_HELP: {
|
||||
int id = ((LPHELPINFO)lParam)->iCtrlId;
|
||||
const char *topic = NULL;
|
||||
switch (id) {
|
||||
case 100: topic = WINHELP_CTX_pageant_keylist; break;
|
||||
case 101: topic = WINHELP_CTX_pageant_addkey; break;
|
||||
case 102: topic = WINHELP_CTX_pageant_remkey; break;
|
||||
}
|
||||
if (topic) {
|
||||
launch_help(hwnd, topic);
|
||||
} else {
|
||||
MessageBeep(0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case WM_CLOSE:
|
||||
keylist = NULL;
|
||||
DestroyWindow(hwnd);
|
||||
@ -1007,20 +1003,19 @@ static LRESULT CALLBACK TrayWndProc(HWND hwnd, UINT message,
|
||||
case WM_COMMAND:
|
||||
case WM_SYSCOMMAND:
|
||||
switch (wParam & ~0xF) { /* low 4 bits reserved to Windows */
|
||||
case IDM_PUTTY:
|
||||
{
|
||||
TCHAR cmdline[10];
|
||||
cmdline[0] = '\0';
|
||||
if (restrict_putty_acl)
|
||||
strcat(cmdline, "&R");
|
||||
case IDM_PUTTY: {
|
||||
TCHAR cmdline[10];
|
||||
cmdline[0] = '\0';
|
||||
if (restrict_putty_acl)
|
||||
strcat(cmdline, "&R");
|
||||
|
||||
if((INT_PTR)ShellExecute(hwnd, NULL, putty_path, cmdline,
|
||||
_T(""), SW_SHOW) <= 32) {
|
||||
MessageBox(NULL, "Unable to execute PuTTY!",
|
||||
"Error", MB_OK | MB_ICONERROR);
|
||||
}
|
||||
if((INT_PTR)ShellExecute(hwnd, NULL, putty_path, cmdline,
|
||||
_T(""), SW_SHOW) <= 32) {
|
||||
MessageBox(NULL, "Unable to execute PuTTY!",
|
||||
"Error", MB_OK | MB_ICONERROR);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case IDM_CLOSE:
|
||||
if (passphrase_box)
|
||||
SendMessage(passphrase_box, WM_CLOSE, 0, 0);
|
||||
@ -1068,31 +1063,30 @@ static LRESULT CALLBACK TrayWndProc(HWND hwnd, UINT message,
|
||||
case IDM_HELP:
|
||||
launch_help(hwnd, WINHELP_CTX_pageant_general);
|
||||
break;
|
||||
default:
|
||||
{
|
||||
if(wParam >= IDM_SESSIONS_BASE && wParam <= IDM_SESSIONS_MAX) {
|
||||
MENUITEMINFO mii;
|
||||
TCHAR buf[MAX_PATH + 1];
|
||||
TCHAR param[MAX_PATH + 1];
|
||||
memset(&mii, 0, sizeof(mii));
|
||||
mii.cbSize = sizeof(mii);
|
||||
mii.fMask = MIIM_TYPE;
|
||||
mii.cch = MAX_PATH;
|
||||
mii.dwTypeData = buf;
|
||||
GetMenuItemInfo(session_menu, wParam, false, &mii);
|
||||
param[0] = '\0';
|
||||
if (restrict_putty_acl)
|
||||
strcat(param, "&R");
|
||||
strcat(param, "@");
|
||||
strcat(param, mii.dwTypeData);
|
||||
if((INT_PTR)ShellExecute(hwnd, NULL, putty_path, param,
|
||||
_T(""), SW_SHOW) <= 32) {
|
||||
MessageBox(NULL, "Unable to execute PuTTY!", "Error",
|
||||
MB_OK | MB_ICONERROR);
|
||||
}
|
||||
}
|
||||
default: {
|
||||
if(wParam >= IDM_SESSIONS_BASE && wParam <= IDM_SESSIONS_MAX) {
|
||||
MENUITEMINFO mii;
|
||||
TCHAR buf[MAX_PATH + 1];
|
||||
TCHAR param[MAX_PATH + 1];
|
||||
memset(&mii, 0, sizeof(mii));
|
||||
mii.cbSize = sizeof(mii);
|
||||
mii.fMask = MIIM_TYPE;
|
||||
mii.cch = MAX_PATH;
|
||||
mii.dwTypeData = buf;
|
||||
GetMenuItemInfo(session_menu, wParam, false, &mii);
|
||||
param[0] = '\0';
|
||||
if (restrict_putty_acl)
|
||||
strcat(param, "&R");
|
||||
strcat(param, "@");
|
||||
strcat(param, mii.dwTypeData);
|
||||
if((INT_PTR)ShellExecute(hwnd, NULL, putty_path, param,
|
||||
_T(""), SW_SHOW) <= 32) {
|
||||
MessageBox(NULL, "Unable to execute PuTTY!", "Error",
|
||||
MB_OK | MB_ICONERROR);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case WM_DESTROY:
|
||||
@ -1108,27 +1102,26 @@ static LRESULT CALLBACK wm_copydata_WndProc(HWND hwnd, UINT message,
|
||||
WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (message) {
|
||||
case WM_COPYDATA:
|
||||
{
|
||||
COPYDATASTRUCT *cds;
|
||||
char *mapname, *err;
|
||||
case WM_COPYDATA: {
|
||||
COPYDATASTRUCT *cds;
|
||||
char *mapname, *err;
|
||||
|
||||
cds = (COPYDATASTRUCT *) lParam;
|
||||
if (cds->dwData != AGENT_COPYDATA_ID)
|
||||
return 0; /* not our message, mate */
|
||||
mapname = (char *) cds->lpData;
|
||||
if (mapname[cds->cbData - 1] != '\0')
|
||||
return 0; /* failure to be ASCIZ! */
|
||||
err = answer_filemapping_message(mapname);
|
||||
if (err) {
|
||||
cds = (COPYDATASTRUCT *) lParam;
|
||||
if (cds->dwData != AGENT_COPYDATA_ID)
|
||||
return 0; /* not our message, mate */
|
||||
mapname = (char *) cds->lpData;
|
||||
if (mapname[cds->cbData - 1] != '\0')
|
||||
return 0; /* failure to be ASCIZ! */
|
||||
err = answer_filemapping_message(mapname);
|
||||
if (err) {
|
||||
#ifdef DEBUG_IPC
|
||||
debug("IPC failed: %s\n", err);
|
||||
debug("IPC failed: %s\n", err);
|
||||
#endif
|
||||
sfree(err);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
sfree(err);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return DefWindowProc(hwnd, message, wParam, lParam);
|
||||
|
Reference in New Issue
Block a user