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

clipboard for win9x

Expand Messages
  • Valery Kondakoff
    Hello, Glenn! ... Yes. Garbage characters that I was describing in my latest mail are looking exactly like these. GM Is this with or without the patch I
    Message 1 of 20 , Mar 13, 2003
    • 0 Attachment
      Hello, Glenn!

      13 ìàðòà 2003 ã., you wrote to me:

      >> 2. If I copy "Cañá" on VIM and paste it in the notepad I get "Cañá"

      Yes. 'Garbage characters' that I was describing in my latest mail are
      looking exactly like these.

      GM> Is this with or without the patch I attached to this thread?

      Glenn, excuse me for asking: if there is a place, where I can download
      GVIM build with your patch applied? (I'm not sure that I can compile
      CVIM by myself, but I'll try if there are no other ways to 'catch' the
      problem...). :)


      --
      Best regards,
      Valery Kondakoff
      http://www.nbk.orc.ru (Ne Bey Kopytom)
      http://www.nbk.orc.ru/mtb (MTB riding in Moscow)

      PGP key: mailto:pgp-public-keys@...?subject=GET%20strauss@...
    • Bram Moolenaar
      ... Yes, this problem exists. After including your previous patch I can now properly copy text in gvim (using encoding set to utf-8 ) and paste in Notepad.
      Message 2 of 20 , Mar 16, 2003
      • 0 Attachment
        Glenn Maynard wrote:

        > On Thu, Mar 06, 2003 at 04:16:53PM -0500, Glenn Maynard wrote:
        > > Try it in reverse; copy them (again one at a line) from Notepad and Word
        > > back to Vim.
        >
        > Here's one problem I've found--not due to the patch, but related: if we
        > ever get text from CF_TEXT, it'll be in the ANSI codepage, and we need
        > to convert it to p_enc. On NT, we never use CF_TEXT, since it'll
        > synthesize CF_UNICODETEXT for us.
        >
        > So, do we ever get CF_TEXT in 95? The recent Notepad problems seem to
        > indicate that we do. Can someone confirm this by copying "Latín tëxt"
        > into Vim on a 95 box with "encoding" set to UTF-8? I expect that
        > you'll see "Lat<ed>n t<eb>xt". (You don't need this patch to test this,
        > just CVS, though I'm still looking for someone to test it in 95.)

        Yes, this problem exists. After including your previous patch I can now
        properly copy text in gvim (using 'encoding' set to "utf-8") and paste in
        Notepad. Thus setting the CF_TEXT entry to text converted from
        'encoding' to the active codepage appears to work.

        The other way around doesn't work. Obviously Notepad only sets CF_TEXT
        and it is in the active codepage. When pasting CF_TEXT in Vim this must
        be converted to 'encoding'.

        Should not be difficult.... Below is a patch that combines the two
        directions. I also fixed a memory leak when using CF_UNICODETEXT.
        Please give this a try.

        -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
        *** ../vim61.406/src/os_mswin.c Sat Mar 15 16:54:47 2003
        --- src/os_mswin.c Sun Mar 16 16:47:15 2003
        ***************
        *** 971,977 ****

        utf8_str = alloc((unsigned)length);
        if (utf8_str != NULL)
        ! WideCharToMultiByte(enc_dbcs, 0, str, *len, utf8_str, length, 0,0);
        *len = length;
        return utf8_str;
        }
        --- 971,977 ----

        utf8_str = alloc((unsigned)length);
        if (utf8_str != NULL)
        ! WideCharToMultiByte(enc_dbcs, 0, str, *len, utf8_str, length, 0, 0);
        *len = length;
        return utf8_str;
        }
        ***************
        *** 1022,1027 ****
        --- 1022,1028 ----
        VimClipType_t metadata = { -1, -1, -1 };
        HGLOBAL hMem = NULL;
        char_u *str = NULL;
        + char_u *to_free = NULL;
        char_u *hMemStr = NULL;
        int str_size = 0;
        int maxlen;
        ***************
        *** 1076,1082 ****
        if (hMemWstr[str_size] == NUL)
        break;
        }
        ! str = ucs2_to_enc(hMemWstr, &str_size);
        GlobalUnlock(hMemW);
        }
        }
        --- 1077,1083 ----
        if (hMemWstr[str_size] == NUL)
        break;
        }
        ! to_free = str = ucs2_to_enc(hMemWstr, &str_size);
        GlobalUnlock(hMemW);
        }
        }
        ***************
        *** 1105,1110 ****
        --- 1106,1128 ----
        if (str[str_size] == NUL)
        break;
        }
        +
        + /* The text is now in the active codepage. Convert to 'encoding',
        + * going through UCS-2. */
        + maxlen = MultiByteToWideChar(CP_ACP, 0, str, str_size, NULL, 0);
        + to_free = alloc((unsigned)(maxlen * sizeof(WCHAR)));
        + if (to_free != NULL)
        + {
        + MultiByteToWideChar(CP_ACP, 0, str, str_size,
        + (WCHAR *)to_free, maxlen);
        + str_size = maxlen;
        + str = ucs2_to_enc((WCHAR *)to_free, &str_size);
        + if (str != NULL)
        + {
        + vim_free(to_free);
        + to_free = str;
        + }
        + }
        }
        }

        ***************
        *** 1129,1134 ****
        --- 1147,1153 ----
        if (hMemStr != NULL)
        GlobalUnlock(hMem);
        CloseClipboard();
        + vim_free(to_free);
        }

        /*
        ***************
        *** 1138,1144 ****
        clip_mch_set_selection(VimClipboard *cbd)
        {
        char_u *str = NULL;
        - long_u str_len;
        VimClipType_t metadata;
        HGLOBAL hMem = NULL;
        HGLOBAL hMemVim = NULL;
        --- 1157,1162 ----
        ***************
        *** 1152,1167 ****
        cbd->owned = FALSE;

        /* Get the text to be put on the clipboard, with CR-LF. */
        ! metadata.type = clip_convert_selection(&str, &str_len, cbd);
        if (metadata.type < 0)
        return;
        - metadata.txtlen = str_len;
        metadata.ucslen = 0;

        # if defined(FEAT_MBYTE) && defined(WIN3264)
        {
        WCHAR *out;
        ! int len = str_len;

        /* Convert the text to UCS-2. This is put on the clipboard as
        * CF_UNICODETEXT. */
        --- 1170,1184 ----
        cbd->owned = FALSE;

        /* Get the text to be put on the clipboard, with CR-LF. */
        ! metadata.type = clip_convert_selection(&str, &metadata.txtlen, cbd);
        if (metadata.type < 0)
        return;
        metadata.ucslen = 0;

        # if defined(FEAT_MBYTE) && defined(WIN3264)
        {
        WCHAR *out;
        ! int len = metadata.txtlen;

        /* Convert the text to UCS-2. This is put on the clipboard as
        * CF_UNICODETEXT. */
        ***************
        *** 1170,1175 ****
        --- 1187,1206 ----
        {
        WCHAR *lpszMemW;

        + /* Convert the text for CF_TEXT to ANSI codepage. Otherwise it's
        + * p_enc, which has no relation to the ANSI codepage. */
        + metadata.txtlen = WideCharToMultiByte(CP_ACP, 0, out, len,
        + NULL, 0, 0, 0);
        + vim_free(str);
        + str = (char_u *)alloc((unsigned)metadata.txtlen);
        + if (str == NULL)
        + {
        + vim_free(out);
        + return; /* out of memory */
        + }
        + WideCharToMultiByte(CP_ACP, 0, out, len,
        + str, metadata.txtlen, 0, 0);
        +
        /* Allocate memory for the UCS-2 text, add one NUL word to
        * terminate the string. */
        hMemW = (LPSTR)GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE,
        ***************
        *** 1189,1202 ****

        /* Allocate memory for the text, add one NUL byte to terminate the string.
        */
        ! hMem = GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, str_len + 1);
        {
        LPSTR lpszMem = (LPSTR)GlobalLock(hMem);

        if (lpszMem)
        {
        ! STRNCPY(lpszMem, str, str_len);
        ! lpszMem[str_len] = NUL;
        GlobalUnlock(hMem);
        }
        }
        --- 1220,1233 ----

        /* Allocate memory for the text, add one NUL byte to terminate the string.
        */
        ! hMem = GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, metadata.txtlen + 1);
        {
        LPSTR lpszMem = (LPSTR)GlobalLock(hMem);

        if (lpszMem)
        {
        ! STRNCPY(lpszMem, str, metadata.txtlen);
        ! lpszMem[metadata.txtlen] = NUL;
        GlobalUnlock(hMem);
        }
        }
        ***************
        *** 1230,1237 ****
        # if defined(FEAT_MBYTE) && defined(WIN3264)
        if (hMemW != NULL)
        {
        ! SetClipboardData(CF_UNICODETEXT, hMemW);
        ! hMemW = 0;
        }
        # endif
        /* Always use CF_TEXT. On Win98 Notepad won't obtain the
        --- 1261,1268 ----
        # if defined(FEAT_MBYTE) && defined(WIN3264)
        if (hMemW != NULL)
        {
        ! if (SetClipboardData(CF_UNICODETEXT, hMemW) != NULL)
        ! hMemW = NULL;
        }
        # endif
        /* Always use CF_TEXT. On Win98 Notepad won't obtain the


        --
        From "know your smileys":
        (X0||) Double hamburger with lettuce and tomato

        /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
        /// Creator of Vim - Vi IMproved -- http://www.Vim.org \\\
        \\\ Project leader for A-A-P -- http://www.A-A-P.org ///
        \\\ Help AIDS victims, buy at Amazon -- http://ICCF.nl/click1.html ///
      • Valery Kondakoff
        Hello, Bram! Sunday, March 16, 2003, you wrote to me: BM Should not be difficult.... Below is a patch that combines the two BM directions. I also fixed a
        Message 3 of 20 , Mar 25, 2003
        • 0 Attachment
          Hello, Bram!

          Sunday, March 16, 2003, you wrote to me:

          BM> Should not be difficult.... Below is a patch that combines the two
          BM> directions. I also fixed a memory leak when using CF_UNICODETEXT.
          BM> Please give this a try.

          BM> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
          BM> *** ../vim61.406/src/os_mswin.c Sat Mar 15 16:54:47 2003
          BM> --- src/os_mswin.c Sun Mar 16 16:47:15 2003

          Please, can you give me rather more details how to apply this patch?
          I'm a real newbie in "patching". With a little help of VIM-community I
          was able to apply 'official' patches. But I still can't understand
          what 'os_mswin.c' revision do I need to have to successfully apply
          your patch.

          When applying your patch on clean 'os_mswin.c' or 'os_mswin.c' with
          all official patches applyed, I receive an error:

          Patching file src/os_mswin.c using Plan A...
          Hunk #1 FAILED at 971.
          Hunk #2 FAILED at 1022.
          Hunk #3 FAILED at 1077.
          Hunk #4 FAILED at 1106.
          Hunk #5 succeeded at 1147 with fuzz 2.
          Hunk #6 FAILED at 1157.
          Hunk #7 FAILED at 1170.
          Hunk #8 FAILED at 1187.
          Hunk #9 FAILED at 1220.
          Hunk #10 FAILED at 1261.
          9 out of 10 hunks FAILED -- saving rejects to file src/os_mswin.c.rej

          Do I need to find a special 'os_mswin.c' version in CVS?

          Thank you in advance! (I think I need to try this patch and
          'strftime_encoding' one, because I'm working in multilangiage
          environment).

          --
          Best regards,
          Valery Kondakoff
          http://www.nbk.orc.ru (Ne Bey Kopytom)
          http://www.nbk.orc.ru/mtb (MTB riding in Moscow)

          PGP key: mailto:pgp-public-keys@...?subject=GET%20strauss@...

          np: Simon Raymonde - The Seventh Day (Blame Someone Else) [stopped]
        • Bram Moolenaar
          ... First make sure the patch file and the source file use the same line endings. Both dos and unix fileformats work, but they must match. I m not sure if
          Message 4 of 20 , Mar 26, 2003
          • 0 Attachment
            Valery Kondakoff wrote:

            > Please, can you give me rather more details how to apply this patch?
            > I'm a real newbie in "patching". With a little help of VIM-community I
            > was able to apply 'official' patches. But I still can't understand
            > what 'os_mswin.c' revision do I need to have to successfully apply
            > your patch.
            >
            > When applying your patch on clean 'os_mswin.c' or 'os_mswin.c' with
            > all official patches applyed, I receive an error:
            >
            > Patching file src/os_mswin.c using Plan A...
            > Hunk #1 FAILED at 971.
            > Hunk #2 FAILED at 1022.
            > Hunk #3 FAILED at 1077.
            > Hunk #4 FAILED at 1106.
            > Hunk #5 succeeded at 1147 with fuzz 2.
            > Hunk #6 FAILED at 1157.
            > Hunk #7 FAILED at 1170.
            > Hunk #8 FAILED at 1187.
            > Hunk #9 FAILED at 1220.
            > Hunk #10 FAILED at 1261.
            > 9 out of 10 hunks FAILED -- saving rejects to file src/os_mswin.c.rej
            >
            > Do I need to find a special 'os_mswin.c' version in CVS?

            First make sure the patch file and the source file use the same line
            endings. Both dos and unix fileformats work, but they must match.

            I'm not sure if this patch depends on previous patches. Simplest is to
            obtain the latest version through CVS. See the CVS page on
            www.vim.org for that.

            --
            hundred-and-one symptoms of being an internet addict:
            214. Your MCI "Circle of Friends" are all Hayes-compatible.

            /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
            /// Creator of Vim - Vi IMproved -- http://www.Vim.org \\\
            \\\ Project leader for A-A-P -- http://www.A-A-P.org ///
            \\\ Help AIDS victims, buy at Amazon -- http://ICCF.nl/click1.html ///
          Your message has been successfully submitted and would be delivered to recipients shortly.