test/testime.c
author Philipp Wiesemann <philipp.wiesemann@arcor.de>
Wed, 17 Aug 2016 21:04:50 +0200
changeset 10275 ba7dc3ebb81e
parent 10111 c14536d0deff
permissions -rw-r--r--
Emscripten: Fixed opening previously closed joystick.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5244
diff changeset
     1
/*
9998
f67cf37e9cd4 Updated copyright to 2016
Sam Lantinga <slouken@libsdl.org>
parents: 9938
diff changeset
     2
  Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5244
diff changeset
     3
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5244
diff changeset
     4
  This software is provided 'as-is', without any express or implied
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5244
diff changeset
     5
  warranty.  In no event will the authors be held liable for any damages
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5244
diff changeset
     6
  arising from the use of this software.
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5244
diff changeset
     7
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5244
diff changeset
     8
  Permission is granted to anyone to use this software for any purpose,
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5244
diff changeset
     9
  including commercial applications, and to alter it and redistribute it
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5244
diff changeset
    10
  freely.
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5244
diff changeset
    11
*/
6251
3e8c673cad58 Removing some more references to SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents: 5535
diff changeset
    12
/* A simple program to test the Input Method support in the SDL library (2.0+) */
3338
9de326b3099c Fixed bug #817
Sam Lantinga <slouken@libsdl.org>
parents: 3281
diff changeset
    13
3280
00cace2d9080 Merged a cleaned up version of Jiang's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    14
#include <stdlib.h>
00cace2d9080 Merged a cleaned up version of Jiang's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    15
#include <stdio.h>
00cace2d9080 Merged a cleaned up version of Jiang's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    16
#include <string.h>
00cace2d9080 Merged a cleaned up version of Jiang's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    17
00cace2d9080 Merged a cleaned up version of Jiang's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    18
#include "SDL.h"
00cace2d9080 Merged a cleaned up version of Jiang's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    19
#ifdef HAVE_SDL_TTF
00cace2d9080 Merged a cleaned up version of Jiang's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    20
#include "SDL_ttf.h"
00cace2d9080 Merged a cleaned up version of Jiang's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    21
#endif
3338
9de326b3099c Fixed bug #817
Sam Lantinga <slouken@libsdl.org>
parents: 3281
diff changeset
    22
6785
c094c438c0a6 Switched the test code over to use the common functions in the test library.
Sam Lantinga <slouken@libsdl.org>
parents: 6318
diff changeset
    23
#include "SDL_test_common.h"
6318
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
    24
3280
00cace2d9080 Merged a cleaned up version of Jiang's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    25
#define DEFAULT_PTSIZE  30
5150
1435f8a6425c Nobody is currently maintaining the QNX code, so removing it for now.
Sam Lantinga <slouken@libsdl.org>
parents: 4763
diff changeset
    26
#define DEFAULT_FONT    "/System/Library/Fonts/华文细黑.ttf"
3280
00cace2d9080 Merged a cleaned up version of Jiang's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    27
#define MAX_TEXT_LENGTH 256
00cace2d9080 Merged a cleaned up version of Jiang's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    28
6785
c094c438c0a6 Switched the test code over to use the common functions in the test library.
Sam Lantinga <slouken@libsdl.org>
parents: 6318
diff changeset
    29
static SDLTest_CommonState *state;
6318
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
    30
static SDL_Rect textRect, markedRect;
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
    31
static SDL_Color lineColor = {0,0,0,0};
10100
a18ec339c8d3 Fixed compile warnings about unused variables in IME test program.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 10097
diff changeset
    32
static SDL_Color backColor = {255,255,255,255};
a18ec339c8d3 Fixed compile warnings about unused variables in IME test program.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 10097
diff changeset
    33
#ifdef HAVE_SDL_TTF
6318
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
    34
static SDL_Color textColor = {0,0,0,0};
10100
a18ec339c8d3 Fixed compile warnings about unused variables in IME test program.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 10097
diff changeset
    35
