#ifndef KEY_COMMAND_H #define KEY_COMMAND_H enum { KeyCommandEntry_type_edit, KeyCommandEntry_type_edit_with_motion, KeyCommandEntry_type_motion, KeyCommandEntry_type_double, }; struct KeyCommandEntry_struct { int type; int keyChar; }; typedef struct KeyCommandEntry_struct *KeyCommandEntry; extern KeyCommandEntry KeyCommandEntry_create(int type, int keyChar); extern void KeyCommandEntry_destroy(KeyCommandEntry this); extern int KeyCommandEntry_type(KeyCommandEntry this); extern int KeyCommandEntry_keyChar(KeyCommandEntry this); #define KEY_COMMAND_TABLE_BUFFER_INCREMENT_SIZE 16 struct KeyCommandTable_struct { int maxSize; int size; KeyCommandEntry *entries; }; typedef struct KeyCommandTable_struct *KeyCommandTable; extern KeyCommandTable KeyCommandTable_create(void); extern void KeyCommandTable_destroy(KeyCommandTable this); extern void KeyCommandTable_add(KeyCommandTable this, int type, int keyChar); extern KeyCommandEntry KeyCommandTable_find(KeyCommandTable this, int keyChar); extern void KeyCommandTable_setup(KeyCommandTable this); #define KEY_COMMAND_SWALLOWED 0 #define KEY_COMMAND_FINISHED 1 #define KEY_COMMAND_CANCELED -1 #define KEY_COMMAND_ERROR -2 enum { KeyCommand_state_initialized, KeyCommand_state_count1, KeyCommand_state_edit, KeyCommand_state_count2, KeyCommand_state_request_mark, KeyCommand_state_finished, KeyCommand_state_canceled, KeyCommand_state_error, }; struct KeyCommand_struct { KeyCommandTable table; int state; int count1; int edit; int count2; int motion; int mark; }; typedef struct KeyCommand_struct *KeyCommand; extern KeyCommand KeyCommand_create(KeyCommandTable table); extern void KeyCommand_destroy(KeyCommand this); extern void KeyCommand_reset(KeyCommand this); extern int KeyCommand_read(KeyCommand this, char c); #endif