Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
X11 messageboxes should treat "\r\n" as "\n" by ignoring the '\r' char.
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Dec 16, 2012
1 parent 5c0dd47 commit e45148d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/video/x11/SDL_x11messagebox.c
Expand Up @@ -250,6 +250,10 @@ X11_MessageBoxInitPositions( SDL_MessageBoxDataX11 *data )
data->text_height = IntMax( data->text_height, height );
text_width_max = IntMax( text_width_max, plinedata->width );

if (lf && (lf > text) && (lf[-1] == '\r')) {
plinedata->length--;
}

text += plinedata->length + 1;

/* Break if there are no more linefeeds. */
Expand Down
19 changes: 19 additions & 0 deletions test/testmessage.c
Expand Up @@ -49,6 +49,15 @@ main(int argc, char *argv[])
quit(1);
}

success = SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR,
"Simple MessageBox",
"This is a simple MessageBox with a newline:\r\nHello world!",
NULL);
if (success == -1) {
printf("Error Presenting MessageBox: %s\n", SDL_GetError());
quit(1);
}

/* Google says this is Traditional Chinese for "beef with broccoli" */
success = SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR,
"UTF-8 Simple MessageBox",
Expand All @@ -59,6 +68,16 @@ main(int argc, char *argv[])
quit(1);
}

/* Google says this is Traditional Chinese for "beef with broccoli" */
success = SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR,
"UTF-8 Simple MessageBox",
"Unicode text and newline:\r\n'牛肉西蘭花'\n'牛肉西蘭花'",
NULL);
if (success == -1) {
printf("Error Presenting MessageBox: %s\n", SDL_GetError());
quit(1);
}

{
const SDL_MessageBoxButtonData buttons[] = {
{
Expand Down

0 comments on commit e45148d

Please sign in to comment.