#define VK_PROCESSKEY 0xE5
#endif
+/* Needed for mouse wheel support and not defined in earlier SDKs. */
+#ifndef WM_MOUSEWHEEL
+#define WM_MOUSEWHEEL 0x020A
+#endif
+
static LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam,
unsigned char *output);
static WPARAM pend_netevent_wParam = 0;
static LPARAM pend_netevent_lParam = 0;
static void enact_pending_netevent(void);
+static void flash_window(int mode);
static time_t last_movement = 0;
}
}
+ /*
+ * Trim leading whitespace off the hostname if it's there.
+ */
+ {
+ int space = strspn(cfg.host, " \t");
+ memmove(cfg.host, cfg.host+space, 1+strlen(cfg.host)-space);
+ }
+
/* See if host is of the form user@host */
if (cfg.host[0] != '\0') {
char *atsign = strchr(cfg.host, '@');
term_out();
term_update();
ShowCaret(hwnd);
+
+ flash_window(1); /* maintain */
+
if (in_vbell)
/* Hmm, term_update didn't want to do an update too soon ... */
timer_id = SetTimer(hwnd, 1, 50, NULL);
else if (!has_focus)
- timer_id = SetTimer(hwnd, 1, 2000, NULL);
+ timer_id = SetTimer(hwnd, 1, 500, NULL);
else
timer_id = SetTimer(hwnd, 1, 100, NULL);
long_timer = 1;
return cfg.mouse_is_xterm ? MBT_PASTE : MBT_EXTEND;
if (button == MBT_RIGHT)
return cfg.mouse_is_xterm ? MBT_EXTEND : MBT_PASTE;
+ return 0; /* shouldn't happen */
}
static void show_mouseptr(int show)
button = MBT_RIGHT;
press = 0;
break;
+ default:
+ button = press = 0; /* shouldn't happen */
}
show_mouseptr(1);
if (press) {
if (wParam & (MK_LBUTTON | MK_MBUTTON | MK_RBUTTON)) {
Mouse_Button b;
if (wParam & MK_LBUTTON)
- b = MBT_SELECT;
+ b = MBT_LEFT;
else if (wParam & MK_MBUTTON)
- b = cfg.mouse_is_xterm ? MBT_PASTE : MBT_EXTEND;
+ b = MBT_MIDDLE;
else
- b = cfg.mouse_is_xterm ? MBT_EXTEND : MBT_PASTE;
+ b = MBT_RIGHT;
term_mouse(b, MA_DRAG, TO_CHR_X(X_POS(lParam)),
TO_CHR_Y(Y_POS(lParam)), wParam & MK_SHIFT,
wParam & MK_CONTROL);
has_focus = TRUE;
CreateCaret(hwnd, caretbm, font_width, font_height);
ShowCaret(hwnd);
+ flash_window(0); /* stop */
compose_state = 0;
term_out();
term_update();
return p - output;
}
- if (cfg.funky_type == 5 && code >= 11 && code <= 24) {
- p += sprintf((char *) p, "\x1B[%c", code + 'M' - 11);
+ if (cfg.funky_type == 5 && code >= 11 && code <= 34) {
+ char codes[] = "MNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz@[\\]^_`{";
+ int index = 0;
+ switch (wParam) {
+ case VK_F1: index = 0; break;
+ case VK_F2: index = 1; break;
+ case VK_F3: index = 2; break;
+ case VK_F4: index = 3; break;
+ case VK_F5: index = 4; break;
+ case VK_F6: index = 5; break;
+ case VK_F7: index = 6; break;
+ case VK_F8: index = 7; break;
+ case VK_F9: index = 8; break;
+ case VK_F10: index = 9; break;
+ case VK_F11: index = 10; break;
+ case VK_F12: index = 11; break;
+ }
+ if (keystate[VK_SHIFT] & 0x80) index += 12;
+ if (keystate[VK_CONTROL] & 0x80) index += 24;
+ p += sprintf((char *) p, "\x1B[%c", codes[index]);
return p - output;
}
if ((vt52_mode || cfg.funky_type == 4) && code >= 11 && code <= 24) {
clipdata = NULL;
return;
} else if (OpenClipboard(NULL)) {
- if (clipdata = GetClipboardData(CF_UNICODETEXT)) {
+ if ((clipdata = GetClipboardData(CF_UNICODETEXT))) {
CloseClipboard();
*p = GlobalLock(clipdata);
if (*p) {
*len = p2 - *p;
return;
}
- } else if (clipdata = GetClipboardData(CF_TEXT)) {
+ } else if ( (clipdata = GetClipboardData(CF_TEXT)) ) {
char *s;
int i;
CloseClipboard();
}
/*
+ * Manage window caption / taskbar flashing, if enabled.
+ * 0 = stop, 1 = maintain, 2 = start
+ */
+static void flash_window(int mode)
+{
+ static long last_flash = 0;
+ static int flashing = 0;
+ if ((mode == 0) || (cfg.beep_ind == B_IND_DISABLED)) {
+ /* stop */
+ if (flashing) {
+ FlashWindow(hwnd, FALSE);
+ flashing = 0;
+ }
+
+ } else if (mode == 2) {
+ /* start */
+ if (!flashing) {
+ last_flash = GetTickCount();
+ flashing = 1;
+ FlashWindow(hwnd, TRUE);
+ }
+
+ } else if ((mode == 1) && (cfg.beep_ind == B_IND_FLASH)) {
+ /* maintain */
+ if (flashing) {
+ long now = GetTickCount();
+ long fdiff = now - last_flash;
+ if (fdiff < 0 || fdiff > 450) {
+ last_flash = now;
+ FlashWindow(hwnd, TRUE); /* toggle */
+ }
+ }
+ }
+}
+
+/*
* Beep.
*/
void beep(int mode)
cfg.beep = BELL_DEFAULT;
}
}
+ /* Otherwise, either visual bell or disabled; do nothing here */
+ if (!has_focus) {
+ flash_window(2); /* start */
+ }
}