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>
|
|
|
|
|
|
|
|
struct termkey_driver
|
|
|
|
{
|
2008-11-08 18:56:44 +01:00
|
|
|
const char *name;
|
2008-10-09 21:23:45 +02:00
|
|
|
void *(*new_driver)(termkey_t *tk, const char *term);
|
2008-11-08 18:47:57 +01:00
|
|
|
void (*free_driver)(void *info);
|
|
|
|
void (*start_driver)(termkey_t *tk, void *info);
|
|
|
|
void (*stop_driver)(termkey_t *tk, void *info);
|
2008-12-10 01:23:47 +01:00
|
|
|
termkey_result (*peekkey)(termkey_t *tk, void *info, termkey_key *key, int force, size_t *nbytes);
|
2008-10-07 00:27:19 +02:00
|
|
|
};
|
|
|
|
|
2008-10-08 01:12:41 +02:00
|
|
|
struct keyinfo {
|
|
|
|
termkey_type type;
|
|
|
|
termkey_keysym sym;
|
|
|
|
int modifier_mask;
|
|
|
|
int modifier_set;
|
|
|
|
};
|
|
|
|
|
2008-11-09 20:58:11 +01:00
|
|
|
struct termkey_drivernode;
|
|
|
|
struct termkey_drivernode {
|
|
|
|
struct termkey_driver *driver;
|
|
|
|
void *info;
|
|
|
|
struct termkey_drivernode *next;
|
|
|
|
};
|
|
|
|
|
2008-10-07 00:27:19 +02:00
|
|
|
struct termkey {
|
|
|
|
int fd;
|
|
|
|
int flags;
|
|
|
|
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];
|
|
|
|
|
2008-11-09 20:58:11 +01:00
|
|
|
struct termkey_drivernode *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 {
|
2008-10-10 01:50:56 +02:00
|
|
|
void (*emit_codepoint)(termkey_t *tk, long codepoint, termkey_key *key);
|
2008-12-10 01:23:47 +01:00
|
|
|
termkey_result (*peekkey_simple)(termkey_t *tk, termkey_key *key, int force, size_t *nbytes);
|
2008-10-07 23:22:59 +02:00
|
|
|
} method;
|
2008-10-07 00:27:19 +02:00
|
|
|
};
|
|
|
|
|
2008-10-07 00:36:14 +02:00
|
|
|
extern struct termkey_driver termkey_driver_csi;
|
2008-10-08 03:04:47 +02:00
|
|
|
extern struct termkey_driver termkey_driver_ti;
|
2008-10-07 00:27:19 +02:00
|
|
|
|
|
|
|
#endif
|