mirror of
https://github.com/mpv-player/mpv
synced 2025-02-18 05:37:04 +00:00
player: handle the corner cases in --term-osd-bar correctly
With the old code and pos == width - 2 one character too many is drawn.
This commit is contained in:
parent
1d9c62b644
commit
d5fce546a4
@ -110,8 +110,8 @@ static void add_term_osd_bar(struct MPContext *mpctx, char **line, int width)
|
|||||||
if (width < 5)
|
if (width < 5)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int pos = get_current_pos_ratio(mpctx, false) * (width - 2);
|
int pos = get_current_pos_ratio(mpctx, false) * (width - 3);
|
||||||
pos = MPCLAMP(pos, 0, width - 2);
|
pos = MPCLAMP(pos, 0, width - 3);
|
||||||
|
|
||||||
bstr chars = bstr0(opts->term_osd_bar_chars);
|
bstr chars = bstr0(opts->term_osd_bar_chars);
|
||||||
bstr parts[5];
|
bstr parts[5];
|
||||||
@ -122,7 +122,7 @@ static void add_term_osd_bar(struct MPContext *mpctx, char **line, int width)
|
|||||||
for (int n = 0; n < pos; n++)
|
for (int n = 0; n < pos; n++)
|
||||||
saddf(line, "%.*s", BSTR_P(parts[1]));
|
saddf(line, "%.*s", BSTR_P(parts[1]));
|
||||||
saddf(line, "%.*s", BSTR_P(parts[2]));
|
saddf(line, "%.*s", BSTR_P(parts[2]));
|
||||||
for (int n = 0; n < width - 2 - pos - 1; n++)
|
for (int n = 0; n < width - 3 - pos; n++)
|
||||||
saddf(line, "%.*s", BSTR_P(parts[3]));
|
saddf(line, "%.*s", BSTR_P(parts[3]));
|
||||||
saddf(line, "%.*s", BSTR_P(parts[4]));
|
saddf(line, "%.*s", BSTR_P(parts[4]));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user