test/testime.c
author Sam Lantinga <slouken@libsdl.org>
Fri, 08 Apr 2011 13:03:26 -0700
changeset 5535 96594ac5fd1a
parent 5244 762e40fb8e28
child 6251 3e8c673cad58
permissions -rw-r--r--
SDL 1.3 is now under the zlib license.
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
/*
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5244
diff changeset
     2
  Copyright (C) 1997-2011 Sam Lantinga <slouken@libsdl.org>
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
*/
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
    12
/* A simple program to test the Input Method support in the SDL library (1.3+) */
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
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
    23
#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
    24
#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
    25
#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
    26
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
SDL_Surface *screen;
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
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
    29
#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
    30
TTF_Font *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
    31
#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
    32
SDL_Rect textRect, markedRect;
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
    33
Uint32 lineColor, backColor;
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
    34
SDL_Color textColor = { 0, 0, 0 };
4756
b99b1024607a Changed markedText to have its own storage to resolve multiple bugs.
dewyatt
parents: 4465
diff changeset
    35
char text[MAX_TEXT_LENGTH], markedText[SDL_TEXTEDITINGEVENT_TEXT_SIZE];
4757
140be6839185 Correctly draw cursor based on position.
dewyatt
parents: 4756
diff changeset
    36
int cursor = 0;
140be6839185 Correctly draw cursor based on position.
dewyatt
parents: 4756
diff changeset
    37
5150
1435f8a6425c Nobody is currently maintaining the QNX code, so removing it for now.
Sam Lantinga <slouken@libsdl.org>
parents: 4763
diff changeset
    38
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
    39
{
1435f8a6425c Nobody is currently maintaining the QNX code, so removing it for now.
Sam Lantinga <slouken@libsdl.org>
parents: 4763
diff changeset
    40
    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
    41
    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
    42
        return 1;
1435f8a6425c Nobody is currently maintaining the QNX code, so removing it for now.
Sam Lantinga <slouken@libsdl.org>
parents: 4763
diff changeset
    43
    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
    44
        return 2;
1435f8a6425c Nobody is currently maintaining the QNX code, so removing it for now.
Sam Lantinga <slouken@libsdl.org>
parents: 4763
diff changeset
    45
    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
    46
        return 3;
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 >> 3) == 0x1e)
1435f8a6425c Nobody is currently maintaining the QNX code, so removing it for now.
Sam Lantinga <slouken@libsdl.org>
parents: 4763
diff changeset
    48
        return 4;
1435f8a6425c Nobody is currently maintaining the QNX code, so removing it for now.
Sam Lantinga <slouken@libsdl.org>
parents: 4763
diff changeset
    49
    else
1435f8a6425c Nobody is currently maintaining the QNX code, so removing it for now.
Sam Lantinga <slouken@libsdl.org>
parents: 4763
diff changeset
    50
        return 0;
1435f8a6425c Nobody is currently maintaining the QNX code, so removing it for now.
Sam Lantinga <slouken@libsdl.org>
parents: 4763
diff changeset
    51
}
1435f8a6425c Nobody is currently maintaining the QNX code, so removing it for now.
Sam Lantinga <slouken@libsdl.org>
parents: 4763
diff changeset
    52
