test/testime.c
changeset 4756 b99b1024607a
parent 4465 3e69e077cb95
child 4757 140be6839185
     1.1 --- a/test/testime.c	Sun Jul 18 13:48:23 2010 -0400
     1.2 +++ b/test/testime.c	Sat Jul 24 20:48:50 2010 -0400
     1.3 @@ -25,7 +25,7 @@
     1.4  SDL_Rect textRect, markedRect;
     1.5  Uint32 lineColor, backColor;
     1.6  SDL_Color textColor = { 0, 0, 0 };
     1.7 -char text[MAX_TEXT_LENGTH], *markedText;
     1.8 +char text[MAX_TEXT_LENGTH], markedText[SDL_TEXTEDITINGEVENT_TEXT_SIZE];
     1.9  
    1.10  void usage()
    1.11  {
    1.12 @@ -124,7 +124,7 @@
    1.13  
    1.14      text[0] = 0;
    1.15      markedRect = textRect;
    1.16 -    markedText = NULL;
    1.17 +    markedText[0] = 0;
    1.18  
    1.19      SDL_StartTextInput();
    1.20  }
    1.21 @@ -178,7 +178,7 @@
    1.22      cursorRect.h = h;
    1.23  
    1.24      SDL_FillRect(screen, &markedRect, backColor);
    1.25 -    if (markedText)
    1.26 +    if (markedText[0])
    1.27      {
    1.28  #ifdef HAVE_SDL_TTF
    1.29          RenderText(screen, font, markedText, markedRect.x, markedRect.y, textColor);
    1.30 @@ -293,13 +293,13 @@
    1.31              fprintf(stderr, "Keyboard: text input \"%s\"\n", event.text.text);
    1.32  
    1.33              if (SDL_strlen(text) + SDL_strlen(event.text.text) < sizeof(text))
    1.34 -                strcpy(text + SDL_strlen(text), event.text.text);
    1.35 +                strcat(text, event.text.text);
    1.36  
    1.37              fprintf(stderr, "text inputed: %s\n", text);
    1.38  
    1.39              // After text inputed, we can clear up markedText because it
    1.40              // is committed
    1.41 -            markedText = NULL;
    1.42 +            markedText[0] = 0;
    1.43              Redraw();
    1.44              break;
    1.45  
    1.46 @@ -307,7 +307,7 @@
    1.47              fprintf(stderr, "text editing \"%s\", selected range (%d, %d)\n",
    1.48                      event.edit.text, event.edit.start, event.edit.length);
    1.49  
    1.50 -            markedText = event.edit.text;
    1.51 +            strcpy(markedText, event.edit.text);
    1.52              Redraw();
    1.53              break;
    1.54