#include <windows.h>
+#include <imm.h>
#include <commctrl.h>
#ifndef AUTO_WINSOCK
#ifdef WINSOCK_TWO
return 1;
}
/* WISHLIST: maybe allow config tweaking even if winsock not present? */
+ sk_init();
InitCommonControls();
char msg[1024], *title;
char *realhost;
- error = back->init (hwnd, cfg.host, cfg.port, &realhost);
+ error = back->init (cfg.host, cfg.port, &realhost);
if (error) {
sprintf(msg, "Unable to open connection:\n%s", error);
MessageBox(NULL, msg, "PuTTY Error", MB_ICONERROR | MB_OK);
}
AppendMenu (m, MF_ENABLED, IDM_SHOWLOG, "&Event Log");
AppendMenu (m, MF_SEPARATOR, 0, 0);
- AppendMenu (m, MF_ENABLED, IDM_NEWSESS, "Ne&w Session");
+ AppendMenu (m, MF_ENABLED, IDM_NEWSESS, "Ne&w Session...");
AppendMenu (m, MF_ENABLED, IDM_DUPSESS, "&Duplicate Session");
s = CreateMenu();
get_sesslist(TRUE);
for (i = 1 ; i < ((nsessions < 256) ? nsessions : 256) ; i++)
AppendMenu (s, MF_ENABLED, IDM_SAVED_MIN + (16 * i) , sessions[i]);
AppendMenu (m, MF_POPUP | MF_ENABLED, (UINT) s, "Sa&ved Sessions");
- AppendMenu (m, MF_ENABLED, IDM_RECONF, "Chan&ge Settings");
+ AppendMenu (m, MF_ENABLED, IDM_RECONF, "Chan&ge Settings...");
AppendMenu (m, MF_SEPARATOR, 0, 0);
AppendMenu (m, MF_ENABLED, IDM_CLRSB, "C&lear Scrollback");
AppendMenu (m, MF_ENABLED, IDM_RESET, "Rese&t Terminal");
return msg.wParam;
}
+/*
+ * Set up, or shut down, an AsyncSelect. Called from winnet.c.
+ */
+char *do_select(SOCKET skt, int startup) {
+ int msg, events;
+ if (startup) {
+ msg = WM_NETEVENT;
+ events = FD_READ | FD_WRITE | FD_OOB | FD_CLOSE;
+ } else {
+ msg = events = 0;
+ }
+ if (!hwnd)
+ return "do_select(): internal error (hwnd==NULL)";
+ if (WSAAsyncSelect (skt, hwnd, msg, events) == SOCKET_ERROR) {
+ switch (WSAGetLastError()) {
+ case WSAENETDOWN: return "Network is down";
+ default: return "WSAAsyncSelect(): unknown error";
+ }
+ }
+ return NULL;
+}
+
/*
* Print a message box and close the connection.
*/
* Actually do the job requested by a WM_NETEVENT
*/
static void enact_pending_netevent(void) {
- int i;
static int reentering = 0;
+ extern int select_result(WPARAM, LPARAM);
+ int ret;
if (reentering)
return; /* don't unpend the pending */
pending_netevent = FALSE;
reentering = 1;
- i = back->msg (pend_netevent_wParam, pend_netevent_lParam);
+ ret = select_result (pend_netevent_wParam, pend_netevent_lParam);
reentering = 0;
- if (i < 0) {
- char buf[1024];
- switch (WSABASEERR + (-i) % 10000) {
- case WSAECONNRESET:
- sprintf(buf, "Connection reset by peer");
- break;
- case WSAECONNABORTED:
- sprintf(buf, "Connection aborted");
- break;
- default:
- sprintf(buf, "Unexpected network error %d", -i);
- break;
- }
- connection_fatal(buf);
- }
- if (i <= 0) {
+ if (ret == 0) {
if (cfg.close_on_exit)
PostQuitMessage(0);
else {
enact_pending_netevent();
if (inbuf_head)
term_out();
+ noise_regular();
HideCaret(hwnd);
term_update();
ShowCaret(hwnd);
case WM_MOUSEMOVE:
/*
* Add the mouse position and message time to the random
- * number noise, if we're using ssh.
+ * number noise.
*/
- if (cfg.protocol == PROT_SSH)
- noise_ultralight(lParam);
+ noise_ultralight(lParam);
if (wParam & (MK_LBUTTON | MK_MBUTTON | MK_RBUTTON)) {
Mouse_Button b;
case WM_SYSKEYUP:
/*
* Add the scan code and keypress timing to the random
- * number noise, if we're using ssh.
+ * number noise.
*/
- if (cfg.protocol == PROT_SSH)
- noise_ultralight(lParam);
+ noise_ultralight(lParam);
/*
* We don't do TranslateMessage since it disassociates the
compose_state = 0;
/* Nastyness with NUMLock - Shift-NUMLock is left alone though */
- if ( (cfg.funky_type == 3 || (cfg.funky_type <= 1 && app_keypad_keys))
+ if ( (cfg.funky_type == 3 ||
+ (cfg.funky_type <= 1 && app_keypad_keys && !cfg.no_applic_k))
&& wParam==VK_NUMLOCK && !(keystate[VK_SHIFT]&0x80)) {
wParam = VK_EXECUTE;
if (compose_state>1 && left_alt) compose_state = 0;
/* Sanitize the number pad if not using a PC NumPad */
- if( left_alt || (app_keypad_keys && cfg.funky_type != 2)
+ if( left_alt || (app_keypad_keys && !cfg.no_applic_k
+ && cfg.funky_type != 2)
|| cfg.funky_type == 3 || cfg.nethack_keypad || compose_state )
{
if ((HIWORD(lParam)&KF_EXTENDED) == 0)
int xkey = 0;
if ( cfg.funky_type == 3 ||
- ( cfg.funky_type <= 1 && app_keypad_keys)) switch(wParam) {
+ ( cfg.funky_type <= 1 &&
+ app_keypad_keys && !cfg.no_applic_k)) switch(wParam) {
case VK_EXECUTE: xkey = 'P'; break;
case VK_DIVIDE: xkey = 'Q'; break;
case VK_MULTIPLY:xkey = 'R'; break;
case VK_SUBTRACT:xkey = 'S'; break;
}
- if(app_keypad_keys) switch(wParam) {
+ if(app_keypad_keys && !cfg.no_applic_k) switch(wParam) {
case VK_NUMPAD0: xkey = 'p'; break;
case VK_NUMPAD1: xkey = 'q'; break;
case VK_NUMPAD2: xkey = 'r'; break;
{
if (vt52_mode)
p += sprintf((char *)p, "\x1B%c", xkey);
- else if (app_cursor_keys)
+ else if (app_cursor_keys && !cfg.no_applic_c)
p += sprintf((char *)p, "\x1BO%c", xkey);
else
p += sprintf((char *)p, "\x1B[%c", xkey);