Pass driver_info as explicit void* parameter into driver methods
This commit is contained in:
parent
9969e197ba
commit
e880602944
|
@ -130,9 +130,9 @@ abort_free_csi:
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void free_driver(void *private)
|
static void free_driver(void *info)
|
||||||
{
|
{
|
||||||
termkey_csi *csi = private;
|
termkey_csi *csi = info;
|
||||||
|
|
||||||
free(csi->csifuncs); csi->csifuncs = NULL;
|
free(csi->csifuncs); csi->csifuncs = NULL;
|
||||||
|
|
||||||
|
@ -286,12 +286,12 @@ static termkey_result getkey_ss3(termkey_t *tk, termkey_csi *csi, size_t introle
|
||||||
return TERMKEY_RES_KEY;
|
return TERMKEY_RES_KEY;
|
||||||
}
|
}
|
||||||
|
|
||||||
static termkey_result getkey(termkey_t *tk, termkey_key *key, int force)
|
static termkey_result getkey(termkey_t *tk, void *info, termkey_key *key, int force)
|
||||||
{
|
{
|
||||||
if(tk->buffcount == 0)
|
if(tk->buffcount == 0)
|
||||||
return tk->is_closed ? TERMKEY_RES_EOF : TERMKEY_RES_NONE;
|
return tk->is_closed ? TERMKEY_RES_EOF : TERMKEY_RES_NONE;
|
||||||
|
|
||||||
termkey_csi *csi = tk->driver_info;
|
termkey_csi *csi = info;
|
||||||
|
|
||||||
// Now we're sure at least 1 byte is valid
|
// Now we're sure at least 1 byte is valid
|
||||||
unsigned char b0 = CHARAT(0);
|
unsigned char b0 = CHARAT(0);
|
||||||
|
|
10
driver-ti.c
10
driver-ti.c
|
@ -77,7 +77,7 @@ abort_free_ti:
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void start_driver(termkey_t *tk)
|
static void start_driver(termkey_t *tk, void *info)
|
||||||
{
|
{
|
||||||
/* The terminfo database will contain keys in application cursor key mode.
|
/* The terminfo database will contain keys in application cursor key mode.
|
||||||
* We may need to enable that mode
|
* We may need to enable that mode
|
||||||
|
@ -88,7 +88,7 @@ static void start_driver(termkey_t *tk)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void stop_driver(termkey_t *tk)
|
static void stop_driver(termkey_t *tk, void *info)
|
||||||
{
|
{
|
||||||
if(keypad_local) {
|
if(keypad_local) {
|
||||||
// Can't call putp or tputs because they suck and don't give us fd control
|
// Can't call putp or tputs because they suck and don't give us fd control
|
||||||
|
@ -96,15 +96,15 @@ static void stop_driver(termkey_t *tk)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void free_driver(void *private)
|
static void free_driver(void *info)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
#define CHARAT(i) (tk->buffer[tk->buffstart + (i)])
|
#define CHARAT(i) (tk->buffer[tk->buffstart + (i)])
|
||||||
|
|
||||||
static termkey_result getkey(termkey_t *tk, termkey_key *key, int force)
|
static termkey_result getkey(termkey_t *tk, void *info, termkey_key *key, int force)
|
||||||
{
|
{
|
||||||
termkey_ti *ti = tk->driver_info;
|
termkey_ti *ti = info;
|
||||||
|
|
||||||
if(tk->buffcount == 0)
|
if(tk->buffcount == 0)
|
||||||
return tk->is_closed ? TERMKEY_RES_EOF : TERMKEY_RES_NONE;
|
return tk->is_closed ? TERMKEY_RES_EOF : TERMKEY_RES_NONE;
|
||||||
|
|
|
@ -9,10 +9,10 @@
|
||||||
struct termkey_driver
|
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 *info);
|
||||||
void (*start_driver)(termkey_t *tk);
|
void (*start_driver)(termkey_t *tk, void *info);
|
||||||
void (*stop_driver)(termkey_t *tk);
|
void (*stop_driver)(termkey_t *tk, void *info);
|
||||||
termkey_result (*getkey)(termkey_t *tk, termkey_key *key, int force);
|
termkey_result (*getkey)(termkey_t *tk, void *info, termkey_key *key, int force);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct keyinfo {
|
struct keyinfo {
|
||||||
|
|
10
termkey.c
10
termkey.c
|
@ -186,7 +186,7 @@ termkey_t *termkey_new_full(int fd, int flags, size_t buffsize, int waittime)
|
||||||
}
|
}
|
||||||
|
|
||||||
if(tk->driver.start_driver)
|
if(tk->driver.start_driver)
|
||||||
(*tk->driver.start_driver)(tk);
|
(*tk->driver.start_driver)(tk, tk->driver_info);
|
||||||
|
|
||||||
return tk;
|
return tk;
|
||||||
|
|
||||||
|
@ -221,7 +221,7 @@ void termkey_free(termkey_t *tk)
|
||||||
void termkey_destroy(termkey_t *tk)
|
void termkey_destroy(termkey_t *tk)
|
||||||
{
|
{
|
||||||
if(tk->driver.stop_driver)
|
if(tk->driver.stop_driver)
|
||||||
(*tk->driver.stop_driver)(tk);
|
(*tk->driver.stop_driver)(tk, tk->driver_info);
|
||||||
|
|
||||||
if(tk->restore_termios_valid)
|
if(tk->restore_termios_valid)
|
||||||
tcsetattr(tk->fd, TCSANOW, &tk->restore_termios);
|
tcsetattr(tk->fd, TCSANOW, &tk->restore_termios);
|
||||||
|
@ -375,7 +375,7 @@ static termkey_result getkey_simple(termkey_t *tk, termkey_key *key, int force)
|
||||||
tk->buffcount--;
|
tk->buffcount--;
|
||||||
|
|
||||||
// Run the full driver
|
// Run the full driver
|
||||||
termkey_result metakey_result = (*tk->driver.getkey)(tk, key, force);
|
termkey_result metakey_result = (*tk->driver.getkey)(tk, tk->driver_info, key, force);
|
||||||
|
|
||||||
tk->buffstart--;
|
tk->buffstart--;
|
||||||
tk->buffcount++;
|
tk->buffcount++;
|
||||||
|
@ -497,12 +497,12 @@ static termkey_result getkey_simple(termkey_t *tk, termkey_key *key, int force)
|
||||||
|
|
||||||
termkey_result termkey_getkey(termkey_t *tk, termkey_key *key)
|
termkey_result termkey_getkey(termkey_t *tk, termkey_key *key)
|
||||||
{
|
{
|
||||||
return (*tk->driver.getkey)(tk, key, 0);
|
return (*tk->driver.getkey)(tk, tk->driver_info, key, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
termkey_result termkey_getkey_force(termkey_t *tk, termkey_key *key)
|
termkey_result termkey_getkey_force(termkey_t *tk, termkey_key *key)
|
||||||
{
|
{
|
||||||
return (*tk->driver.getkey)(tk, key, 1);
|
return (*tk->driver.getkey)(tk, tk->driver_info, key, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
termkey_result termkey_waitkey(termkey_t *tk, termkey_key *key)
|
termkey_result termkey_waitkey(termkey_t *tk, termkey_key *key)
|
||||||
|
|
Loading…
Reference in New Issue