Loading ...
Sorry, an error occurred while loading the content.

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

Expand Messages
  • Christian Brabandt
    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
    Message 1 of 3 , Mar 4, 2013
    View Source
    • 0 Attachment
      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

      --
      --
      You received this message from the "vim_dev" maillist.
      Do not top-post! Type your reply below the text you are replying to.
      For more information, visit http://www.vim.org/maillist.php

      ---
      You received this message because you are subscribed to the Google Groups "vim_dev" group.
      To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
      For more options, visit https://groups.google.com/groups/opt_out.
    • Bram Moolenaar
      ... 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
      Message 2 of 3 , Mar 4, 2013
      View Source
      • 0 Attachment
        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 -- Bram@... -- 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 ///

        --
        --
        You received this message from the "vim_dev" maillist.
        Do not top-post! Type your reply below the text you are replying to.
        For more information, visit http://www.vim.org/maillist.php

        ---
        You received this message because you are subscribed to the Google Groups "vim_dev" group.
        To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
        For more options, visit https://groups.google.com/groups/opt_out.
      • Christian Brabandt
        ... Not sure, those keys are actual useful when recording a script. ... Nevermind, I just tried to replay such a script on Windows and didn t see any errors.
        Message 3 of 3 , Mar 5, 2013
        View Source
        • 0 Attachment
          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

          --
          --
          You received this message from the "vim_dev" maillist.
          Do not top-post! Type your reply below the text you are replying to.
          For more information, visit http://www.vim.org/maillist.php

          ---
          You received this message because you are subscribed to the Google Groups "vim_dev" group.
          To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
          For more options, visit https://groups.google.com/groups/opt_out.
        Your message has been successfully submitted and would be delivered to recipients shortly.