summaryrefslogtreecommitdiffstats
path: root/osdep/io.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-08-21 22:11:38 +0200
committerwm4 <wm4@nowhere>2014-08-21 22:45:58 +0200
commit47b29094c34bdf0aab9f213c8eb2347993e4d505 (patch)
tree3c68821d10cd713c6d515705b79d1513160bd494 /osdep/io.c
parent218ace2b02e2f2a867c4b792d4a1ec03015d7294 (diff)
downloadmpv-47b29094c34bdf0aab9f213c8eb2347993e4d505.tar.bz2
mpv-47b29094c34bdf0aab9f213c8eb2347993e4d505.tar.xz
win32: emulate some ANSI terminal escape codes
We already redirect all terminal output through our own wrappers (for the sake of UTF-8), so we might as well use it to handle ANSI escape codes. This also changes behavior on UNIX: we don't retrieve some escape codes per terminfo anymore, and just hardcode them. Every terminal should understand them. The advantage is that we can pretend to have a real terminal in the normal player code, and Windows atrocities are locked away in glue code.
Diffstat (limited to 'osdep/io.c')
-rw-r--r--osdep/io.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/osdep/io.c b/osdep/io.c
index 8423a6beff..cc90f145d9 100644
--- a/osdep/io.c
+++ b/osdep/io.c
@@ -25,6 +25,7 @@
#include "config.h"
#include "osdep/io.h"
+#include "osdep/terminal.h"
// Set the CLOEXEC flag on the given fd.
// On error, false is returned (and errno set).
@@ -179,13 +180,10 @@ static int mp_vfprintf(FILE *stream, const char *format, va_list args)
char *buf = talloc_array(NULL, char, len);
if (buf) {
- vsnprintf(buf, len, format, args);
- wchar_t *out = mp_from_utf8(NULL, buf);
- size_t out_len = wcslen(out);
- talloc_free(buf);
- done = WriteConsoleW(wstream, out, out_len, NULL, NULL);
- talloc_free(out);
+ done = vsnprintf(buf, len, format, args);
+ mp_write_console_ansi(wstream, buf);
}
+ talloc_free(buf);
} else {
done = vfprintf(stream, format, args);
}