/*
 * Name:	MG 2a keymap.c setup for Amiga-specific function keys.
 * Created:	14-May-1988 Mic Kaczmarczik (mic@emx.utexas.edu) Last edit:
 * 14-May-1988 Mic Kaczmarczik
 * 
 * One big table for coding convenience, because the number of different
 * compilation possibilities makes setting up data structures kind of tricky.
 * Once again for convenience, the file is #included into keymap.c instead of
 * being linked.  I tried to minimize the changes to keymap.c, while making
 * it possible to have the Amiga function/arrow keys in dired mode as well as
 * fundamental mode.  In the future, we might want to rebind some of the
 * function keys in dired mode, but for right now they do the same thing as
 * in fundamental mode.
 */

/* Carefully include anything we may have missed */
#ifndef	FKEYS
#include "fkeys.h"
#endif
#ifndef	BROWSER
#include "browser.h"
#endif
#ifndef	MOUSE
#include "mouse.h"
#endif
#ifndef MENU
#include "menu.h"
#endif
#ifndef DO_ICONIFY
#include "do_iconify.h"
#endif

static struct function amiga_keys[] = {
#ifdef	FKEYS
	{backline, F_CFUNCT},	/* Up			(0x100)	 */
	{forwline, F_CFUNCT},	/* Down				 */
	{backchar, F_CFUNCT},	/* Left				 */
	{forwchar, F_CFUNCT},	/* Right			 */
	{gotobop, F_CFUNCT},	/* Shift-Up			 */
	{gotoeop, F_CFUNCT},	/* Shift-Down			 */
	{backword, F_CFUNCT},	/* Shift-Left			 */
	{forwword, F_CFUNCT},	/* Shift-Right		(0x107)	 */
#else
	/* 8 unbound keys */
	{rescan, F_CFUNCT},
	{rescan, F_CFUNCT},
	{rescan, F_CFUNCT},
	{rescan, F_CFUNCT},
	{rescan, F_CFUNCT},
	{rescan, F_CFUNCT},
	{rescan, F_CFUNCT},
	{rescan, F_CFUNCT},
#endif

#ifdef	FKEYS
	{filevisit, F_CFUNCT},	/* F1			(0x108)	 */
	{filesave, F_CFUNCT},	/* F2				 */
	{forwpage, F_CFUNCT},	/* F3				 */
	{enlargewind, F_CFUNCT},/* F4				 */
	{fillpara, F_CFUNCT},	/* F5				 */
	{splitwind, F_CFUNCT},	/* F6				 */
	{twiddle, F_CFUNCT},	/* F7				 */
	{definemacro, F_CFUNCT},/* F8				 */
	{executemacro, F_CFUNCT},	/* F9				 */
	{listbuffers, F_CFUNCT},/* F10				 */
	{poptofile, F_CFUNCT},	/* Shift-F1		(0x112)	 */
	{filewrite, F_CFUNCT},	/* Shift-F2			 */
	{backpage, F_CFUNCT},	/* Shift-F3			 */
	{shrinkwind, F_CFUNCT},	/* Shift-F4			 */
	{queryrepl, F_CFUNCT},	/* Shift-F5			 */
	{onlywind, F_CFUNCT},	/* Shift-F6			 */
	{justone, F_CFUNCT},	/* Shift-F7			 */
	{finishmacro, F_CFUNCT},/* Shift-F8			 */
	{wallchart, F_CFUNCT},	/* Shift-F9			 */
	{quit, F_CFUNCT},	/* Shift-F10		(0x11B)	 */
#else
	{rescan, F_CFUNCT},
	{rescan, F_CFUNCT},
	{rescan, F_CFUNCT},
	{rescan, F_CFUNCT},
	{rescan, F_CFUNCT},
	{rescan, F_CFUNCT},
	{rescan, F_CFUNCT},
	{rescan, F_CFUNCT},
	{rescan, F_CFUNCT},
	{rescan, F_CFUNCT},
	{rescan, F_CFUNCT},
	{rescan, F_CFUNCT},
	{rescan, F_CFUNCT},
	{rescan, F_CFUNCT},
	{rescan, F_CFUNCT},
	{rescan, F_CFUNCT},
	{rescan, F_CFUNCT},
	{rescan, F_CFUNCT},
	{rescan, F_CFUNCT},
	{rescan, F_CFUNCT},
#endif

#ifdef	FKEYS
	{desckey, F_CFUNCT},	/* Help			(0x11C)	 */
#else
	{rescan, F_CFUNCT},
#endif

#ifdef	DO_MENU
	{amigamenu, F_CFUNCT},	/* Menu selction	(0x11D)	 */
#else
	{rescan, F_CFUNCT},	/* Menu selection	(0x11D)	 */
#endif
	{refresh, F_CFUNCT},	/* Resize window	(0x11E)	 */
	{rescan, F_CFUNCT},	/* used to be Mouse		 */

#ifdef	MOUSE
	{amigamouse, F_CFUNCT},	/* Mouse		(0x120)	 */
	{mforwdel, F_CFUNCT},	/* Ctrl-Mouse			 */
	{mreposition, F_CFUNCT},/* Shift-Mouse			 */
	{mdelwhite, F_CFUNCT},	/* Shift-Ctrl-Mouse		 */
	{mdelfword, F_CFUNCT},	/* Meta-Mouse			 */
	{mkillregion, F_CFUNCT},/* Meta-Ctrl-Mouse		 */
	{mkillline, F_CFUNCT},	/* Meta-Shift-Mouse		 */
	{myank, F_CFUNCT},	/* Meta-Shift-Ctrl-Mouse	 */
	{mforwpage, F_CFUNCT},	/* Mode-Mouse		(0x128)	 */
	{mgotobob, F_CFUNCT},	/* Ctrl-Mode-Mouse		 */
	{mbackpage, F_CFUNCT},	/* Shift-Mode-Mouse		 */
	{mgotoeob, F_CFUNCT},	/* Shift-Ctrl-Mode-Mouse	 */
	{msplitwind, F_CFUNCT},	/* Meta-Mode-Mouse		 */
	{menlargewind, F_CFUNCT},	/* Meta-Ctrl-Mode-Mouse		 */
	{mdelwind, F_CFUNCT},	/* Meta-Shift-Mode-Mouse	 */
	{mshrinkwind, F_CFUNCT},/* Meta-Shift-Ctrl-Mode-Mouse	 */
#ifdef	DO_ICONIFY
	{tticon, F_CFUNCT},	/* Echo-Mouse		(0x130)	 */
#else
	{usebuffer, F_CFUNCT},	/* Echo-Mouse		(0x130)	 */
#endif
	{spawncli, F_CFUNCT},	/* Ctrl-Echo-Mouse		 */
	{killbuffer, F_CFUNCT},	/* Shift-Echo-Mouse		 */
	{quit, F_CFUNCT},	/* Shift-Ctrl-Echo-Mouse	 */
	{desckey, F_CFUNCT},	/* Meta-Echo-Mouse		 */
	{listbuffers, F_CFUNCT},/* Meta-Ctrl-Echo-Mouse		 */
	{wallchart, F_CFUNCT},	/* Meta-Shift-Echo-Mouse	 */
	{togglewindow, F_CFUNCT},	/* Meta-Shift-Ctrl-Echo-Mouse	 */
#endif
};


/*
 * Define extra maps for fundamental mode.  Have to provide the number of
 * extra map segments because it's used by the KEYMAPE() macro that builds
 * keymaps.  The keymap setup, while compact, is pretty complex...
 */

#define	NFUND_XMAPS	1

#ifdef	MOUSE
#define	FUND_XMAPS	{KUP,	KEASCMOUSE,	amiga_keys}
#else
#define	FUND_XMAPS	{KUP,	KSF10,		amiga_keys}
#endif

/*
 * Extra map segments for dired mode -- just use fundamental mode segments
 */
#define	NDIRED_XMAPS	NFUND_XMAPS
#define	DIRED_XMAPS	FUND_XMAPS
