src/video/windows/SDL_windowsclipboard.c
changeset 7332 b53acf6ab70b
parent 7191 75360622e65f
child 7721 bdf8c2c84e14
equal deleted inserted replaced
7308:728e5f22a82f 7332:b53acf6ab70b
    75 
    75 
    76         /* Save the data to the clipboard */
    76         /* Save the data to the clipboard */
    77         hMem = GlobalAlloc(GMEM_MOVEABLE, size);
    77         hMem = GlobalAlloc(GMEM_MOVEABLE, size);
    78         if (hMem) {
    78         if (hMem) {
    79             LPTSTR dst = (LPTSTR)GlobalLock(hMem);
    79             LPTSTR dst = (LPTSTR)GlobalLock(hMem);
    80             /* Copy the text over, adding carriage returns as necessary */
    80             if (dst) {
    81             for (i = 0; tstr[i]; ++i) {
    81                 /* Copy the text over, adding carriage returns as necessary */
    82                 if (tstr[i] == '\n' && (i == 0 || tstr[i-1] != '\r')) {
    82                 for (i = 0; tstr[i]; ++i) {
    83                     *dst++ = '\r';
    83                     if (tstr[i] == '\n' && (i == 0 || tstr[i-1] != '\r')) {
       
    84                         *dst++ = '\r';
       
    85                     }
       
    86                     *dst++ = tstr[i];
    84                 }
    87                 }
    85                 *dst++ = tstr[i];
    88                 *dst = 0;
       
    89                 GlobalUnlock(hMem);
    86             }
    90             }
    87             *dst = 0;
       
    88             GlobalUnlock(hMem);
       
    89 
    91 
    90             EmptyClipboard();
    92             EmptyClipboard();
    91             if (!SetClipboardData(TEXT_FORMAT, hMem)) {
    93             if (!SetClipboardData(TEXT_FORMAT, hMem)) {
    92                 result = WIN_SetError("Couldn't set clipboard data");
    94                 result = WIN_SetError("Couldn't set clipboard data");
    93             }
    95             }