SDL Unicode Text Input Mac Support Monthly Report (June 2009)


This is the first monthly status report about my GSoC project: adding
Unicode text input support in SDL for Mac OS X. So far, here are what
I’ve done:

  1. Modified video/cocoa/SDL_cocoakeyboard.m to send SDL_TEXTINPUT
    event for composed text (aka. the text produced by IME) instead of raw

What does it mean?

Before this change, when you trying to input a Chinese character, say,
"?", you’ll activate a Chinese Pinyin IME, type “zhong”, but within a
SDL program, you will only receive SDL_TEXTINPUT event with raw
characters, “zhong”.

After this change, the character we intended to get, “?” will be
receive as the ‘event.text.text’ parameter through SDL_TEXTINPUT

See 1 for detailed code.

  1. Support system-wide keyboard shortcuts to activate/switch between
    input methods.

Normally a user will use keyboard shortcuts (CMD + Space and CMD +
Shift + Space) to pick the input method. If we can’t do that in a SDL
program, we will have to pick the input method from system status bar
(upper-right corner of the screen) with mouse click.

See 2.

  1. Marked text (on-the-spot text editing) support.

As described in 3, marked text is a crucial part of full text input
support for Mac OS X applications, without that there is no way to
tell what characters we are currently inputing, and the system can’t
put the candidate window close to the text field.

In short, supporting marked text in Mac OS X means we need to provide
the location and area of the marked text (only the client program
knows where it will be placed in), and receive events to display such
marked text. For that purpose:

  1. Added NSTextInput protocol support (4)
  2. Added a new API called SDL_StartTextInput(SDL_Rect *rect) to inform
    SDL where the text we are going to input should be placed in.
    NSTextInput protocol will utilize such information to tell the system
    where to place the candidate window. (5)
  3. Add a event type called SDL_TEXTEDITING, to tell the client program
    what marked text are currently being edited (6)
  1. Finally, I created a sample program called testime.c to cover all
    the above changes and demonstrate how to use the above APIs.

See 7.

That’s it for June, during July, I’d like to:

  1. Discuss the above APIs with other students and mentors involved in
    this project.
  2. Fix bugs in current implementation.
  • Jiang