/*
**   ----------------------------------------------------------------- 
**        Copyright (C) 1990, 1991 Sun Microsystems, Inc
**                   All rights reserved.
**         Notice of copyright on this source code
**         product does not indicate publication.
**   
**   RESTRICTED RIGHTS LEGEND: Use, duplication, or disclosure by
**   the U.S. Government is subject to restrictions as set forth
**   in subparagraph (c)(1)(ii) of the Rights in Technical Data
**   and Computer Software Clause at DFARS 252.227-7013 (Oct. 1988)
**   and FAR 52.227-19 (c) (June 1987).
**   
**     Sun Microsystems, Inc., 2550 Garcia Avenue,
**     Mountain View, California 94043.
**   ----------------------------------------------------------------- 
*/
/*	Copyright (c) 1990 UNIX System Laboratories, Inc.	*/
/*	Copyright (c) 1988 AT&T	*/
/*	  All Rights Reserved  	*/

/*	THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF     	*/
/*	UNIX System Laboratories, Inc.                     	*/
/*	The copyright notice above does not evidence any   	*/
/*	actual or intended publication of such source code.	*/

#ifndef NOIDENT
#ident	"@(#)olmisc:DynamicI.h	1.4"
#ident  "@(#)DynamicI.h	3.8 SMI"
#endif

#ifndef __DynamicI_h__
#define __DynamicI_h__

/*
 *  Description:
 *		This file contains all private tables for Dynamic.c.
 */

static ModifierInfo mod_info[] = {
   {Alt,   "Alt",   XK_Alt_L,    XK_Alt_R,   (KeyCode)0, (KeyCode)0,    None },
   {Meta,  "Meta",  XK_Meta_L,   XK_Meta_R,  (KeyCode)0, (KeyCode)0,    None },
   {Hyper, "Hyper", XK_Hyper_L,  XK_Hyper_R, (KeyCode)0, (KeyCode)0,    None },
   {Super, "Super", XK_Super_L,  XK_Super_R, (KeyCode)0, (KeyCode)0,    None },
   {NumLock, "NumLock", XK_Num_Lock, XK_Num_Lock, (KeyCode)0, (KeyCode)0,None },
};

static KeypadInfo keypad_table[] = {
    { XK_KP_0, NULL, 0 },
    { XK_KP_1, NULL, 0 },
    { XK_KP_2, NULL, 0 },
    { XK_KP_3, NULL, 0 },
    { XK_KP_4, NULL, 0 },
    { XK_KP_5, NULL, 0 },
    { XK_KP_6, NULL, 0 },
    { XK_KP_7, NULL, 0 },
    { XK_KP_8, NULL, 0 },
    { XK_KP_9, NULL, 0 },
    { XK_KP_Equal, NULL, 0 },
    { XK_KP_Multiply, NULL, 0 },
    { XK_KP_Add, NULL, 0 },
    { XK_KP_Separator, NULL, 0 },
    { XK_KP_Subtract, NULL, 0 },
    { XK_KP_Decimal, NULL, 0 },
    { XK_KP_Divide, NULL, 0 },
    { XK_KP_Space, NULL, 0 },
    { XK_KP_Tab, NULL, 0 },
    { XK_KP_Enter, NULL, 0 },
    { XK_KP_F1, NULL, 0 },
    { XK_KP_F2, NULL, 0 },
    { XK_KP_F3, NULL, 0 },
    { XK_KP_F4, NULL, 0 },
};

static btn_mapping btn_mappings[] = {
   { Button1, Button1Mask },
   { Button2, Button2Mask },
   { Button3, Button3Mask },
   { Button4, Button4Mask },
   { Button5, Button5Mask },
};

/*
 * The modifier masks for Alt/Meta/Super/Hyper are initialized here to
 * Mod1Mask (an arbitrary choice). These masks are fixed up to the actual
 * server-dependent mask when _OlGetModifierMapping() is called from
 * OlPostInitialize().
 * I've re-ordered the entries in this table by the frequency they occur
 * in the default (Sun) bindings so on average a match will be found quicker.
 * 	--- jsc
 */

