Skip to content

Commit 7f60e38

Browse files
committed
command: show circles in lists instead of bold
Bolding the selected item breaks the alignment in lists with similarly-named items, so prepend a filled circle instead. This allows to quickly differentiate the selected item with a different color while still working with color blindness.
1 parent 53796ca commit 7f60e38

1 file changed

Lines changed: 17 additions & 11 deletions

File tree

player/command.c

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -321,13 +321,19 @@ void mark_seek(struct MPContext *mpctx)
321321
cmd->last_seek_time = now;
322322
}
323323

324-
static char *append_selected_style(struct MPContext *mpctx, char *str)
324+
static char *append_selected_style(struct MPContext *mpctx, char *str, bool selected)
325325
{
326-
if (!mpctx->video_out || !mpctx->opts->video_osd)
327-
return talloc_strdup_append(str, TERM_ESC_REVERSE_COLORS);
326+
if (!mpctx->video_out || !mpctx->opts->video_osd) {
327+
if (selected)
328+
return talloc_strdup_append(str, TERM_ESC_REVERSE_COLORS);
329+
return str;
330+
}
331+
332+
if (!selected)
333+
return talloc_strdup_append(str, OSD_ASS_0 "{\\alpha&HFF}" BLACK_CIRCLE "{\\r} " OSD_ASS_1);
328334

329335
return talloc_asprintf_append(str,
330-
"%s{\\b1\\1c&H%02hhx%02hhx%02hhx&\\1a&H%02hhx&\\3c&H%02hhx%02hhx%02hhx&\\3a&H%02hhx&}%s",
336+
"%s{\\1c&H%02hhx%02hhx%02hhx&\\1a&H%02hhx&\\3c&H%02hhx%02hhx%02hhx&\\3a&H%02hhx&}%s%s ",
331337
OSD_ASS_0,
332338
mpctx->video_out->osd->opts->osd_selected_color.b,
333339
mpctx->video_out->osd->opts->osd_selected_color.g,
@@ -337,6 +343,7 @@ static char *append_selected_style(struct MPContext *mpctx, char *str)
337343
mpctx->video_out->osd->opts->osd_selected_outline_color.g,
338344
mpctx->video_out->osd->opts->osd_selected_outline_color.r,
339345
(uint8_t)(255 - mpctx->video_out->osd->opts->osd_selected_outline_color.a),
346+
BLACK_CIRCLE,
340347
OSD_ASS_1);
341348
}
342349

@@ -1099,8 +1106,7 @@ static int mp_property_list_chapters(void *ctx, struct m_property *prop,
10991106
}
11001107

11011108
for (n = 0; n < count; n++) {
1102-
if (n == cur)
1103-
res = append_selected_style(mpctx, res);
1109+
res = append_selected_style(mpctx, res, n == cur);
11041110
char *name = chapter_name(mpctx, n);
11051111
double t = chapter_start_time(mpctx, n);
11061112
char* time = mp_format_time(t, false);
@@ -1222,8 +1228,7 @@ static int mp_property_list_editions(void *ctx, struct m_property *prop,
12221228
for (int n = 0; n < num_editions; n++) {
12231229
struct demux_edition *ed = &editions[n];
12241230

1225-
if (n == current)
1226-
res = append_selected_style(mpctx, res);
1231+
res = append_selected_style(mpctx, res, n == current);
12271232
res = talloc_asprintf_append(res, "%d: ", n);
12281233
char *title = mp_tags_get_str(ed->metadata, "title");
12291234
if (!title)
@@ -3553,8 +3558,10 @@ static int mp_property_sub_lines(void *ctx, struct m_property *prop,
35533558
const char *reset = "";
35543559

35553560
if (line->start <= time_pos && line->end > time_pos) {
3556-
res = append_selected_style(mpctx, res);
3561+
res = append_selected_style(mpctx, res, true);
35573562
reset = get_style_reset(mpctx);
3563+
} else {
3564+
res = append_selected_style(mpctx, res, false);
35583565
}
35593566

35603567
res = talloc_asprintf_append(res, "%s%s\n", line->text, reset);
@@ -3695,8 +3702,7 @@ static int mp_property_playlist(void *ctx, struct m_property *prop,
36953702

36963703
for (int n = 0; n < pl->num_entries; n++) {
36973704
struct playlist_entry *e = pl->entries[n];
3698-
if (pl->current == e)
3699-
res = append_selected_style(mpctx, res);
3705+
res = append_selected_style(mpctx, res, pl->current == e);
37003706
const char *reset = pl->current == e ? get_style_reset(mpctx) : "";
37013707
const char *p = e->title;
37023708
if (!p || mpctx->opts->playlist_entry_name > 0) {

0 commit comments

Comments
 (0)