1
0
mirror of https://github.com/tmux/tmux.git synced 2025-04-30 18:03:37 +00:00

Merge branch 'obsd-master'

This commit is contained in:
Thomas Adam 2025-04-02 12:01:13 +01:00
commit 2905395695
5 changed files with 29 additions and 8 deletions

View File

@ -102,6 +102,7 @@ struct mode_tree_item {
int draw_as_parent; int draw_as_parent;
int no_tag; int no_tag;
int align;
struct mode_tree_list children; struct mode_tree_list children;
TAILQ_ENTRY(mode_tree_item) entry; TAILQ_ENTRY(mode_tree_item) entry;
@ -667,6 +668,16 @@ mode_tree_no_tag(struct mode_tree_item *mti)
mti->no_tag = 1; mti->no_tag = 1;
} }
/*
* Set the alignment of mti->name: -1 to align left, 0 (default) to not align,
* or 1 to align right.
*/
void
mode_tree_align(struct mode_tree_item *mti, int align)
{
mti->align = align;
}
void void
mode_tree_remove(struct mode_tree_data *mtd, struct mode_tree_item *mti) mode_tree_remove(struct mode_tree_data *mtd, struct mode_tree_item *mti)
{ {
@ -693,7 +704,7 @@ mode_tree_draw(struct mode_tree_data *mtd)
char *text, *start, *key; char *text, *start, *key;
const char *tag, *symbol; const char *tag, *symbol;
size_t size, n; size_t size, n;
int keylen, pad, namelen[mtd->maxdepth + 1]; int keylen, pad, alignlen[mtd->maxdepth + 1];
if (mtd->line_size == 0) if (mtd->line_size == 0)
return; return;
@ -718,12 +729,13 @@ mode_tree_draw(struct mode_tree_data *mtd)
} }
for (i = 0; i < mtd->maxdepth + 1; i++) for (i = 0; i < mtd->maxdepth + 1; i++)
namelen[i] = 0; alignlen[i] = 0;
for (i = 0; i < mtd->line_size; i++) { for (i = 0; i < mtd->line_size; i++) {
line = &mtd->line_list[i]; line = &mtd->line_list[i];
mti = line->item; mti = line->item;
if ((int)strlen(mti->name) > namelen[line->depth]) if (mti->align &&
namelen[line->depth] = strlen(mti->name); (int)strlen(mti->name) > alignlen[line->depth])
alignlen[line->depth] = strlen(mti->name);
} }
for (i = 0; i < mtd->line_size; i++) { for (i = 0; i < mtd->line_size; i++) {
@ -776,7 +788,7 @@ mode_tree_draw(struct mode_tree_data *mtd)
else else
tag = ""; tag = "";
xasprintf(&text, "%-*s%s%*s%s%s", keylen, key, start, xasprintf(&text, "%-*s%s%*s%s%s", keylen, key, start,
namelen[line->depth], mti->name, tag, mti->align * alignlen[line->depth], mti->name, tag,
(mti->text != NULL) ? ": " : "" ); (mti->text != NULL) ? ": " : "" );
width = utf8_cstrwidth(text); width = utf8_cstrwidth(text);
if (width > w) if (width > w)

View File

@ -530,7 +530,7 @@ popup_key_cb(struct client *c, void *data, struct key_event *event)
(border == LEFT || border == TOP)) (border == LEFT || border == TOP))
goto menu; goto menu;
if (((m->b & MOUSE_MASK_MODIFIERS) == MOUSE_MASK_META) || if (((m->b & MOUSE_MASK_MODIFIERS) == MOUSE_MASK_META) ||
border != NONE) { (border != NONE && !MOUSE_DRAG(m->lb))) {
if (!MOUSE_DRAG(m->b)) if (!MOUSE_DRAG(m->b))
goto out; goto out;
if (MOUSE_BUTTONS(m->lb) == MOUSE_BUTTON_1) if (MOUSE_BUTTONS(m->lb) == MOUSE_BUTTON_1)

1
tmux.h
View File

@ -3354,6 +3354,7 @@ struct mode_tree_item *mode_tree_add(struct mode_tree_data *,
const char *, int); const char *, int);
void mode_tree_draw_as_parent(struct mode_tree_item *); void mode_tree_draw_as_parent(struct mode_tree_item *);
void mode_tree_no_tag(struct mode_tree_item *); void mode_tree_no_tag(struct mode_tree_item *);
void mode_tree_align(struct mode_tree_item *, int);
void mode_tree_remove(struct mode_tree_data *, struct mode_tree_item *); void mode_tree_remove(struct mode_tree_data *, struct mode_tree_item *);
void mode_tree_draw(struct mode_tree_data *); void mode_tree_draw(struct mode_tree_data *);
int mode_tree_key(struct mode_tree_data *, struct client *, key_code *, int mode_tree_key(struct mode_tree_data *, struct client *, key_code *,

View File

@ -300,6 +300,7 @@ window_tree_build_pane(struct session *s, struct winlink *wl,
{ {
struct window_tree_modedata *data = modedata; struct window_tree_modedata *data = modedata;
struct window_tree_itemdata *item; struct window_tree_itemdata *item;
struct mode_tree_item *mti;
char *name, *text; char *name, *text;
u_int idx; u_int idx;
struct format_tree *ft; struct format_tree *ft;
@ -318,9 +319,11 @@ window_tree_build_pane(struct session *s, struct winlink *wl,
xasprintf(&name, "%u", idx); xasprintf(&name, "%u", idx);
format_free(ft); format_free(ft);
mode_tree_add(data->data, parent, item, (uint64_t)wp, name, text, -1); mti = mode_tree_add(data->data, parent, item, (uint64_t)wp, name, text,
-1);
free(text); free(text);
free(name); free(name);
mode_tree_align(mti, 1);
} }
static int static int
@ -375,6 +378,7 @@ window_tree_build_window(struct session *s, struct winlink *wl,
expanded); expanded);
free(text); free(text);
free(name); free(name);
mode_tree_align(mti, 1);
if ((wp = TAILQ_FIRST(&wl->window->panes)) == NULL) if ((wp = TAILQ_FIRST(&wl->window->panes)) == NULL)
goto empty; goto empty;

View File

@ -1887,11 +1887,15 @@ window_pane_get_fg_control_client(struct window_pane *wp)
enum client_theme enum client_theme
window_pane_get_theme(struct window_pane *wp) window_pane_get_theme(struct window_pane *wp)
{ {
struct window *w = wp->window; struct window *w;
struct client *loop; struct client *loop;
enum client_theme theme; enum client_theme theme;
int found_light = 0, found_dark = 0; int found_light = 0, found_dark = 0;
if (wp == NULL)
return (THEME_UNKNOWN);
w = wp->window;
/* /*
* Derive theme from pane background color, if it's not the default * Derive theme from pane background color, if it's not the default
* colour. * colour.