1 // SPDX-License-Identifier: GPL-2.0
5 #include <linux/kernel.h>
6 #include <linux/string.h>
8 #include "../helpline.h"
10 #include "../libslang.h"
12 char ui_helpline__last_msg[1024];
13 bool tui_helpline__set;
15 static void tui_helpline__pop(void)
19 static void tui_helpline__push(const char *msg)
21 const size_t sz = sizeof(ui_helpline__current);
23 SLsmg_gotorc(SLtt_Screen_Rows - 1, 0);
25 SLsmg_write_nstring((char *)msg, SLtt_Screen_Cols);
27 strlcpy(ui_helpline__current, msg, sz);
30 static int tui_helpline__show(const char *format, va_list ap)
35 mutex_lock(&ui__lock);
36 ret = vscnprintf(ui_helpline__last_msg + backlog,
37 sizeof(ui_helpline__last_msg) - backlog, format, ap);
40 tui_helpline__set = true;
42 if (ui_helpline__last_msg[backlog - 1] == '\n') {
43 ui_helpline__puts(ui_helpline__last_msg);
47 mutex_unlock(&ui__lock);
52 struct ui_helpline tui_helpline_fns = {
53 .pop = tui_helpline__pop,
54 .push = tui_helpline__push,
55 .show = tui_helpline__show,
58 void ui_helpline__init(void)
60 helpline_fns = &tui_helpline_fns;
61 ui_helpline__puts(" ");