text: /* input.h */
  
  #ifndef INPUT_H_FILE
  #define INPUT_H_FILE
  
  #define CTRL_KEY(k) ((k) & 0x1f)
  #define ALT_KEY(k)  (((k) & 0x1f) + KEY_ALT_FIRST)
  
  #define FIRST_NONCHAR_KEY  0x110000
  
  enum hex_editor_key {
    KEY_READ_ERROR = -1,
  
    KEY_NONE = FIRST_NONCHAR_KEY,
    KEY_BAD_SEQUENCE,
    KEY_REDRAW,
    
    KEY_ARROW_LEFT = FIRST_NONCHAR_KEY + 0x1000,
    KEY_ARROW_RIGHT,
    KEY_ARROW_UP,
    KEY_ARROW_DOWN,
    KEY_INS,
    KEY_DEL,
    KEY_HOME,
    KEY_END,
    KEY_PAGE_UP,
    KEY_PAGE_DOWN,
  
    KEY_SHIFT_ARROW_LEFT,
    KEY_SHIFT_ARROW_RIGHT,
    KEY_SHIFT_ARROW_UP,
    KEY_SHIFT_ARROW_DOWN,
    KEY_SHIFT_INS,
    KEY_SHIFT_DEL,
    KEY_SHIFT_HOME,
    KEY_SHIFT_END,
    KEY_SHIFT_PAGE_UP,
    KEY_SHIFT_PAGE_DOWN,
  
    KEY_CTRL_ARROW_LEFT,
    KEY_CTRL_ARROW_RIGHT,
    KEY_CTRL_ARROW_UP,
    KEY_CTRL_ARROW_DOWN,
    KEY_CTRL_INS,
    KEY_CTRL_DEL,
    KEY_CTRL_HOME,
    KEY_CTRL_END,
    KEY_CTRL_PAGE_UP,
    KEY_CTRL_PAGE_DOWN,
  
    KEY_F1,
    KEY_F2,
    KEY_F3,
    KEY_F4,
    KEY_F5,
    KEY_F6,
    KEY_F7,
    KEY_F8,
    KEY_F9,
    KEY_F10,
    KEY_F11,
    KEY_F12,
  
    KEY_SHIFT_F1,
    KEY_SHIFT_F2,
    KEY_SHIFT_F3,
    KEY_SHIFT_F4,
    KEY_SHIFT_F5,
    KEY_SHIFT_F6,
    KEY_SHIFT_F7,
    KEY_SHIFT_F8,
    KEY_SHIFT_F9,
    KEY_SHIFT_F10,
    KEY_SHIFT_F11,
    KEY_SHIFT_F12,
  
    KEY_ALT_FIRST = FIRST_NONCHAR_KEY + 0x2000,
  };
  
  int read_key(int fd, char *seq, size_t max_seq_len);
  
  #endif /* INPUT_H_FILE */
  