Back to index

im-sdk  12.3.91
composeIM.h
Go to the documentation of this file.
00001 /*
00002 Copyright 1990-2001 Sun Microsystems, Inc. All Rights Reserved.
00003 
00004 Permission is hereby granted, free of charge, to any person obtaining a
00005 copy of this software and associated documentation files (the
00006 "Software"), to deal in the Software without restriction, including
00007 without limitation the rights to use, copy, modify, merge, publish,
00008 distribute, sublicense, and/or sell copies of the Software, and to
00009 permit persons to whom the Software is furnished to do so, subject to
00010 the following conditions: The above copyright notice and this
00011 permission notice shall be included in all copies or substantial
00012 portions of the Software.
00013 
00014 
00015 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00016 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00017 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
00018 IN NO EVENT SHALL THE OPEN GROUP OR SUN MICROSYSTEMS, INC. BE LIABLE
00019 FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
00020 CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
00021 THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE EVEN IF
00022 ADVISED IN ADVANCE OF THE POSSIBILITY OF SUCH DAMAGES.
00023 
00024 
00025 Except as contained in this notice, the names of The Open Group and/or
00026 Sun Microsystems, Inc. shall not be used in advertising or otherwise to
00027 promote the sale, use or other dealings in this Software without prior
00028 written authorization from The Open Group and/or Sun Microsystems,
00029 Inc., as applicable.
00030 
00031 
00032 X Window System is a trademark of The Open Group
00033 
00034 OSF/1, OSF/Motif and Motif are registered trademarks, and OSF, the OSF
00035 logo, LBX, X Window System, and Xinerama are trademarks of the Open
00036 Group. All other trademarks and registered trademarks mentioned herein
00037 are the property of their respective owners. No right, title or
00038 interest in or to any trademark, service mark, logo or trade name of
00039 Sun Microsystems, Inc. or its licensors is granted.
00040 
00041 */
00042 
00043 #ifndef composeIM_H
00044 #define composeIM_H
00045 
00046 #include <X11/Xlib.h>
00047 #define XIMP_40
00048 #include "XIMProto.h"
00049 #include "XimpIm.h"
00050 
00051 #include "commonIM.h"
00052 
00053 #define       COMPOSE_FILE  "Compose"
00054 
00055 typedef enum {
00056   NoAction,
00057   SwitchTo,
00058   NextPage,
00059   PrevPage,
00060   TopPage,
00061   LastPage,
00062   NextCand,
00063   PrevCand,
00064   UpCand,
00065   DownCand,
00066   SelectCand,
00067   DoLookup,
00068   DoConv
00069 } ActionType;
00070 
00071 typedef struct _DefTree {
00072   struct _DefTree *next;    /* another Key definition */
00073   struct _DefTree *succession;     /* successive Key Sequence */
00074                             /* Key definitions */
00075   unsigned         modifier_mask;
00076   unsigned         modifier;
00077   KeySym           keysym;  /* leaf only */
00078   int              keycode; /* leaf only */
00079   char            *mb;
00080   KeySym keysym_return;
00081   ActionType       action;
00082   char        *target_name; /* not NULL if "Change State" */
00083   struct _LocalIMState      *target;
00084 } DefTree;
00085 
00086 typedef enum {
00087   ComposeState,
00088   CodeInputState,
00089   LookupState,                     /* Table Input */
00090   RemoteIMState                    /* Remote IM State */
00091 } StateType;
00092 
00093 typedef enum {
00094   HEX,
00095   OCTET
00096 } InputType;
00097 
00098 typedef struct _LuRange {
00099   char RangeName[80];
00100   int  start_range;
00101   int  end_range;
00102 } LuRange;
00103 
00104 typedef struct _AttribList {
00105   union {
00106     struct {
00107       int     max_input_len;
00108       InputType type_of_input;
00109     } CIstruct;
00110     struct {
00111       LuRange *range;
00112       int     nrange;
00113       int     num_of_rows;
00114       int     num_of_cols;
00115       int     num_of_cands;
00116       char   *title;
00117     } LUstruct;
00118   } _attr_u;
00119 } StateAttrib;
00120 
00121 #define SET_KEYCODEINFO(s) ((s)->use_keycodeinfo = True)
00122 #define USE_KEYCODEINFO(s) ((s)->use_keycodeinfo == True)
00123 
00124 /* Macros for struct DefTreeMap and LocalIMStateMap */
00125 #define BCF_HDR_SIZE               72
00126 #define BCF_HDR_SIGNATURE          0xffff
00127 #define BCF_HDR_PLATFORM_MSB              0x0000
00128 #define BCF_HDR_PLATFORM_LSB              0x0101
00129 #define BCF_HDR_PLATFORM_UNKNOWN   0x0202
00130 #define BCF_HDR_VERSION                   0x0100
00131 #define BCF_HDR_VENDER_STRING             "Sun Microsystems, Inc."
00132 #define BCF_HDR_VENDER_STRING_LEN  64
00133 
00134 #define BCF_STATE_SIZE                 3
00135 #define BCF_STATE_PTR(b)        (CARD32 *)((CARD8 *)b + BCF_HDR_SIZE)
00136 #define BCF_STATE_LENGTH(p)     (*(CARD32 *)p)
00137 #define BCF_STATE_NAME(p, i)           (*((CARD32 *)p + BCF_STATE_SIZE * (i-1) + 1))
00138 #define BCF_STATE_USE_KEYCODE(p, i) (*((CARD32 *)p + BCF_STATE_SIZE * (i-1) + 2))
00139 #define BCF_STATE_PARSER(p, i)         (*((CARD32 *)p + BCF_STATE_SIZE * (i-1) + 3))
00140 
00141 #define BCF_DEF_SIZE            9
00142 #define BCF_DEF_PTR(b)                 (BCF_STATE_PTR(b) + 1 + BCF_STATE_SIZE * BCF_STATE_LENGTH(BCF_STATE_PTR(b)))
00143 #define BCF_DEF_LENGTH(p)       (*(CARD32 *)p)
00144 #define BCF_DEF_NEXT(p, i)      (*((CARD32 *)p + BCF_DEF_SIZE * (i-1) + 1))
00145 #define BCF_DEF_SUCCESSION(p, i)    (*((CARD32 *)p + BCF_DEF_SIZE * (i-1) + 2))
00146 #define BCF_DEF_MODIFIER_MASK(p, i) (*((CARD32 *)p + BCF_DEF_SIZE * (i-1) + 3))
00147 #define BCF_DEF_MODIFIER(p, i)         (*((CARD32 *)p + BCF_DEF_SIZE * (i-1) + 4))
00148 #define BCF_DEF_KEYSYM(p, i)           (*((CARD32 *)p + BCF_DEF_SIZE * (i-1) + 5))
00149 #define BCF_DEF_KEYCODE(p, i)          (*((INT32 *)p + BCF_DEF_SIZE * (i-1) + 6))
00150 #define BCF_DEF_MB(p, i)        (*((CARD32 *)p + BCF_DEF_SIZE * (i-1) + 7))
00151 #define BCF_DEF_KEYSYM_RETURN(p, i) (*((CARD32 *)p + BCF_DEF_SIZE * (i-1) + 8))
00152 #define BCF_DEF_TARGET(p, i)           (*((CARD32 *)p + BCF_DEF_SIZE * (i-1) + 9))
00153 
00154 #define BCF_STR_PTR(b)             (CARD8 *)(BCF_DEF_PTR(b) + 1 + BCF_DEF_SIZE * BCF_DEF_LENGTH(BCF_DEF_PTR(b)))
00155 #define BCF_STR_LENGTH(p)   (*(CARD32 *)p)
00156 #define BCF_STR_STRING(p, i)       (char *)((CARD8 *)p + i + 3)
00157 
00158 typedef struct _LocalIMState {
00159     char                *name;
00160     char                *language; 
00161     Bool                use_keycodeinfo;
00162     DefTree             *parser;
00163     StateAttrib            *attr;
00164     Bool                   attrflag;
00165     Bool                   actionflag;
00166     StateType              type; 
00167    struct _LocalIMState   *next;
00168 } LocalIMState;
00169 
00170 /* private XIM data for ComposeIM */
00171 typedef struct _XIMComposeIMRec {
00172   XIC         current_ic;
00173   LocalIMState       *top_state;
00174   Bool        use_binary_table; /* True if use binary table */
00175   void        *map_addr;    /* for binary table */
00176   size_t      map_len;      /* for binary table */
00177   CARD32      *state_addr;  /* for binary table */
00178   CARD32      *def_addr;    /* for binary table */
00179   CARD8              *str_addr;    /* for binary table */
00180 
00181   XIMMethods  switch_methods;
00182 } XIMComposeIMRec;
00183 
00184 /*
00185  * IC dependent data struction 
00186  */
00187 
00188 /* private XIC data for ComposeIM */
00189 typedef struct _XICComposeIMRec {
00190   LocalIMState       *imstate;
00191   DefTree     *context;
00192   DefTree     *composed;
00193   void        *status_ext;
00194   void        *preedit_ext;
00195   void        *lookup_ext;
00196   void        *table_ext;
00197   XICMethods  switch_methods;
00198 } XICComposeIMRec;
00199 
00200 extern Status COMPOSE_OpenIM_SWITCH(XIM xim, XLCd lcd);
00201 extern Status COMPOSE_CreateIC_SWITCH(XIC xic, XIMArg *arg);
00202 extern Bool Ximp_Local_KeyFilter(Display *d, Window w,
00203                              XEvent *ev, XPointer client_data);
00204 
00205 extern XICMethods get_local_ic_methods();
00206 
00207 #endif