History

msg: split mp_msg_flush_status_line into private and public variant

Kacper Michajłow committed 2 years ago

Commit 895dd9e1 parent 243c1d61 file · +17 −12Browse files

Unified · Split

common/msg.c+17−12
@@ -246,34 +246,39 @@ static void prepare_prefix(struct mp_log_root *root, bstr *out, int lev, int ter · 245 unmodified lines
246 root->blank_lines += root->status_lines;246 root->blank_lines += root->status_lines;
247}247}
248 248
249void mp_msg_flush_status_line(struct mp_log *log, bool clear)249static void msg_flush_status_line(struct mp_log_root *root, bool clear)
250{250{
251 if (!log->root)251 if (!root->status_lines)
252 return;
253
254 mp_mutex_lock(&log->root->lock);
255 if (!log->root->status_lines)
256 goto done;252 goto done;
257 253
258 FILE *fp = term_msg_fp(log->root, MSGL_STATUS);254 FILE *fp = term_msg_fp(root, MSGL_STATUS);
259 if (!clear) {255 if (!clear) {
260 if (log->root->isatty[term_msg_fileno(log->root, MSGL_STATUS)])256 if (root->isatty[term_msg_fileno(root, MSGL_STATUS)])
261 fprintf(fp, TERM_ESC_RESTORE_CURSOR);257 fprintf(fp, TERM_ESC_RESTORE_CURSOR);
262 fprintf(fp, "\n");258 fprintf(fp, "\n");
263 log->root->blank_lines = 0;259 root->blank_lines = 0;
264 log->root->status_lines = 0;260 root->status_lines = 0;
265 goto done;261 goto done;
266 }262 }
267 263
268 bstr term_msg = {0};264 bstr term_msg = {0};
269 prepare_prefix(log->root, &term_msg, MSGL_STATUS, 0);265 prepare_prefix(root, &term_msg, MSGL_STATUS, 0);
270 if (term_msg.len) {266 if (term_msg.len) {
271 fprintf(fp, "%.*s", BSTR_P(term_msg));267 fprintf(fp, "%.*s", BSTR_P(term_msg));
272 talloc_free(term_msg.start);268 talloc_free(term_msg.start);
273 }269 }
274 270
275done:271done:
276 log->root->status_line.len = 0;272 root->status_line.len = 0;
273}
274
275void mp_msg_flush_status_line(struct mp_log *log, bool clear)
276{
277 if (!log->root)
278 return;
279
280 mp_mutex_lock(&log->root->lock);
281 msg_flush_status_line(log->root, clear);
277 mp_mutex_unlock(&log->root->lock);282 mp_mutex_unlock(&log->root->lock);
278}283}
279 284

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t