diff options
author | Paul LeoNerd Evans <leonerd@leonerd.org.uk> | 2008-10-07 03:17:06 +0100 |
---|---|---|
committer | Paul LeoNerd Evans <leonerd@leonerd.org.uk> | 2008-10-07 03:17:06 +0100 |
commit | 8b7c2b5d4f79cf600df60a583accd04fb273c300 (patch) | |
tree | ab2a6bafdb1b095bf2df94f3c4c0f3f4f666f3bf | |
parent | d7358c43afa34f5be4ef26ddb4b1ec7aa104ee77 (diff) | |
download | termo-8b7c2b5d4f79cf600df60a583accd04fb273c300.tar.gz termo-8b7c2b5d4f79cf600df60a583accd04fb273c300.tar.xz termo-8b7c2b5d4f79cf600df60a583accd04fb273c300.zip |
Support a list of potential backend drivers
-rw-r--r-- | termkey.c | 19 |
1 files changed, 17 insertions, 2 deletions
@@ -8,6 +8,11 @@ #include <stdio.h> +static struct termkey_driver *drivers[] = { + &termkey_driver_csi, + NULL, +}; + termkey_t *termkey_new_full(int fd, int flags, size_t buffsize, int waittime) { termkey_t *tk = malloc(sizeof(*tk)); @@ -59,9 +64,19 @@ termkey_t *termkey_new_full(int fd, int flags, size_t buffsize, int waittime) for(i = 0; i < tk->nkeynames; i++) tk->keynames[i] = NULL; - tk->driver = termkey_driver_csi; + for(i = 0; drivers[i]; i++) { + void *driver_info = (*drivers[i]->new_driver)(tk); + if(!driver_info) + continue; + + tk->driver = *(drivers[i]); + tk->driver_info = driver_info; + } - tk->driver_info = (*tk->driver.new_driver)(tk); + if(!tk->driver_info) { + fprintf(stderr, "Unable to find a terminal driver\n"); + return NULL; + } // Special built-in names termkey_register_keyname(tk, TERMKEY_SYM_NONE, "NONE"); |