2 // "$Id: Fl_compose.cxx 8626 2011-04-27 11:21:57Z manolo $"
4 // Character compose processing for the Fast Light Tool Kit (FLTK).
6 // Copyright 1998-2010 by Bill Spitzak and others.
8 // This library is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU Library General Public
10 // License as published by the Free Software Foundation; either
11 // version 2 of the License, or (at your option) any later version.
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Library General Public License for more details.
18 // You should have received a copy of the GNU Library General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
23 // Please report all bugs and problems on the following page:
25 // http://www.fltk.org/str.php
32 int Fl::compose_state
= 0;
35 #if !defined(WIN32) && !defined(__APPLE__)
39 /** Any text editing widget should call this for each FL_KEYBOARD event.
40 Use of this function is very simple.
42 <p>If <i>true</i> is returned, then it has modified the
43 Fl::event_text() and Fl::event_length() to a set of <i>bytes</i> to
44 insert (it may be of zero length!). In will also set the "del"
45 parameter to the number of <i>bytes</i> to the left of the cursor to
46 delete, this is used to delete the results of the previous call to
49 <p>If <i>false</i> is returned, the keys should be treated as function
50 keys, and del is set to zero. You could insert the text anyways, if
51 you don't know what else to do.
53 <p>Though the current implementation returns immediately, future
54 versions may take quite awhile, as they may pop up a window or do
55 other user-interface things to allow characters to be selected.
57 int Fl::compose(int& del
) {
58 // character composition is now handled by the OS
60 #if defined(__APPLE__)
61 // this stuff is to be treated as a function key
62 if(Fl::e_length
== 0 || Fl::e_keysym
== FL_Enter
|| Fl::e_keysym
== FL_KP_Enter
||
63 Fl::e_keysym
== FL_Tab
|| Fl::e_keysym
== FL_Escape
|| Fl::e_state
&(FL_META
| FL_CTRL
) ) {
67 unsigned char ascii
= (unsigned)e_text
[0];
68 if ((e_state
& (FL_ALT
| FL_META
)) && !(ascii
& 128)) return 0;
70 unsigned char ascii
= (unsigned)e_text
[0];
71 if ((e_state
& (FL_ALT
| FL_META
| FL_CTRL
)) && !(ascii
& 128)) return 0;
73 if(Fl::compose_state
) {
74 del
= Fl::compose_state
;
75 Fl::compose_state
= 0;
78 // Only insert non-control characters:
79 if (! (ascii
& ~31 && ascii
!=127)) { return 0; }
86 If the user moves the cursor, be sure to call Fl::compose_reset().
87 The next call to Fl::compose() will start out in an initial state. In
88 particular it will not set "del" to non-zero. This call is very fast
89 so it is ok to call it many times and in many places.
91 void Fl::compose_reset()
93 Fl::compose_state
= 0;
94 #if !defined(WIN32) && !defined(__APPLE__)
95 if (fl_xim_ic
) XmbResetIC(fl_xim_ic
);
100 // End of "$Id: Fl_compose.cxx 8626 2011-04-27 11:21:57Z manolo $"