static mapping mappings[] = {
   { "c",          ControlMask   },
   { "a",          Mod1Mask      },
   { "s",          ShiftMask     },
   { "n",          None          },
   { "m",          Mod1Mask      },
   { "Button1",    Button1       },
   { "Button3",    Button3       },
   { "Button2",    Button2       },
   { "Ctrl",       ControlMask   },
   { "Alt",        Mod1Mask      },
   { "Shift",      ShiftMask     },
   { "None",       None          },
   { "Lock",       LockMask      },
   { "l",          LockMask      },
   { "Meta",       Mod1Mask      },
   { "Mod1",       Mod1Mask      },
   { "1",          Mod1Mask      },
   { "Mod2",       Mod2Mask      },
   { "2",          Mod2Mask      },
   { "Mod3",       Mod3Mask      },
   { "3",          Mod3Mask      },
   { "Mod4",       Mod4Mask      },
   { "4",          Mod4Mask      },
   { "Mod5",       Mod5Mask      },
   { "5",          Mod5Mask      },
   { "Super",      Mod1Mask      },
   { "su",         Mod1Mask      },
   { "Hyper",      Mod1Mask      },
   { "h",          Mod1Mask      },
   { "Button4",    Button4       },
   { "Button5",    Button5       },
};

/*
 * The following two tables are used by StringToKey().
 * (I18N)
 */

static CharKeysymMap backslash_map[] = {
   { 'b',  XK_BackSpace    },
   { 't',  XK_Tab          },
   { 'n',  XK_Linefeed     },
   { 'v',  XK_Clear        },
   { 'f',  XK_Clear        },
   { 'r',  XK_Return       },
   {   0,  0               }
};

static CharKeysymMap singlechar_map[] = {
   { ' ',  XK_space        },
   { '!',  XK_exclam       },
   { '"',  XK_quotedbl     },
   { '#',  XK_numbersign   },
   { '$',  XK_dollar       },
   { '%',  XK_percent      },
   { '&',  XK_ampersand    },
#if	defined(XK_apostrophe)
   { '\'', XK_apostrophe   },
#else
   { '\'', XK_quoteright   },
#endif
   { '(',  XK_parenleft    },
   { ')',  XK_parenright   },
   { '*',  XK_asterisk     },
   { '+',  XK_plus         },
   { ',',  XK_comma        },
   { '-',  XK_minus        },
   { '.',  XK_period       },
   { '/',  XK_slash        },
   { ':',  XK_colon        },
   { ';',  XK_semicolon    },
   { '<',  XK_less         },
   { '=',  XK_equal        },
   { '>',  XK_greater      },
   { '?',  XK_question     },
   { '@',  XK_at           },
   { '[',  XK_bracketleft  },
   { '\\', XK_backslash    },
   { ']',  XK_bracketright },
   { '^',  XK_asciicircum  },
   { '_',  XK_underscore   },
#if	defined(XK_grave)
   { '`',  XK_grave        },
#else
   { '`',  XK_quoteleft    },
#endif
   { '{',  XK_braceleft    },
   { '|',  XK_bar          },
   { '}',  XK_braceright   },
   { '~',  XK_asciitilde   },
   {   0,  0               }
};