#endif
6318
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
    36
static char text[MAX_TEXT_LENGTH], markedText[SDL_TEXTEDITINGEVENT_TEXT_SIZE];
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
    37
static int cursor = 0;
3280
00cace2d9080 Merged a cleaned up version of Jiang's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    38
#ifdef HAVE_SDL_TTF
6318
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
    39
static TTF_Font *font;
3280
00cace2d9080 Merged a cleaned up version of Jiang's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    40
#endif
4757
140be6839185 Correctly draw cursor based on position.
dewyatt
parents: 4756
diff changeset
    41
5150
1435f8a6425c Nobody is currently maintaining the QNX code, so removing it for now.
Sam Lantinga <slouken@libsdl.org>
parents: 4763
diff changeset
    42
size_t utf8_length(unsigned char c)
1435f8a6425c Nobody is currently maintaining the QNX code, so removing it for now.
Sam Lantinga <slouken@libsdl.org>
parents: 4763
diff changeset
    43
{
1435f8a6425c Nobody is currently maintaining the QNX code, so removing it for now.
Sam Lantinga <slouken@libsdl.org>
parents: 4763
diff changeset
    44
    c = (unsigned char)(0xff & c);
1435f8a6425c Nobody is currently maintaining the QNX code, so removing it for now.
Sam Lantinga <slouken@libsdl.org>
parents: 4763
diff changeset
    45
    if (c < 0x80)
1435f8a6425c Nobody is currently maintaining the QNX code, so removing it for now.
Sam Lantinga <slouken@libsdl.org>
parents: 4763
diff changeset
    46
        return 1;
1435f8a6425c Nobody is currently maintaining the QNX code, so removing it for now.
Sam Lantinga <slouken@libsdl.org>
parents: 4763
diff changeset
    47
    else if ((c >> 5) ==0x6)
1435f8a6425c Nobody is currently maintaining the QNX code, so removing it for now.
Sam Lantinga <slouken@libsdl.org>
parents: 4763
diff changeset
    48
        return 2;
1435f8a6425c Nobody is currently maintaining the QNX code, so removing it for now.
Sam Lantinga <slouken@libsdl.org>
parents: 4763
diff changeset
    49
    else if ((c >> 4) == 0xe)
1435f8a6425c Nobody is currently maintaining the QNX code, so removing it for now.
Sam Lantinga <slouken@libsdl.org>
parents: 4763
diff changeset
    50
        return 3;
1435f8a6425c Nobody is currently maintaining the QNX code, so removing it for now.
Sam Lantinga <slouken@libsdl.org>
parents: 4763
diff changeset
    51
    else if ((c >> 3) == 0x1e)
1435f8a6425c Nobody is currently maintaining the QNX code, so removing it for now.
Sam Lantinga <slouken@libsdl.org>
parents: 4763
diff changeset
    52
        return 4;
1435f8a6425c Nobody is currently maintaining the QNX code, so removing it for now.
Sam Lantinga <slouken@libsdl.org>
parents: 4763
diff changeset
    53
    else
1435f8a6425c Nobody is currently maintaining the QNX code, so removing it for now.
Sam Lantinga <slouken@libsdl.org>
parents: 4763
diff changeset
    54
        return 0;
1435f8a6425c Nobody is currently maintaining the QNX code, so removing it for now.
Sam Lantinga <slouken@libsdl.org>
parents: 4763
diff changeset
    55
}
1435f8a6425c Nobody is currently maintaining the QNX code, so removing it for now.
Sam Lantinga <slouken@libsdl.org>
parents: 4763
diff changeset
    56
1435f8a6425c Nobody is currently maintaining the QNX code, so removing it for now.
Sam Lantinga <slouken@libsdl.org>
parents: 4763
diff changeset
    57
