Merge branch 'obsd-master'

This commit is contained in:
Thomas Adam 2017-10-06 13:33:32 +01:00
commit 2be01ab4ec
5 changed files with 121 additions and 5 deletions

25
input.c
View File

@ -1693,12 +1693,33 @@ input_csi_dispatch_winops(struct input_ctx *ictx)
/* FALLTHROUGH */ /* FALLTHROUGH */
case 9: case 9:
case 10: case 10:
case 22:
case 23:
m++; m++;
if (input_get(ictx, m, 0, -1) == -1) if (input_get(ictx, m, 0, -1) == -1)
return; return;
break; break;
case 22:
m++;
switch (input_get(ictx, m, 0, -1)) {
case -1:
return;
case 0:
case 2:
screen_push_title(ictx->ctx.s);
break;
}
break;
case 23:
m++;
switch (input_get(ictx, m, 0, -1)) {
case -1:
return;
case 0:
case 2:
screen_pop_title(ictx->ctx.s);
server_status_window(ictx->wp->window);
break;
}
break;
case 18: case 18:
input_reply(ictx, "\033[8;%u;%ut", wp->sy, wp->sx); input_reply(ictx, "\033[8;%u;%ut", wp->sy, wp->sx);
break; break;

View File

@ -162,13 +162,13 @@ key_bindings_init(void)
"bind ! break-pane", "bind ! break-pane",
"bind '\"' split-window", "bind '\"' split-window",
"bind '#' list-buffers", "bind '#' list-buffers",
"bind '$' command-prompt -I'#S' \"rename-session '%%'\"", "bind '$' command-prompt -I'#S' \"rename-session -- '%%'\"",
"bind % split-window -h", "bind % split-window -h",
"bind & confirm-before -p\"kill-window #W? (y/n)\" kill-window", "bind & confirm-before -p\"kill-window #W? (y/n)\" kill-window",
"bind \"'\" command-prompt -pindex \"select-window -t ':%%'\"", "bind \"'\" command-prompt -pindex \"select-window -t ':%%'\"",
"bind ( switch-client -p", "bind ( switch-client -p",
"bind ) switch-client -n", "bind ) switch-client -n",
"bind , command-prompt -I'#W' \"rename-window '%%'\"", "bind , command-prompt -I'#W' \"rename-window -- '%%'\"",
"bind - delete-buffer", "bind - delete-buffer",
"bind . command-prompt \"move-window -t '%%'\"", "bind . command-prompt \"move-window -t '%%'\"",
"bind 0 select-window -t:=0", "bind 0 select-window -t:=0",
@ -192,7 +192,7 @@ key_bindings_init(void)
"bind ] paste-buffer", "bind ] paste-buffer",
"bind c new-window", "bind c new-window",
"bind d detach-client", "bind d detach-client",
"bind f command-prompt \"find-window '%%'\"", "bind f command-prompt \"find-window -- '%%'\"",
"bind i display-message", "bind i display-message",
"bind l last-window", "bind l last-window",
"bind m select-pane -m", "bind m select-pane -m",

View File

