X11 messageboxes should treat "\r\n" as "\n" by ignoring the '\r' char.
authorRyan C. Gordon <icculus@icculus.org>
Sun, 16 Dec 2012 14:39:49 -0500
changeset 67582a218048b45f
parent 6757 9935f71c8c81
child 6759 b74da0b33530
X11 messageboxes should treat "\r\n" as "\n" by ignoring the '\r' char.
src/video/x11/SDL_x11messagebox.c
test/testmessage.c
     1.1 --- a/src/video/x11/SDL_x11messagebox.c	Sat Dec 15 21:50:17 2012 -0800
     1.2 +++ b/src/video/x11/SDL_x11messagebox.c	Sun Dec 16 14:39:49 2012 -0500
     1.3 @@ -250,6 +250,10 @@
     1.4              data->text_height = IntMax( data->text_height, height );
     1.5              text_width_max = IntMax( text_width_max, plinedata->width );
     1.6  
     1.7 +            if (lf && (lf > text) && (lf[-1] == '\r')) {
     1.8 +                plinedata->length--;
     1.9 +            }
    1.10 +
    1.11              text += plinedata->length + 1;
    1.12  
    1.13              /* Break if there are no more linefeeds. */
     2.1 --- a/test/testmessage.c	Sat Dec 15 21:50:17 2012 -0800
     2.2 +++ b/test/testmessage.c	Sun Dec 16 14:39:49 2012 -0500
     2.3 @@ -49,6 +49,15 @@
     2.4          quit(1);
     2.5      }
     2.6  
     2.7 +    success = SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR,
     2.8 +                "Simple MessageBox",
     2.9 +                "This is a simple MessageBox with a newline:\r\nHello world!",
    2.10 +                NULL);
    2.11 +    if (success == -1) {
    2.12 +        printf("Error Presenting MessageBox: %s\n", SDL_GetError());
    2.13 +        quit(1);
    2.14 +    }
    2.15 +
    2.16      /* Google says this is Traditional Chinese for "beef with broccoli" */
    2.17      success = SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR,
    2.18                  "UTF-8 Simple MessageBox",
    2.19 @@ -59,6 +68,16 @@
    2.20          quit(1);
    2.21      }
    2.22  
    2.23 +    /* Google says this is Traditional Chinese for "beef with broccoli" */
    2.24 +    success = SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR,
    2.25 +                "UTF-8 Simple MessageBox",
    2.26 +                "Unicode text and newline:\r\n'牛肉西蘭花'\n'牛肉西蘭花'",
    2.27 +                NULL);
    2.28 +    if (success == -1) {
    2.29 +        printf("Error Presenting MessageBox: %s\n", SDL_GetError());
    2.30 +        quit(1);
    2.31 +    }
    2.32 +
    2.33      {
    2.34          const SDL_MessageBoxButtonData buttons[] = {
    2.35              {