-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathStatusLine.cc
More file actions
62 lines (49 loc) · 999 Bytes
/
StatusLine.cc
File metadata and controls
62 lines (49 loc) · 999 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// Implementation of a status line
#include "StatusLine.h"
#include "Config.h"
#include <stdarg.h>
#define STATUSLINE_TIMEOUT 5
extern time_t current_time;
StatusLine::StatusLine(Window *_parent)
: Window(_parent, wh_full,1),
message(NULL), end_time(0)
{
sticky_status = false;
}
void StatusLine::idle()
{
if (message && current_time > end_time && !sticky_status)
{
free(message);
message = NULL;
show(false);
}
}
// Set the status line (using a formatted string)
void StatusLine::setf(const char *fmt ...)
{
char buf[256];
va_list va;
va_start(va,fmt);
vsnprintf (buf, 256, fmt, va);
va_end(va);
set(buf);
}
void StatusLine::set(const char *s)
{
if (message)
free(message);
message = strdup(s);
end_time = current_time + STATUSLINE_TIMEOUT;
show(true);
}
void StatusLine::redraw()
{
if (message)
{
gotoxy(0,0);
set_color (config->getOption(opt_statuscolor));
printf("%-*.*s", width, width, message);
dirty = false;
}
}