@ -1243,6 +1243,7 @@ screen_write_collect_end(struct screen_write_ctx *ctx)
struct screen *s = ctx->s; struct screen *s = ctx->s;
struct screen_write_collect_item *ci = ctx->item; struct screen_write_collect_item *ci = ctx->item;
struct grid_cell gc; struct grid_cell gc;
u_int xx;
if (ci->used == 0) if (ci->used == 0)
return; return;
@ -1255,9 +1256,27 @@ screen_write_collect_end(struct screen_write_ctx *ctx)
log_debug("%s: %u %s (at %u,%u)", __func__, ci->used, ci->data, s->cx, log_debug("%s: %u %s (at %u,%u)", __func__, ci->used, ci->data, s->cx,
s->cy); s->cy);
if (s->cx != 0) {
for (xx = s->cx; xx > 0; xx--) {
grid_view_get_cell(s->grid, xx, s->cy, &gc);
if (~gc.flags & GRID_FLAG_PADDING)
break;
grid_view_set_cell(s->grid, xx, s->cy, &grid_default_cell);
}
if (gc.data.width > 1)
grid_view_set_cell(s->grid, xx, s->cy, &grid_default_cell);
}
memcpy(&gc, &ci->gc, sizeof gc); memcpy(&gc, &ci->gc, sizeof gc);
grid_view_set_cells(s->grid, s->cx, s->cy, &gc, ci->data, ci->used); grid_view_set_cells(s->grid, s->cx, s->cy, &gc, ci->data, ci->used);
s->cx += ci->used; s->cx += ci->used;
for (xx = s->cx; xx < screen_size_x(s); xx++) {
grid_view_get_cell(s->grid, xx, s->cy, &gc);
if (~gc.flags & GRID_FLAG_PADDING)
break;
grid_view_set_cell(s->grid, xx, s->cy, &grid_default_cell);
}
} }
/* Write cell data, collecting if necessary. */ /* Write cell data, collecting if necessary. */
@ -1388,6 +1407,7 @@ screen_write_cell(struct screen_write_ctx *ctx, const struct grid_cell *gc)
* already ensured there is enough room. * already ensured there is enough room.
*/ */
for (xx = s->cx + 1; xx < s->cx + width; xx++) { for (xx = s->cx + 1; xx < s->cx + width; xx++) {
log_debug("%s: new padding at %u,%u", __func__, xx, s->cy);
grid_view_set_cell(gd, xx, s->cy, &screen_write_pad_cell); grid_view_set_cell(gd, xx, s->cy, &screen_write_pad_cell);
skip = 0; skip = 0;
} }
@ -1537,10 +1557,12 @@ screen_write_overwrite(struct screen_write_ctx *ctx, struct grid_cell *gc,
grid_view_get_cell(gd, xx, s->cy, &tmp_gc); grid_view_get_cell(gd, xx, s->cy, &tmp_gc);
if (~tmp_gc.flags & GRID_FLAG_PADDING) if (~tmp_gc.flags & GRID_FLAG_PADDING)
break; break;
log_debug("%s: padding at %u,%u", __func__, xx, s->cy);
grid_view_set_cell(gd, xx, s->cy, &grid_default_cell); grid_view_set_cell(gd, xx, s->cy, &grid_default_cell);
} }
/* Overwrite the character at the start of this padding. */ /* Overwrite the character at the start of this padding. */
log_debug("%s: character at %u,%u", __func__, xx, s->cy);
grid_view_set_cell(gd, xx, s->cy, &grid_default_cell); grid_view_set_cell(gd, xx, s->cy, &grid_default_cell);
done = 1; done = 1;
} }
@ -1557,6 +1579,7 @@ screen_write_overwrite(struct screen_write_ctx *ctx, struct grid_cell *gc,
grid_view_get_cell(gd, xx, s->cy, &tmp_gc); grid_view_get_cell(gd, xx, s->cy, &tmp_gc);
if (~tmp_gc.flags & GRID_FLAG_PADDING) if (~tmp_gc.flags & GRID_FLAG_PADDING)
break; break;
log_debug("%s: overwrite at %u,%u", __func__, xx, s->cy);
grid_view_set_cell(gd, xx, s->cy, &grid_default_cell); grid_view_set_cell(gd, xx, s->cy, &grid_default_cell);
done = 1; done = 1;
} }

View File

