aboutsummaryrefslogtreecommitdiff
path: root/termkey-internal.h
blob: 2a1a831173b22a30f4871daa5c28388761df0b92 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#ifndef GUARD_TERMKEY_INTERNAL_H_
#define GUARD_TERMKEY_INTERNAL_H_

#include "termkey.h"

#include <stdint.h>
#include <termios.h>

struct termkey_driver
{
  const char      *name;
  void          *(*new_driver)(termkey_t *tk, const char *term);
  void           (*free_driver)(void *info);
  void           (*start_driver)(termkey_t *tk, void *info);
  void           (*stop_driver)(termkey_t *tk, void *info);
  termkey_result (*getkey)(termkey_t *tk, void *info, termkey_key *key, int force);
};

struct keyinfo {
  termkey_type type;
  termkey_keysym sym;
  int modifier_mask;
  int modifier_set;
};

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;

  // There are 32 C0 codes
  struct keyinfo c0[32];

  struct termkey_driver driver;
  void *driver_info;

  // Now some "protected" methods for the driver to call but which we don't
  // want exported as real symbols in the library
  struct {
    void (*eat_bytes)(termkey_t *tk, size_t count);
    void (*emit_codepoint)(termkey_t *tk, long codepoint, termkey_key *key);
    termkey_result (*getkey_simple)(termkey_t *tk, termkey_key *key, int force);
  } method;
};

extern struct termkey_driver termkey_driver_csi;
extern struct termkey_driver termkey_driver_ti;

#endif