~ubuntu-branches/ubuntu/lucid/libx11/lucid

« back to all changes in this revision

Viewing changes to modules/im/ximcp/imThaiFlt.c

  • Committer: Bazaar Package Importer
  • Author(s): Timo Aaltonen
  • Date: 2009-01-17 16:34:54 UTC
  • mfrom: (1.1.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20090117163454-gaey3cd32xyavueo
Tags: 2:1.1.99.2-1build1
Fakesync with Debian, all previous Ubuntu changes are included
in the new upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
 
29
29
                        All Rights Reserved
30
30
 
31
 
Permission to use, copy, modify, and distribute this software and its 
32
 
documentation for any purpose and without fee is hereby granted, 
 
31
Permission to use, copy, modify, and distribute this software and its
 
32
documentation for any purpose and without fee is hereby granted,
33
33
provided that the above copyright notice appear in all copies and that
34
 
both that copyright notice and this permission notice appear in 
 
34
both that copyright notice and this permission notice appear in
35
35
supporting documentation, and that the name of Digital not be
36
36
used in advertising or publicity pertaining to distribution of the
37
 
software without specific, written prior permission.  
 
37
software without specific, written prior permission.
38
38
 
39
39
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
40
40
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
48
48
/* $XFree86: xc/lib/X11/imThaiFlt.c,v 3.22tsi Exp $ */
49
49
 
50
50
/*
51
 
**++ 
52
 
**  FACILITY: 
53
 
** 
54
 
**      Xlib 
55
 
** 
56
 
**  ABSTRACT: 
57
 
** 
 
51
**++
 
52
**  FACILITY:
 
53
**
 
54
**      Xlib
 
55
**
 
56
**  ABSTRACT:
 
57
**
58
58
**      Thai specific functions.
59
59
**      Handles character classifications, composibility checking,
60
60
**      Input sequence check and other Thai specific requirements
61
61
**      according to WTT specification and DEC extensions.
62
 
** 
63
 
**  MODIFICATION HISTORY: 
64
 
** 
 
62
**
 
63
**  MODIFICATION HISTORY:
 
64
**
65
65
**/
66
66
 
67
67
#ifdef HAVE_CONFIG_H
318
318
 
319
319
Private Bool
320
320
THAI_iscomposible (
321
 
    unsigned char       follow_ch, 
 
321
    unsigned char       follow_ch,
322
322
    unsigned char       lead_ch)
323
323
{/* "Can follow_ch be put in the same display cell as lead_ch?" */
324
324
 
325
 
    return (write_rules_lookup[THAI_chtype(lead_ch)][THAI_chtype(follow_ch)] 
 
325
    return (write_rules_lookup[THAI_chtype(lead_ch)][THAI_chtype(follow_ch)]
326
326
            == CP);
327
327
}
328
328
 
329
329
Private Bool
330
330
THAI_isaccepted (
331
 
    unsigned char       follow_ch, 
 
331
    unsigned char       follow_ch,
332
332
    unsigned char       lead_ch,
333
333
    unsigned char       mode)
334
334
{
337
337
    switch (mode)
338
338
    {
339
339
        case WTT_ISC1:
340
 
            iskeyvalid = 
 
340
            iskeyvalid =
341
341
          (wtt_isc1_lookup[THAI_chtype(lead_ch)][THAI_chtype(follow_ch)] != RJ);
342
342
            break;
343
343
        case WTT_ISC2:
344
 
            iskeyvalid = 
 
344
            iskeyvalid =
345
345
          (wtt_isc2_lookup[THAI_chtype(lead_ch)][THAI_chtype(follow_ch)] != RJ);
346
346
            break;
347
347
        case THAICAT_ISC:
357
357
}
358
358
 
359
359
#ifdef UNUSED
360
 
Private void 
 
360
Private void
361
361
THAI_apply_write_rules(
362
 
    unsigned char       *instr, 
363
 
    unsigned char       *outstr, 
364
 
    unsigned char       insert_ch, 
 
362
    unsigned char       *instr,
 
363
    unsigned char       *outstr,
 
364
    unsigned char       insert_ch,
365
365
    int                 *num_insert_ch)
366
366
{
367
367
/*
368
 
Input parameters: 
 
368
Input parameters:
369
369
    instr - input string
370
370
    insert_ch specify what char to be added when invalid composition is found
371
371
Output parameters:
389
389
        *out_ch++ = *lead_ch;
390
390
        while (*follow_ch != '\0')  /* more char in string to check */
391
391
        {
392
 
            if (THAI_isdead(*follow_ch) && 
393
 
                 !THAI_iscomposible(*follow_ch,*lead_ch)) 
 
392
            if (THAI_isdead(*follow_ch) &&
 
393
                 !THAI_iscomposible(*follow_ch,*lead_ch))
394
394
            {
395
395
                *out_ch++ = SPACE;
396
396
                (*num_insert_ch)++;
403
403
    }
404
404
}
405
405
 
406
 
Private int 
 
406
Private int
407
407
THAI_find_chtype (
408
 
    unsigned char       *instr, 
 
408
    unsigned char       *instr,
409
409
    int         chtype)
410
410
{
411
411
/*
423
423
        case DEAD:
424
424
            for (i = 0; *instr != '\0' && THAI_isdead(*instr); i++, instr++)
425
425
                ;
426
 
            if (*instr != '\0') position = i; 
 
426
            if (*instr != '\0') position = i;
427
427
            break;
428
428
        default:
429
429
            break;
432
432
}
433
433
 
434
434
 
435
 
Private int 
 
435
Private int
436
436
THAI_apply_scm(
437
 
    unsigned char       *instr, 
438
 
    unsigned char       *outstr, 
439
 
    unsigned char       spec_ch, 
440
 
    int         num_sp, 
 
437
    unsigned char       *instr,
 
438
    unsigned char       *outstr,
 
439
    unsigned char       spec_ch,
 
440
    int         num_sp,
441
441
    unsigned char       insert_ch)
442
442
{
443
443
    unsigned char   *scan, *outch;
452
452
        if (THAI_isdead(*scan))
453
453
            dead_count++;       /* count number of non-spacing char */
454
454
        if (*scan == spec_ch)
455
 
            if (!isconsecutive) 
 
455
            if (!isconsecutive)
456
456
                found_count++;      /* count number consecutive spec char found */
457
457
        *outch++ = *scan++;
458
458
        if (found_count == num_sp) {
474
474
Private CARD8 FindKeyCode();
475
475
 
476
476
 
477
 
/* The following functions are specific to this module */ 
 
477
/* The following functions are specific to this module */
478
478
 
479
479
Private int XThaiTranslateKey();
480
480
Private int XThaiTranslateKeySym();
794
794
    }
795
795
    /*
796
796
     * ThaiCat keyboard support :
797
 
     * When the Shift and Thai keys are hold for some keys a 'Thai Compose'  
 
797
     * When the Shift and Thai keys are hold for some keys a 'Thai Compose'
798
798
     * character code is generated which is different from column 3 and
799
 
     * 4 of the keymap. 
 
799
     * 4 of the keymap.
800
800
     * Since we don't know whether ThaiCat keyboard or WTT keyboard is
801
801
     * in use, the same mapping is done for all Thai input.
802
 
     * We just arbitary choose to use column 3 keysyms as the indices of 
 
802
     * We just arbitary choose to use column 3 keysyms as the indices of
803
803
     * this mapping.
804
804
     * When the control key is also hold, this mapping has no effect.
805
805
     */
817
817
    return 1;
818
818
}
819
819
 
820
 
/* 
 
820
/*
821
821
 * XThaiTranslateKeySym
822
822
 *
823
823
 * Translate KeySym to TACTIS code output.
836
836
    int nbytes)
837
837
{
838
838
    KeySym ckey = 0;
839
 
    register struct _XKeytrans *p; 
 
839
    register struct _XKeytrans *p;
840
840
    int length;
841
841
    unsigned long hiBytes;
842
842
    register unsigned char c;
913
913
    }
914
914
    /*
915
915
     *  ThaiCat has a key that generates two TACTIS codes D1 & E9.
916
 
     *  It is represented by the latin-1 keysym XK_thorn (0xfe). 
917
 
     *  If c is XK_thorn, this key is pressed and it is converted to  
 
916
     *  It is represented by the latin-1 keysym XK_thorn (0xfe).
 
917
     *  If c is XK_thorn, this key is pressed and it is converted to
918
918
     *  0xd1 0xe9.
919
919
     */
920
920
    if (c == XK_thorn) {
940
940
    register KeySym code)
941
941
{
942
942
 
943
 
    register KeySym *kmax = dpy->keysyms + 
 
943
    register KeySym *kmax = dpy->keysyms +
944
944
        (dpy->max_keycode - dpy->min_keycode + 1) * dpy->keysyms_per_keycode;
945
945
    register KeySym *k = dpy->keysyms;
946
946
    while (k < kmax) {
990
990
 *
991
991
 *
992
992
 * Compose handling routines - compose handlers 0,1,2
993
 
 * 
994
 
 * 
 
993
 *
 
994
 *
995
995
 ************************************************************************/
996
996
 
997
997
#define NORMAL_KEY_STATE 0
1087
1087
        hi_digit = ks1 - XK_a + 10;
1088
1088
    else        /* out of range */
1089
1089
        return NoSymbol;
1090
 
            
 
1090
 
1091
1091
    if ((ks2 >= XK_0) && (ks2 <= XK_9))
1092
1092
        lo_digit = ks2 - XK_0;
1093
1093
    else if ((ks2 >= XK_A) && (ks2 <= XK_F))
1156
1156
#endif
1157
1157
 
1158
1158
/*
1159
 
 * Initialize ISC mode from im modifier 
 
1159
 * Initialize ISC mode from im modifier
1160
1160
 */
1161
1161
Private void InitIscMode(Xic ic)
1162
1162
{
1187
1187
 
1188
1188
    return;
1189
1189
}
1190
 
    
 
1190
 
1191
1191
/*
1192
1192
 * Helper functions for _XimThaiFilter()
1193
1193
 */
1285
1285
           IsMiscFunctionKey(symbol) ||
1286
1286
           IsFunctionKey(symbol))))
1287
1287
        {
1288
 
            IC_ClearPreviousChar(ic); 
 
1288
            IC_ClearPreviousChar(ic);
1289
1289
            return False;
1290
1290
        }
1291
1291
    if (((symbol >> 8 == 0xFF) &&
1304
1304
        return False;
1305
1305
 
1306
1306
    /*
1307
 
     *  Hex input method processing 
 
1307
     *  Hex input method processing
1308
1308
     */
1309
1309
 
1310
1310
    thai_part = &ic->private.local.thai;