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

Re: [PATCH] add {dict} argument to getcharmod()

Expand Messages
  • tyru
    oops, sorry. forgot to fix getcharmod() s return value. should be Number or Dictionary , not Number . ... -- You received this message from the vim_dev
    Message 1 of 7 , Dec 1, 2011
    • 0 Attachment
      oops, sorry.
      forgot to fix getcharmod()'s return value. should be "Number or Dictionary", not "Number".

      On Thu, Dec 1, 2011 at 10:42 PM, tyru <tyru.exe@...> wrote:
      Hi list.

      I wrote a patch to add {dict} argument to getcharmod().
      `getcharmod(1)` returns Dictionary.

      It is a hassle to see the modifier keys pressed
      because Vimscript does not have bitwise AND operator.
      If getcharmod() had the feature, it is no more necessary for yak shaving like this: https://github.com/tyru/stickykey.vim/blob/aabe981322e7be283b3fc005070e1f99f449558f/autoload/stickykey.vim#L87-L126

      --
      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
    • tyru
      Yukihiro Nakadaira has told me that each value does not become 1 or 0. fixed in attached patch. ... -- You received this message from the vim_dev maillist.
      Message 2 of 7 , Dec 1, 2011
      • 0 Attachment
        Yukihiro Nakadaira has told me that each value does not become 1 or 0.
        fixed in attached patch.

        On Thu, Dec 1, 2011 at 10:49 PM, tyru <tyru.exe@...> wrote:
        oops, sorry.
        forgot to fix getcharmod()'s return value. should be "Number or Dictionary", not "Number".


        On Thu, Dec 1, 2011 at 10:42 PM, tyru <tyru.exe@...> wrote:
        Hi list.

        I wrote a patch to add {dict} argument to getcharmod().
        `getcharmod(1)` returns Dictionary.

        It is a hassle to see the modifier keys pressed
        because Vimscript does not have bitwise AND operator.
        If getcharmod() had the feature, it is no more necessary for yak shaving like this: https://github.com/tyru/stickykey.vim/blob/aabe981322e7be283b3fc005070e1f99f449558f/autoload/stickykey.vim#L87-L126


        --
        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
      • Bram Moolenaar
        ... I don t like the function returning a different type depending on an argument. Can we use a getcharmoddict() function instead? Another solution would be
        Message 3 of 7 , Dec 1, 2011
        • 0 Attachment
          Tyru wrote:

          > I wrote a patch to add {dict} argument to getcharmod().
          > `getcharmod(1)` returns Dictionary.
          >
          > It is a hassle to see the modifier keys pressed
          > because Vimscript does not have bitwise AND operator.
          > If getcharmod() had the feature, it is no more necessary for yak shaving
          > like this:
          > https://github.com/tyru/stickykey.vim/blob/aabe981322e7be283b3fc005070e1f99f449558f/autoload/stickykey.vim#L87-L126

          I don't like the function returning a different type depending on an
          argument. Can we use a getcharmoddict() function instead?

          Another solution would be to add a bitwise AND operator.

          Yet another solution to add a function that returns both the character
          and its modifier.

          --
          hundred-and-one symptoms of being an internet addict:
          226. You sit down at the computer right after dinner and your spouse
          says "See you in the morning."

          /// 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
        • Yukihiro Nakadaira
          `:help getcharmod()` is not correct. Result was changed by v7-0055. And mouse double, triple and quadruple do not have individual bit. Actual result is 2
          Message 4 of 7 , Dec 2, 2011
          • 0 Attachment
            `:help getcharmod()` is not correct.
            Result was changed by v7-0055.
            And mouse double, triple and quadruple do not have individual bit.
            Actual result is

            2 shift
            4 control
            8 alt
            16 meta (when it's different from ALT)
            32 mouse double click
            64 mouse triple click
            96 mouse quadruple click
            128 Macintosh only: command

            Two bits are used for mouse.
            0b00100000 = double
            0b01000000 = triple
            0b01100000 = quadruple

            Dictionary version should behave as following.

            function! Getcharmoddict()
            let mod = getcharmod()
            return {
            \ 'shift': mod / 2 % 2,
            \ 'control': mod / 4 % 2,
            \ 'alt': mod / 8 % 2,
            \ 'meta': mod / 16 % 2,
            \ 'mousedouble': mod / 32 % 4 == 1,
            \ 'mousetriple': mod / 32 % 4 == 2,
            \ 'mousequad': mod / 32 % 4 == 3,
            \ 'command': mod / 128 % 2,
            \ }
            endfunction

            --
            Yukihiro Nakadaira - yukihiro.nakadaira@...

            --
            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
          • Bram Moolenaar
            ... Thanks for the correction! ... Yep. -- hundred-and-one symptoms of being an internet addict: 235. You start naming your kids Pascal, COBOL, Algol and
            Message 5 of 7 , Dec 2, 2011
            • 0 Attachment
              Yukihiro Nakadaira wrote:

              > `:help getcharmod()` is not correct.
              > Result was changed by v7-0055.
              > And mouse double, triple and quadruple do not have individual bit.
              > Actual result is
              >
              > 2 shift
              > 4 control
              > 8 alt
              > 16 meta (when it's different from ALT)
              > 32 mouse double click
              > 64 mouse triple click
              > 96 mouse quadruple click
              > 128 Macintosh only: command

              Thanks for the correction!

              > Two bits are used for mouse.
              > 0b00100000 = double
              > 0b01000000 = triple
              > 0b01100000 = quadruple
              >
              > Dictionary version should behave as following.
              >
              > function! Getcharmoddict()
              > let mod = getcharmod()
              > return {
              > \ 'shift': mod / 2 % 2,
              > \ 'control': mod / 4 % 2,
              > \ 'alt': mod / 8 % 2,
              > \ 'meta': mod / 16 % 2,
              > \ 'mousedouble': mod / 32 % 4 == 1,
              > \ 'mousetriple': mod / 32 % 4 == 2,
              > \ 'mousequad': mod / 32 % 4 == 3,
              > \ 'command': mod / 128 % 2,
              > \ }
              > endfunction

              Yep.

              --
              hundred-and-one symptoms of being an internet addict:
              235. You start naming your kids Pascal, COBOL, Algol and Fortran.

              /// 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
            • tyru
              On Fri, Dec 2, 2011 at 6:40 PM, Yukihiro Nakadaira
              Message 6 of 7 , Dec 2, 2011
              • 0 Attachment
                On Fri, Dec 2, 2011 at 6:40 PM, Yukihiro Nakadaira <yukihiro.nakadaira@...> wrote:
                `:help getcharmod()` is not correct.
                Result was changed by v7-0055.
                And mouse double, triple and quadruple do not have individual bit.
                Actual result is

                 2   shift
                 4   control
                 8   alt
                 16  meta (when it's different from ALT)
                 32  mouse double click
                 64  mouse triple click
                 96  mouse quadruple click
                 128 Macintosh only: command

                Two bits are used for mouse.
                0b00100000 = double
                0b01000000 = triple
                0b01100000 = quadruple

                Dictionary version should behave as following.

                function! Getcharmoddict()
                 let mod = getcharmod()
                 return {
                       \ 'shift': mod / 2 % 2,
                       \ 'control': mod / 4 % 2,
                       \ 'alt': mod / 8 % 2,
                       \ 'meta': mod / 16 % 2,
                       \ 'mousedouble': mod / 32 % 4 == 1,
                       \ 'mousetriple': mod / 32 % 4 == 2,
                       \ 'mousequad': mod / 32 % 4 == 3,
                       \ 'command': mod / 128 % 2,
                       \ }
                endfunction
                oh, I don't think about that code...
                maybe this patch becomes useless.
                but that code should be on getcharmod() help, isn't it?
                 

                --
                Yukihiro Nakadaira - yukihiro.nakadaira@...

                --
                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 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
              Your message has been successfully submitted and would be delivered to recipients shortly.