On Friday 24 January 2003 3:04 pm, [EMAIL PROTECTED] wrote: > On Thu, 23 Jan 2003, Angus Leeming wrote: > > Excellent. Why don't you send this patch to the xforms list too. > > I have not finished the work yet. > > >That means you've fixed two of the three problem areas. All that remains > > is the XmbLookupString mess and the 'linking problem'. > > Yes, sort of ... > > > Ie, the code in XWorkArea would become: > > // Moving lyxim.LookupString into xforms means that we > > // don't have to interrogate the raw XEvent any more. > > case FL_KEYPRESS: > > { > > KeySym keysym = event; > > int num_bytes = 0; > > char str[256]; > > if (keysym == 0) > > // New xforms routine. > > fl_fill_composed_string(&num_bytes, str); > > > > if (!keysym && num_bytes) > > area->workAreaCJK_IMprocess(num_bytes,str); > > > > ... > > } > > What does this "fi_fill_composed_string" do?
The essential features of xforms' do_keyboard routine can be viewed as void do_keyboard(XEvent * xev, int formevent) { KeySym keysym = 0; unsigned char keybuf[227]; kbuflen = fl_XLookupString((XKeyEvent *) xev, (char *) keybuf, sizeof(keybuf), &keysym); fl_handle_form(keyform, formevent, keysym, xev); } (Assume that fl_XLookupString contains your LookupString code and therefore 'does the right thing'.) fl_handle_form passes control to fl_keyboard in the case of a KEYPRESS event, but the kbuflen and keybuf that are important to CJK are discarded. I'm proposing that these variables become global static variables in forms.c and that a new function is used to access them. void fl_get_composed_string(int * ptr_kbuflen, char const * ptr_keybuf) { if (!ptr_kbuflen) return; *ptr_kbuflen = kbuflen; ptr_keybuf = keybuf; } This suggestion has the added advantage that the current code in do_keyboard: unsigned char *ch; /* all regular keys, including mapped strings */ for (ch = keybuf; ch < (keybuf + kbuflen) && keyform; ch++) fl_handle_form(keyform, formevent, *ch, xev); is no longer necessary and we can use fl_handle_form(keyform, formevent, keysym, xev); Which make life really easy for non-CJK use (and enables a considerable clean up in the rest of xforms' keyboard handling code). > > Does this make sense? > I think your idea will work at least for CJK-LyX. I have a modified version of the xforms 1.0final code in which I have performed this clean-up already. Most of the changes in the code are due to the changed way I call fl_handle_form from do_keyboard; no need for magic numbers like '27' anymore. Instead I use XK_Escape. (I've also fixed a couple of other little bugs, but that's not relevant to this discussion). This clean-up allows the code in XWorkArea.C to be simplified also since it only receives XEvents for which keysym != 0. I believe that CJK-LyX is also interested only in such XEvents if the XmbLookupString code in xforms works correctly and if kbuflen and keybuf are accessible? Anyway, I attach my diff to the xforms 1.0final code in the hope that you find it useful. Best regards, Angus ps, I have not added void fl_get_composed_string(int * ptr_kbuflen, char const * ptr_keybuf); to forms.h. You'll need to declare it's prototype in your own code. A
xforms.diff.bz2
Description: BZip2 compressed data