1
0
mirror of https://github.com/mpv-player/mpv synced 2025-02-16 12:17:12 +00:00
Commit Graph

143 Commits

Author SHA1 Message Date
Kacper Michajłow
201a39d7fa msg: skip formatting if there is only control char present
This doesn't change behaviour just skips some redundant code early.
2024-10-21 20:06:48 +02:00
Kacper Michajłow
3cf0f8309f msg: add newline conditionally
In idle mode, there is not status line and we sometimes want to have
output without last new line, which were always added after truncation.

Also, make sure we don't overwrite important chars with ellipsis, this
could happen when cut point is near the end.

Fixes: bf025cd289ab6e5f094204d8aee070811fd99bdf
2024-10-21 20:06:48 +02:00
Kacper Michajłow
6b695ac6e4 msg: use .. instead of … as ellipsis char
There were some concerns about the width of the … glyph, so avoid it and
use two dots.

Fixes: 6aa331289f
2024-10-18 19:57:53 +02:00
Kacper Michajłow
3e499ff3bc msg: fix width with ellipsis
Fixes: 6aa331289f10b12622fadc1589092276d30296aa
2024-10-18 00:25:10 +02:00
Kacper Michajłow
b026fded7d msg: fix clipped output to non-tty
Not sure how it got lost.
2024-10-17 23:55:51 +02:00
Kacper Michajłow
6aa331289f msg: use … instead of ... dots 2024-10-17 23:55:51 +02:00
Kacper Michajłow
2df582b839 msg: don't format status line if not printing to terminal 2024-10-17 22:32:10 +02:00
Kacper Michajłow
39d3591bb2 msg: strip control char also when not printing to terminal 2024-10-12 01:26:43 +02:00
Kacper Michajłow
bf025cd289 msg: allow to truncate the message to terminal width 2024-10-11 15:16:33 +02:00
Kacper Michajłow
95f0046309 misc/codepoint_width: add unicode width detection support
Add 4 stage trie to lookup unicode codepoint width and grapheme join
rules.

Generated by GraphemeTableGen from Microsoft Terminal (MIT Licence):
a7e47b711a/src/tools/GraphemeTableGen/Program.cs

With minor adjustment to use it in C codebase.
- Replaced constexpr with static
- Replaced auto with explicit types

Generated from Unicode 16.0.0:
ucd.nounihan.grouped.xml: sha256(b11c2d23673bae660fff8ddcd3c1de4d54bdf6c60188a07696b010282f515fcf)
2024-10-11 15:06:14 +02:00
Kacper Michajłow
4c19df1ded msg: print format string on format errors 2024-09-29 16:06:25 +02:00
Kacper Michajłow
4de6390d25 msg: don't use bold colors and instead use bright ones
Also avoid regular white/black, because it is often the terminal
background and invisible as foreground color.

Change debug messages to blue while at it to differentiate them from
trace ones.
2024-09-14 17:11:07 +02:00
Kacper Michajłow
a16f653eb5 msg: clear status line only if needed 2024-05-19 19:10:58 +02:00
Kacper Michajłow
895dd9e4e2 msg: split mp_msg_flush_status_line into private and public variant 2024-05-19 19:10:58 +02:00
Kacper Michajłow
243c1d6d91 msg: check target stream before printing
After f18ce7eca0 status is not always
printed to stderr.
2024-05-19 19:10:58 +02:00
Kacper Michajłow
f18ce7eca0 msg: print all messages to one stream
This reverts commit 4939570e17 and makes
it more strict about the output stream. Status message is also on the
same stream now.
2024-05-06 22:21:46 +02:00
Kacper Michajłow
18ef834ef4 various: move unistd.h inclusion to common.h 2024-05-06 22:01:17 +02:00
Kacper Michajłow
9030e6a7ad msg: use fwrite
No need to recalc string length.
2024-04-13 18:23:16 +02:00
Kacper Michajłow
f53e941ba0 msg: use defines for hide/restore cursor code 2024-04-13 18:23:16 +02:00
Kacper Michajłow
247ef82a76 msg: don't keep status line in partial
Noticed while looking at this code, we shouldn't append status line to
partial when !print_term.
2024-04-13 13:37:21 +02:00
Kacper Michajłow
0deefd80bf msg: clear buffered status_line on flush
It shouldn't be used after flush anymore.
2024-03-21 01:47:15 +01:00
Kacper Michajłow
17a0756ed3 msg: simplify the line_skip calculation
Make it more straightforward by always calculating top offset first
instead of having two branches, that tries to calc it directly.

