Skip to content

Commit 05c398f

Browse files
author
wm4
committedMay 3, 2016
command: slightly nicer OSD list formatting
For "current" markers on OSD properties like chapter-list. The marker is now an actual arrow instead of "> ", and non-current entries will have the same indentation as the current entry. While I'm not entirely sure about the new look of those lists, it's a bit better than the visual mess that was before.
1 parent 485ae09 commit 05c398f

File tree

1 file changed

+17
-19
lines changed

1 file changed

+17
-19
lines changed
 

‎player/command.c

+17-19
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,13 @@ struct hook_handler {
112112
bool active; // hook is currently in progress (only 1 at a time for now)
113113
};
114114

115+
// U+279C HEAVY ROUND-TIPPED RIGHTWARDS ARROW
116+
#define ARROW "\342\236\234"
117+
#define ARROW_SP ARROW " "
118+
119+
const char list_current[] = OSD_ASS_0 ARROW_SP OSD_ASS_1;
120+
const char list_normal[] = OSD_ASS_0 "{\\alpha&HFF}" ARROW_SP "{\\r}" OSD_ASS_1;
121+
115122
static int edit_filters(struct MPContext *mpctx, struct mp_log *log,
116123
enum stream_type mediatype,
117124
const char *cmd, const char *arg);
@@ -870,10 +877,8 @@ static int mp_property_list_chapters(void *ctx, struct m_property *prop,
870877
char* time = mp_format_time(t, false);
871878
res = talloc_asprintf_append(res, "%s", time);
872879
talloc_free(time);
873-
char *m1 = "> ", *m2 = " <";
874-
if (n != cur)
875-
m1 = m2 = "";
876-
res = talloc_asprintf_append(res, " %s%s%s\n", m1, name, m2);
880+
const char *m = n == cur ? list_current : list_normal;
881+
res = talloc_asprintf_append(res, " %s%s\n", m, name);
877882
talloc_free(name);
878883
}
879884

@@ -964,16 +969,13 @@ static int property_list_editions(void *ctx, struct m_property *prop,
964969
for (int n = 0; n < num_editions; n++) {
965970
struct demux_edition *ed = &editions[n];
966971

967-
if (n == current)
968-
res = talloc_asprintf_append(res, "> ");
972+
res = talloc_strdup_append(res, n == current ? list_current
973+
: list_normal);
969974
res = talloc_asprintf_append(res, "%d: ", n);
970975
char *title = mp_tags_get_str(ed->metadata, "title");
971976
if (!title)
972977
title = "unnamed";
973-
res = talloc_asprintf_append(res, "'%s' ", title);
974-
if (n == current)
975-
res = talloc_asprintf_append(res, "<");
976-
res = talloc_asprintf_append(res, "\n");
978+
res = talloc_asprintf_append(res, "'%s'\n", title);
977979
}
978980

979981
*(char **)arg = res;
@@ -2033,17 +2035,15 @@ static int property_list_tracks(void *ctx, struct m_property *prop,
20332035

20342036
res = talloc_asprintf_append(res, "%s: ",
20352037
track_type_name(track->type));
2036-
if (track->selected)
2037-
res = talloc_asprintf_append(res, "> ");
2038+
res = talloc_strdup_append(res,
2039+
track->selected ? list_current : list_normal);
20382040
res = talloc_asprintf_append(res, "(%d) ", track->user_tid);
20392041
if (track->title)
20402042
res = talloc_asprintf_append(res, "'%s' ", track->title);
20412043
if (track->lang)
20422044
res = talloc_asprintf_append(res, "(%s) ", track->lang);
20432045
if (track->is_external)
20442046
res = talloc_asprintf_append(res, "(external) ");
2045-
if (track->selected)
2046-
res = talloc_asprintf_append(res, "<");
20472047
res = talloc_asprintf_append(res, "\n");
20482048
}
20492049

@@ -3145,11 +3145,9 @@ static int mp_property_playlist(void *ctx, struct m_property *prop,
31453145
if (s[0])
31463146
p = s;
31473147
}
3148-
if (mpctx->playlist->current == e) {
3149-
res = talloc_asprintf_append(res, "> %s <\n", p);
3150-
} else {
3151-
res = talloc_asprintf_append(res, "%s\n", p);
3152-
}
3148+
const char *m = mpctx->playlist->current == e ?
3149+
list_current : list_normal;
3150+
res = talloc_asprintf_append(res, "%s%s\n", m, p);
31533151
}
31543152

31553153
*(char **)arg = res;

0 commit comments

Comments
 (0)