Sean Egan's Blog

Enter vs. Control-Enter

Another change made in the beta cycle between 1.5.0 and 2.0.0beta7 is in our handling of what key you press to send a message. In 1.5.0 there was an option in the Preferences dialog that let you choose between Enter and Control-Enter. In beta7, that option is removed from the preferences window, leading many to believe you can no longer customize this keybinding. In fact, it still is possible, but the configuration has been delegated elsewhere. Perhaps this shall explain why, but first you'll need to learn a little Korean.

A Korean Lesson

In the Korean alphabet, called Hangul, each character represents a single sylable. My name, "Sean Egan," is three sylables long and is written in Korean as 숀이근. Three sylables, three characters.

Each sylable is composed of between one to four sounds, each sound being represented by a letter. My first name, 숀, is composed of three letters, ㅅ, ㅛ, and ㄴ. These represent the sounds "s," "yo," and "n," respectively. Stack them all on top of each other, and you get "Sean."

This is a really good picture of a Korean keyboard. You can see the first two letters of my name on the T and Y keys. The third letter is on the S key, just out of view. So, to spell my name in Korean, I have to type "TYS," just to create one character. A fairly low-level element in the computer's windowing system called the Input Method is responsible for interpreting these three keystrokes and telling the application "this is the character 숀."

Gaim 1.5.0

Gaim 1.5.0 (and earlier) offered the ability to configure the "send" (among other) keystrokes from the preferences window. This worked by intercepting these low-level, individual keystrokes (t, y, and s), and saying "is this the enter key?" or "is this ctrl-enter?" and, if so, copy what's in the textbox and send it.

The problem with this is that, since we intercepted the keystrokes as they came in, the input method never received them. This means that, if the input method has not yet 'finished' the character, then it's not in the input box, when we pull it out to send. This should illustrate it nicely:

After typing 근, the input method still doesn't know if this character is done yet (it could potentially be 귽, for instance), and so it doesn't get sent. It remains, uncompleted, in the textbox. This, of course, is not at all unique to Korean, but to any language that requires complex input methods (e.g. Japanese, Chinese, etc.).

Pidgin 2.0.0beta7

For 2.0.0, we've changed this behavior. No longer do we intercept keystrokes before the input method sees them, but we've asked the lower layer (in this case, GTK+, the GUI toolkit we use) to tell us when someone has asked us to "Send." We've also told GTK+ that "Enter" is a reasonable default character to use to trigger this signal. Now, GTK+ receives keyboard input, correctly processes it with the input method, and if it matches its 'Send' command, tells Pidgin to send.

Everything works as it should.

Conclusion

So, since GTK+ now tells us "this person wants to send a message," instead of "this person hit the Enter key," we can't easily make the key to use configurable. Thankfully, GTK+ makes it possible to configure it to anything. See our example gtkrc file to see how to configure keybindings. It's certainly not as straightforward as a checkbox in the preferences dialog, but compared to keeping a huge percentage of the world's population from sending IMs at all, it's a fair sacrifice.