Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
helpline.c
Go to the documentation of this file.
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
4 #include <pthread.h>
5 
6 #include "../../util/debug.h"
7 #include "../helpline.h"
8 #include "../ui.h"
9 #include "../libslang.h"
10 
11 static void tui_helpline__pop(void)
12 {
13 }
14 
15 static void tui_helpline__push(const char *msg)
16 {
17  const size_t sz = sizeof(ui_helpline__current);
18 
19  SLsmg_gotorc(SLtt_Screen_Rows - 1, 0);
20  SLsmg_set_color(0);
21  SLsmg_write_nstring((char *)msg, SLtt_Screen_Cols);
22  SLsmg_refresh();
23  strncpy(ui_helpline__current, msg, sz)[sz - 1] = '\0';
24 }
25 
27  .pop = tui_helpline__pop,
28  .push = tui_helpline__push,
29 };
30 
32 {
34  ui_helpline__puts(" ");
35 }
36 
38 
40 {
41  int ret;
42  static int backlog;
43 
44  pthread_mutex_lock(&ui__lock);
45  ret = vscnprintf(ui_helpline__last_msg + backlog,
46  sizeof(ui_helpline__last_msg) - backlog, format, ap);
47  backlog += ret;
48 
49  if (ui_helpline__last_msg[backlog - 1] == '\n') {
50  ui_helpline__puts(ui_helpline__last_msg);
51  SLsmg_refresh();
52  backlog = 0;
53  }
54  pthread_mutex_unlock(&ui__lock);
55 
56  return ret;
57 }