diff options
author | wm4 <wm4@nowhere> | 2012-09-12 12:12:27 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2012-09-18 21:08:20 +0200 |
commit | b24869203489bd89928af241ca26992558fbb5ee (patch) | |
tree | ddbf881b982fdbc24cc922aa955a07dd366c2991 /m_property.c | |
parent | 416c03417ebd7538882ee586bb049a25e202a7e6 (diff) | |
download | mpv-b24869203489bd89928af241ca26992558fbb5ee.tar.bz2 mpv-b24869203489bd89928af241ca26992558fbb5ee.tar.xz |
commands: allow printing raw properties
Extend m_properties_expand_string() so that it can print properties as
unformatted string. Normally, properties will be pretty-printed
(intended for OSD and user interface purposes). Add the '=' modifier to
the format string syntax that disables pretty-printing and returns them
"raw".
For example, "${=switch_audio}" will print the track number, instead of
returning an OSD friendly string containing additional information like
track title and language.
Diffstat (limited to 'm_property.c')
-rw-r--r-- | m_property.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/m_property.c b/m_property.c index 4d1fb90ed6..e75cbe43ac 100644 --- a/m_property.c +++ b/m_property.c @@ -160,12 +160,17 @@ char *m_properties_expand_string(const m_option_t *prop_list, char *str, lvl--, str++, l = 0; } else if (str[0] == '$' && str[1] == '{' && (e = strchr(str + 2, '}'))) { - int pl = e - str - 2; + str += 2; + int method = M_PROPERTY_PRINT; + if (str[0] == '=') { + str += 1; + method = M_PROPERTY_TO_STRING; + } + int pl = e - str; char pname[pl + 1]; - memcpy(pname, str + 2, pl); + memcpy(pname, str, pl); pname[pl] = 0; - if (m_property_do(prop_list, pname, - M_PROPERTY_PRINT, &p, ctx) >= 0 && p) + if (m_property_do(prop_list, pname, method, &p, ctx) >= 0 && p) l = strlen(p), fr = 1; else l = 0; |