home *** CD-ROM | disk | FTP | other *** search
- To: vim-dev@vim.org
- Subject: Patch 6.2.398 (extra)
- Fcc: outbox
- From: Bram Moolenaar <Bram@moolenaar.net>
- Mime-Version: 1.0
- Content-Type: text/plain; charset=ISO-8859-1
- Content-Transfer-Encoding: 8bit
- ------------
-
- Patch 6.2.398 (extra)
- Problem: Win32 console: no extra key modifiers are supported.
- Solution: Encode the modifiers into the input stream. Also fix that special
- keys are converted and stop working when 'tenc' is set. Also fix
- that when 'tenc' is intialized the input and output conversion is
- not setup properly until 'enc' or 'tenc' is set.
- Files: src/getchar.c, src/option.c, src/os_win32.c
-
-
- *** ../vim-6.2.397/src/getchar.c Sun Feb 29 14:45:49 2004
- --- src/getchar.c Tue Mar 23 19:44:59 2004
- ***************
- *** 2750,2756 ****
- }
- else
- #endif
- ! if (p[0] == NUL || (p[0] == K_SPECIAL && !script))
- {
- mch_memmove(p + 3, p + 1, (size_t)i);
- p[2] = K_THIRD(p[0]);
- --- 2750,2761 ----
- }
- else
- #endif
- ! if (p[0] == NUL || (p[0] == K_SPECIAL && !script
- ! #if defined(WIN3264) && !defined(FEAT_GUI)
- ! /* Win32 console passes modifiers */
- ! && (i < 2 || p[1] != KS_MODIFIER)
- ! #endif
- ! ))
- {
- mch_memmove(p + 3, p + 1, (size_t)i);
- p[2] = K_THIRD(p[0]);
- *** ../vim-6.2.397/src/option.c Mon Mar 22 21:11:50 2004
- --- src/option.c Tue Mar 23 16:16:31 2004
- ***************
- *** 2820,2825 ****
- --- 2832,2839 ----
- opt_idx = findoption((char_u *)"termencoding");
- options[opt_idx].def_val[VI_DEFAULT] = p_tenc;
- options[opt_idx].flags |= P_DEF_ALLOCED;
- + convert_setup(&input_conv, p_tenc, p_enc);
- + convert_setup(&output_conv, p_enc, p_tenc);
- }
- else
- p_tenc = empty_option;
- *** ../vim-6.2.397/src/os_win32.c Sat Mar 20 21:17:12 2004
- --- src/os_win32.c Tue Mar 23 20:33:33 2004
- ***************
- *** 163,169 ****
- static int g_fCBrkPressed = FALSE; /* set by ctrl-break interrupt */
- static int g_fCtrlCPressed = FALSE; /* set when ctrl-C or ctrl-break detected */
- static int g_fForceExit = FALSE; /* set when forcefully exiting */
- - static char_u g_chPending = NUL;
-
- static void termcap_mode_start(void);
- static void termcap_mode_end(void);
- --- 163,168 ----
- ***************
- *** 186,192 ****
- static void visual_bell(void);
- static void cursor_visible(BOOL fVisible);
- static BOOL write_chars(LPCSTR pchBuf, DWORD cchToWrite);
- ! static char_u tgetch(void);
- static void create_conin(void);
- static int s_cursor_visible = TRUE;
- static int did_create_conin = FALSE;
- --- 185,191 ----
- static void visual_bell(void);
- static void cursor_visible(BOOL fVisible);
- static BOOL write_chars(LPCSTR pchBuf, DWORD cchToWrite);
- ! static char_u tgetch(int *pmodifiers, char_u *pch2);
- static void create_conin(void);
- static int s_cursor_visible = TRUE;
- static int did_create_conin = FALSE;
- ***************
- *** 596,608 ****
- decode_key_event(
- KEY_EVENT_RECORD *pker,
- char_u *pch,
- ! char_u *pchPending,
- BOOL fDoPost)
- {
- int i;
- const int nModifs = pker->dwControlKeyState & (SHIFT | ALT | CTRL);
-
- ! *pch = *pchPending = NUL;
- g_fJustGotFocus = FALSE;
-
- /* ignore key up events */
- --- 595,608 ----
- decode_key_event(
- KEY_EVENT_RECORD *pker,
- char_u *pch,
- ! char_u *pch2,
- ! int *pmodifiers,
- BOOL fDoPost)
- {
- int i;
- const int nModifs = pker->dwControlKeyState & (SHIFT | ALT | CTRL);
-
- ! *pch = *pch2 = NUL;
- g_fJustGotFocus = FALSE;
-
- /* ignore key up events */
- ***************
- *** 649,655 ****
- if (pker->wVirtualKeyCode == VK_TAB && (nModifs & SHIFT_PRESSED))
- {
- *pch = K_NUL;
- ! *pchPending = '\017';
- return TRUE;
- }
-
- --- 649,655 ----
- if (pker->wVirtualKeyCode == VK_TAB && (nModifs & SHIFT_PRESSED))
- {
- *pch = K_NUL;
- ! *pch2 = '\017';
- return TRUE;
- }
-
- ***************
- *** 670,676 ****
- {
- if (VirtKeyMap[i].fAnsiKey)
- {
- ! *pchPending = *pch;
- *pch = K_NUL;
- }
-
- --- 670,676 ----
- {
- if (VirtKeyMap[i].fAnsiKey)
- {
- ! *pch2 = *pch;
- *pch = K_NUL;
- }
-
- ***************
- *** 685,695 ****
- *pch = NUL;
- else
- {
- ! *pch = (i > 0) ? pker->AChar : NUL;
- ! /* Interpret the ALT key as making the key META, but only when not
- ! * combined with CTRL (which is ALTGR). */
- ! if ((nModifs & ALT) != 0 && (nModifs & CTRL) == 0)
- ! *pch |= 0x80;
- }
-
- return (*pch != NUL);
- --- 685,711 ----
- *pch = NUL;
- else
- {
- ! *pch = (i > 0) ? pker->AChar : NUL;
- !
- ! if (pmodifiers != NULL)
- ! {
- ! /* Pass on the ALT key as a modifier, but only when not combined
- ! * with CTRL (which is ALTGR). */
- ! if ((nModifs & ALT) != 0 && (nModifs & CTRL) == 0)
- ! *pmodifiers |= MOD_MASK_ALT;
- !
- ! /* Pass on SHIFT only for special keys, because we don't know when
- ! * it's already included with the character. */
- ! if ((nModifs & SHIFT) != 0 && *pch <= 0x20)
- ! *pmodifiers |= MOD_MASK_SHIFT;
- !
- ! /* Pass on CTRL only for non-special keys, because we don't know
- ! * when it's already included with the character. And not when
- ! * combined with ALT (which is ALTGR). */
- ! if ((nModifs & CTRL) != 0 && (nModifs & ALT) == 0
- ! && *pch >= 0x20 && *pch < 0x80)
- ! *pmodifiers |= MOD_MASK_CTRL;
- ! }
- }
-
- return (*pch != NUL);
- ***************
- *** 1079,1085 ****
- #ifdef FEAT_CLIENTSERVER
- serverProcessPendingMessages();
- #endif
- ! if (g_chPending != NUL
- #ifdef FEAT_MOUSE
- || g_nMouseClick != -1
- #endif
- --- 1095,1101 ----
- #ifdef FEAT_CLIENTSERVER
- serverProcessPendingMessages();
- #endif
- ! if (0
- #ifdef FEAT_MOUSE
- || g_nMouseClick != -1
- #endif
- ***************
- *** 1146,1152 ****
- continue;
- }
- #endif
- ! if (decode_key_event(&ir.Event.KeyEvent, &ch, &ch2, FALSE))
- return TRUE;
- }
-
- --- 1162,1169 ----
- continue;
- }
- #endif
- ! if (decode_key_event(&ir.Event.KeyEvent, &ch, &ch2,
- ! NULL, FALSE))
- return TRUE;
- }
-
- ***************
- *** 1202,1218 ****
- * Get a keystroke or a mouse event
- */
- static char_u
- ! tgetch(void)
- {
- char_u ch;
-
- - if (g_chPending != NUL)
- - {
- - ch = g_chPending;
- - g_chPending = NUL;
- - return ch;
- - }
- -
- for (;;)
- {
- INPUT_RECORD ir;
- --- 1219,1228 ----
- * Get a keystroke or a mouse event
- */
- static char_u
- ! tgetch(int *pmodifiers, char_u *pch2)
- {
- char_u ch;
-
- for (;;)
- {
- INPUT_RECORD ir;
- ***************
- *** 1237,1243 ****
-
- if (ir.EventType == KEY_EVENT)
- {
- ! if (decode_key_event(&ir.Event.KeyEvent, &ch, &g_chPending, TRUE))
- return ch;
- }
- else if (ir.EventType == FOCUS_EVENT)
- --- 1247,1254 ----
-
- if (ir.EventType == KEY_EVENT)
- {
- ! if (decode_key_event(&ir.Event.KeyEvent, &ch, pch2,
- ! pmodifiers, TRUE))
- return ch;
- }
- else if (ir.EventType == FOCUS_EVENT)
- ***************
- *** 1355,1361 ****
- fputc('[', fdDump);
- #endif
-
- ! while ((len == 0 || WaitForChar(0L)) && len < maxlen)
- {
- if (typebuf_changed(tb_change_cnt))
- {
- --- 1366,1372 ----
- fputc('[', fdDump);
- #endif
-
- ! while ((len == 0 || WaitForChar(0L)) && len < maxlen - 1)
- {
- if (typebuf_changed(tb_change_cnt))
- {
- ***************
- *** 1384,1390 ****
- else
- #endif /* FEAT_MOUSE */
- {
- ! c = tgetch();
-
- if (typebuf_changed(tb_change_cnt))
- {
- --- 1395,1404 ----
- else
- #endif /* FEAT_MOUSE */
- {
- ! char_u ch2 = NUL;
- ! int modifiers = 0;
- !
- ! c = tgetch(&modifiers, &ch2);
-
- if (typebuf_changed(tb_change_cnt))
- {
- ***************
- *** 1406,1419 ****
- if (g_nMouseClick == -1)
- #endif
- {
- ! *buf++ = c;
- ! len++;
- #ifdef FEAT_MBYTE
- ! /* Only convert normal characters, not special keys. */
- if (input_conv.vc_type != CONV_NONE
- ! && (len == 1 || buf[-2] != K_NUL))
- ! len += convert_input(buf - 1, 1, maxlen - len + 1) - 1;
- #endif
-
- #ifdef MCH_WRITE_DUMP
- if (fdDump)
- --- 1420,1471 ----
- if (g_nMouseClick == -1)
- #endif
- {
- ! int n = 1;
- !
- ! /* A key may have one or two bytes. */
- ! buf[0] = c;
- ! if (ch2 != NUL)
- ! {
- ! buf[1] = ch2;
- ! ++n;
- ! }
- #ifdef FEAT_MBYTE
- ! /* Only convert normal characters, not special keys. Need to
- ! * convert before applying ALT, otherwise mapping <M-x> breaks
- ! * when 'tenc' is set. */
- if (input_conv.vc_type != CONV_NONE
- ! && (ch2 == NUL || c != K_NUL))
- ! n = convert_input(buf, n, maxlen - len);
- ! #endif
- !
- ! /* Use the ALT key to set the 8th bit of the character
- ! * when it's one byte, the 8th bit isn't set yet and not
- ! * using a double-byte encoding (would become a lead
- ! * byte). */
- ! if ((modifiers & MOD_MASK_ALT)
- ! && n == 1
- ! && (buf[0] & 0x80) == 0
- ! #ifdef FEAT_MBYTE
- ! && !enc_dbcs
- #endif
- + )
- + {
- + buf[0] |= 0x80;
- + modifiers &= ~MOD_MASK_ALT;
- + }
- +
- + if (modifiers != 0 && len + 4 < maxlen)
- + {
- + /* Prepend modifiers to the character. */
- + mch_memmove(buf + 3, buf, n);
- + buf[0] = K_SPECIAL;
- + buf[1] = (char_u)KS_MODIFIER;
- + buf[2] = modifiers;
- + n += 3;
- + }
- +
- + buf += n;
- + len += n;
-
- #ifdef MCH_WRITE_DUMP
- if (fdDump)
- *** ../vim-6.2.397/src/version.c Tue Mar 23 21:19:08 2004
- --- src/version.c Tue Mar 23 21:20:32 2004
- ***************
- *** 639,640 ****
- --- 639,642 ----
- { /* Add new patch number below this line */
- + /**/
- + 398,
- /**/
-
- --
- hundred-and-one symptoms of being an internet addict:
- 126. You brag to all of your friends about your date Saturday night...but
- you don't tell them it was only in a chat room.
-
- /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
- /// Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
- \\\ Project leader for A-A-P -- http://www.A-A-P.org ///
- \\\ Buy at Amazon and help AIDS victims -- http://ICCF.nl/click1.html ///
-