static OlKeyBinding OlCoreKeyBindings[] = {

/* button equivalents */

#ifndef sun
   { XtNselectKey,       "<space>,c<space>",  OL_SELECTKEY	},
   { XtNmenuKey,         "c<m>,n<F4>",        OL_MENUKEY	},
   { XtNmenuDefaultKey,  "c s<m>,s<F4>",      OL_MENUDEFAULTKEY	},
   { XtNhorizSBMenuKey,  "a c<r>",            OL_HSBMENU	},
   { XtNvertSBMenuKey,   "c<r>",              OL_VSBMENU	},
   { XtNadjustKey,       "c s<ampersand>",    OL_ADJUSTKEY	},
#else
   { XtNselectKey,       "n<space>",  	      OL_SELECTKEY	},
   { XtNmenuKey,         "a<space>",          OL_MENUKEY	},
   { XtNmenuDefaultKey,  "c<space>",          OL_MENUDEFAULTKEY	},
   { XtNhorizSBMenuKey,  "a<h>",              OL_HSBMENU	},
   { XtNvertSBMenuKey,   "a<v>",              OL_VSBMENU	},
   { XtNadjustKey,       "a<Insert>",         OL_ADJUSTKEY	},
#endif
#ifndef sun	/* Sun model has no mouseless keyboard DnD */
   { XtNduplicateKey,	 "s<space>",	      OL_DUPLICATEKEY	},
#endif

/* olwm + olwsm */
#ifndef sun
   { XtNworkspaceMenuKey,"c<w>",              OL_WORKSPACEMENU	},
   { XtNnextAppKey,      "a<Escape>",         OL_NEXTAPP	},
   { XtNnextWinKey,      "a<F6>",             OL_NEXTWINDOW	},
   { XtNprevAppKey,      "a s<Escape>",       OL_PREVAPP	},
   { XtNprevWinKey,      "a s<F6>",           OL_PREVWINDOW	},
   { XtNwindowMenuKey,   "s<Escape>",         OL_WINDOWMENU	},
#else
   { XtNworkspaceMenuKey,"a s<m>",            OL_WORKSPACEMENU	},
   { XtNnextAppKey,      "a<n>",              OL_NEXTAPP	},
   { XtNnextWinKey,      "a<w>",              OL_NEXTWINDOW	},
   { XtNprevAppKey,      "a s<n>",            OL_PREVAPP	},
   { XtNprevWinKey,      "a s<w>",            OL_PREVWINDOW	},
   { XtNwindowMenuKey,   "a<m>",              OL_WINDOWMENU	},
#endif

/* traversal */

   { XtNdownKey,         "<Down>",            OL_MOVEDOWN	},
   { XtNleftKey,         "<Left>",            OL_MOVELEFT	},
   { XtNmultiDownKey,    "c<Down>",           OL_MULTIDOWN	},
   { XtNmultiLeftKey,    "c<Left>",           OL_MULTILEFT	},
   { XtNmultiRightKey,   "c<Right>",          OL_MULTIRIGHT	},
   { XtNmultiUpKey,      "c<Up>",             OL_MULTIUP	},
   { XtNnextFieldKey,    "n<Tab>,c<Tab>",     OL_NEXT_FIELD	},
   { XtNprevFieldKey,    "s<Tab>,c s<Tab>",   OL_PREV_FIELD	},
   { XtNrightKey,        "<Right>",           OL_MOVERIGHT	},
   { XtNupKey,           "<Up>",              OL_MOVEUP		},

/* selection */

#ifndef	sun
   { XtNcopyKey,         "c<Insert>",         OL_COPY		},
   { XtNcutKey,          "s<Delete>",         OL_CUT		},
   { XtNpasteKey,        "s<Insert>",         OL_PASTE		},
#else
   { XtNcopyKey,         "n<F16>",            OL_COPY		},
   { XtNcutKey,          "n<F20>",            OL_CUT		},
   { XtNpasteKey,        "n<F18>, c<y>",      OL_PASTE		},
#endif
   { XtNselCharBakKey,   "s<Left>, s c<b>",   OL_SELCHARBAK	},
   { XtNselCharFwdKey,   "s<Right>, s c<f>",  OL_SELCHARFWD	},
   { XtNselLineKey,      "c a<Left>",         OL_SELLINE	},
#ifndef sun
   { XtNselLineBakKey,   "s<Home>",           OL_SELLINEBAK	},
   { XtNselLineFwdKey,   "s<End>",            OL_SELLINEFWD	},
#else
   { XtNselLineBakKey,   "s<R7>, s c<p>",     OL_SELLINEBAK	},
   { XtNselLineFwdKey,   "s<R13>, s c<n>",    OL_SELLINEFWD	},
#endif
   { XtNselWordBakKey,   "c s<Left>",         OL_SELWORDBAK	},
   { XtNselWordFwdKey,   "c s<Right>",        OL_SELWORDFWD	},
#ifndef sun	/* Sun's model has no FlipEnds */
   { XtNselFlipEndsKey,  "a<Insert>",         OL_SELFLIPENDS	},
#endif

/* misc */

   { XtNcancelKey,       "n<Escape>",         OL_CANCEL		},
   { XtNdefaultActionKey,"<Return>,c<Return>",OL_DEFAULTACTION	},
#ifndef sun	/* Sun's model has no mouseless DnD */
   { XtNdragKey,         "n<F5>",             OL_DRAG		},
   { XtNdropKey,         "n<F2>",             OL_DROP		},
#endif

#ifndef	sun
   { XtNhelpKey,         "n<F1>",             OL_HELP		},
   { XtNpropertiesKey,   "c<p>",              OL_PROPERTY	},
   { XtNstopKey,         "c<s>",              OL_STOP		},
#else
   { XtNhelpKey,         "n<Help>",           OL_HELP		},
   { XtNpropertiesKey,   "n<F13>",            OL_PROPERTY	},
   { XtNstopKey,         "n<F11>",            OL_STOP		},
#endif
   { XtNtogglePushpinKey,"c<t>",              OL_TOGGLEPUSHPIN	},
#ifndef	sun
   { XtNundoKey,         "a<BackSpace>",      OL_UNDO		},
#else
   { XtNundoKey,         "n<F14>",            OL_UNDO		},
#endif

/* scrolling */

#ifndef sun
   { XtNpageDownKey,     "c<Next>",           OL_PAGEDOWN	},
   { XtNpageLeftKey,     "c<bracketleft>",    OL_PAGELEFT	},
   { XtNpageRightKey,    "c<bracketright>",   OL_PAGERIGHT	},
   { XtNpageUpKey,       "c<Prior>",          OL_PAGEUP		},
   { XtNscrollBottomKey, "a<Next>",           OL_SCROLLBOTTOM	},
   { XtNscrollDownKey,   "n<Next>",           OL_SCROLLDOWN	},
   { XtNscrollLeftKey,   "a<bracketleft>",    OL_SCROLLLEFT	},
   { XtNscrollLeftEdgeKey,"a s<braceleft>",   OL_SCROLLLEFTEDGE	},
   { XtNscrollRightKey,  "a<bracketright>",   OL_SCROLLRIGHT	},
   { XtNscrollRightEdgeKey,"a s<braceright>", OL_SCROLLRIGHTEDGE},
   { XtNscrollTopKey,    "a<Prior>",          OL_SCROLLTOP	},
   { XtNscrollUpKey,     "n<Prior>",          OL_SCROLLUP	},
#else
   { XtNpageDownKey,     "a<R15>",            OL_PAGEDOWN	},
   { XtNpageLeftKey,     "a c<R9>",           OL_PAGELEFT	},
   { XtNpageRightKey,    "a c<R15>",          OL_PAGERIGHT	},
   { XtNpageUpKey,       "a<R9>",             OL_PAGEUP		},
   { XtNscrollBottomKey, "a c<R13>",          OL_SCROLLBOTTOM	},
   { XtNscrollDownKey,   "a<Down>",           OL_SCROLLDOWN	},
   { XtNscrollLeftKey,   "a<Left>",           OL_SCROLLLEFT	},
   { XtNscrollLeftEdgeKey,"a<R7>",            OL_SCROLLLEFTEDGE	},
   { XtNscrollRightKey,  "a<Right>",          OL_SCROLLRIGHT	},
   { XtNscrollRightEdgeKey,"a<R13>",          OL_SCROLLRIGHTEDGE},
   { XtNscrollTopKey,    "a c<R7>",           OL_SCROLLTOP	},
   { XtNscrollUpKey,     "a<Up>",             OL_SCROLLUP	},
#endif
};

