1 #ifndef GUARD_TERMKEY_INTERNAL_H_
2 #define GUARD_TERMKEY_INTERNAL_H_
12 void *(*new_driver
)(TermKey
*tk
, const char *term
);
13 void (*free_driver
)(void *info
);
14 int (*start_driver
)(TermKey
*tk
, void *info
);
15 int (*stop_driver
)(TermKey
*tk
, void *info
);
16 TermKeyResult (*peekkey
)(TermKey
*tk
, void *info
, TermKeyKey
*key
, int force
, size_t *nbytes
);
26 struct TermKeyDriverNode
;
27 struct TermKeyDriverNode
{
28 struct TermKeyDriver
*driver
;
30 struct TermKeyDriverNode
*next
;
37 unsigned char *buffer
;
38 size_t buffstart
; // First offset in buffer
39 size_t buffcount
; // NUMBER of entires valid in buffer
40 size_t buffsize
; // Total malloc'ed size
41 size_t hightide
; /* Position beyond buffstart at which peekkey() should next start
42 * normally 0, but see also termkey_interpret_csi */
44 struct termios restore_termios
;
45 char restore_termios_valid
;
53 const char **keynames
;
55 // There are 32 C0 codes
56 struct keyinfo c0
[32];
58 struct TermKeyDriverNode
*drivers
;
60 // Now some "protected" methods for the driver to call but which we don't
61 // want exported as real symbols in the library
63 void (*emit_codepoint
)(TermKey
*tk
, long codepoint
, TermKeyKey
*key
);
64 TermKeyResult (*peekkey_simple
)(TermKey
*tk
, TermKeyKey
*key
, int force
, size_t *nbytes
);
65 TermKeyResult (*peekkey_mouse
)(TermKey
*tk
, TermKeyKey
*key
, size_t *nbytes
);
69 static inline void termkey_key_get_linecol(const TermKeyKey
*key
, int *line
, int *col
)
72 *col
= (unsigned char)key
->code
.mouse
[1] | ((unsigned char)key
->code
.mouse
[3] & 0x0f) << 8;
75 *line
= (unsigned char)key
->code
.mouse
[2] | ((unsigned char)key
->code
.mouse
[3] & 0x70) << 4;
78 static inline void termkey_key_set_linecol(TermKeyKey
*key
, int line
, int col
)
86 key
->code
.mouse
[1] = (line
& 0x0ff);
87 key
->code
.mouse
[2] = (col
& 0x0ff);
88 key
->code
.mouse
[3] = (line
& 0xf00) >> 8 | (col
& 0x300) >> 4;
91 extern struct TermKeyDriver termkey_driver_csi
;
92 extern struct TermKeyDriver termkey_driver_ti
;