Merge branch 'obsd-master'

This commit is contained in:
Thomas Adam
2026-06-19 19:00:05 +01:00
5 changed files with 116 additions and 89 deletions

View File

@@ -84,6 +84,7 @@ struct mode_tree_data {
int no_matches;
enum mode_tree_search_dir search_dir;
int search_icase;
int help;
};
struct mode_tree_item {
@@ -124,6 +125,8 @@ struct mode_tree_menu {
};
static void mode_tree_free_items(struct mode_tree_list *);
static void mode_tree_draw_help(struct mode_tree_data *,
struct screen_write_ctx *);
static const struct menu_item mode_tree_menu_items[] = {
{ "Scroll Left", '<', NULL },
@@ -135,31 +138,31 @@ static const struct menu_item mode_tree_menu_items[] = {
};
static const char* mode_tree_help_start[] = {
"\r\033[1m Up, k \033[0m\016x\017 \033[0mMove cursor up\n",
"\r\033[1m Down, j \033[0m\016x\017 \033[0mMove cursor down\n",
"\r\033[1m g \033[0m\016x\017 \033[0mGo to top\n",
"\r\033[1m G \033[0m\016x\017 \033[0mGo to bottom\n",
"\r\033[1m PPage, C-b \033[0m\016x\017 \033[0mPage up\n",
"\r\033[1m NPage, C-f \033[0m\016x\017 \033[0mPage down\n",
"\r\033[1m Left, h \033[0m\016x\017 \033[0mCollapse %1\n",
"\r\033[1m Right, l \033[0m\016x\017 \033[0mExpand %1\n",
"\r\033[1m M-- \033[0m\016x\017 \033[0mCollapse all %1s\n",
"\r\033[1m M-+ \033[0m\016x\017 \033[0mExpand all %1s\n",
"\r\033[1m t \033[0m\016x\017 \033[0mToggle %1 tag\n",
"\r\033[1m T \033[0m\016x\017 \033[0mUntag all %1s\n",
"\r\033[1m C-t \033[0m\016x\017 \033[0mTag all %1s\n",
"\r\033[1m C-s \033[0m\016x\017 \033[0mSearch forward\n",
"\r\033[1m C-r \033[0m\016x\017 \033[0mSearch backward\n",
"\r\033[1m n \033[0m\016x\017 \033[0mRepeat search forward\n",
"\r\033[1m N \033[0m\016x\017 \033[0mRepeat search backward\n",
"\r\033[1m f \033[0m\016x\017 \033[0mFilter %1s\n",
"\r\033[1m O \033[0m\016x\017 \033[0mChange sort order\n",
"\r\033[1m r \033[0m\016x\017 \033[0mReverse sort order\n",
"\r\033[1m v \033[0m\016x\017 \033[0mToggle preview\n",
"#[bold] Up, k #[default]#[acs]x#[default] Move cursor up",
"#[bold] Down, j #[default]#[acs]x#[default] Move cursor down",
"#[bold] g #[default]#[acs]x#[default] Go to top",
"#[bold] G #[default]#[acs]x#[default] Go to bottom",
"#[bold] PPage, C-b #[default]#[acs]x#[default] Page up",
"#[bold] NPage, C-f #[default]#[acs]x#[default] Page down",
"#[bold] Left, h #[default]#[acs]x#[default] Collapse %1",
"#[bold] Right, l #[default]#[acs]x#[default] Expand %1",
"#[bold] M-- #[default]#[acs]x#[default] Collapse all %1s",
"#[bold] M-+ #[default]#[acs]x#[default] Expand all %1s",
"#[bold] t #[default]#[acs]x#[default] Toggle %1 tag",
"#[bold] T #[default]#[acs]x#[default] Untag all %1s",
"#[bold] C-t #[default]#[acs]x#[default] Tag all %1s",
"#[bold] C-s #[default]#[acs]x#[default] Search forward",
"#[bold] C-r #[default]#[acs]x#[default] Search backward",
"#[bold] n #[default]#[acs]x#[default] Repeat search forward",
"#[bold] N #[default]#[acs]x#[default] Repeat search backward",
"#[bold] f #[default]#[acs]x#[default] Filter %1s",
"#[bold] O #[default]#[acs]x#[default] Change sort order",
"#[bold] r #[default]#[acs]x#[default] Reverse sort order",
"#[bold] v #[default]#[acs]x#[default] Toggle preview",
NULL
};
static const char* mode_tree_help_end[] = {
"\r\033[1m q, Escape \033[0m\016x\017 \033[0mExit mode\033[H",
"#[bold] q, Escape #[default]#[acs]x#[default] Exit mode",
NULL
};
#define MODE_TREE_HELP_DEFAULT_WIDTH 39
@@ -928,6 +931,8 @@ mode_tree_draw(struct mode_tree_data *mtd)
}
done:
if (mtd->help)
mode_tree_draw_help(mtd, &ctx);
screen_write_cursormove(&ctx, 0, mtd->current - mtd->offset, 0);
screen_write_stop(&ctx);
}
@@ -1175,12 +1180,28 @@ mode_tree_display_menu(struct mode_tree_data *mtd, struct client *c, u_int x,
}
static void
mode_tree_display_help(__unused struct mode_tree_data *mtd, struct client *c)
mode_tree_draw_help_line(struct screen_write_ctx *ctx,
const struct grid_cell *gc, const char *line, const char *item, u_int x,
u_int y, u_int w)
{
struct session *s = c->session;
u_int px, py, w, h = 0;
char *expanded;
expanded = cmd_template_replace(line, item, 1);
screen_write_cursormove(ctx, x, y, 0);
screen_write_clearcharacter(ctx, w, gc->bg);
screen_write_cursormove(ctx, x, y, 0);
format_draw(ctx, gc, w, expanded, NULL, 0);
free(expanded);
}
static void
mode_tree_draw_help(struct mode_tree_data *mtd, struct screen_write_ctx *ctx)
{
struct screen *s = &mtd->screen;
struct grid_cell gc;
const char **line, **lines = NULL, *item = "item";
char *new_line;
u_int sx = screen_size_x(s), sy = screen_size_y(s);
u_int x, y, w, h = 0, box_w, box_h;
if (mtd->helpcb == NULL)
w = MODE_TREE_HELP_DEFAULT_WIDTH;
@@ -1196,33 +1217,32 @@ mode_tree_display_help(__unused struct mode_tree_data *mtd, struct client *c)
for (line = mode_tree_help_end; *line != NULL; line++)
h++;
if (c->tty.sx < w || c->tty.sy < h)
box_w = w + 2;
box_h = h + 2;
if (sx < box_w || sy < box_h)
return;
px = (c->tty.sx - w) / 2;
py = (c->tty.sy - h) / 2;
x = (sx - box_w) / 2;
y = (sy - box_h) / 2;
if (popup_display(POPUP_CLOSEANYKEY|POPUP_NOJOB, BOX_LINES_DEFAULT,
NULL, px, py, w, h, NULL, NULL, 0, NULL, NULL, NULL, c, s, NULL,
NULL, NULL, NULL) != 0)
return;
memcpy(&gc, &grid_default_cell, sizeof gc);
screen_write_cursormove(ctx, x, y, 0);
screen_write_box(ctx, box_w, box_h, BOX_LINES_DEFAULT, &gc, NULL);
popup_write(c, "\033[H\033[?25l\033[?7l\033)0", 17);
for (line = mode_tree_help_start; *line != NULL; line++) {
new_line = cmd_template_replace(*line, item, 1);
popup_write(c, new_line, strlen(new_line));
free(new_line);
y++;
x++;
for (line = mode_tree_help_start; *line != NULL; line++, y++)
mode_tree_draw_help_line(ctx, &gc, *line, item, x, y, w);
for (line = lines; line != NULL && *line != NULL; line++, y++)
mode_tree_draw_help_line(ctx, &gc, *line, item, x, y, w);
for (line = mode_tree_help_end; *line != NULL; line++, y++)
mode_tree_draw_help_line(ctx, &gc, *line, item, x, y, w);
}
for (line = lines; line != NULL && *line != NULL; line++) {
new_line = cmd_template_replace(*line, item, 1);
popup_write(c, new_line, strlen(new_line));
free(new_line);
}
for (line = mode_tree_help_end; *line != NULL; line++) {
new_line = cmd_template_replace(*line, item, 1);
popup_write(c, new_line, strlen(new_line));
free(new_line);
}
popup_write(c, "\033[H", 3);
static void
mode_tree_display_help(struct mode_tree_data *mtd)
{
mtd->help = 1;
mode_tree_draw(mtd);
}
int
@@ -1239,6 +1259,13 @@ mode_tree_key(struct mode_tree_data *mtd, struct client *c, key_code *key,
return (1);
}
if (mtd->help) {
mtd->help = 0;
mode_tree_draw(mtd);
*key = KEYC_NONE;
return (0);
}
if (KEYC_IS_MOUSE(*key) && m != NULL) {
if (cmd_mouse_at(mtd->wp, m, &x, &y, 0) != 0) {
*key = KEYC_NONE;
@@ -1304,7 +1331,7 @@ mode_tree_key(struct mode_tree_data *mtd, struct client *c, key_code *key,
return (1);
case KEYC_F1:
case 'h'|KEYC_CTRL:
mode_tree_display_help(mtd, c);
mode_tree_display_help(mtd);
break;
case KEYC_UP:
case 'k':

View File

@@ -330,13 +330,13 @@ window_buffer_sort(struct sort_criteria *sort_crit)
}
static const char* window_buffer_help_lines[] = {
"\r\033[1m Enter \033[0m\016x\017 \033[0mPaste selected %1\n",
"\r\033[1m p \033[0m\016x\017 \033[0mPaste selected %1\n",
"\r\033[1m P \033[0m\016x\017 \033[0mPaste tagged %1s\n",
"\r\033[1m d \033[0m\016x\017 \033[0mDelete selected %1\n",
"\r\033[1m D \033[0m\016x\017 \033[0mDelete tagged %1s\n",
"\r\033[1m e \033[0m\016x\017 \033[0mOpen %1 in editor\n",
"\r\033[1m f \033[0m\016x\017 \033[0mEnter a filter\n",
"#[bold] Enter #[default]#[acs]x#[default] Paste selected %1",
"#[bold] p #[default]#[acs]x#[default] Paste selected %1",
"#[bold] P #[default]#[acs]x#[default] Paste tagged %1s",
"#[bold] d #[default]#[acs]x#[default] Delete selected %1",
"#[bold] D #[default]#[acs]x#[default] Delete tagged %1s",
"#[bold] e #[default]#[acs]x#[default] Open %1 in editor",
"#[bold] f #[default]#[acs]x#[default] Enter a filter",
NULL
};

View File

@@ -369,15 +369,15 @@ window_client_sort(struct sort_criteria *sort_crit)
}
static const char* window_client_help_lines[] = {
"\r\033[1m i \033[0m\016x\017 \033[0mToggle info view\n",
"\r\033[1m Enter \033[0m\016x\017 \033[0mChoose selected %1\n",
"\r\033[1m d \033[0m\016x\017 \033[0mDetach selected %1\n",
"\r\033[1m D \033[0m\016x\017 \033[0mDetach tagged %1s\n",
"\r\033[1m x \033[0m\016x\017 \033[0mDetach selected %1\n",
"\r\033[1m X \033[0m\016x\017 \033[0mDetach tagged %1s\n",
"\r\033[1m z \033[0m\016x\017 \033[0mSuspend selected %1\n",
"\r\033[1m Z \033[0m\016x\017 \033[0mSuspend tagged %1s\n",
"\r\033[1m f \033[0m\016x\017 \033[0mEnter a filter\n",
"#[bold] i #[default]#[acs]x#[default] Toggle info view",
"#[bold] Enter #[default]#[acs]x#[default] Choose selected %1",
"#[bold] d #[default]#[acs]x#[default] Detach selected %1",
"#[bold] D #[default]#[acs]x#[default] Detach tagged %1s",
"#[bold] x #[default]#[acs]x#[default] Detach selected %1",
"#[bold] X #[default]#[acs]x#[default] Detach tagged %1s",
"#[bold] z #[default]#[acs]x#[default] Suspend selected %1",
"#[bold] Z #[default]#[acs]x#[default] Suspend tagged %1s",
"#[bold] f #[default]#[acs]x#[default] Enter a filter",
NULL
};

View File

@@ -869,15 +869,15 @@ window_customize_height(__unused void *modedata, __unused u_int height)
}
static const char* window_customize_help_lines[] = {
"\r\033[1m Enter, s \033[0m\016x\017 \033[0mSet %1 value\n",
"\r\033[1m S \033[0m\016x\017 \033[0mSet global %1 value\n",
"\r\033[1m w \033[0m\016x\017 \033[0mSet window %1 value\n",
"\r\033[1m d \033[0m\016x\017 \033[0mSet to default value\n",
"\r\033[1m D \033[0m\016x\017 \033[0mSet tagged %1s to default value\n",
"\r\033[1m u \033[0m\016x\017 \033[0mUnset an %1\n",
"\r\033[1m U \033[0m\016x\017 \033[0mUnset tagged %1s\n",
"\r\033[1m f \033[0m\016x\017 \033[0mEnter a filter\n",
"\r\033[1m v \033[0m\016x\017 \033[0mToggle information\n",
"#[bold] Enter, s #[default]#[acs]x#[default] Set %1 value",
"#[bold] S #[default]#[acs]x#[default] Set global %1 value",
"#[bold] w #[default]#[acs]x#[default] Set window %1 value",
"#[bold] d #[default]#[acs]x#[default] Set to default value",
"#[bold] D #[default]#[acs]x#[default] Set tagged %1s to default value",
"#[bold] u #[default]#[acs]x#[default] Unset an %1",
"#[bold] U #[default]#[acs]x#[default] Unset tagged %1s",
"#[bold] f #[default]#[acs]x#[default] Enter a filter",
"#[bold] v #[default]#[acs]x#[default] Toggle information",
NULL
};

View File

@@ -889,18 +889,18 @@ window_tree_sort(struct sort_criteria *sort_crit)
}
static const char* window_tree_help_lines[] = {
"\r\033[1m Enter \033[0m\016x\017 \033[0mChoose selected item\n",
"\r\033[1m S-Up \033[0m\016x\017 \033[0mSwap current and previous window\n",
"\r\033[1m S-Down \033[0m\016x\017 \033[0mSwap current and next window\n",
"\r\033[1m x \033[0m\016x\017 \033[0mKill selected item\n",
"\r\033[1m X \033[0m\016x\017 \033[0mKill tagged items\n",
"\r\033[1m < \033[0m\016x\017 \033[0mScroll previews left\n",
"\r\033[1m > \033[0m\016x\017 \033[0mScroll previews right\n",
"\r\033[1m m \033[0m\016x\017 \033[0mSet the marked pane\n",
"\r\033[1m M \033[0m\016x\017 \033[0mClear the marked pane\n",
"\r\033[1m : \033[0m\016x\017 \033[0mRun a command for each tagged item\n",
"\r\033[1m f \033[0m\016x\017 \033[0mEnter a format\n",
"\r\033[1m H \033[0m\016x\017 \033[0mJump to the starting pane\n",
"#[bold] Enter #[default]#[acs]x#[default] Choose selected item",
"#[bold] S-Up #[default]#[acs]x#[default] Swap current and previous window",
"#[bold] S-Down #[default]#[acs]x#[default] Swap current and next window",
"#[bold] x #[default]#[acs]x#[default] Kill selected item",
"#[bold] X #[default]#[acs]x#[default] Kill tagged items",
"#[bold] < #[default]#[acs]x#[default] Scroll previews left",
"#[bold] > #[default]#[acs]x#[default] Scroll previews right",
"#[bold] m #[default]#[acs]x#[default] Set the marked pane",
"#[bold] M #[default]#[acs]x#[default] Clear the marked pane",
"#[bold] : #[default]#[acs]x#[default] Run a command for each tagged item",
"#[bold] f #[default]#[acs]x#[default] Enter a format",
"#[bold] H #[default]#[acs]x#[default] Jump to the starting pane",
NULL
};