static OlKeyBinding OlTextKeyBindings[] = {

/* text */

#ifndef sun
   { XtNdelCharBakKey,   "<BackSpace>",       OL_DELCHARBAK     },
   { XtNdelCharFwdKey,   "<Delete>",          OL_DELCHARFWD     },
   { XtNdelLineKey,      "a s<Delete>",       OL_DELLINE        },
   { XtNdelLineBakKey,   "c<BackSpace>",      OL_DELLINEBAK     },
   { XtNdelLineFwdKey,   "c<Delete>",         OL_DELLINEFWD     },
   { XtNdelWordBakKey,   "c s<BackSpace>",    OL_DELWORDBAK     },
   { XtNdelWordFwdKey,   "c s<Delete>",       OL_DELWORDFWD     },
#else
   { XtNdelCharBakKey,   "<BackSpace>,<Delete>", OL_DELCHARBAK	},
   { XtNdelCharFwdKey,   "s<BackSpace>,c<d>", OL_DELCHARFWD },
   { XtNdelLineKey,      "m<BackSpace>,m<Delete>", OL_DELLINE   },
   { XtNdelLineBakKey,   "c<BackSpace>,c<u>", OL_DELLINEBAK	},
   { XtNdelLineFwdKey,   "c<Delete>,c<k>",    OL_DELLINEFWD	},
   { XtNdelWordBakKey,   "c s<BackSpace>,c<w>", OL_DELWORDBAK	},
   { XtNdelWordFwdKey,   "c s<Delete>",       OL_DELWORDFWD	},
#endif

/* text navigation */

#ifndef sun
   { XtNdocEndKey,       "c<End>",            OL_DOCEND		},
   { XtNdocStartKey,     "c<Home>",           OL_DOCSTART	},
   { XtNlineEndKey,      "n<End>",            OL_LINEEND	},
   { XtNlineStartKey,    "n<Home>",           OL_LINESTART	},
   { XtNpaneEndKey,      "c s<End>",          OL_PANEEND	},  /*?*/
   { XtNpaneStartKey,    "c s<Home>",         OL_PANESTART	},  /*?*/
   { XtNwordBakKey,      "c<Left>",           OL_WORDBAK	},
   { XtNwordFwdKey,      "c<Right>",          OL_WORDFWD	},
#else	/* why can't we use the keysym names Home and End ? */
   { XtNdocEndKey,       "c<R13>",            OL_DOCEND		},
   { XtNdocStartKey,     "c<R7>",             OL_DOCSTART	},
   { XtNlineEndKey,      "n<R13>, c<e>",      OL_LINEEND	},
   { XtNlineStartKey,    "n<R7>, c<a>",       OL_LINESTART	},
   { XtNpaneEndKey,      "c s<R13>",          OL_PANEEND	},
   { XtNpaneStartKey,    "c s<R7>",           OL_PANESTART	},
   { XtNwordBakKey,      "c<Left>",           OL_WORDBAK	},
   { XtNwordFwdKey,      "c<Right>",          OL_WORDFWD	},
#endif

/* text backward compatibilities */

   { XtNcharBakKey,      "<Left>, c<b>",      OL_CHARBAK	},
   { XtNcharFwdKey,      "<Right>, c<f>",     OL_CHARFWD	},
   { XtNrowDownKey,      "<Down>, c<n>",      OL_ROWDOWN	},
   { XtNrowUpKey,        "<Up>, c<p>",        OL_ROWUP		},
   { XtNreturnKey,       "<Return>",          OL_RETURN		},

};

static OlBtnBinding OlCoreBtnBindings[] = {
   { XtNselectBtn,       "n<Button1>",        OL_SELECT      },
   { XtNadjustBtn,       "n<Button2>",        OL_ADJUST      },
   { XtNmenuBtn,         "n<Button3>",        OL_MENU        },
#ifndef sun
   { XtNconstrainBtn,    "c<Button1>",        OL_CONSTRAIN   },
   { XtNduplicateBtn,    "s<Button1>",        OL_DUPLICATE   },
#else
   { XtNconstrainBtn,    "s<Button1>",        OL_CONSTRAIN   },
   { XtNduplicateBtn,    "c<Button1>",        OL_DUPLICATE   },
#endif
   { XtNpanBtn,          "a<Button1>",        OL_PAN         },/*was C1*/
#ifndef sun
   { XtNmenuDefaultBtn,  "s<Button3>",        OL_MENUDEFAULT },
#else
   { XtNmenuDefaultBtn,  "c<Button3>",        OL_MENUDEFAULT },
#endif
};

#endif /* __DynamicI_h__ */
