Merge branch 'obsd-master'

This commit is contained in:
Thomas Adam 2017-07-05 00:01:10 +01:00
commit 6b1ceca86a
2 changed files with 34 additions and 7 deletions

2
tmux.1
View File

@ -1426,6 +1426,8 @@ The following keys may be used in tree mode:
.It Li "Enter" Ta "Choose selected item" .It Li "Enter" Ta "Choose selected item"
.It Li "Up" Ta "Select previous item" .It Li "Up" Ta "Select previous item"
.It Li "Down" Ta "Select next item" .It Li "Down" Ta "Select next item"
.It Li "<" Ta "Scroll list of previews left"
.It Li ">" Ta "Scroll list of previews right"
.It Li "C-s" Ta "Search by name" .It Li "C-s" Ta "Search by name"
.It Li "n" Ta "Repeat last search" .It Li "n" Ta "Repeat last search"
.It Li "t" Ta "Toggle if item is tagged" .It Li "t" Ta "Toggle if item is tagged"

View File

@ -83,6 +83,8 @@ struct window_tree_modedata {
struct cmd_find_state fs; struct cmd_find_state fs;
enum window_tree_type type; enum window_tree_type type;
int offset;
}; };
static void static void
@ -409,8 +411,8 @@ window_tree_build(void *modedata, u_int sort_type, uint64_t *tag,
} }
static void static void
window_tree_draw_session(struct session *s, struct screen_write_ctx *ctx, window_tree_draw_session(struct window_tree_modedata *data, struct session *s,
u_int sx, u_int sy) struct screen_write_ctx *ctx, u_int sx, u_int sy)
{ {
struct options *oo = s->options; struct options *oo = s->options;
struct winlink *wl; struct winlink *wl;
@ -453,6 +455,13 @@ window_tree_draw_session(struct session *s, struct screen_write_ctx *ctx,
end = start + visible; end = start + visible;
} }
if (data->offset < -(int)start)
data->offset = -(int)start;
if (data->offset > (int)(total - end))
data->offset = (int)(total - end);
start += data->offset;
end += data->offset;
left = (start != 0); left = (start != 0);
right = (end != total); right = (end != total);
if (((left && right) && sx <= 6) || ((left || right) && sx <= 3)) if (((left && right) && sx <= 6) || ((left || right) && sx <= 3))
@ -530,8 +539,8 @@ window_tree_draw_session(struct session *s, struct screen_write_ctx *ctx,
} }
static void static void
window_tree_draw_window(struct session *s, struct window *w, window_tree_draw_window(struct window_tree_modedata *data, struct session *s,
struct screen_write_ctx *ctx, u_int sx, u_int sy) struct window *w, struct screen_write_ctx *ctx, u_int sx, u_int sy)
{ {
struct options *oo = s->options; struct options *oo = s->options;
struct window_pane *wp; struct window_pane *wp;
@ -573,6 +582,13 @@ window_tree_draw_window(struct session *s, struct window *w,
end = start + visible; end = start + visible;
} }
if (data->offset < -(int)start)
data->offset = -(int)start;
if (data->offset > (int)(total - end))
data->offset = (int)(total - end);
start += data->offset;
end += data->offset;
left = (start != 0); left = (start != 0);
right = (end != total); right = (end != total);
if (((left && right) && sx <= 6) || ((left || right) && sx <= 3)) if (((left && right) && sx <= 6) || ((left || right) && sx <= 3))
@ -647,7 +663,7 @@ window_tree_draw_window(struct session *s, struct window *w,
} }
static struct screen * static struct screen *
window_tree_draw(__unused void *modedata, void *itemdata, u_int sx, u_int sy) window_tree_draw(void *modedata, void *itemdata, u_int sx, u_int sy)
{ {
struct window_tree_itemdata *item = itemdata; struct window_tree_itemdata *item = itemdata;
struct session *sp; struct session *sp;
@ -667,10 +683,10 @@ window_tree_draw(__unused void *modedata, void *itemdata, u_int sx, u_int sy)
case WINDOW_TREE_NONE: case WINDOW_TREE_NONE:
return (0); return (0);
case WINDOW_TREE_SESSION: case WINDOW_TREE_SESSION:
window_tree_draw_session(sp, &ctx, sx, sy); window_tree_draw_session(modedata, sp, &ctx, sx, sy);
break; break;
case WINDOW_TREE_WINDOW: case WINDOW_TREE_WINDOW:
window_tree_draw_window(sp, wlp->window, &ctx, sx, sy); window_tree_draw_window(modedata, sp, wlp->window, &ctx, sx, sy);
break; break;
case WINDOW_TREE_PANE: case WINDOW_TREE_PANE:
screen_write_preview(&ctx, &wp->base, sx, sy); screen_write_preview(&ctx, &wp->base, sx, sy);
@ -898,8 +914,17 @@ window_tree_key(struct window_pane *wp, struct client *c,
int finished; int finished;
u_int tagged; u_int tagged;
item = mode_tree_get_current(data->data);
finished = mode_tree_key(data->data, c, &key, m); finished = mode_tree_key(data->data, c, &key, m);
if (item != mode_tree_get_current(data->data))
data->offset = 0;
switch (key) { switch (key) {
case '<':
data->offset--;
break;
case '>':
data->offset++;
break;
case ':': case ':':
tagged = mode_tree_count_tagged(data->data); tagged = mode_tree_count_tagged(data->data);
if (tagged != 0) if (tagged != 0)