about summary refs log tree commit diff stats
path: root/kb.c
diff options
context:
space:
mode:
Diffstat (limited to 'kb.c')
-rw-r--r--kb.c55
1 files changed, 55 insertions, 0 deletions
diff --git a/kb.c b/kb.c
new file mode 100644
index 0000000..7caae15
--- /dev/null
+++ b/kb.c
@@ -0,0 +1,55 @@
+/*
+ * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
+ * See LICENSE file for license details.
+ */
+
+#include "wm.h"
+
+#include <X11/keysym.h>
+
+static const char *term[] = { 
+	"xterm", "-u8", "-bg", "black", "-fg", "white", "-fn",
+	"-*-terminus-medium-*-*-*-13-*-*-*-*-*-iso10646-*", 0 
+};
+
+static const char *proglist[] = {
+		"sh", "-c", "exec `ls -lL /bin /sbin /usr/bin /usr/local/bin 2>/dev/null | awk 'NF>2 && $1 ~ /^[^d].*x/ {print $NF}' | sort | uniq | gridmenu`", 0
+};
+
+static Key key[] = {
+	{ Mod1Mask, XK_Return, run, term },
+	{ Mod1Mask, XK_p, run, proglist }, 
+	{ Mod1Mask | ShiftMask, XK_c, kill, NULL}, 
+	{ Mod1Mask | ShiftMask, XK_q, quit, NULL},
+};
+
+void
+update_keys()
+{
+	unsigned int i, len;
+	KeyCode code;
+
+	len = sizeof(key) / sizeof(key[0]);
+	for(i = 0; i < len; i++) {
+		code = XKeysymToKeycode(dpy, key[i].keysym);
+		XUngrabKey(dpy, code, key[i].mod, root);
+		XGrabKey(dpy, code, key[i].mod, root, True, GrabModeAsync, GrabModeAsync);
+	}
+}
+
+void
+keypress(XEvent *e)
+{
+	XKeyEvent *ev = &e->xkey;
+	unsigned int i, len;
+	KeySym keysym;
+
+	keysym = XKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0);
+	len = sizeof(key) / sizeof(key[0]);
+	for(i = 0; i < len; i++)
+		if((keysym == key[i].keysym) && (key[i].mod == ev->state)) {
+			if(key[i].func)
+				key[i].func(key[i].aux);
+			return;
+		}
+}
='#n160'>160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192
/*
 * $LynxId: LYStructs.h,v 1.30 2010/12/08 23:30:08 tom Exp $
 */
#ifndef LYSTRUCTS_H
#define LYSTRUCTS_H

#ifndef HTANCHOR_H
#include <HTAnchor.h>
#endif /* HTANCHOR_H */

