Scott Harper <lareon comcast.net> writes:
Here are my thoughts on that, however. I don’t recall (though I may
be very wrong) SDL having a focus on text input, necessarily. This
makes me think that an IME (I don’t know about XIM at all) would be
better served as a separate library altogether. My (off the top of
my head) method of implementation would likely be something where you
acquire an instance or a reference to an IME object based on the
language and encoding (probably need to do some abstraction of the
encoding here, though, as I don’t think every programmer using a
library should have to learn the minute details of things like that
to use it right), then as the user types in characters, the
programmer sends those characters (added to each other) to the IME
object, which returns an initial state of what to display. For
instance, when I type in Japanese using Windows’ or Apple’s IMEs, as
I type the string “watashi” I get it in chunks, like “w”, “?”, “?
t”, “??”, “??s”, “??sh”, “???”, because the
different characters represent larger sounds than are made by roman
alpha letters. (Hopefully most people could read that, otherwise
you’ll just have to imagine.)
??? ??? (Thank you very much!)
http://sdl-im.csie.net/image/thanks_jp.png
That is the same sample just with the different font
and using different IM Client.
The original one is here:
http://sdl-im.csie.net/image/sdl_ttf_sample.png
The Japanese input would be a simple case.
Because Japanese is a phonetic transcription language,
the most composition rules of Japanese IM is typing roman alpha letters
to combine the sounds form words.
But for ideogram, the composition rules is many.
As I know, there are more then twenty rules to type Traditional Chinese.
I also think SDL doesn’t focus on text input.
But If SDL could support IM handle,
there would be many possible imagination to implement.
For example, If I want to design a RPG that players could type
their native language to talk with AI NPC in the game
to get some information or make friends(or make girl friends),
not just select the talking selections to talk,
I could feel easy in mind to use SDL.
It would be more interesting.
Since to support IM handle couldn’t effect the performance of SDL,
we would be only too glad to do it!
(About performance statistics, please see http://sdlim.thoforum.com/ .
The title is “A strange problem with SDL1.2.8” in talk board.)
I also consider to provide a separated library altogether is a better idea,
(Wow, my own project! so cool, isn’t it?)
but to provide a optional package is difficult.
If it is easy, I am very glad to provide a cross-platform package,
even if it doesn’t need SDL.
Because to get an IM instance you could do nothing,
we have to patch the inner event handling of SDL to support IM handle.
I had complained the problems when I used SDL_inputmethod(it’s not my work):
http://sdl-im.csie.net/SDL_inputmethod.html
I had said that “it has strange bugs in win32 that can’t show
the IM state is on or off correctly.
it fails in my Linux. In my laptop, it may crash,
and in another machine, it can’t work.”.
But please see the official site of SDL_inputmethod:
http://sdlinputmethod.sourceforge.net/index.php?l=en
especially the screenshots, it worked fine, didn’t it?
Is their XIM server different from mine? Impossible.
Because SDL_inputmethod project is earlier then SDL-IM,
perhaps it is not the bugs of SDL_inputmethod.
Honestly, I guess the reason of working fail of SDL_inputmethod is
that the newer version of SDL might change some behavior of event handling
and SDL_inputmethod just support early version of SDL,
so that SDL_inputmethod works fail with newer version of SDL.
If it is true unfortunately and I decide to provide a optional package,
then people could see the announcement in my site:
"Well, SDL_im is an independent package altogether,
but it just support SDL-1.2.11.
If you want to upgrade to SDL-1.2.12, you have to patch it please."
Hmm… it looks not a good idea, doesn’t it?
Input Method is not a fashion word. Since the age of DOS,
people try hard to let they can type their native language.
Until the coming of win95, it has a standard to do,
although it is not a good standard.
In fact, I really don’t care whether my patch
could be a part of official release or not,
just because the IM support problem had bother many people so long time ago.
If anybody has a better idea, I will do my best to support him.
I planed to start a improved version of SDL-IM after three or four months.
(Maybe just support the newer version of SDL.)
Before starting, I hope to hear more suggestions, complaint, or bug reports.
If SDL developers could give me their thinking, I will be appreciated.
So then the next thing to do is for the program to listen for the
window key (ie: the key to open the options for the other characters
to use in each case), and then get a list of the items and display
them, allow interaction, etc…
Pardon me, I am not very sure what you mean.
If the window key is to act on IM window,
there is nothing to do with server side.
It occurs to me that one could design it such that if you’re editing
text, ALL keyboard input gets sent to the IME library which then
tells the program either what to do OR (somewhat like a UI library)
takes over drawing things itself using whatever variant’s drawing
methods, for instance Opengl, SDL, Allegro, etc… The UI library
Guichan does this and it generally works pretty well I’ve noticed.
Pardon me, would you mean to draw IM window in SDL window?
If it is, you could use SDL_imm.
And you mention the Guichan,
there is a patch made by harpy for Guichan to use SDL-IM to support IME.
But the link in my site is dead.
Anyway, those are my thoughts, though where to even BEGIN writing an
IME library I am COMPLETELY lost! >.<
I am, however, always happy to theorize and discuss,
Thanks you again.
Your reply give me a chance to explain more.
I think Input Method support is a easy hard work.
It is easy because to patch is not a hard work.
It is hard because to test is not a easy work.
I will be appreciated any suggestion, complaint, or bug report.
Finally, thanks for Scott and Bill’s replies.