char *utf8_next(char *p)
1435f8a6425c Nobody is currently maintaining the QNX code, so removing it for now.
Sam Lantinga <slouken@libsdl.org>
parents: 4763
diff changeset
    58
{
1435f8a6425c Nobody is currently maintaining the QNX code, so removing it for now.
Sam Lantinga <slouken@libsdl.org>
parents: 4763
diff changeset
    59
    size_t len = utf8_length(*p);
1435f8a6425c Nobody is currently maintaining the QNX code, so removing it for now.
Sam Lantinga <slouken@libsdl.org>
parents: 4763
diff changeset
    60
    size_t i = 0;
1435f8a6425c Nobody is currently maintaining the QNX code, so removing it for now.
Sam Lantinga <slouken@libsdl.org>
parents: 4763
diff changeset
    61
    if (!len)
1435f8a6425c Nobody is currently maintaining the QNX code, so removing it for now.
Sam Lantinga <slouken@libsdl.org>
parents: 4763
diff changeset
    62
        return 0;
1435f8a6425c Nobody is currently maintaining the QNX code, so removing it for now.
Sam Lantinga <slouken@libsdl.org>
parents: 4763
diff changeset
    63
1435f8a6425c Nobody is currently maintaining the QNX code, so removing it for now.
Sam Lantinga <slouken@libsdl.org>
parents: 4763
diff changeset
    64
    for (; i < len; ++i)
1435f8a6425c Nobody is currently maintaining the QNX code, so removing it for now.
Sam Lantinga <slouken@libsdl.org>
parents: 4763
diff changeset
    65
    {
1435f8a6425c Nobody is currently maintaining the QNX code, so removing it for now.
Sam Lantinga <slouken@libsdl.org>
parents: 4763
diff changeset
    66
        ++p;
1435f8a6425c Nobody is currently maintaining the QNX code, so removing it for now.
Sam Lantinga <slouken@libsdl.org>
parents: 4763
diff changeset
    67
        if (!*p)
1435f8a6425c Nobody is currently maintaining the QNX code, so removing it for now.
Sam Lantinga <slouken@libsdl.org>
parents: 4763
diff changeset
    68
            return 0;
1435f8a6425c Nobody is currently maintaining the QNX code, so removing it for now.
Sam Lantinga <slouken@libsdl.org>
parents: 4763
diff changeset
    69
    }
1435f8a6425c Nobody is currently maintaining the QNX code, so removing it for now.
Sam Lantinga <slouken@libsdl.org>
parents: 4763
diff changeset
    70
    return p;
1435f8a6425c Nobody is currently maintaining the QNX code, so removing it for now.
Sam Lantinga <slouken@libsdl.org>
parents: 4763
diff changeset
    71
}
4757
140be6839185 Correctly draw cursor based on position.
dewyatt
parents: 4756
diff changeset
    72
140be6839185 Correctly draw cursor based on position.
dewyatt
parents: 4756
diff changeset
    73
char *utf8_advance(char *p, size_t distance)
140be6839185 Correctly draw cursor based on position.
dewyatt
parents: 4756
diff changeset
    74
{
140be6839185 Correctly draw cursor based on position.
dewyatt
parents: 4756
diff changeset
    75
    size_t i = 0;
140be6839185 Correctly draw cursor based on position.
dewyatt
parents: 4756
diff changeset
    76
    for (; i < distance && p; ++i)
140be6839185 Correctly draw cursor based on position.
dewyatt
parents: 4756
diff changeset
    77
    {
140be6839185 Correctly draw cursor based on position.
dewyatt
parents: 4756
diff changeset
    78
        p = utf8_next(p);
140be6839185 Correctly draw cursor based on position.
dewyatt
parents: 4756
diff changeset
    79
    }
140be6839185 Correctly draw cursor based on position.
dewyatt
parents: 4756
diff changeset
    80
    return p;
140be6839185 Correctly draw cursor based on position.
dewyatt
parents: 4756
diff changeset
    81
}
3280
00cace2d9080 Merged a cleaned up version of Jiang's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    82
00cace2d9080 Merged a cleaned up version of Jiang's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    83
void usage()
00cace2d9080 Merged a cleaned up version of Jiang's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    84
{
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
    85
    SDL_Log("usage: testime [--font fontfile]\n");
3280
00cace2d9080 Merged a cleaned up version of Jiang's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    86
    exit(0);
00cace2d9080 Merged a cleaned up version of Jiang's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    87
}
00cace2d9080 Merged a cleaned up version of Jiang's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    88
6318
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
    89