@ -24,17 +24,44 @@
#include "tmux.h" #include "tmux.h"
struct screen_title_entry {
char *text;
TAILQ_ENTRY(screen_title_entry) entry;
};
TAILQ_HEAD(screen_titles, screen_title_entry);
static void screen_resize_x(struct screen *, u_int); static void screen_resize_x(struct screen *, u_int);
static void screen_resize_y(struct screen *, u_int); static void screen_resize_y(struct screen *, u_int);
static void screen_reflow(struct screen *, u_int); static void screen_reflow(struct screen *, u_int);
/* Free titles stack. */
static void
screen_free_titles(struct screen *s)
{
struct screen_title_entry *title_entry;
if (s->titles == NULL)
return;
while ((title_entry = TAILQ_FIRST(s->titles)) != NULL) {
TAILQ_REMOVE(s->titles, title_entry, entry);
free(title_entry->text);
free(title_entry);
}
free(s->titles);
s->titles = NULL;
}
/* Create a new screen. */ /* Create a new screen. */
void void
screen_init(struct screen *s, u_int sx, u_int sy, u_int hlimit) screen_init(struct screen *s, u_int sx, u_int sy, u_int hlimit)
{ {
s->grid = grid_create(sx, sy, hlimit); s->grid = grid_create(sx, sy, hlimit);
s->title = xstrdup(""); s->title = xstrdup("");
s->titles = NULL;
s->cstyle = 0; s->cstyle = 0;
s->ccolour = xstrdup(""); s->ccolour = xstrdup("");
@ -60,6 +87,7 @@ screen_reinit(struct screen *s)
grid_clear_lines(s->grid, s->grid->hsize, s->grid->sy, 8); grid_clear_lines(s->grid, s->grid->hsize, s->grid->sy, 8);
screen_clear_selection(s); screen_clear_selection(s);
screen_free_titles(s);
} }
/* Destroy a screen. */ /* Destroy a screen. */
@ -69,7 +97,10 @@ screen_free(struct screen *s)
free(s->tabs); free(s->tabs);
free(s->title); free(s->title);
free(s->ccolour); free(s->ccolour);
grid_destroy(s->grid); grid_destroy(s->grid);
screen_free_titles(s);
} }
/* Reset tabs to default, eight spaces apart. */ /* Reset tabs to default, eight spaces apart. */
@ -110,6 +141,43 @@ screen_set_title(struct screen *s, const char *title)
utf8_stravis(&s->title, title, VIS_OCTAL|VIS_CSTYLE|VIS_TAB|VIS_NL); utf8_stravis(&s->title, title, VIS_OCTAL|VIS_CSTYLE|VIS_TAB|VIS_NL);
} }
/* Push the current title onto the stack. */
void
screen_push_title(struct screen *s)
{
struct screen_title_entry *title_entry;
if (s->titles == NULL) {
s->titles = xmalloc(sizeof *s->titles);
TAILQ_INIT(s->titles);
}
title_entry = xmalloc(sizeof *title_entry);
title_entry->text = xstrdup(s->title);
TAILQ_INSERT_HEAD(s->titles, title_entry, entry);
}
/*
* Pop a title from the stack and set it as the screen title. If the stack is
* empty, do nothing.
*/
void
screen_pop_title(struct screen *s)
{
struct screen_title_entry *title_entry;
if (s->titles == NULL)
return;
title_entry = TAILQ_FIRST(s->titles);
if (title_entry != NULL) {
screen_set_title(s, title_entry->text);
TAILQ_REMOVE(s->titles, title_entry, entry);
free(title_entry->text);
free(title_entry);
}
}
/* Resize screen. */ /* Resize screen. */
void void
screen_resize(struct screen *s, u_int sx, u_int sy, int reflow) screen_resize(struct screen *s, u_int sx, u_int sy, int reflow)

4
tmux.h
View File

@ -664,8 +664,10 @@ struct screen_sel {
}; };
/* Virtual screen. */ /* Virtual screen. */
struct screen_titles;
struct screen { struct screen {
char *title; char *title;
struct screen_titles *titles;
struct grid *grid; /* grid data */ struct grid *grid; /* grid data */
@ -2086,6 +2088,8 @@ void screen_reset_tabs(struct screen *);
void screen_set_cursor_style(struct screen *, u_int); void screen_set_cursor_style(struct screen *, u_int);
void screen_set_cursor_colour(struct screen *, const char *); void screen_set_cursor_colour(struct screen *, const char *);
void screen_set_title(struct screen *, const char *); void screen_set_title(struct screen *, const char *);
void screen_push_title(struct screen *);
void screen_pop_title(struct screen *);
void screen_resize(struct screen *, u_int, u_int, int); void screen_resize(struct screen *, u_int, u_int, int);
void screen_set_selection(struct screen *, void screen_set_selection(struct screen *,
u_int, u_int, u_int, u_int, u_int, struct grid_cell *); u_int, u_int, u_int, u_int, u_int, struct grid_cell *);