test/testime.c
changeset 10111 c14536d0deff
parent 10100 a18ec339c8d3
child 10416 d6e839e8b339
     1.1 --- a/test/testime.c	Thu Mar 10 21:00:13 2016 +0100
     1.2 +++ b/test/testime.c	Thu Mar 10 21:00:27 2016 +0100
     1.3 @@ -110,7 +110,6 @@
     1.4  #endif
     1.5  }
     1.6  
     1.7 -
     1.8  void _Redraw(SDL_Renderer * renderer) {
     1.9      int w = 0, h = textRect.h;
    1.10      SDL_Rect cursorRect, underlineRect;
    1.11 @@ -122,9 +121,14 @@
    1.12      if (*text)
    1.13      {
    1.14          SDL_Surface *textSur = TTF_RenderUTF8_Blended(font, text, textColor);
    1.15 -        SDL_Rect dest = {textRect.x, textRect.y, textSur->w, textSur->h };
    1.16 +        SDL_Rect dest;
    1.17 +        SDL_Texture *texture;
    1.18 +        dest.x = textRect.x;
    1.19 +        dest.y = textRect.y;
    1.20 +        dest.w = textSur->w;
    1.21 +        dest.h = textSur->h;
    1.22  
    1.23 -        SDL_Texture *texture = SDL_CreateTextureFromSurface(renderer,textSur);
    1.24 +        texture = SDL_CreateTextureFromSurface(renderer,textSur);
    1.25          SDL_FreeSurface(textSur);
    1.26  
    1.27          SDL_RenderCopy(renderer,texture,NULL,&dest);
    1.28 @@ -156,6 +160,9 @@
    1.29      if (markedText[0])
    1.30      {
    1.31  #ifdef HAVE_SDL_TTF
    1.32 +        SDL_Surface *textSur;
    1.33 +        SDL_Rect dest;
    1.34 +        SDL_Texture *texture;
    1.35          if (cursor)
    1.36          {
    1.37              char *p = utf8_advance(markedText, cursor);
    1.38 @@ -169,10 +176,13 @@
    1.39              cursorRect.x += w;
    1.40              *p = c;
    1.41          }
    1.42 -        SDL_Surface *textSur = TTF_RenderUTF8_Blended(font, markedText, textColor);
    1.43 -        SDL_Rect dest = {markedRect.x, markedRect.y, textSur->w, textSur->h };
    1.44 +        textSur = TTF_RenderUTF8_Blended(font, markedText, textColor);
    1.45 +        dest.x = markedRect.x;
    1.46 +        dest.y = markedRect.y;
    1.47 +        dest.w = textSur->w;
    1.48 +        dest.h = textSur->h;
    1.49          TTF_SizeUTF8(font, markedText, &w, &h);
    1.50 -        SDL_Texture *texture = SDL_CreateTextureFromSurface(renderer,textSur);
    1.51 +        texture = SDL_CreateTextureFromSurface(renderer,textSur);
    1.52          SDL_FreeSurface(textSur);
    1.53  
    1.54          SDL_RenderCopy(renderer,texture,NULL,&dest);