void InitInput()
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
    90
{
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
    91
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
    92
    /* Prepare a rect for text input */
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
    93
    textRect.x = textRect.y = 100;
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
    94
    textRect.w = DEFAULT_WINDOW_WIDTH - 2 * textRect.x;
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
    95
    textRect.h = 50;
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
    96
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
    97
    text[0] = 0;
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
    98
    markedRect = textRect;
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
    99
    markedText[0] = 0;
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   100
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   101
    SDL_StartTextInput();
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   102
}
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   103
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   104
void CleanupVideo()
3280
00cace2d9080 Merged a cleaned up version of Jiang's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   105
{
6318
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   106
    SDL_StopTextInput();
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   107
#ifdef HAVE_SDL_TTF
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   108
    TTF_CloseFont(font);
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   109
    TTF_Quit();
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   110
#endif
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   111
}
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   112
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   113
void _Redraw(SDL_Renderer * renderer) {
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   114
    int w = 0, h = textRect.h;
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   115
    SDL_Rect cursorRect, underlineRect;
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   116
10100
a18ec339c8d3 Fixed compile warnings about unused variables in IME test program.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 10097
diff changeset
   117
    SDL_SetRenderDrawColor(renderer, backColor.r, backColor.g, backColor.b, backColor.a);
6318
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   118
    SDL_RenderFillRect(renderer,&textRect);
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   119
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   120
#ifdef HAVE_SDL_TTF
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   121
    if (*text)
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   122
    {
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   123
        SDL_Surface *textSur = TTF_RenderUTF8_Blended(font, text, textColor);
10111
c14536d0deff Fixed compiling IME test program with HAVE_SDL_TTF on C89 compilers.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 10100
diff changeset
   124
        SDL_Rect dest;
c14536d0deff Fixed compiling IME test program with HAVE_SDL_TTF on C89 compilers.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 10100
diff changeset
   125
        SDL_Texture *texture;
c14536d0deff Fixed compiling IME test program with HAVE_SDL_TTF on C89 compilers.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 10100
diff changeset
   126
        dest.x = textRect.x;
c14536d0deff Fixed compiling IME test program with HAVE_SDL_TTF on C89 compilers.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 10100
diff changeset
   127
        dest.y = textRect.y;
c14536d0deff Fixed compiling IME test program with HAVE_SDL_TTF on C89 compilers.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 10100
diff changeset
   128
        dest.w = textSur->w;
c14536d0deff Fixed compiling IME test program with HAVE_SDL_TTF on C89 compilers.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 10100
diff changeset
   129
        dest.h = textSur->h;
6318
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   130
10111
c14536d0deff Fixed compiling IME test program with HAVE_SDL_TTF on C89 compilers.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 10100
diff changeset
   131
        texture = SDL_CreateTextureFromSurface(renderer,textSur);
6318
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   132
        SDL_FreeSurface(textSur);
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   133
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   134
        SDL_RenderCopy(renderer,texture,NULL,&dest);
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   135
        SDL_DestroyTexture(texture);
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   136
        TTF_SizeUTF8(font, text, &w, &h);
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   137
    }
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   138
#endif
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   139
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   140
    markedRect.x = textRect.x + w;
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   141
    markedRect.w = textRect.w - w;
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   142
    if (markedRect.w < 0)
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   143
    {
7663
53fe1b64eb2d More non C89 compliant comments
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7639
diff changeset
   144
        /* Stop text input because we cannot hold any more characters */
6318
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   145
        SDL_StopTextInput();
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   146
        return;
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   147
    }
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   148
    else
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   149
    {
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   150
        SDL_StartTextInput();
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   151
    }
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   152
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   153
    cursorRect = markedRect;
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   154
    cursorRect.w = 2;
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   155
    cursorRect.h = h;
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   156
10100
a18ec339c8d3 Fixed compile warnings about unused variables in IME test program.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 10097
diff changeset
   157
    SDL_SetRenderDrawColor(renderer, backColor.r, backColor.g, backColor.b, backColor.a);
6318
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   158
    SDL_RenderFillRect(renderer,&markedRect);
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   159
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   160
    if (markedText[0])
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   161
    {
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   162
#ifdef HAVE_SDL_TTF
10111
c14536d0deff Fixed compiling IME test program with HAVE_SDL_TTF on C89 compilers.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 10100
diff changeset
   163
        SDL_Surface *textSur;
c14536d0deff Fixed compiling IME test program with HAVE_SDL_TTF on C89 compilers.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 10100
diff changeset
   164
        SDL_Rect dest;
c14536d0deff Fixed compiling IME test program with HAVE_SDL_TTF on C89 compilers.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 10100
diff changeset
   165
        SDL_Texture *texture;
6318
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   166
        if (cursor)
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   167
        {
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   168
            char *p = utf8_advance(markedText, cursor);
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   169
            char c = 0;
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   170
            if (!p)
10097
06085b9c73ef Replaced strlen() with SDL_strlen() in IME test program.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 9998
diff changeset
   171
                p = &markedText[SDL_strlen(markedText)];
6318
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   172
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   173
            c = *p;
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   174
            *p = 0;
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   175
            TTF_SizeUTF8(font, markedText, &w, 0);
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   176
            cursorRect.x += w;
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   177
            *p = c;
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   178
        }
10111
c14536d0deff Fixed compiling IME test program with HAVE_SDL_TTF on C89 compilers.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 10100
diff changeset
   179
        textSur = TTF_RenderUTF8_Blended(font, markedText, textColor);
c14536d0deff Fixed compiling IME test program with HAVE_SDL_TTF on C89 compilers.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 10100
diff changeset
   180
        dest.x = markedRect.x;
c14536d0deff Fixed compiling IME test program with HAVE_SDL_TTF on C89 compilers.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 10100
diff changeset
   181
        dest.y = markedRect.y;
c14536d0deff Fixed compiling IME test program with HAVE_SDL_TTF on C89 compilers.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 10100
diff changeset
   182
        dest.w = textSur->w;
c14536d0deff Fixed compiling IME test program with HAVE_SDL_TTF on C89 compilers.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 10100
diff changeset
   183
        dest.h = textSur->h;
6318
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   184
        TTF_SizeUTF8(font, markedText, &w, &h);
10111
c14536d0deff Fixed compiling IME test program with HAVE_SDL_TTF on C89 compilers.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 10100
diff changeset
   185
        texture = SDL_CreateTextureFromSurface(renderer,textSur);
6318
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   186
        SDL_FreeSurface(textSur);
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   187
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   188
        SDL_RenderCopy(renderer,texture,NULL,&dest);
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   189
        SDL_DestroyTexture(texture);
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   190
#endif
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   191
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   192
        underlineRect = markedRect;
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   193
        underlineRect.y += (h - 2);
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   194
        underlineRect.h = 2;
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   195
        underlineRect.w = w;
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   196
10100
a18ec339c8d3 Fixed compile warnings about unused variables in IME test program.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 10097
diff changeset
   197
        SDL_SetRenderDrawColor(renderer, lineColor.r, lineColor.g, lineColor.b, lineColor.a);
6318
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   198
        SDL_RenderFillRect(renderer,&markedRect);
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   199
    }
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   200
10100
a18ec339c8d3 Fixed compile warnings about unused variables in IME test program.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 10097
diff changeset
   201
    SDL_SetRenderDrawColor(renderer, lineColor.r, lineColor.g, lineColor.b, lineColor.a);
6318
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   202
    SDL_RenderFillRect(renderer,&cursorRect);
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   203
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   204
    SDL_SetTextInputRect(&markedRect);
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   205
}
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   206
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   207
void Redraw() {
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   208
    int i;
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   209
    for (i = 0; i < state->num_windows; ++i) {
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   210
        SDL_Renderer *renderer = state->renderers[i];
7787
e6f3e8fc96ea Fixed bug 2132 - Tests may use invalid SDL_window pointers when windows are closed
Sam Lantinga <slouken@libsdl.org>
parents: 7721
diff changeset
   211
        if (state->windows[i] == NULL)
e6f3e8fc96ea Fixed bug 2132 - Tests may use invalid SDL_window pointers when windows are closed
Sam Lantinga <slouken@libsdl.org>
parents: 7721
diff changeset
   212
            continue;
6318
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   213
        SDL_SetRenderDrawColor(renderer, 0, 0, 0, 0);
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   214
        SDL_RenderClear(renderer);
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   215
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   216
        _Redraw(renderer);
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   217
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   218
        SDL_RenderPresent(renderer);
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   219
    }
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   220
}
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   221
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   222
int main(int argc, char *argv[]) {
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   223
    int i, done;
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   224
    SDL_Event event;
3280
00cace2d9080 Merged a cleaned up version of Jiang's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   225
    const char *fontname = DEFAULT_FONT;
00cace2d9080 Merged a cleaned up version of Jiang's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   226
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   227
    /* Enable standard application logging */
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   228
    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   229
6318
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   230
    /* Initialize test framework */
6785
c094c438c0a6 Switched the test code over to use the common functions in the test library.
Sam Lantinga <slouken@libsdl.org>
parents: 6318
diff changeset
   231
    state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
6318
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   232
    if (!state) {
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   233
        return 1;
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   234
    }
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   235
    for (i = 1; i < argc;i++) {
6785
c094c438c0a6 Switched the test code over to use the common functions in the test library.
Sam Lantinga <slouken@libsdl.org>
parents: 6318
diff changeset
   236
        SDLTest_CommonArg(state, i);
6318
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   237
    }
3280
00cace2d9080 Merged a cleaned up version of Jiang's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   238
    for (argc--, argv++; argc > 0; argc--, argv++)
00cace2d9080 Merged a cleaned up version of Jiang's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   239
    {
6318
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   240
        if (strcmp(argv[0], "--help") == 0) {
3280
00cace2d9080 Merged a cleaned up version of Jiang's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   241
            usage();
6318
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   242
            return 0;
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   243
        }
3280
00cace2d9080 Merged a cleaned up version of Jiang's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   244
00cace2d9080 Merged a cleaned up version of Jiang's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   245
        else if (strcmp(argv[0], "--font") == 0)
00cace2d9080 Merged a cleaned up version of Jiang's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   246
        {
00cace2d9080 Merged a cleaned up version of Jiang's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   247
            argc--;
00cace2d9080 Merged a cleaned up version of Jiang's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   248
            argv++;
00cace2d9080 Merged a cleaned up version of Jiang's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   249
00cace2d9080 Merged a cleaned up version of Jiang's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   250
            if (argc > 0)
00cace2d9080 Merged a cleaned up version of Jiang's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   251
                fontname = argv[0];
6318
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   252
            else {
3280
00cace2d9080 Merged a cleaned up version of Jiang's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   253
                usage();
6318
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   254
                return 0;
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   255
            }
3280
00cace2d9080 Merged a cleaned up version of Jiang's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   256
        }
00cace2d9080 Merged a cleaned up version of Jiang's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   257
    }
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6785
diff changeset
   258
6785
c094c438c0a6 Switched the test code over to use the common functions in the test library.
Sam Lantinga <slouken@libsdl.org>
parents: 6318
diff changeset
   259
    if (!SDLTest_CommonInit(state)) {
6318
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   260
        return 2;
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   261
    }
3280
00cace2d9080 Merged a cleaned up version of Jiang's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   262
00cace2d9080 Merged a cleaned up version of Jiang's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   263
00cace2d9080 Merged a cleaned up version of Jiang's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   264
#ifdef HAVE_SDL_TTF
00cace2d9080 Merged a cleaned up version of Jiang's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   265
    /* Initialize fonts */
00cace2d9080 Merged a cleaned up version of Jiang's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   266
    TTF_Init();
00cace2d9080 Merged a cleaned up version of Jiang's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   267
00cace2d9080 Merged a cleaned up version of Jiang's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   268
    font = TTF_OpenFont(fontname, DEFAULT_PTSIZE);
00cace2d9080 Merged a cleaned up version of Jiang's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   269
    if (! font)
00cace2d9080 Merged a cleaned up version of Jiang's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   270
    {
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   271
        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to find font: %s\n", TTF_GetError());
3280
00cace2d9080 Merged a cleaned up version of Jiang's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   272
        exit(-1);
00cace2d9080 Merged a cleaned up version of Jiang's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   273
    }
00cace2d9080 Merged a cleaned up version of Jiang's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   274
#endif
00cace2d9080 Merged a cleaned up version of Jiang's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   275
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   276
    SDL_Log("Using font: %s\n", fontname);
3280
00cace2d9080 Merged a cleaned up version of Jiang's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   277
    atexit(SDL_Quit);
00cace2d9080 Merged a cleaned up version of Jiang's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   278
6318
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   279
    InitInput();
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   280
    /* Create the windows and initialize the renderers */
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   281
    for (i = 0; i < state->num_windows; ++i) {
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   282
        SDL_Renderer *renderer = state->renderers[i];
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   283
        SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_NONE);
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   284
        SDL_SetRenderDrawColor(renderer, 0xA0, 0xA0, 0xA0, 0xFF);
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   285
        SDL_RenderClear(renderer);
3280
00cace2d9080 Merged a cleaned up version of Jiang's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   286
    }
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6785
diff changeset
   287
    Redraw();
