~ubuntu-branches/ubuntu/saucy/fltk1.1/saucy-proposed

« back to all changes in this revision

Viewing changes to src/Fl_compose.cxx

  • Committer: Bazaar Package Importer
  • Author(s): Aaron M. Ucko
  • Date: 2008-03-29 09:48:46 UTC
  • mto: (2.1.10 intrepid)
  • mto: This revision was merged to the branch mainline in revision 5.
  • Revision ID: james.westby@ubuntu.com-20080329094846-cof1xqv7t0dnv0bc
Tags: upstream-1.1.8
ImportĀ upstreamĀ versionĀ 1.1.8

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
//
2
 
// "$Id: Fl_compose.cxx 4288 2005-04-16 00:13:17Z mike $"
 
2
// "$Id: Fl_compose.cxx 5211 2006-06-19 07:43:39Z matt $"
3
3
//
4
4
// Character compose processing for the Fast Light Tool Kit (FLTK).
5
5
//
36
36
//#define OLD_DEAD_KEY_CODE
37
37
 
38
38
 
39
 
static const char* const compose_pairs =
 
39
#ifdef __APPLE__
 
40
 
 
41
static const char* const compose_pairs =
 
42
":A*A,C'E~N:O:U'a`a^a:a~a*a,c'e`e"
 
43
"^e:e'i`i^i:i~n'o`o^o:o~o'u`u^u:u"
 
44
"+ o /c# SS* P|ssrOcOTM' : !=AE/O"
 
45
"oo+-<=>=Y=mudtSgPipiS a dgOmaeo/"
 
46
"? ! !!v-f ~~Dt<<>>..  `A~A~OOEoe"
 
47
"- --''``\"'\"`:-^V:y:Y//E=< > fifl"
 
48
"++..,,_\"%%^A^E'A:E`E'I^I:I`I'O^O"
 
49
"mc`O'U^U`U||^ ~^_ u . * , ~-; v ";
 
50
 
 
51
#else
 
52
 
 
53
static const char* const compose_pairs =
 
54
"=E  _'f _\"..+ ++^ %%^S< OE  ^Z    ^''^^\"\"^-*- --~ TM^s> oe  ^z:Y" 
40
55
"  ! % # $ y=| & : c a <<~ - r _ * +-2 3 ' u p . , 1 o >>141234? "
41
56
"`A'A^A~A:A*AAE,C`E'E^E:E`I'I^I:I-D~N`O'O^O~O:Ox O/`U'U^U:U'YTHss"
42
57
"`a'a^a~a:a*aae,c`e'e^e:e`i'i^i:i-d~n`o'o^o~o:o-:o/`u'u^u:u'yth:y";
43
58
 
 
59
#endif
 
60
 
44
61
#if !defined(WIN32) && defined(OLD_DEAD_KEY_CODE) // X only
45
62
// X dead-key lookup table.  This turns a dead-key keysym into the
46
63
// first of two characters for one of the compose sequences.  These
88
105
#endif // __APPLE__
89
106
 
90
107
  if (compose_state == 1) { // after the compose key
 
108
    if ( // do not get distracted by any modifier keys
 
109
      e_keysym==FL_Shift_L||
 
110
      e_keysym==FL_Shift_R ||
 
111
      e_keysym==FL_Alt_L ||
 
112
      e_keysym==FL_Alt_R ||
 
113
      e_keysym==FL_Meta_L ||
 
114
      e_keysym==FL_Meta_R ||
 
115
      e_keysym==FL_Control_R ||
 
116
      e_keysym==FL_Control_L ||
 
117
      e_keysym==FL_Menu
 
118
      ) return 0;
91
119
 
92
120
    if (ascii == ' ') { // space turns into nbsp
 
121
#ifdef __APPLE__
 
122
      e_text[0] = char(0xCA);
 
123
#else
93
124
      e_text[0] = char(0xA0);
 
125
#endif
94
126
      compose_state = 0;
95
127
      return 1;
96
128
    } else if (ascii < ' ' || ascii == 127) {
101
133
    // see if it is either character of any pair:
102
134
    for (const char *p = compose_pairs; *p; p += 2) 
103
135
      if (p[0] == ascii || p[1] == ascii) {
104
 
        if (p[1] == ' ') e_text[0] = (p-compose_pairs)/2+0xA0;
 
136
        if (p[1] == ' ') e_text[0] = (p-compose_pairs)/2+0x80;
105
137
        compose_state = ascii;
106
138
        return 1;
107
139
      }
114
146
  } else if (compose_state) { // second character of compose
115
147
 
116
148
    char c1 = char(compose_state); // retrieve first character
 
149
#ifdef __APPLE__
 
150
    if ( (c1==0x60 && ascii==0xab) || (c1==0x27 && ascii==0x60)) {
 
151
      del = 1;
 
152
      compose_state = '^';
 
153
      e_text[0] = 0xf6;
 
154
      return 1;
 
155
    }
 
156
    if (ascii==' ') {
 
157
      del = 0;
 
158
      compose_state = 0;
 
159
      return 0;
 
160
    }
 
161
#endif
117
162
    // now search for the pair in either order:
118
163
    for (const char *p = compose_pairs; *p; p += 2) {
119
164
      if (p[0] == ascii && p[1] == c1 || p[1] == ascii && p[0] == c1) {
120
 
        e_text[0] = (p-compose_pairs)/2+0xA0;
 
165
        e_text[0] = (p-compose_pairs)/2+0x80;
121
166
        del = 1; // delete the old character and insert new one
122
167
        compose_state = 0;
123
168
        return 1;
134
179
    return 1;
135
180
  }
136
181
 
137
 
#ifndef WIN32 // X only
 
182
#ifdef WIN32
 
183
#elif (defined __APPLE__)
 
184
  if (e_state & 0x40000000) {
 
185
    if (ascii<0x80)
 
186
      compose_state = ascii;
 
187
    else
 
188
      compose_state = compose_pairs[(ascii-0x80)*2];
 
189
    return 1;
 
190
  }
 
191
#else
138
192
  // See if they typed a dead key.  This gets it into the same state as
139
193
  // typing prefix+accent:
140
194
  if (i >= 0xfe50 && i <= 0xfe5b) {
149
203
    ascii = e_text[0];
150
204
    for (const char *p = compose_pairs; *p; p += 2)
151
205
      if (p[0] == ascii ||
152
 
          (p[1] == ' ' && (p - compose_pairs) / 2 + 0xA0 == ascii)) {
 
206
          (p[1] == ' ' && (p - compose_pairs) / 2 + 0x80 == ascii)) {
153
207
        compose_state = p[0];
154
208
        return 1;
155
209
      }
165
219
  return 0;
166
220
}
167
221
 
 
222
 
 
223