1 // SPDX-License-Identifier: GPL-2.0
3 #include "../progress.h"
4 #include "../libslang.h"
7 #include "../browser.h"
9 static void tui_progress__update(struct ui_progress *p)
13 * FIXME: We should have a per UI backend way of showing progress,
14 * stdio will just show a percentage as NN%, etc.
22 ui__refresh_dimensions(false);
23 pthread_mutex_lock(&ui__lock);
24 y = SLtt_Screen_Rows / 2 - 2;
26 SLsmg_draw_box(y, 0, 3, SLtt_Screen_Cols);
28 SLsmg_write_string((char *)p->title);
29 SLsmg_fill_region(y, 1, 1, SLtt_Screen_Cols - 2, ' ');
30 SLsmg_set_color(HE_COLORSET_SELECTED);
31 bar = ((SLtt_Screen_Cols - 2) * p->curr) / p->total;
32 SLsmg_fill_region(y, 1, 1, bar, ' ');
34 pthread_mutex_unlock(&ui__lock);
37 static void tui_progress__finish(void)
44 ui__refresh_dimensions(false);
45 pthread_mutex_lock(&ui__lock);
46 y = SLtt_Screen_Rows / 2 - 2;
48 SLsmg_fill_region(y, 0, 3, SLtt_Screen_Cols, ' ');
50 pthread_mutex_unlock(&ui__lock);
53 static struct ui_progress_ops tui_progress__ops =
55 .update = tui_progress__update,
56 .finish = tui_progress__finish,
59 void tui_progress__init(void)
61 ui_progress__ops = &tui_progress__ops;