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

Re: Make langmap accept multi-byte characters

Expand Messages
  • Konstantin Korikov
    ... This patch have a mistake here: /* insert new page at position a */ pages = (langmap_page_T*)(langmap_pages.ga_data) + a; mch_memmove(pages + 1, pages,
    Message 1 of 10 , Oct 15, 2006
    • 0 Attachment
      > http://lostclus.linux.kiev.ua/patches/all/vim70-langmapmb-2.patch
      >
      > I use combination of binary search and simple array lockup.

      This patch have a mistake here:

      /* insert new page at position a */
      pages = (langmap_page_T*)(langmap_pages.ga_data) + a;
      mch_memmove(pages + 1, pages,
      (langmap_pages.ga_len - a) * sizeof(langmap_page_T));
      ++langmap_pages.ga_len;
      pages[0].num = page_num;
      /* init with a-one-to one map */
      for (b = 0; b < (1 << LANGMAP_PAGESIZE_POT); b++)
      pages[0].charmap[b] = b;

      Last loop will correctly initialize array only if page number is zero.
      To resolve this problem

      char_u charmap[1 << LANGMAP_PAGESIZE_POT];

      needs to be replaced with

      int charmap[1 << LANGMAP_PAGESIZE_POT];

      But this will increase memory usage in 4 (for 32 bit machines) times.
      Another solution: fill array with zeros and insert addition check in
      LANGMAP_ADJUST.

      But I think there is no reason to complicate this task and separate
      entry for each key will be really optimal way, that keeps task simple.

      Thanks.

      http://lostclus.linux.kiev.ua/patches/all/vim70-langmapmb-3.patch

      --
      Best regards,
      Konstantin Korikov
      --------------------------------------------------
      gstreamer-0.10.4 - GStreamer streaming media framework runtime
      --------------------------------------------------
    • Bram Moolenaar
      ... Looks OK. The lookup will be a little slower, but I doubt if someone would notice. I wonder if there is any to entry that doesn t fit in 8 bits. All
      Message 2 of 10 , Oct 15, 2006
      • 0 Attachment
        Konstantin Korikov wrote:

        > > http://lostclus.linux.kiev.ua/patches/all/vim70-langmapmb-2.patch
        > >
        > > I use combination of binary search and simple array lockup.
        >
        > This patch have a mistake here:
        >
        > /* insert new page at position a */
        > pages = (langmap_page_T*)(langmap_pages.ga_data) + a;
        > mch_memmove(pages + 1, pages,
        > (langmap_pages.ga_len - a) * sizeof(langmap_page_T));
        > ++langmap_pages.ga_len;
        > pages[0].num = page_num;
        > /* init with a-one-to one map */
        > for (b = 0; b < (1 << LANGMAP_PAGESIZE_POT); b++)
        > pages[0].charmap[b] = b;
        >
        > Last loop will correctly initialize array only if page number is zero.
        > To resolve this problem
        >
        > char_u charmap[1 << LANGMAP_PAGESIZE_POT];
        >
        > needs to be replaced with
        >
        > int charmap[1 << LANGMAP_PAGESIZE_POT];
        >
        > But this will increase memory usage in 4 (for 32 bit machines) times.
        > Another solution: fill array with zeros and insert addition check in
        > LANGMAP_ADJUST.
        >
        > But I think there is no reason to complicate this task and separate
        > entry for each key will be really optimal way, that keeps task simple.
        >
        > Thanks.
        >
        > http://lostclus.linux.kiev.ua/patches/all/vim70-langmapmb-3.patch

        Looks OK. The lookup will be a little slower, but I doubt if someone
        would notice.

        I wonder if there is any "to" entry that doesn't fit in 8 bits. All
        Normal mode commands are 8 bit. Perhaps we should give a warning when
        someone tries to langmap a character to a multi-byte character?

        --
        Just remember...if the world didn't suck, we'd all fall off.

        /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
        /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
        \\\ download, build and distribute -- http://www.A-A-P.org ///
        \\\ help me help AIDS victims -- http://ICCF-Holland.org ///
      • Konstantin Korikov
        ... I added such warning. http://lostclus.linux.kiev.ua/patches/all/vim70-langmapmb-4.patch -- Best regards, Konstantin Korikov ... eel2-2.14.3 - Eazel
        Message 3 of 10 , Oct 15, 2006
        • 0 Attachment
          > I wonder if there is any "to" entry that doesn't fit in 8 bits. All
          > Normal mode commands are 8 bit. Perhaps we should give a warning when
          > someone tries to langmap a character to a multi-byte character?

          I added such warning.

          http://lostclus.linux.kiev.ua/patches/all/vim70-langmapmb-4.patch

          --
          Best regards,
          Konstantin Korikov
          --------------------------------------------------
          eel2-2.14.3 - Eazel Extensions Library.
          --------------------------------------------------
        Your message has been successfully submitted and would be delivered to recipients shortly.