6318
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   288
    /* Main render loop */
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   289
    done = 0;
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   290
    while (!done) {
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   291
        /* Check for events */
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   292
        while (SDL_PollEvent(&event)) {
6785
c094c438c0a6 Switched the test code over to use the common functions in the test library.
Sam Lantinga <slouken@libsdl.org>
parents: 6318
diff changeset
   293
            SDLTest_CommonEvent(state, &event, &done);
6318
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   294
            switch(event.type) {
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   295
                case SDL_KEYDOWN: {
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   296
                    switch (event.key.keysym.sym)
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   297
                    {
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   298
                        case SDLK_RETURN:
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   299
                             text[0]=0x00;
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   300
                             Redraw();
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   301
                             break;
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   302
                        case SDLK_BACKSPACE:
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   303
                             {
9938
c1bdce8e9c64 Fixed compile warning in IME test program.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 9619
diff changeset
   304
                                 size_t textlen = SDL_strlen(text);
3280
00cace2d9080 Merged a cleaned up version of Jiang's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   305
6318
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   306
                                 do {
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   307
                                     if (textlen==0)
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   308
                                     {
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   309
                                         break;
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   310
                                     }
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   311
                                     if ((text[textlen-1] & 0x80) == 0x00)
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   312
                                     {
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   313
                                         /* One byte */
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   314
                                         text[textlen-1]=0x00;
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   315
                                         break;
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   316
                                     }
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   317
                                     if ((text[textlen-1] & 0xC0) == 0x80)
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   318
                                     {
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   319
                                         /* Byte from the multibyte sequence */
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   320
                                         text[textlen-1]=0x00;
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   321
                                         textlen--;
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   322
                                     }
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   323
                                     if ((text[textlen-1] & 0xC0) == 0xC0)
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   324
                                     {
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   325
                                         /* First byte of multibyte sequence */
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   326
                                         text[textlen-1]=0x00;
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   327
                                         break;
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   328
                                     }
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   329
                                 } while(1);
3280
00cace2d9080 Merged a cleaned up version of Jiang's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   330
6318
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   331
                                 Redraw();
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   332
                             }
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   333
                             break;
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   334
                    }
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   335
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   336
                    if (done)
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   337
                    {
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   338
                        break;
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   339
                    }
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   340
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   341
                    SDL_Log("Keyboard: scancode 0x%08X = %s, keycode 0x%08X = %s\n",
6318
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   342
                            event.key.keysym.scancode,
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   343
                            SDL_GetScancodeName(event.key.keysym.scancode),
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   344
                            event.key.keysym.sym, SDL_GetKeyName(event.key.keysym.sym));
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   345
                    break;
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   346
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   347
                case SDL_TEXTINPUT:
7721
bdf8c2c84e14 Christoph Mallon: Replace strlen(x) == 0 (O(n)) by x[0] == '\0' (O(1)).
Sam Lantinga <slouken@libsdl.org>
parents: 7677
diff changeset
   348
                    if (event.text.text[0] == '\0' || event.text.text[0] == '\n' ||
6318
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   349
                        markedRect.w < 0)
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   350
                        break;
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   351
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   352
                    SDL_Log("Keyboard: text input \"%s\"\n", event.text.text);
3280
00cace2d9080 Merged a cleaned up version of Jiang's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   353
6318
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   354
                    if (SDL_strlen(text) + SDL_strlen(event.text.text) < sizeof(text))
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   355
                        SDL_strlcat(text, event.text.text, sizeof(text));
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   356
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   357
                    SDL_Log("text inputed: %s\n", text);
6318
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   358
7663
53fe1b64eb2d More non C89 compliant comments
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7639
diff changeset
   359
                    /* After text inputed, we can clear up markedText because it */
7677
871d43c6968a OCD fixes: Adds a space before */
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7663
diff changeset
   360
                    /* is committed */
6318
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   361
                    markedText[0] = 0;
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   362
                    Redraw();
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   363
                    break;
3280
00cace2d9080 Merged a cleaned up version of Jiang's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   364
6318
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   365
                case SDL_TEXTEDITING:
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   366
                    SDL_Log("text editing \"%s\", selected range (%d, %d)\n",
6318
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   367
                            event.edit.text, event.edit.start, event.edit.length);
3280
00cace2d9080 Merged a cleaned up version of Jiang's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   368
6318
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   369
                    strcpy(markedText, event.edit.text);
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   370
                    cursor = event.edit.start;
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   371
                    Redraw();
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   372
                    break;
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   373
                }
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   374
                break;
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6785
diff changeset
   375
6318
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   376
            }
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   377
        }
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   378
    }
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   379
    CleanupVideo();
6785
c094c438c0a6 Switched the test code over to use the common functions in the test library.
Sam Lantinga <slouken@libsdl.org>
parents: 6318
diff changeset
   380
    SDLTest_CommonQuit(state);
6318
49b2cb56db6e 1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents: 6256
diff changeset
   381
    return 0;
3280
00cace2d9080 Merged a cleaned up version of Jiang's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   382
}
00cace2d9080 Merged a cleaned up version of Jiang's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   383
5244
762e40fb8e28 Be explicit about what display you're querying. The default display is 0.
Sam Lantinga <slouken@libsdl.org>
parents: 5150
diff changeset
   384
762e40fb8e28 Be explicit about what display you're querying. The default display is 0.
Sam Lantinga <slouken@libsdl.org>
parents: 5150
diff changeset
   385
/* vi: set ts=4 sw=4 expandtab: */