mirror of
https://github.com/tmux/tmux.git
synced 2025-09-04 06:56:58 +00:00
Only align panes and windows, not sessions, from David Mandelberg in
GitHub issue 4444.
This commit is contained in:
22
mode-tree.c
22
mode-tree.c
@ -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)
|
||||||
|
1
tmux.h
1
tmux.h
@ -3306,6 +3306,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 *,
|
||||||
|
@ -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;
|
||||||
|
Reference in New Issue
Block a user