[patch] make vim skip K_SPECIAL and following bytes when using -W

11 views
Skip to first unread message

Christian Brabandt

unread,
Mar 4, 2013, 2:54:54 PM3/4/13
to vim...@vim.org
Bram,
there seems to be a problem, that vim also records K_SPECIAL and the
following bytes that are used for mouseclicks, and which seems to be a
problem when replaying a script in Windows.
See this question stackoverflow:
http://stackoverflow.com/questions/3981535/using-the-w-option-of-vim

This patch fixes it by making sure, when writing the scriptout file, to
skip the K_SPECIAL and following bytes.

diff --git a/src/getchar.c b/src/getchar.c
--- a/src/getchar.c
+++ b/src/getchar.c
@@ -1228,6 +1228,7 @@
int c;
char_u buf[2];
int todo = len;
+ static int skip = 0;

/* remember how many chars were last recorded */
if (Recording)
@@ -1238,13 +1239,26 @@
{
/* Handle one byte at a time; no translation to be done. */
c = *s++;
- updatescript(c);

if (Recording)
{
buf[0] = c;
add_buff(&recordbuff, buf, 1L);
}
+
+#ifdef FEAT_GUI
+ /* but skip K_SPECIAL and following bytes */
+ if (c == K_SPECIAL || skip)
+ {
+ if (c == K_SPECIAL)
+ skip = 2; /* skip K_SPECIAL and following 2 bytes */
+ else
+ skip--;
+ continue;
+ }
+#endif
+ updatescript(c);
+
}
may_sync_undo();



Mit freundlichen Gr��en
Christian
--
Du kannst nicht verhindern, da� ein Vogelschwarm �ber deinen Kopf
hinwegfliegt. Aber du kannst verhindern, da� er in deinen Haaren
nistet.
-- Martin Luther

Bram Moolenaar

unread,
Mar 4, 2013, 5:32:42 PM3/4/13
to Christian Brabandt, vim...@vim.org

Christian Brabandt wrote:

> Bram,
> there seems to be a problem, that vim also records K_SPECIAL and the
> following bytes that are used for mouseclicks, and which seems to be a
> problem when replaying a script in Windows.
> See this question stackoverflow:
> http://stackoverflow.com/questions/3981535/using-the-w-option-of-vim
>
> This patch fixes it by making sure, when writing the scriptout file, to
> skip the K_SPECIAL and following bytes.

Dropping all K_SPECIAL codes would mean some commands get lost, right?
How about inserting a CSI character (0x80) ?


--
How To Keep A Healthy Level Of Insanity:
6. In the memo field of all your checks, write "for sexual favors".

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Christian Brabandt

unread,
Mar 5, 2013, 11:58:37 AM3/5/13
to Bram Moolenaar, vim...@vim.org
On Mon, March 4, 2013 23:32, Bram Moolenaar wrote:
> Christian Brabandt wrote:
>> Bram,
>> there seems to be a problem, that vim also records K_SPECIAL and the
>> following bytes that are used for mouseclicks, and which seems to be a
>> problem when replaying a script in Windows.
>> See this question stackoverflow:
>> http://stackoverflow.com/questions/3981535/using-the-w-option-of-vim
>>
>> This patch fixes it by making sure, when writing the scriptout file, to
>> skip the K_SPECIAL and following bytes.
>
> Dropping all K_SPECIAL codes would mean some commands get lost, right?

Not sure, those keys are actual useful when recording a script.

> How about inserting a CSI character (0x80) ?

Nevermind, I just tried to replay such a script on Windows
and didn't see any errors. Perhaps he used :source to source such a
script and didn't use :source! and I don't see
an error with using the parameter -s so it seems ok for now.

I wonder, why people start complaining over there at Stackoverflow
and don't write actual bug reports anymore.

regards,
Christian

Reply all
Reply to author
Forward
0 new messages