2000-02-21 10:30:00 +00:00
|
|
|
//
|
2005-02-24 21:55:12 +00:00
|
|
|
// "$Id$"
|
2000-02-21 10:30:00 +00:00
|
|
|
//
|
|
|
|
// Character compose processing for the Fast Light Tool Kit (FLTK).
|
|
|
|
//
|
2010-11-28 21:06:39 +00:00
|
|
|
// Copyright 1998-2010 by Bill Spitzak and others.
|
2000-02-21 10:30:00 +00:00
|
|
|
//
|
|
|
|
// This library is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU Library General Public
|
|
|
|
// License as published by the Free Software Foundation; either
|
|
|
|
// version 2 of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// Library General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Library General Public
|
|
|
|
// License along with this library; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
|
// USA.
|
|
|
|
//
|
2005-04-16 00:13:17 +00:00
|
|
|
// Please report all bugs and problems on the following page:
|
|
|
|
//
|
|
|
|
// http://www.fltk.org/str.php
|
2000-02-21 10:30:00 +00:00
|
|
|
//
|
|
|
|
|
|
|
|
#include <FL/Fl.H>
|
2009-12-06 22:21:55 +00:00
|
|
|
#include <FL/x.H>
|
2000-02-21 10:30:00 +00:00
|
|
|
|
2008-09-18 19:09:34 +00:00
|
|
|
#ifndef FL_DOXYGEN
|
2010-11-28 09:12:36 +00:00
|
|
|
// at present, this is effectively used by Mac OS X only
|
2002-11-08 16:05:33 +00:00
|
|
|
int Fl::compose_state = 0;
|
2008-09-18 19:09:34 +00:00
|
|
|
#endif
|
2000-02-21 10:30:00 +00:00
|
|
|
|
2010-11-28 09:12:36 +00:00
|
|
|
/** Any text editing widget should call this for each FL_KEYBOARD event.
|
|
|
|
Use of this function is very simple.
|
|
|
|
|
|
|
|
<p>If <i>true</i> is returned, then it has modified the
|
|
|
|
Fl::event_text() and Fl::event_length() to a set of <i>bytes</i> to
|
|
|
|
insert (it may be of zero length!). In will also set the "del"
|
|
|
|
parameter to the number of <i>bytes</i> to the left of the cursor to
|
|
|
|
delete, this is used to delete the results of the previous call to
|
|
|
|
Fl::compose().
|
|
|
|
|
|
|
|
<p>If <i>false</i> is returned, the keys should be treated as function
|
|
|
|
keys, and del is set to zero. You could insert the text anyways, if
|
|
|
|
you don't know what else to do.
|
|
|
|
|
|
|
|
<p>Though the current implementation returns immediately, future
|
|
|
|
versions may take quite awhile, as they may pop up a window or do
|
|
|
|
other user-interface things to allow characters to be selected.
|
|
|
|
*/
|
2010-10-26 21:01:17 +00:00
|
|
|
int Fl::compose(int& del) {
|
2010-11-28 09:12:36 +00:00
|
|
|
// character composition is now handled by the OS
|
2010-11-20 12:59:39 +00:00
|
|
|
del = 0;
|
2010-11-28 09:12:36 +00:00
|
|
|
#if defined(__APPLE__)
|
2010-11-19 19:00:50 +00:00
|
|
|
// this stuff is to be treated as a function key
|
2010-10-26 21:01:17 +00:00
|
|
|
if(Fl::e_length == 0 || Fl::e_keysym == FL_Enter || Fl::e_keysym == FL_KP_Enter ||
|
2010-11-28 09:12:36 +00:00
|
|
|
Fl::e_keysym == FL_Tab || Fl::e_keysym == FL_Escape || Fl::e_state&(FL_META | FL_CTRL) ) {
|
2010-10-26 21:01:17 +00:00
|
|
|
return 0;
|
2010-11-20 18:03:14 +00:00
|
|
|
}
|
2010-11-28 09:12:36 +00:00
|
|
|
#else
|
|
|
|
unsigned char ascii = (unsigned)e_text[0];
|
|
|
|
if ((e_state & (FL_ALT | FL_META)) && !(ascii & 128)) return 0;
|
2010-11-20 12:59:39 +00:00
|
|
|
#endif
|
2010-10-26 21:01:17 +00:00
|
|
|
if(Fl::compose_state) {
|
2011-01-03 16:50:34 +00:00
|
|
|
del = Fl::compose_state;
|
2010-10-26 21:01:17 +00:00
|
|
|
Fl::compose_state = 0;
|
2010-11-20 18:03:14 +00:00
|
|
|
} else {
|
2010-11-28 09:12:36 +00:00
|
|
|
#ifndef __APPLE__
|
2010-11-19 19:00:50 +00:00
|
|
|
// Only insert non-control characters:
|
2010-11-20 12:59:39 +00:00
|
|
|
if (! (ascii & ~31 && ascii!=127)) { return 0; }
|
2010-11-19 19:00:50 +00:00
|
|
|
#endif
|
2010-11-20 18:03:14 +00:00
|
|
|
}
|
2010-10-26 21:01:17 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// End of "$Id$"
|
|
|
|
//
|
2006-04-19 03:00:26 +00:00
|
|
|
|