Mercurial > sdl-ios-xcode
changeset 4756:b99b1024607a
Changed markedText to have its own storage to resolve multiple bugs.
Changed an odd strcpy to a more appropriate strcat.
author | dewyatt |
---|---|
date | Sat, 24 Jul 2010 20:48:50 -0400 |
parents | 436183eb30c8 |
children | 140be6839185 |
files | test/testime.c |
diffstat | 1 files changed, 6 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/test/testime.c Sun Jul 18 13:48:23 2010 -0400 +++ b/test/testime.c Sat Jul 24 20:48:50 2010 -0400 @@ -25,7 +25,7 @@ SDL_Rect textRect, markedRect; Uint32 lineColor, backColor; SDL_Color textColor = { 0, 0, 0 }; -char text[MAX_TEXT_LENGTH], *markedText; +char text[MAX_TEXT_LENGTH], markedText[SDL_TEXTEDITINGEVENT_TEXT_SIZE]; void usage() { @@ -124,7 +124,7 @@ text[0] = 0; markedRect = textRect; - markedText = NULL; + markedText[0] = 0; SDL_StartTextInput(); } @@ -178,7 +178,7 @@ cursorRect.h = h; SDL_FillRect(screen, &markedRect, backColor); - if (markedText) + if (markedText[0]) { #ifdef HAVE_SDL_TTF RenderText(screen, font, markedText, markedRect.x, markedRect.y, textColor); @@ -293,13 +293,13 @@ fprintf(stderr, "Keyboard: text input \"%s\"\n", event.text.text); if (SDL_strlen(text) + SDL_strlen(event.text.text) < sizeof(text)) - strcpy(text + SDL_strlen(text), event.text.text); + strcat(text, event.text.text); fprintf(stderr, "text inputed: %s\n", text); // After text inputed, we can clear up markedText because it // is committed - markedText = NULL; + markedText[0] = 0; Redraw(); break; @@ -307,7 +307,7 @@ fprintf(stderr, "text editing \"%s\", selected range (%d, %d)\n", event.edit.text, event.edit.start, event.edit.length); - markedText = event.edit.text; + strcpy(markedText, event.edit.text); Redraw(); break;