This also fixes missing negative check before `\033[%dA` which was in
practice only problem on macOS which was handling negative values, while
in fact it shouldn't.

Fixes: #13484
2024-03-21 01:47:15 +01:00
nanahi
18bd03d31a common/msg: fix warning: void function should not return void expression 2024-03-19 08:58:18 +01:00
nanahi
98ab8d87a1 common/msg: fix warning: use of non-standard escape character '\e' 2024-03-19 08:58:18 +01:00
sfan5
dcf8adf289 common: don't force terminal log buffer to small size
Using the 'terminal-default' log level a client can request
to get all messages that would normally appear on the terminal.

8c2d73f112 changed the size of the
relevant buffer to 100 lines, which was prone to quickly overflowing
once you enable verbose or debug output.
This size is kept for the early terminal buffer but now enlarged
once a client actually requests this log level. This fixes the overflow
risk while not consuming more resources if this feature is unused.
2024-01-27 10:04:16 +01:00
Guido Cella
25bef997ce msg: reset status_lines when setting --really-quiet
This prevents mp_msg_flush_status_line() from printing an unnecessary
newline when changing file after setting --really-quiet at runtime. If
mpv is backgrounded, this newline garbles the output of TUI programs.

With this change the cursor is not re-enabled after setting
--really-quiet at runtime and quitting with mpv in the foreground, so
enable it on uninit.
2024-01-21 17:54:21 +00:00
Kacper Michajłow
13ed292ab0 terminal: don't print escape sequence if not tty 2024-01-15 10:39:42 +01:00
Kacper Michajłow
485221ba22 msg: return zero length if bstr_split_utf8 fails
In theory bstr_split_utf8 should skip invalid sequence and move further,
but it doesn't do that currently, so just the string if unsuported code if
found.

Fixes infinite loop on code.len == 0 condition.

Fixes: 5864b72d1a
2024-01-10 00:31:57 +01:00
Kacper Michajłow
5864b72d1a msg: improve term_disp_width to support unicode
All characters are assumed to be single-width. This is consistent with
the rest of the code and documentation.

Fixes: #13150
2024-01-04 13:41:06 +00:00
Kacper Michajłow
1306ea9854 msg: reduce nesting in mp_msg_flush_status_line
Cosmetic change only.
2023-12-27 20:59:22 +00:00
Kacper Michajłow
cadb68487e msg: keep status line on the end of file
Apparently found useful by some users.

Fixes: #13092
2023-12-27 20:59:22 +00:00
Kacper Michajłow
7d7276e384 common/msg: remove redundant check
It is already strcmp above, so cannot be NULL.
2023-11-18 23:55:28 +00:00
Kacper Michajłow
82451bdf04 msg: ensure status line is always visible
Restore last status line if it has been cleared by another message.
2023-11-08 21:55:08 +00:00
Kacper Michajłow
5c3faf71e8 msg: factor out print code
Will be useful for next commit.
2023-11-08 21:55:08 +00:00
Kacper Michajłow
773f72e6c6 msg: convert dump_stats to bstr 2023-11-08 21:55:08 +00:00
Kacper Michajłow
0853c719f1 msg: use bstr for partial msg 2023-11-08 21:55:08 +00:00
Kacper Michajłow
2fdb1d31ae msg: check isatty separately per each stream 2023-11-08 21:55:08 +00:00
Kacper Michajłow
24270b8587 msg: refactor how terminal messages are printed
- prepare string before printing
- reduce amount of fflush(), especially for multiline messages
- clear status line and keep it always at the bottom
- indent module name to the longest value
- disable cursor for status line
- properly support wrapped status line