1435f8a6425c Nobody is currently maintaining the QNX code, so removing it for now.
Sam Lantinga <slouken@libsdl.org>
parents: 4763
diff changeset
    53
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
    54
{
1435f8a6425c Nobody is currently maintaining the QNX code, so removing it for now.
Sam Lantinga <slouken@libsdl.org>
parents: 4763
diff changeset
    55
    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
    56
    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
    57
    if (!len)
1435f8a6425c Nobody is currently maintaining the QNX code, so removing it for now.
Sam Lantinga <slouken@libsdl.org>
parents: 4763
diff changeset
    58
        return 0;
1435f8a6425c Nobody is currently maintaining the QNX code, so removing it for now.
Sam Lantinga <slouken@libsdl.org>
parents: 4763
diff changeset
    59
1435f8a6425c Nobody is currently maintaining the QNX code, so removing it for now.
Sam Lantinga <slouken@libsdl.org>
parents: 4763
diff changeset
    60
    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
    61
    {
1435f8a6425c Nobody is currently maintaining the QNX code, so removing it for now.
Sam Lantinga <slouken@libsdl.org>
parents: 4763
diff changeset
    62
        ++p;
1435f8a6425c Nobody is currently maintaining the QNX code, so removing it for now.
Sam Lantinga <slouken@libsdl.org>
parents: 4763
diff changeset
    63
        if (!*p)
1435f8a6425c Nobody is currently maintaining the QNX code, so removing it for now.
Sam Lantinga <slouken@libsdl.org>
parents: 4763
diff changeset
    64
            return 0;
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
    return p;
1435f8a6425c Nobody is currently maintaining the QNX code, so removing it for now.
Sam Lantinga <slouken@libsdl.org>
parents: 4763
diff changeset
    67
}
4757
140be6839185 Correctly draw cursor based on position.
dewyatt
parents: 4756
diff changeset
    68
140be6839185 Correctly draw cursor based on position.
dewyatt
parents: 4756
diff changeset
    69
char *utf8_advance(char *p, size_t distance)
140be6839185 Correctly draw cursor based on position.
dewyatt
parents: 4756
diff changeset
    70
{
140be6839185 Correctly draw cursor based on position.
dewyatt
parents: 4756
diff changeset
    71
    size_t i = 0;
140be6839185 Correctly draw cursor based on position.
dewyatt
parents: 4756
diff changeset
    72
    for (; i < distance && p; ++i)
140be6839185 Correctly draw cursor based on position.
dewyatt
parents: 4756
diff changeset
    73
    {
140be6839185 Correctly draw cursor based on position.
dewyatt
parents: 4756
diff changeset
    74
        p = utf8_next(p);
140be6839185 Correctly draw cursor based on position.
dewyatt
parents: 4756
diff changeset
    75
    }
140be6839185 Correctly draw cursor based on position.
dewyatt
parents: 4756
diff changeset
    76
    return p;
140be6839185 Correctly draw cursor based on position.
dewyatt
parents: 4756
diff changeset
    77
}
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
    78
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
    79
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
    80
{
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
    81
    printf("usage: testime [--font fontfile] [--fullscreen]\n");
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
    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
    83
}
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
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
    85
void InitVideo(int argc, char *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
    86
{
3478
f7541260e89c Added support for QNX default font. Backspace and Return keys now handled.
Mike Gorchak <lestat@i.com.ua>
parents: 3338
diff changeset
    87
    int width = 640, height = 480;
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
    88
    int flags = SDL_HWSURFACE;
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
    89
    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
    90
    int fullscreen = 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
    91
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
    92
    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
    93
    {
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
    94
        if (strcmp(argv[0], "--help") == 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
    95
            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
    96
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
    97
        else if (strcmp(argv[0], "--fullscreen") == 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
    98
            fullscreen = 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
    99
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
   100
        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
   101
        {
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
   102
            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
   103
            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
   104
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
            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
   106
                fontname = argv[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
   107
            else
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
   108
                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
   109
        }
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
   110
    }
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
   111
3581
15eea7a1fa97 Implemented SDL_setenv(), moved SDL_putenv() to compat.
Ryan C. Gordon <icculus@icculus.org>
parents: 3478
diff changeset
   112
    SDL_setenv("SDL_VIDEO_WINDOW_POS", "center", 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
   113
    if (SDL_Init(SDL_INIT_VIDEO) < 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
   114
    {
3281
2d3a9f229ba1 I'm gussing that this was never compiled where TTF support was missing. As a result a call to SDL_GetError and a call to TTF_GetError were swapped.
Bob Pendleton <bob@pendleton.com>
parents: 3280
diff changeset
   115
        fprintf(stderr, "Unable to init SDL: %s\n", SDL_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
   116
        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
   117
    }
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
   118
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
   119
#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
   120
    /* 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
   121
    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
   122
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
   123
    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
   124
    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
   125
    {
3281
2d3a9f229ba1 I'm gussing that this was never compiled where TTF support was missing. As a result a call to SDL_GetError and a call to TTF_GetError were swapped.
Bob Pendleton <bob@pendleton.com>
parents: 3280
diff changeset
   126
        fprintf(stderr, "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
   127
        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
   128
    }
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
   129
#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
   130
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
   131
    printf("Using font: %s\n", fontname);
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
   132
    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
   133
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
   134
    if (fullscreen)
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
   135
    {
5244
762e40fb8e28 Be explicit about what display you're querying. The default display is 0.
Sam Lantinga <slouken@libsdl.org>
parents: 5150
diff changeset
   136
        /* Use the desktop mode */
762e40fb8e28 Be explicit about what display you're querying. The default display is 0.
Sam Lantinga <slouken@libsdl.org>
parents: 5150
diff changeset
   137
        width = 0;
762e40fb8e28 Be explicit about what display you're querying. The default display is 0.
Sam Lantinga <slouken@libsdl.org>
parents: 5150
diff changeset
   138
        height = 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
   139
        flags |= SDL_FULLSCREEN;
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
   140
    }
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
   141
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
   142
    /* Create window */
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
   143
    screen = SDL_SetVideoMode(width, height, 32, flags);
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
   144
    if (screen == NULL)
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
   145
    {
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
   146
        fprintf(stderr, "Unable to set %dx%d video: %s\n",
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
   147
                width, height, SDL_GetError());
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
   148
        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
   149
    }
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
   150
}
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
   151
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
   152
void CleanupVideo()
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
   153
{
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
   154
    SDL_StopTextInput();
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
   155
#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
   156
    TTF_CloseFont(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
   157
    TTF_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
   158
#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
   159
}
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
   160
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
   161
void InitInput()
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
   162
{
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
   163
    backColor = SDL_MapRGB(screen->format, 0xFF, 0xFF, 0xFF);
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
   164
    lineColor = SDL_MapRGB(screen->format, 0x0, 0x0, 0x0);
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
   165
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
   166
    /* Prepare a rect for text input */
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
   167
    textRect.x = textRect.y = 100;
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
   168
    textRect.w = screen->w - 2 * textRect.x;
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
   169
    textRect.h = 50;
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
   170
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
   171
    text[0] = 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
   172
    markedRect = textRect;
4756
b99b1024607a Changed markedText to have its own storage to resolve multiple bugs.
dewyatt
parents: 4465
diff changeset
   173
    markedText[0] = 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
   174
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
   175
    SDL_StartTextInput();
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
   176
}
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
   177
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
   178
#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
   179
static void RenderText(SDL_Surface *sur,
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
   180
                        TTF_Font *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
   181
                        const char *text,
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
   182
                        int x, int y,
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
   183
                        SDL_Color color)
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
   184
{
4638
08d22c54a21f Don't need to use strlen() to determine if there's text.
Sam Lantinga <slouken@libsdl.org>
parents: 4637
diff changeset
   185
    if (text && *text) {
4637
8c229370ddba Fix for deleting the last uncommit character
Jjgod Jiang <gzjjgod@gmail.com>
parents: 4465
diff changeset
   186
        SDL_Surface *textSur = TTF_RenderUTF8_Blended(font, text, color);
8c229370ddba Fix for deleting the last uncommit character
Jjgod Jiang <gzjjgod@gmail.com>
parents: 4465
diff changeset
   187
        SDL_Rect dest = { x, y, textSur->w, textSur->h };
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
   188
4637
8c229370ddba Fix for deleting the last uncommit character
Jjgod Jiang <gzjjgod@gmail.com>
parents: 4465
diff changeset
   189
        SDL_BlitSurface(textSur, NULL, sur, &dest);
8c229370ddba Fix for deleting the last uncommit character
Jjgod Jiang <gzjjgod@gmail.com>
parents: 4465
diff changeset
   190
        SDL_FreeSurface(textSur);
8c229370ddba Fix for deleting the last uncommit character
Jjgod Jiang <gzjjgod@gmail.com>
parents: 4465
diff changeset
   191
    }
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
   192
}
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
   193
#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
   194
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
   195
void Redraw()
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
   196
{
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
   197
    int w = 0, h = textRect.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
   198
    SDL_Rect cursorRect, underlineRect;
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
   199
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
   200
    SDL_FillRect(screen, &textRect, backColor);
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
   201
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
   202
#ifdef HAVE_SDL_TTF
4638
08d22c54a21f Don't need to use strlen() to determine if there's text.
Sam Lantinga <slouken@libsdl.org>
parents: 4637
diff changeset
   203
    if (*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
   204
    {
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
   205
        RenderText(screen, font, text, textRect.x, textRect.y, textColor);
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
   206
        TTF_SizeUTF8(font, text, &w, &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
   207
    }
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
   208
#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
   209
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
   210
    markedRect.x = textRect.x + w;
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
   211
    markedRect.w = textRect.w - w;
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
   212
    if (markedRect.w < 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
   213
    {
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
   214
        SDL_Flip(screen);
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
   215
        // Stop text input because we cannot hold any more characters
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
   216
        SDL_StopTextInput();
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
   217
        return;
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
   218
    }
3478
f7541260e89c Added support for QNX default font. Backspace and Return keys now handled.
Mike Gorchak <lestat@i.com.ua>
parents: 3338
diff changeset
   219
    else
f7541260e89c Added support for QNX default font. Backspace and Return keys now handled.
Mike Gorchak <lestat@i.com.ua>
parents: 3338
diff changeset
   220
    {
f7541260e89c Added support for QNX default font. Backspace and Return keys now handled.
Mike Gorchak <lestat@i.com.ua>
parents: 3338
diff changeset
   221
        SDL_StartTextInput();
f7541260e89c Added support for QNX default font. Backspace and Return keys now handled.
Mike Gorchak <lestat@i.com.ua>
parents: 3338
diff changeset
   222
    }
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
   223
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
   224
    cursorRect = markedRect;
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
    cursorRect.w = 2;
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
    cursorRect.h = 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
   227
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
   228
    SDL_FillRect(screen, &markedRect, backColor);
4756
b99b1024607a Changed markedText to have its own storage to resolve multiple bugs.
dewyatt
parents: 4465
diff changeset
   229
    if (markedText[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
   230
    {
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
   231
#ifdef HAVE_SDL_TTF
4757
140be6839185 Correctly draw cursor based on position.
dewyatt
parents: 4756
diff changeset
   232
        if (cursor)
140be6839185 Correctly draw cursor based on position.
dewyatt
parents: 4756
diff changeset
   233
        {
140be6839185 Correctly draw cursor based on position.
dewyatt
parents: 4756
diff changeset
   234
            char *p = utf8_advance(markedText, cursor);
140be6839185 Correctly draw cursor based on position.
dewyatt
parents: 4756
diff changeset
   235
            char c = 0;
140be6839185 Correctly draw cursor based on position.
dewyatt
parents: 4756
diff changeset
   236
            if (!p)
140be6839185 Correctly draw cursor based on position.
dewyatt
parents: 4756
diff changeset
   237
                p = &markedText[strlen(markedText)];
140be6839185 Correctly draw cursor based on position.
dewyatt
parents: 4756
diff changeset
   238
140be6839185 Correctly draw cursor based on position.
dewyatt
parents: 4756
diff changeset
   239
            c = *p;
140be6839185 Correctly draw cursor based on position.
dewyatt
parents: 4756
diff changeset
   240
            *p = 0;
140be6839185 Correctly draw cursor based on position.
dewyatt
parents: 4756
diff changeset
   241
            TTF_SizeUTF8(font, markedText, &w, 0);
140be6839185 Correctly draw cursor based on position.
dewyatt
parents: 4756
diff changeset
   242
            cursorRect.x += w;
140be6839185 Correctly draw cursor based on position.
dewyatt
parents: 4756
diff changeset
   243
            *p = c;
140be6839185 Correctly draw cursor based on position.
dewyatt
parents: 4756
diff changeset
   244
        }
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
   245
        RenderText(screen, font, markedText, markedRect.x, markedRect.y, textColor);
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
        TTF_SizeUTF8(font, markedText, &w, &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
   247
#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
   248
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
        underlineRect = markedRect;
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
        underlineRect.y += (h - 2);
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
        underlineRect.h = 2;
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
   252
        underlineRect.w = w;
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
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
   254
        SDL_FillRect(screen, &underlineRect, lineColor);
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
   255
    }
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
    SDL_FillRect(screen, &cursorRect, lineColor);
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
   258
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
   259
    SDL_Flip(screen);
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
   260
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
   261
    SDL_SetTextInputRect(&markedRect);
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
void
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
HotKey_ToggleFullScreen(void)
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
{
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
    SDL_Surface *screen;
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
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
    screen = SDL_GetVideoSurface();
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
    if (SDL_WM_ToggleFullScreen(screen)) {
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
   271
        printf("Toggled fullscreen mode - now %s\n",
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
               (screen->flags & SDL_FULLSCREEN) ? "fullscreen" : "windowed");
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
    } else {
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
        printf("Unable to toggle fullscreen mode\n");
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
    }
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
   276
}
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
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
int main(int argc, char *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
   279
{
3338
9de326b3099c Fixed bug #817
Sam Lantinga <slouken@libsdl.org>
parents: 3281
diff changeset
   280
    SDL_Event event;
9de326b3099c Fixed bug #817
Sam Lantinga <slouken@libsdl.org>
parents: 3281
diff changeset
   281
    int done = 0;
9de326b3099c Fixed bug #817
Sam Lantinga <slouken@libsdl.org>
parents: 3281
diff changeset
   282
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
   283
    InitVideo(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
   284
    InitInput();
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
   285
    Redraw();
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
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
   287
    while (! done && SDL_WaitEvent(&event))
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
   288
    {
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
   289
        switch (event.type)
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
   290
        {
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
   291
        case SDL_KEYDOWN:
3478
f7541260e89c Added support for QNX default font. Backspace and Return keys now handled.
Mike Gorchak <lestat@i.com.ua>
parents: 3338
diff changeset
   292
            switch (event.key.keysym.sym)
f7541260e89c Added support for QNX default font. Backspace and Return keys now handled.
Mike Gorchak <lestat@i.com.ua>
parents: 3338
diff changeset
   293
            {
f7541260e89c Added support for QNX default font. Backspace and Return keys now handled.
Mike Gorchak <lestat@i.com.ua>
parents: 3338
diff changeset
   294
                case SDLK_ESCAPE:
f7541260e89c Added support for QNX default font. Backspace and Return keys now handled.
Mike Gorchak <lestat@i.com.ua>
parents: 3338
diff changeset
   295
                     done = 1;
f7541260e89c Added support for QNX default font. Backspace and Return keys now handled.
Mike Gorchak <lestat@i.com.ua>
parents: 3338
diff changeset
   296
                     break;
f7541260e89c Added support for QNX default font. Backspace and Return keys now handled.
Mike Gorchak <lestat@i.com.ua>
parents: 3338
diff changeset
   297
                case SDLK_RETURN:
f7541260e89c Added support for QNX default font. Backspace and Return keys now handled.
Mike Gorchak <lestat@i.com.ua>
parents: 3338
diff changeset
   298
                     text[0]=0x00;
f7541260e89c Added support for QNX default font. Backspace and Return keys now handled.
Mike Gorchak <lestat@i.com.ua>
parents: 3338
diff changeset
   299
                     Redraw();
f7541260e89c Added support for QNX default font. Backspace and Return keys now handled.
Mike Gorchak <lestat@i.com.ua>
parents: 3338
diff changeset
   300
                     break;
f7541260e89c Added support for QNX default font. Backspace and Return keys now handled.
Mike Gorchak <lestat@i.com.ua>
parents: 3338
diff changeset
   301
                case SDLK_BACKSPACE:
f7541260e89c Added support for QNX default font. Backspace and Return keys now handled.
Mike Gorchak <lestat@i.com.ua>
parents: 3338
diff changeset
   302
                     {
f7541260e89c Added support for QNX default font. Backspace and Return keys now handled.
Mike Gorchak <lestat@i.com.ua>
parents: 3338
diff changeset
   303
                         int textlen=SDL_strlen(text);
f7541260e89c Added support for QNX default font. Backspace and Return keys now handled.
Mike Gorchak <lestat@i.com.ua>
parents: 3338
diff changeset
   304
f7541260e89c Added support for QNX default font. Backspace and Return keys now handled.
Mike Gorchak <lestat@i.com.ua>
parents: 3338
diff changeset
   305
                         do {
f7541260e89c Added support for QNX default font. Backspace and Return keys now handled.
Mike Gorchak <lestat@i.com.ua>
parents: 3338
diff changeset
   306
                             if (textlen==0)
f7541260e89c Added support for QNX default font. Backspace and Return keys now handled.
Mike Gorchak <lestat@i.com.ua>
parents: 3338
diff changeset
   307
                             {
f7541260e89c Added support for QNX default font. Backspace and Return keys now handled.
Mike Gorchak <lestat@i.com.ua>
parents: 3338
diff changeset
   308
                                 break;
f7541260e89c Added support for QNX default font. Backspace and Return keys now handled.
Mike Gorchak <lestat@i.com.ua>
parents: 3338
diff changeset
   309
                             }
f7541260e89c Added support for QNX default font. Backspace and Return keys now handled.
Mike Gorchak <lestat@i.com.ua>
parents: 3338
diff changeset
   310
                             if ((text[textlen-1] & 0x80) == 0x00)
f7541260e89c Added support for QNX default font. Backspace and Return keys now handled.
Mike Gorchak <lestat@i.com.ua>
parents: 3338
diff changeset
   311
                             {
f7541260e89c Added support for QNX default font. Backspace and Return keys now handled.
Mike Gorchak <lestat@i.com.ua>
parents: 3338
diff changeset
   312
                                 /* One byte */
f7541260e89c Added support for QNX default font. Backspace and Return keys now handled.
Mike Gorchak <lestat@i.com.ua>
parents: 3338
diff changeset
   313
                                 text[textlen-1]=0x00;
f7541260e89c Added support for QNX default font. Backspace and Return keys now handled.
Mike Gorchak <lestat@i.com.ua>
parents: 3338
diff changeset
   314
                                 break;
f7541260e89c Added support for QNX default font. Backspace and Return keys now handled.
Mike Gorchak <lestat@i.com.ua>
parents: 3338
diff changeset
   315
                             }
f7541260e89c Added support for QNX default font. Backspace and Return keys now handled.
Mike Gorchak <lestat@i.com.ua>
parents: 3338
diff changeset
   316
                             if ((text[textlen-1] & 0xC0) == 0x80)
f7541260e89c Added support for QNX default font. Backspace and Return keys now handled.
Mike Gorchak <lestat@i.com.ua>
parents: 3338
diff changeset
   317
                             {
f7541260e89c Added support for QNX default font. Backspace and Return keys now handled.
Mike Gorchak <lestat@i.com.ua>
parents: 3338
diff changeset
   318
                                 /* Byte from the multibyte sequence */
f7541260e89c Added support for QNX default font. Backspace and Return keys now handled.
Mike Gorchak <lestat@i.com.ua>
parents: 3338
diff changeset
   319
                                 text[textlen-1]=0x00;
f7541260e89c Added support for QNX default font. Backspace and Return keys now handled.
Mike Gorchak <lestat@i.com.ua>
parents: 3338
diff changeset
   320
                                 textlen--;
f7541260e89c Added support for QNX default font. Backspace and Return keys now handled.
Mike Gorchak <lestat@i.com.ua>
parents: 3338
diff changeset
   321
                             }
f7541260e89c Added support for QNX default font. Backspace and Return keys now handled.
Mike Gorchak <lestat@i.com.ua>
parents: 3338
diff changeset
   322
                             if ((text[textlen-1] & 0xC0) == 0xC0)
f7541260e89c Added support for QNX default font. Backspace and Return keys now handled.
Mike Gorchak <lestat@i.com.ua>
parents: 3338
diff changeset
   323
                             {
f7541260e89c Added support for QNX default font. Backspace and Return keys now handled.
Mike Gorchak <lestat@i.com.ua>
parents: 3338
diff changeset
   324
                                 /* First byte of multibyte sequence */
f7541260e89c Added support for QNX default font. Backspace and Return keys now handled.
Mike Gorchak <lestat@i.com.ua>
parents: 3338
diff changeset
   325
                                 text[textlen-1]=0x00;
f7541260e89c Added support for QNX default font. Backspace and Return keys now handled.
Mike Gorchak <lestat@i.com.ua>
parents: 3338
diff changeset
   326
                                 break;
f7541260e89c Added support for QNX default font. Backspace and Return keys now handled.
Mike Gorchak <lestat@i.com.ua>
parents: 3338
diff changeset
   327
                             }
f7541260e89c Added support for QNX default font. Backspace and Return keys now handled.
Mike Gorchak <lestat@i.com.ua>
parents: 3338
diff changeset
   328
                         } while(1);
f7541260e89c Added support for QNX default font. Backspace and Return keys now handled.
Mike Gorchak <lestat@i.com.ua>
parents: 3338
diff changeset
   329
f7541260e89c Added support for QNX default font. Backspace and Return keys now handled.
Mike Gorchak <lestat@i.com.ua>
parents: 3338
diff changeset
   330
                         Redraw();
f7541260e89c Added support for QNX default font. Backspace and Return keys now handled.
Mike Gorchak <lestat@i.com.ua>
parents: 3338
diff changeset
   331
                     }
f7541260e89c Added support for QNX default font. Backspace and Return keys now handled.
Mike Gorchak <lestat@i.com.ua>
parents: 3338
diff changeset
   332
                     break;
f7541260e89c Added support for QNX default font. Backspace and Return keys now handled.
Mike Gorchak <lestat@i.com.ua>
parents: 3338
diff changeset
   333
            }
f7541260e89c Added support for QNX default font. Backspace and Return keys now handled.
Mike Gorchak <lestat@i.com.ua>
parents: 3338
diff changeset
   334
f7541260e89c Added support for QNX default font. Backspace and Return keys now handled.
Mike Gorchak <lestat@i.com.ua>
parents: 3338
diff changeset
   335
            if (done)
f7541260e89c Added support for QNX default font. Backspace and Return keys now handled.
Mike Gorchak <lestat@i.com.ua>
parents: 3338
diff changeset
   336
            {
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
   337
                break;
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
   338
            }
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
   339
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
   340
            fprintf(stderr,
4465
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 3581
diff changeset
   341
                    "Keyboard: scancode 0x%08X = %s, keycode 0x%08X = %s\n",
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 3581
diff changeset
   342
                    event.key.keysym.scancode,
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
   343
                    SDL_GetScancodeName(event.key.keysym.scancode),
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
   344
                    event.key.keysym.sym, SDL_GetKeyName(event.key.keysym.sym));
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
   345
            break;
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
   346
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
   347
        case SDL_TEXTINPUT:
3478
f7541260e89c Added support for QNX default font. Backspace and Return keys now handled.
Mike Gorchak <lestat@i.com.ua>
parents: 3338
diff changeset
   348
            if (SDL_strlen(event.text.text) == 0 || event.text.text[0] == '\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
   349
                markedRect.w < 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
   350
                break;
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
   351
4465
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 3581
diff changeset
   352
            fprintf(stderr, "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
3478
f7541260e89c Added support for QNX default font. Backspace and Return keys now handled.
Mike Gorchak <lestat@i.com.ua>
parents: 3338
diff changeset
   354
            if (SDL_strlen(text) + SDL_strlen(event.text.text) < sizeof(text))
4763
518d1679d2d0 Merged Daniel's Google Summer of Code work from SDL-gsoc2010_IME
Sam Lantinga <slouken@libsdl.org>
parents: 4638 4757
diff changeset
   355
                SDL_strlcat(text, event.text.text, sizeof(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
   356
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
   357
            fprintf(stderr, "text inputed: %s\n", text);
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
   358
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
   359
            // After text inputed, we can clear up markedText because it
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
   360
            // is committed
4756
b99b1024607a Changed markedText to have its own storage to resolve multiple bugs.
dewyatt
parents: 4465
diff changeset
   361
            markedText[0] = 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
   362
            Redraw();
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
   363
            break;
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
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
   365
        case SDL_TEXTEDITING:
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
   366
            fprintf(stderr, "text editing \"%s\", selected range (%d, %d)\n",
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
   367
                    event.edit.text, event.edit.start, event.edit.length);
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
4756
b99b1024607a Changed markedText to have its own storage to resolve multiple bugs.
dewyatt
parents: 4465
diff changeset
   369
            strcpy(markedText, event.edit.text);
4757
140be6839185 Correctly draw cursor based on position.
dewyatt
parents: 4756
diff changeset
   370
            cursor = event.edit.start;
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
   371
            Redraw();
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
   372
            break;
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
   373
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
   374
        case 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
   375
            done = 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
   376
            break;
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
   377
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
   378
        default:
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
   379
            break;
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
   380
        }
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
   381
    }
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
    CleanupVideo();
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
   384
    return 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
   385
}
5244
762e40fb8e28 Be explicit about what display you're querying. The default display is 0.
Sam Lantinga <slouken@libsdl.org>
parents: 5150
diff changeset
   386
762e40fb8e28 Be explicit about what display you're querying. The default display is 0.
Sam Lantinga <slouken@libsdl.org>
parents: 5150
diff changeset
   387
/* vi: set ts=4 sw=4 expandtab: */