summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2019-06-02 16:41:38 +0200
committerwm4 <wm4@nowhere>2019-09-19 20:37:05 +0200
commit277ab02f3820b41286f3fa9c637f6322b564ea77 (patch)
tree63aff016ea411bbdffaeb545bc3ad0a9a4798e0c
parent7ed4d77a97bc17d96967f7f2bfa41842226d0c1c (diff)
downloadmpv-277ab02f3820b41286f3fa9c637f6322b564ea77.tar.bz2
mpv-277ab02f3820b41286f3fa9c637f6322b564ea77.tar.xz
command: show number of hidden items in OSD lists
Affects the "classic" OSD rendering of some properties, like playlists.
-rw-r--r--player/command.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/player/command.c b/player/command.c
index 33b60158d4..333e4fe784 100644
--- a/player/command.c
+++ b/player/command.c
@@ -330,29 +330,35 @@ static char *cut_osd_list(struct MPContext *mpctx, char *text, int pos)
char *new = talloc_strdup(NULL, "");
- int start = pos - max_lines / 2;
+ int start = MPMAX(pos - max_lines / 2, 0);
if (start == 1)
start = 0; // avoid weird transition when pad_h becomes visible
int pad_h = start > 0;
- if (pad_h)
- new = talloc_strdup_append_buffer(new, "\342\206\221 (hidden items)\n");
int space = max_lines - pad_h - 1;
int pad_t = count - start > space;
if (!pad_t)
start = count - space;
+ if (pad_h) {
+ new = talloc_asprintf_append_buffer(new, "\342\206\221 (%d hidden items)\n",
+ start);
+ }
+
char *head = skip_n_lines(text, start);
if (!head) {
talloc_free(new);
return text;
}
- char *tail = skip_n_lines(head, max_lines - pad_h - pad_t);
+ int lines_shown = max_lines - pad_h - pad_t;
+ char *tail = skip_n_lines(head, lines_shown);
new = talloc_asprintf_append_buffer(new, "%.*s",
(int)(tail ? tail - head : strlen(head)), head);
- if (pad_t)
- new = talloc_strdup_append_buffer(new, "\342\206\223 (hidden items)\n");
+ if (pad_t) {
+ new = talloc_asprintf_append_buffer(new, "\342\206\223 (%d hidden items)\n",
+ count - start - lines_shown + 1);
+ }
talloc_free(text);
return new;