Added new driver virtual methods 'start_driver' and 'stop_driver'

This commit is contained in:
Paul LeoNerd Evans 2008-11-02 17:54:24 +00:00
parent 1d4d908cb8
commit 5107112a91
2 changed files with 8 additions and 0 deletions

View File

@ -10,6 +10,8 @@ struct termkey_driver
{ {
void *(*new_driver)(termkey_t *tk, const char *term); void *(*new_driver)(termkey_t *tk, const char *term);
void (*free_driver)(void *); void (*free_driver)(void *);
void (*start_driver)(termkey_t *tk);
void (*stop_driver)(termkey_t *tk);
termkey_result (*getkey)(termkey_t *tk, termkey_key *key, int force); termkey_result (*getkey)(termkey_t *tk, termkey_key *key, int force);
}; };

View File

@ -185,6 +185,9 @@ termkey_t *termkey_new_full(int fd, int flags, size_t buffsize, int waittime)
} }
} }
if(tk->driver.start_driver)
(*tk->driver.start_driver)(tk);
return tk; return tk;
abort_free_keynames: abort_free_keynames:
@ -217,6 +220,9 @@ void termkey_free(termkey_t *tk)
void termkey_destroy(termkey_t *tk) void termkey_destroy(termkey_t *tk)
{ {
if(tk->driver.stop_driver)
(*tk->driver.stop_driver)(tk);
if(tk->restore_termios_valid) if(tk->restore_termios_valid)
tcsetattr(tk->fd, TCSANOW, &tk->restore_termios); tcsetattr(tk->fd, TCSANOW, &tk->restore_termios);