summaryrefslogtreecommitdiff
path: root/client/ui.c
blob: c47e1fb0c09e1eb69387d4565cdde1f70b50d694 (plain)
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
#include <string.h>
#include <ncurses.h>

#include "../shared/bin.h"
#include "../shared/util.h"
#include "i18n.h"
#include "main.h"
#include "term.h"
#include "ui.h"

WINDOW *g_w2_ui_win;
unsigned int g_w2_ui_width = 0;
unsigned int g_w2_ui_height = 0;

void w2_ui_main() {
	g_w2_ui_width = getmaxx(g_w2_ui_win);
	g_w2_ui_height = getmaxy(g_w2_ui_win);

	w2_ui_paint();
}

void w2_ui_paint() {
	w2_ui_paint_statusbar();
	refresh();
}

void w2_ui_paint_statusbar() {
	char temp[g_w2_ui_width + 1];
	sprintf(temp, "%s, %ims %s",
			g_w2_state.connected ? W2_UI_CONN_STAT_CONNECTED : W2_UI_CONN_STAT_DISCONNECTED,
			g_w2_state.ping,
			W2_UI_CONN_STAT_PING);
	mvaddstr(0, 0, temp);

	sprintf(temp, "(%s)", g_w2_state.info.build_str);
	mvaddstr(0, g_w2_ui_width / 2 - strlen(temp) / 2, temp);

	sprintf(temp, "%s %i%%", W2_UI_BATT_STAT_BATTERY, g_w2_state.battery_level);
	mvaddstr(0, g_w2_ui_width - strlen(temp), temp);

	sprintf(temp, "[mode 0x%02x]", g_w2_state.mode);
	mvaddstr(1, 0, temp);

	sprintf(temp, "%i %s, %i %s",
			0, W2_UI_EXPT_STAT_WARNINGS,
			0, W2_UI_EXPT_STAT_ERRORS);
	mvaddstr(1, g_w2_ui_width - strlen(temp), temp);

	w2_ui_paint_tabbar();

	for (unsigned int i = 0; i < g_w2_ui_width; i++) temp[i] = '-';
	temp[g_w2_ui_width] = 0;
	mvaddstr(3, 0, temp);
}

void w2_ui_paint_tabbar() {
	char temp[g_w2_ui_width];
	sprintf(temp, "-- tab bar here --");
	mvaddstr(2, g_w2_ui_width / 2 - strlen(temp) / 2, temp);
}