Merge branch 'master' of ssh://git.code.sf.net/p/tmux/tmux-code

pull/1/head
Nicholas Marriott 2013-08-21 18:03:07 +01:00
commit b2fe9bff3f
7 changed files with 121 additions and 64 deletions

View File

@ -225,7 +225,6 @@ windows_only:
free(final_win_template_last);
window_choose_ready(wl->window->active, cur_win, NULL);
window_choose_collapse_all(wl->window->active);
if (args_has(args, 'u')) {
window_choose_expand_all(wl->window->active);

151
input.c
View File

@ -70,6 +70,10 @@ int input_input(struct input_ctx *);
int input_c0_dispatch(struct input_ctx *);
int input_esc_dispatch(struct input_ctx *);
int input_csi_dispatch(struct input_ctx *);
void input_csi_dispatch_rm(struct input_ctx *);
void input_csi_dispatch_rm_private(struct input_ctx *);
void input_csi_dispatch_sm(struct input_ctx *);
void input_csi_dispatch_sm_private(struct input_ctx *);
void input_csi_dispatch_sgr(struct input_ctx *);
int input_dcs_dispatch(struct input_ctx *);
int input_utf8_open(struct input_ctx *);
@ -1071,7 +1075,6 @@ int
input_csi_dispatch(struct input_ctx *ictx)
{
struct screen_write_ctx *sctx = &ictx->ctx;
struct window_pane *wp = ictx->wp;
struct screen *s = sctx->s;
struct input_table_entry *entry;
int n, m;
@ -1230,7 +1233,60 @@ input_csi_dispatch(struct input_ctx *ictx)
screen_write_cursormove(sctx, ictx->old_cx, ictx->old_cy);
break;
case INPUT_CSI_RM:
switch (input_get(ictx, 0, 0, -1)) {
input_csi_dispatch_rm(ictx);
break;
case INPUT_CSI_RM_PRIVATE:
input_csi_dispatch_rm_private(ictx);
break;
case INPUT_CSI_SCP:
memcpy(&ictx->old_cell, &ictx->cell, sizeof ictx->old_cell);
ictx->old_cx = s->cx;
ictx->old_cy = s->cy;
break;
case INPUT_CSI_SGR:
input_csi_dispatch_sgr(ictx);
break;
case INPUT_CSI_SM:
input_csi_dispatch_sm(ictx);
break;
case INPUT_CSI_SM_PRIVATE:
input_csi_dispatch_sm_private(ictx);
break;
case INPUT_CSI_TBC:
switch (input_get(ictx, 0, 0, 0)) {
case 0:
if (s->cx < screen_size_x(s))
bit_clear(s->tabs, s->cx);
break;
case 3:
bit_nclear(s->tabs, 0, screen_size_x(s) - 1);
break;
default:
log_debug("%s: unknown '%c'", __func__, ictx->ch);
break;
}
break;
case INPUT_CSI_VPA:
n = input_get(ictx, 0, 1, 1);
screen_write_cursormove(sctx, s->cx, n - 1);
break;
case INPUT_CSI_DECSCUSR:
n = input_get(ictx, 0, 0, 0);
screen_set_cursor_style(s, n);
break;
}
return (0);
}
/* Handle CSI RM. */
void
input_csi_dispatch_rm(struct input_ctx *ictx)
{
u_int i;
for (i = 0; i < ictx->param_list_len; i++) {
switch (input_get(ictx, i, 0, -1)) {
case 4: /* IRM */
screen_write_mode_clear(&ictx->ctx, MODE_INSERT);
break;
@ -1238,10 +1294,18 @@ input_csi_dispatch(struct input_ctx *ictx)
log_debug("%s: unknown '%c'", __func__, ictx->ch);
break;
}
break;
case INPUT_CSI_RM_PRIVATE:
switch (input_get(ictx, 0, 0, -1)) {
case 1: /* GATM */
}
}
/* Handle CSI private RM. */
void
input_csi_dispatch_rm_private(struct input_ctx *ictx)
{
u_int i;
for (i = 0; i < ictx->param_list_len; i++) {
switch (input_get(ictx, i, 0, -1)) {
case 1: /* DECCKM */
screen_write_mode_clear(&ictx->ctx, MODE_KCURSOR);
break;
case 3: /* DECCOLM */
@ -1271,10 +1335,10 @@ input_csi_dispatch(struct input_ctx *ictx)
break;
case 47:
case 1047:
window_pane_alternate_off(wp, &ictx->cell, 0);
window_pane_alternate_off(ictx->wp, &ictx->cell, 0);
break;
case 1049:
window_pane_alternate_off(wp, &ictx->cell, 1);
window_pane_alternate_off(ictx->wp, &ictx->cell, 1);
break;
case 2004:
screen_write_mode_clear(&ictx->ctx, MODE_BRACKETPASTE);
@ -1283,17 +1347,17 @@ input_csi_dispatch(struct input_ctx *ictx)
log_debug("%s: unknown '%c'", __func__, ictx->ch);
break;
}
break;
case INPUT_CSI_SCP:
memcpy(&ictx->old_cell, &ictx->cell, sizeof ictx->old_cell);
ictx->old_cx = s->cx;
ictx->old_cy = s->cy;
break;
case INPUT_CSI_SGR:
input_csi_dispatch_sgr(ictx);
break;
case INPUT_CSI_SM:
switch (input_get(ictx, 0, 0, -1)) {
}
}
/* Handle CSI SM. */
void
input_csi_dispatch_sm(struct input_ctx *ictx)
{
u_int i;
for (i = 0; i < ictx->param_list_len; i++) {
switch (input_get(ictx, i, 0, -1)) {
case 4: /* IRM */
screen_write_mode_set(&ictx->ctx, MODE_INSERT);
break;
@ -1301,10 +1365,18 @@ input_csi_dispatch(struct input_ctx *ictx)
log_debug("%s: unknown '%c'", __func__, ictx->ch);
break;
}
break;
case INPUT_CSI_SM_PRIVATE:
switch (input_get(ictx, 0, 0, -1)) {
case 1: /* GATM */
}
}
/* Handle CSI private SM. */
void
input_csi_dispatch_sm_private(struct input_ctx *ictx)
{
u_int i;
for (i = 0; i < ictx->param_list_len; i++) {
switch (input_get(ictx, i, 0, -1)) {
case 1: /* DECCKM */
screen_write_mode_set(&ictx->ctx, MODE_KCURSOR);
break;
case 3: /* DECCOLM */
@ -1330,10 +1402,10 @@ input_csi_dispatch(struct input_ctx *ictx)
screen_write_mode_set(&ictx->ctx, MODE_MOUSE_ANY);
break;
case 1004:
if (s->mode & MODE_FOCUSON)
if (ictx->ctx.s->mode & MODE_FOCUSON)
break;
screen_write_mode_set(&ictx->ctx, MODE_FOCUSON);
wp->flags |= PANE_FOCUSPUSH; /* force update */
ictx->wp->flags |= PANE_FOCUSPUSH; /* force update */
break;
case 1005:
screen_write_mode_set(&ictx->ctx, MODE_MOUSE_UTF8);
@ -1343,10 +1415,10 @@ input_csi_dispatch(struct input_ctx *ictx)
break;
case 47:
case 1047:
window_pane_alternate_on(wp, &ictx->cell, 0);
window_pane_alternate_on(ictx->wp, &ictx->cell, 0);
break;
case 1049:
window_pane_alternate_on(wp, &ictx->cell, 1);
window_pane_alternate_on(ictx->wp, &ictx->cell, 1);
break;
case 2004:
screen_write_mode_set(&ictx->ctx, MODE_BRACKETPASTE);
@ -1355,32 +1427,7 @@ input_csi_dispatch(struct input_ctx *ictx)
log_debug("%s: unknown '%c'", __func__, ictx->ch);
break;
}
break;
case INPUT_CSI_TBC:
switch (input_get(ictx, 0, 0, 0)) {
case 0:
if (s->cx < screen_size_x(s))
bit_clear(s->tabs, s->cx);
break;
case 3:
bit_nclear(s->tabs, 0, screen_size_x(s) - 1);
break;
default:
log_debug("%s: unknown '%c'", __func__, ictx->ch);
break;
}
break;
case INPUT_CSI_VPA:
n = input_get(ictx, 0, 1, 1);
screen_write_cursormove(sctx, s->cx, n - 1);
break;
case INPUT_CSI_DECSCUSR:
n = input_get(ictx, 0, 0, 0);
screen_set_cursor_style(s, n);
break;
}
return (0);
}
/* Handle CSI SGR. */

View File

@ -615,7 +615,7 @@ session_renumber_windows(struct session *s)
memcpy(&old_lastw, &s->lastw, sizeof old_lastw);
TAILQ_INIT(&s->lastw);
TAILQ_FOREACH(wl, &old_lastw, sentry) {
wl_new = winlink_find_by_index(&s->windows, wl->idx);
wl_new = winlink_find_by_window(&s->windows, wl->window);
if (wl_new != NULL)
TAILQ_INSERT_TAIL(&s->lastw, wl_new, sentry);
}

1
tmux.h
View File

@ -1005,6 +1005,7 @@ struct window {
#define WINDOW_REDRAW 0x4
#define WINDOW_SILENCE 0x8
#define WINDOW_ZOOMED 0x10
#define WINDOW_ALERTFLAGS (WINDOW_BELL|WINDOW_ACTIVITY|WINDOW_SILENCE)
struct options options;

View File

@ -746,6 +746,8 @@ tty_keys_mouse(struct tty *tty, const char *buf, size_t len, size_t *size)
m->sgr = sgr;
m->sgr_xb = sgr_b;
m->sgr_rel = sgr_rel;
m->x = x;
m->y = y;
if (b & 64) { /* wheel button */
b &= 3;
if (b == 0)
@ -773,8 +775,6 @@ tty_keys_mouse(struct tty *tty, const char *buf, size_t len, size_t *size)
}
m->button = (b & 3);
}
m->x = x;
m->y = y;
return (0);
}

View File

@ -81,6 +81,7 @@ int window_choose_key_index(struct window_choose_mode_data *, u_int);
int window_choose_index_key(struct window_choose_mode_data *, int);
void window_choose_prompt_input(enum window_choose_input_type,
const char *, struct window_pane *, int);
void window_choose_reset_top(struct window_pane *, u_int);
void
window_choose_add(struct window_pane *wp, struct window_choose_data *wcd)
@ -107,8 +108,17 @@ window_choose_set_current(struct window_pane *wp, u_int cur)
struct screen *s = &data->screen;
data->selected = cur;
if (data->selected > screen_size_y(s) - 1)
data->top = ARRAY_LENGTH(&data->list) - screen_size_y(s);
window_choose_reset_top(wp, screen_size_y(s));
}
void
window_choose_reset_top(struct window_pane *wp, u_int sy)
{
struct window_choose_mode_data *data = wp->modedata;
data->top = 0;
if (data->selected > sy - 1)
data->top = data->selected - (sy - 1);
window_choose_redraw_screen(wp);
}
@ -277,10 +287,7 @@ window_choose_resize(struct window_pane *wp, u_int sx, u_int sy)
struct window_choose_mode_data *data = wp->modedata;
struct screen *s = &data->screen;
data->top = 0;
if (data->selected > sy - 1)
data->top = data->selected - (sy - 1);
window_choose_reset_top(wp, sy);
screen_resize(s, sx, sy, 0);
window_choose_redraw_screen(wp);
}
@ -373,6 +380,7 @@ window_choose_collapse_all(struct window_pane *wp)
{
struct window_choose_mode_data *data = wp->modedata;
struct window_choose_mode_item *item;
struct screen *scr = &data->screen;
struct session *s, *chosen;
u_int i;
@ -391,7 +399,7 @@ window_choose_collapse_all(struct window_pane *wp)
if (item->wcd->type & TREE_SESSION)
data->selected = i;
}
window_choose_redraw_screen(wp);
window_choose_reset_top(wp, screen_size_y(scr));
}
void
@ -399,6 +407,7 @@ window_choose_expand_all(struct window_pane *wp)
{
struct window_choose_mode_data *data = wp->modedata;
struct window_choose_mode_item *item;
struct screen *scr = &data->screen;
struct session *s;
u_int i;
@ -414,7 +423,7 @@ window_choose_expand_all(struct window_pane *wp)
}
}
window_choose_redraw_screen(wp);
window_choose_reset_top(wp, screen_size_y(scr));
}
void

View File

@ -1243,6 +1243,7 @@ winlink_clear_flags(struct winlink *wl)
continue;
wm->flags &= ~WINLINK_ALERTFLAGS;
wm->window->flags &= ~WINDOW_ALERTFLAGS;
server_status_session(s);
}
}