msg, client API: buffer partial lines

The API could return partial lines, meaning the message could stop
in the middle of a line, and the next message would have the rest of
it (or just the next part of it). This was a pain for the user, so do
the nasty task of buffering the lines ourselves.

Now only complete lines are sent. To make things even easier for the
API user, don't put multiple lines into a single event, but split them.

The terminal output code needed something similar (inserting a prefix
header on start of each line). To avoid code duplication, this commit
refactors the terminal output so that lines are split in a single
place.
This commit is contained in:
wm4
2014-10-08 13:11:55 +02:00
parent 2632ea3de6
commit f73778ad82
3 changed files with 78 additions and 69 deletions

View File

@@ -1044,13 +1044,9 @@ typedef struct mpv_event_log_message {
*/
const char *level;
/**
* The log message. Note that this is the direct output of a printf()
* style output API. The text will contain embedded newlines, and it's
* possible that a single message contains multiple lines, or that a
* message contains a partial line.
*
* It's safe to display messages only if they end with a newline character,
* and to buffer them otherwise.
* The log message. It consists of 1 line of text, and is terminated with
* a newline character. (Before API version 1.6, it could contain multiple
* or partial lines.)
*/
const char *text;
} mpv_event_log_message;