#ifdef __cplusplus
extern "C" {
#endif
    typedef struct {
	char *hl_text;
	short hl_x;
    } HiliteInfo;

    typedef struct {
	HiliteInfo *hl_info;
	HiliteInfo hl_base;
	short hl_len;		/* number of strings in this struct */
    } HiliteList;

    typedef struct {
	char *lname;
	char *target;
	char *l_hightext;
	char *l_hightext2;
	int l_hightext2_offset;
	BOOL inUnderline;	/* TRUE when this link is in underlined context. */
	int lx;
	int ly;
	int type;		/* Type of link, Forms, WWW, etc. */
	int sgml_offset;	/* document offset used in reparsing */
	int anchor_number;	/* The anchor number within the HText structure.  */
	int anchor_line_num;	/* The anchor line number in the HText structure. */
	HiliteList list;
	struct _FormInfo *l_form;	/* Pointer to form info. */
    } LinkInfo;
    extern LinkInfo links[MAXLINKS];
    extern int nlinks;

    typedef struct {
	/* FIXME: see DocAddress */
	char *title;
	char *address;
	bstring *post_data;
	char *post_content_type;
	char *bookmark;
	BOOL isHEAD;
	BOOL safe;

	int link;
	int line;
	BOOL internal_link;	/* whether doc was reached via an internal
				   (fragment) link. - kw */
#ifdef USE_COLOR_STYLE
	char *style;
#endif
    } DocInfo;

    typedef struct {
	DocInfo hdoc;
	int intern_seq_start;	/* indicates which element on the history
				   is the start of this sequence of
				   "internal links", otherwise -1 */
    } HistInfo;

#define HDOC(n) history[n].hdoc

    extern int Visited_Links_As;

#define VISITED_LINKS_AS_FIRST_V 0
#define VISITED_LINKS_AS_TREE    1
#define VISITED_LINKS_AS_LATEST  2
#define VISITED_LINKS_REVERSE    4

    typedef struct _VisitedLink {
	char *title;
	char *address;
	int level;
	struct _VisitedLink *next_tree;
	struct _VisitedLink *prev_latest;
	struct _VisitedLink *next_latest;
	struct _VisitedLink *prev_first;
    } VisitedLink;

    extern HistInfo *history;
    extern int nhist;
    extern int size_history;

/******************************************************************************/

    typedef struct _lynx_list_item_type {
	struct _lynx_list_item_type *next;	/* the next item in the linked list */
	char *name;		/* a description of the item */
	char *menu_name;	/* menu-name for EXTERNAL / EXTERNAL_MENU */
	char *command;		/* the command to execute */
	BOOL always_enabled;	/* a constant to tell whether or
				 * not to disable the printer
				 * when the no_print option is on
				 */
	/* HTML lists: */
	BOOL override_action;	/* whether primary action will be
				 * overridden by this - e.g. this
				 * allows invoking user's MUA when
				 * mailto:  link is activated using
				 * normal "activate" command.  This
				 * field is only examined by code that
				 * handles EXTERNAL command.
				 */
	/* PRINTER lists: */
	int pagelen;		/* an integer to store the printer's
				 * page length
				 */
    } lynx_list_item_type;

    extern lynx_list_item_type *printers;

/* for download commands */
    extern lynx_list_item_type *downloaders;

/* for upload commands */
    extern lynx_list_item_type *uploaders;

#ifdef USE_EXTERNALS
/* for external commands */
    extern lynx_list_item_type *externals;
#endif

/******************************************************************************/

    typedef struct {
	const char *name;
	int value;
    } Config_Enum;

    typedef int (*ParseFunc) (char *);

#define ParseUnionMembers \
	lynx_list_item_type** add_value; \
	BOOLEAN * set_value; \
	int *     int_value; \
	char **   str_value; \
	ParseFunc fun_value; \
	long	  def_value; \
	HTList**  lst_value

    typedef union {
	ParseUnionMembers;
    } ParseUnion;

#define	PARSE_DEBUG 1
#ifdef	PARSE_DEBUG

#define ParseUnionPtr      Config_Type *
#define ParseUnionOf(tbl)  tbl
#define ParseData          ParseUnionMembers

#define UNION_ADD(v) &v,  0,  0,  0,  0,  0,  0
#define UNION_SET(v)  0, &v,  0,  0,  0,  0,  0
#define UNION_INT(v)  0,  0, &v,  0,  0,  0,  0
#define UNION_STR(v)  0,  0,  0, &v,  0,  0,  0
#define UNION_ENV(v)  0,  0,  0,  v,  0,  0,  0
#define UNION_FUN(v)  0,  0,  0,  0,  v,  0,  0
#define UNION_DEF(v)  0,  0,  0,  0,  0,  v,  0
#define UNION_LST(v)  0,  0,  0,  0,  0,  0, &v

#else

    typedef void *ParseType;

#define ParseUnionPtr      ParseUnion *
#define ParseUnionOf(tbl) (ParseUnionPtr)(&(tbl->value))
#define ParseData          ParseType value

#define UNION_ADD(v) (ParseType)&(v)
#define UNION_SET(v) (ParseType)&(v)
#define UNION_INT(v) (ParseType)&(v)
#define UNION_STR(v) (ParseType)&(v)
#define UNION_ENV(v) (ParseType) (v)
#define UNION_FUN(v) (ParseType) (v)
#define UNION_DEF(v) (ParseType) (v)
#define UNION_LST(v) (ParseType)&(v)

#endif

#ifdef __cplusplus
}
#endif
#endif				/* LYSTRUCTS_H */