mirror of
https://github.com/tmate-io/tmate.git
synced 2024-12-28 01:28:50 +01:00
Use a char **,u_int pair for cfg_causes.
This commit is contained in:
parent
07dfdb974d
commit
a568b9cadc
33
cfg.c
33
cfg.c
@ -30,7 +30,8 @@
|
||||
struct cmd_q *cfg_cmd_q;
|
||||
int cfg_finished;
|
||||
int cfg_references;
|
||||
ARRAY_DECL (, char *) cfg_causes = ARRAY_INITIALIZER;
|
||||
char** cfg_causes;
|
||||
u_int cfg_ncauses;
|
||||
struct client *cfg_client;
|
||||
|
||||
int
|
||||
@ -122,40 +123,42 @@ cfg_add_cause(const char* fmt, ...)
|
||||
xvasprintf(&msg, fmt, ap);
|
||||
va_end (ap);
|
||||
|
||||
ARRAY_ADD(&cfg_causes, msg);
|
||||
cfg_ncauses++;
|
||||
cfg_causes = xreallocarray(cfg_causes, cfg_ncauses, sizeof *cfg_causes);
|
||||
cfg_causes[cfg_ncauses - 1] = msg;
|
||||
}
|
||||
|
||||
void
|
||||
cfg_print_causes(struct cmd_q *cmdq)
|
||||
{
|
||||
char *cause;
|
||||
u_int i;
|
||||
|
||||
for (i = 0; i < ARRAY_LENGTH(&cfg_causes); i++) {
|
||||
cause = ARRAY_ITEM(&cfg_causes, i);
|
||||
cmdq_print(cmdq, "%s", cause);
|
||||
free(cause);
|
||||
for (i = 0; i < cfg_ncauses; i++) {
|
||||
cmdq_print(cmdq, "%s", cfg_causes[i]);
|
||||
free(cfg_causes[i]);
|
||||
}
|
||||
ARRAY_FREE(&cfg_causes);
|
||||
|
||||
free(cfg_causes);
|
||||
cfg_causes = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
cfg_show_causes(struct session *s)
|
||||
{
|
||||
struct window_pane *wp;
|
||||
char *cause;
|
||||
u_int i;
|
||||
|
||||
if (s == NULL || ARRAY_EMPTY(&cfg_causes))
|
||||
if (s == NULL || cfg_ncauses == 0)
|
||||
return;
|
||||
wp = s->curw->window->active;
|
||||
|
||||
window_pane_set_mode(wp, &window_copy_mode);
|
||||
window_copy_init_for_output(wp);
|
||||
for (i = 0; i < ARRAY_LENGTH(&cfg_causes); i++) {
|
||||
cause = ARRAY_ITEM(&cfg_causes, i);
|
||||
window_copy_add(wp, "%s", cause);
|
||||
free(cause);
|
||||
for (i = 0; i < cfg_ncauses; i++) {
|
||||
window_copy_add(wp, "%s", cfg_causes[i]);
|
||||
free(cfg_causes[i]);
|
||||
}
|
||||
ARRAY_FREE(&cfg_causes);
|
||||
|
||||
free(cfg_causes);
|
||||
cfg_causes = NULL;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user