2008-10-07 00:27:19 +02:00
|
|
|
#ifndef GUARD_TERMKEY_INTERNAL_H_
|
|
|
|
#define GUARD_TERMKEY_INTERNAL_H_
|
|
|
|
|
|
|
|
#include "termkey.h"
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <termios.h>
|
|
|
|
|
2009-07-15 21:40:44 +02:00
|
|
|
struct TermKeyDriver
|
2008-10-07 00:27:19 +02:00
|
|
|
{
|
2008-11-08 18:56:44 +01:00
|
|
|
const char *name;
|
2009-07-15 21:40:44 +02:00
|
|
|
void *(*new_driver)(TermKey *tk, const char *term);
|
2008-11-08 18:47:57 +01:00
|
|
|
void (*free_driver)(void *info);
|
2012-01-20 18:00:09 +01:00
|
|
|
int (*start_driver)(TermKey *tk, void *info);
|
|
|
|
int (*stop_driver)(TermKey *tk, void *info);
|
2009-07-15 21:40:44 +02:00
|
|
|
TermKeyResult (*peekkey)(TermKey *tk, void *info, TermKeyKey *key, int force, size_t *nbytes);
|
2008-10-07 00:27:19 +02:00
|
|
|
};
|
|
|
|
|
2008-10-08 01:12:41 +02:00
|
|
|
struct keyinfo {
|
2009-07-15 21:40:44 +02:00
|
|
|
TermKeyType type;
|
|
|
|
TermKeySym sym;
|
2008-10-08 01:12:41 +02:00
|
|
|
int modifier_mask;
|
|
|
|
int modifier_set;
|
|
|
|
};
|
|
|
|
|
2009-07-15 21:40:44 +02:00
|
|
|
struct TermKeyDriverNode;
|
|
|
|
struct TermKeyDriverNode {
|
|
|
|
struct TermKeyDriver *driver;
|
2008-11-09 20:58:11 +01:00
|
|
|
void *info;
|
2009-07-15 21:40:44 +02:00
|
|
|
struct TermKeyDriverNode *next;
|
2008-11-09 20:58:11 +01:00
|
|
|
};
|
|
|
|
|
2009-07-15 21:40:44 +02:00
|
|
|
struct _TermKey {
|
2008-10-07 00:27:19 +02:00
|
|
|
int fd;
|
|
|
|
int flags;
|
2011-08-28 18:50:18 +02:00
|
|
|
int canonflags;
|
2008-10-07 00:27:19 +02:00
|
|
|
unsigned char *buffer;
|
|
|
|
size_t buffstart; // First offset in buffer
|
|
|
|
size_t buffcount; // NUMBER of entires valid in buffer
|
|
|
|
size_t buffsize; // Total malloc'ed size
|
|
|
|
|
|
|
|
struct termios restore_termios;
|
|
|
|
char restore_termios_valid;
|
|
|
|
|
|
|
|
int waittime; // msec
|
|
|
|
|
|
|
|
char is_closed;
|
|
|
|
|
|
|
|
int nkeynames;
|
|
|
|
const char **keynames;
|
|
|
|
|
2008-10-08 01:12:41 +02:00
|
|
|
// There are 32 C0 codes
|
|
|
|
struct keyinfo c0[32];
|
|
|
|
|
2009-07-15 21:40:44 +02:00
|
|
|
struct TermKeyDriverNode *drivers;
|
2008-10-07 23:22:59 +02:00
|
|
|
|
|
|
|
// Now some "protected" methods for the driver to call but which we don't
|
|
|
|
// want exported as real symbols in the library
|
|
|
|
struct {
|
2009-07-15 21:40:44 +02:00
|
|
|
void (*emit_codepoint)(TermKey *tk, long codepoint, TermKeyKey *key);
|
|
|
|
TermKeyResult (*peekkey_simple)(TermKey *tk, TermKeyKey *key, int force, size_t *nbytes);
|
2009-11-26 01:27:58 +01:00
|
|
|
TermKeyResult (*peekkey_mouse)(TermKey *tk, TermKeyKey *key, size_t *nbytes);
|
2008-10-07 23:22:59 +02:00
|
|
|
} method;
|
2008-10-07 00:27:19 +02:00
|
|
|
};
|
|
|
|
|
2009-07-15 21:40:44 +02:00
|
|
|
extern struct TermKeyDriver termkey_driver_csi;
|
|
|
|
extern struct TermKeyDriver termkey_driver_ti;
|
2008-10-07 00:27:19 +02:00
|
|
|
|
|
|
|
#endif
|