Overall makes status line less flickering and remove stray status
instead of scrolling them up.
2023-11-08 21:55:08 +00:00
Kacper Michajłow
d0b8472e5a msg: don't mix partial log messages, with unrelated log levels 2023-11-08 21:55:08 +00:00
Kacper Michajłow
174df99ffa ALL: use new mp_thread abstraction 2023-11-05 17:36:17 +00:00
Kacper Michajłow
cb829879af mp_threads: rename threads for consistent naming across all of them
I'd like some names to be more descriptive, but to work with 15 chars
limit we have to make some sacrifice.

Also because of the limit, remove the `mpv/` prefix and prioritize
actuall thread name.
2023-10-27 23:18:56 +00:00
NRK
8bbcc87fee timer: remove MP_START_TIME
instead require mp_raw_time_ns() to not return 0, which all current
implementation already should follow.
2023-10-27 18:07:19 +00:00
Kacper Michajłow
29e677fea5 msg: make mp_msg_find_level case insensitive 2023-10-27 18:07:08 +00:00
NRK
d05ef7fdc4 various: sort some standard headers
since i was going to fix the include order of stdatomic, might as well
sort the surrouding includes in accordance with the project's coding
style.

some headers can sometime require specific include order. standard
library headers usually don't. but mpv might "hack into" the standard
headers (e.g pthreads) so that complicates things a bit more.

hopefully nothing breaks. if it does, the style guide is to blame.
2023-10-20 21:31:09 +02:00
NRK
450a69b1d6 various: remove ATOMIC_VAR_INIT
the fallback needed it due to the struct wrapper. but the fallback is
now removed so it's no longer needed.

as for standard atomics, it was never really needed either, was useless
and then made obsolete in C17 and removed in C23.

ref: https://gustedt.wordpress.com/2018/08/06/c17-obsoletes-atomic_var_init/
ref: https://en.cppreference.com/w/c/atomic/ATOMIC_VAR_INIT
2023-10-20 21:31:09 +02:00
NRK
2070331f64 osdep: remove atomic.h
replace it with <stdatomic.h> and replace the mp_atomic_* typedefs with
explicit _Atomic qualified types.

also add missing config.h includes on some files.
2023-10-20 21:31:09 +02:00
Dudemanguy
84fa7ea411 msg: use nanosecond precision
The timestamps when making a log file is actually dependent on
MP_START_TIME. This is a 10 microsecond offset that was added to the
timer as an offset. With the nanosecond change, this unit needs to be
converted as well so the offset is the same as before. After doing that,
we need to change the various mp_time_us calls in msg to mp_time_ns and
do the right conversion. This fixes the logs timestamps (i.e. so they
aren't negative anymore).
2023-09-29 18:20:30 -05:00
Dudemanguy
4939570e17 msg: print MSGL_WARN and higher error messages to stderr
mpv has a convention of printing everything to stdout. The reasons for
this are pretty unclear and in certain situations rather unintuitive. It
leads to some bad behavior in fringe cases with encoding mode and isn't
the norm for programs so just adjust it so warnings and up are printed
to stderr. Fixes #8608.
2023-07-24 22:48:30 +02:00
Avi Halachmi (:avih)
8eb7a00fa1 msg: log-file set at mpv.conf: don't ignore early messages
Previously, if log-file was set not via a CLI option (e.g. set via
mpv.conf or other config file, or set from a script init phase),
then meaningful early log messages were thrown away because the log
file name was unknown initially.

Such early log messages include the command line arguments, any
options set from mpv.conf, and possibly more.

Now we store up to 5000 early messages before the log file name is
known, and flush them once/if it becomes known, or destroy this
buffer once mpv init is complete.

The implementation is similar and adjacent, but not identical, to an
existing early log system for mpv clients which request a log buffer.
2023-01-23 11:05:08 +02:00
Avi Halachmi (:avih)
17baa00e02 msg: log-file buffer size: don't use magic number (no-op) 2023-01-23 11:05:08 +02:00