summaryrefslogtreecommitdiffstats
path: root/player
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-01-15 16:14:37 +0100
committerwm4 <wm4@nowhere>2014-01-15 16:14:37 +0100
commit45641378a2df4d5fe227ad7ba575b01f787ad8e8 (patch)
tree5d795556042b8f71365ffcda41c3603cd0425c68 /player
parentca8937d7d269c0ef8881d2ac7a227fdb990a5753 (diff)
downloadmpv-45641378a2df4d5fe227ad7ba575b01f787ad8e8.tar.bz2
mpv-45641378a2df4d5fe227ad7ba575b01f787ad8e8.tar.xz
player: add --term-osd-bar, which shows a status bar on the terminal
Feature request from github issue #451. Disabled by default, will probably stay this way.
Diffstat (limited to 'player')
-rw-r--r--player/osd.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/player/osd.c b/player/osd.c
index b2062701ea..29ac7af8fe 100644
--- a/player/osd.c
+++ b/player/osd.c
@@ -103,6 +103,29 @@ static void term_osd_set_status(struct MPContext *mpctx, const char *text)
term_osd_update(mpctx);
}
+static void add_term_osd_bar(struct MPContext *mpctx, char **line, int width)
+{
+ struct MPOpts *opts = mpctx->opts;
+
+ if (width < 5)
+ return;
+
+ int pos = get_percent_pos(mpctx) / 100.0 * (width - 2);
+
+ bstr chars = bstr0(opts->term_osd_bar_chars);
+ bstr parts[5];
+ for (int n = 0; n < 5; n++)
+ parts[n] = bstr_split_utf8(chars, &chars);
+
+ saddf(line, "%.*s", BSTR_P(parts[0]));
+ for (int n = 0; n < pos; n++)
+ saddf(line, "%.*s", BSTR_P(parts[1]));
+ saddf(line, "%.*s", BSTR_P(parts[2]));
+ for (int n = 0; n < width - 2 - pos - 1; n++)
+ saddf(line, "%.*s", BSTR_P(parts[3]));
+ saddf(line, "%.*s", BSTR_P(parts[4]));
+}
+
void print_status(struct MPContext *mpctx)
{
struct MPOpts *opts = mpctx->opts;
@@ -182,6 +205,12 @@ void print_status(struct MPContext *mpctx)
if (cache >= 0)
saddf(&line, " Cache: %d%%", cache);
+ if (opts->term_osd_bar) {
+ saddf(&line, "\n");
+ get_screen_size();
+ add_term_osd_bar(mpctx, &line, screen_width);
+ }
+
// end
term_osd_set_status(mpctx, line);
talloc_free(line);