version 1.161, 2016/06/06 07:24:31 |
version 1.162, 2016/06/15 09:13:46 |
|
|
*/ |
*/ |
|
|
#include <sys/types.h> |
#include <sys/types.h> |
|
#include <sys/ioctl.h> |
|
|
#include <errno.h> |
#include <errno.h> |
#include <fcntl.h> |
#include <fcntl.h> |
|
|
wp->flags |= PANE_REDRAW; |
wp->flags |= PANE_REDRAW; |
} |
} |
|
|
|
static void |
|
window_pane_mode_timer(__unused int fd, __unused short events, void *arg) |
|
{ |
|
struct window_pane *wp = arg; |
|
struct timeval tv = { .tv_sec = 10 }; |
|
int n = 0; |
|
|
|
evtimer_del(&wp->modetimer); |
|
evtimer_add(&wp->modetimer, &tv); |
|
|
|
log_debug("%%%u in mode: last=%ld", wp->id, (long)wp->modelast); |
|
|
|
if (wp->modelast < time(NULL) - WINDOW_MODE_TIMEOUT) { |
|
if (ioctl(wp->fd, FIONREAD, &n) == -1 || n > 0) |
|
window_pane_reset_mode(wp); |
|
} |
|
} |
|
|
int |
int |
window_pane_set_mode(struct window_pane *wp, const struct window_mode *mode) |
window_pane_set_mode(struct window_pane *wp, const struct window_mode *mode) |
{ |
{ |
struct screen *s; |
struct screen *s; |
|
struct timeval tv = { .tv_sec = 10 }; |
|
|
if (wp->mode != NULL) |
if (wp->mode != NULL) |
return (1); |
return (1); |
wp->mode = mode; |
wp->mode = mode; |
|
|
|
wp->modelast = time(NULL); |
|
evtimer_set(&wp->modetimer, window_pane_mode_timer, wp); |
|
evtimer_add(&wp->modetimer, &tv); |
|
|
if ((s = wp->mode->init(wp)) != NULL) |
if ((s = wp->mode->init(wp)) != NULL) |
wp->screen = s; |
wp->screen = s; |
wp->flags |= (PANE_REDRAW|PANE_CHANGED); |
wp->flags |= (PANE_REDRAW|PANE_CHANGED); |
|
|
if (wp->mode == NULL) |
if (wp->mode == NULL) |
return; |
return; |
|
|
|
evtimer_del(&wp->modetimer); |
|
|
wp->mode->free(wp); |
wp->mode->free(wp); |
wp->mode = NULL; |
wp->mode = NULL; |
|
|
|
|
return; |
return; |
|
|
if (wp->mode != NULL) { |
if (wp->mode != NULL) { |
|
wp->modelast = time(NULL); |
if (wp->mode->key != NULL) |
if (wp->mode->key != NULL) |
wp->mode->key(wp, c, s, key, m); |
wp->mode->key(wp, c, s, key, m); |
return; |
return; |