mirror of
https://github.com/tmux/tmux.git
synced 2026-05-30 22:26:18 +00:00
Do not sanitize title when popping it from stack, also add a limit to
number of pushed titles.
This commit is contained in:
18
screen.c
18
screen.c
@@ -264,6 +264,16 @@ screen_push_title(struct screen *s)
|
|||||||
{
|
{
|
||||||
struct screen_title_entry *title_entry;
|
struct screen_title_entry *title_entry;
|
||||||
|
|
||||||
|
log_debug("%s: %u", __func__, s->ntitles);
|
||||||
|
|
||||||
|
while (s->ntitles >= 10) {
|
||||||
|
title_entry = TAILQ_LAST(s->titles, screen_titles);
|
||||||
|
free(title_entry->text);
|
||||||
|
TAILQ_REMOVE(s->titles, title_entry, entry);
|
||||||
|
free(title_entry);
|
||||||
|
s->ntitles--;
|
||||||
|
}
|
||||||
|
|
||||||
if (s->titles == NULL) {
|
if (s->titles == NULL) {
|
||||||
s->titles = xmalloc(sizeof *s->titles);
|
s->titles = xmalloc(sizeof *s->titles);
|
||||||
TAILQ_INIT(s->titles);
|
TAILQ_INIT(s->titles);
|
||||||
@@ -271,6 +281,7 @@ screen_push_title(struct screen *s)
|
|||||||
title_entry = xmalloc(sizeof *title_entry);
|
title_entry = xmalloc(sizeof *title_entry);
|
||||||
title_entry->text = xstrdup(s->title);
|
title_entry->text = xstrdup(s->title);
|
||||||
TAILQ_INSERT_HEAD(s->titles, title_entry, entry);
|
TAILQ_INSERT_HEAD(s->titles, title_entry, entry);
|
||||||
|
s->ntitles++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -284,14 +295,15 @@ screen_pop_title(struct screen *s)
|
|||||||
|
|
||||||
if (s->titles == NULL)
|
if (s->titles == NULL)
|
||||||
return;
|
return;
|
||||||
|
log_debug("%s: %u", __func__, s->ntitles);
|
||||||
|
|
||||||
title_entry = TAILQ_FIRST(s->titles);
|
title_entry = TAILQ_FIRST(s->titles);
|
||||||
if (title_entry != NULL) {
|
if (title_entry != NULL) {
|
||||||
screen_set_title(s, title_entry->text);
|
free(s->title);
|
||||||
|
s->title = title_entry->text;
|
||||||
TAILQ_REMOVE(s->titles, title_entry, entry);
|
TAILQ_REMOVE(s->titles, title_entry, entry);
|
||||||
free(title_entry->text);
|
|
||||||
free(title_entry);
|
free(title_entry);
|
||||||
|
s->ntitles--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user