aboutsummaryrefslogtreecommitdiff
path: root/client/ui.c
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2022-05-29 22:35:04 +0200
committerlonkaars <loek@pipeframe.xyz>2022-05-29 22:35:04 +0200
commit555e5d2c0ce77dd1e031690c98ec9a1366182347 (patch)
tree69a505a23ae6ca5d0951e8f832f9895fcbb88b83 /client/ui.c
parent87d8b0ceb349e101b693cf43336a98647f4b92dc (diff)
`make format`
Diffstat (limited to 'client/ui.c')
-rw-r--r--client/ui.c53
1 files changed, 25 insertions, 28 deletions
diff --git a/client/ui.c b/client/ui.c
index 84408bb..1f42db5 100644
--- a/client/ui.c
+++ b/client/ui.c
@@ -1,11 +1,11 @@
#include <string.h>
-#include "../shared/util.h"
#include "../shared/bin.h"
+#include "../shared/util.h"
#include "i18n.h"
#include "main.h"
-#include "ui.h"
#include "term.h"
+#include "ui.h"
w2_s_ui_tty_canvas g_w2_ui_canvas;
@@ -14,63 +14,61 @@ void w2_ui_main() {
w2_ui_paint();
}
-void w2_ui_update() {
- w2_term_props();
-}
+void w2_ui_update() { w2_term_props(); }
-void w2_ui_paint() {
- w2_ui_paint_statusbar();
-}
+void w2_ui_paint() { w2_ui_paint_statusbar(); }
-void w2_ui_align(char* text, w2_e_alignment align, unsigned int length) {
+void w2_ui_align(char *text, w2_e_alignment align, unsigned int length) {
unsigned int padding = 0;
- switch(align) {
+ switch (align) {
case W2_UI_ALIGN_LEFT: {
break;
}
case W2_UI_ALIGN_CENTER: {
unsigned int middle = length / 2;
unsigned int offset = strlen(text) / 2;
- padding = W2_MAX(0, middle - offset);
+ padding = W2_MAX(0, middle - offset);
break;
}
case W2_UI_ALIGN_RIGHT: {
- unsigned int right = length;
+ unsigned int right = length;
unsigned int offset = strlen(text);
- padding = W2_MAX(0, right - offset);
+ padding = W2_MAX(0, right - offset);
break;
}
}
- char* temp = calloc(length, 1);
+ char *temp = calloc(length, 1);
sprintf(temp, "%*s%s", padding, "", text);
memcpy(text, temp, length);
free(temp);
}
-char* w2_ui_pt_sb_con_sts() {
- char* connected = g_w2_state.connected ? W2_UI_CONN_STAT_CONNECTED : W2_UI_CONN_STAT_DISCONNECTED;
- char* out = calloc(g_w2_ui_canvas.width, 1);
+char *w2_ui_pt_sb_con_sts() {
+ char *connected =
+ g_w2_state.connected ? W2_UI_CONN_STAT_CONNECTED : W2_UI_CONN_STAT_DISCONNECTED;
+ char *out = calloc(g_w2_ui_canvas.width, 1);
sprintf(out, "%s, %ims %s", connected, g_w2_state.ping, W2_UI_CONN_STAT_PING);
w2_ui_align(out, W2_UI_ALIGN_LEFT, g_w2_ui_canvas.width);
return out;
}
-char* w2_ui_pt_sb_ver_num() {
- char* out = calloc(g_w2_ui_canvas.width, 1);
+char *w2_ui_pt_sb_ver_num() {
+ char *out = calloc(g_w2_ui_canvas.width, 1);
sprintf(out, "(%s)", g_w2_state.info.build_str);
w2_ui_align(out, W2_UI_ALIGN_CENTER, g_w2_ui_canvas.width);
return out;
}
-char* w2_ui_pt_sb_bat_sts() {
- char* out = calloc(g_w2_ui_canvas.width, 1);
+char *w2_ui_pt_sb_bat_sts() {
+ char *out = calloc(g_w2_ui_canvas.width, 1);
sprintf(out, "%s %i%%", W2_UI_BATT_STAT_BATTERY, g_w2_state.battery_level);
w2_ui_align(out, W2_UI_ALIGN_RIGHT, g_w2_ui_canvas.width);
return out;
}
-void w2_ui_nullsub(char* str, unsigned int length) {
- for (int i = 0; i < length; i++) if (str[i] == 0x00) str[i] = ' ';
+void w2_ui_nullsub(char *str, unsigned int length) {
+ for (int i = 0; i < length; i++)
+ if (str[i] == 0x00) str[i] = ' ';
}
void w2_ui_overlay(char *bottom, char *top, unsigned int length) {
@@ -100,9 +98,9 @@ void w2_ui_overlay(char *bottom, char *top, unsigned int length) {
void w2_ui_paint_statusbar() {
char top_row[g_w2_ui_canvas.width];
- char* con_sts = w2_ui_pt_sb_con_sts();
- char* ver_num = w2_ui_pt_sb_ver_num();
- char* bat_sts = w2_ui_pt_sb_bat_sts();
+ char *con_sts = w2_ui_pt_sb_con_sts();
+ char *ver_num = w2_ui_pt_sb_ver_num();
+ char *bat_sts = w2_ui_pt_sb_bat_sts();
w2_ui_overlay(top_row, con_sts, g_w2_ui_canvas.width);
w2_ui_overlay(top_row, ver_num, g_w2_ui_canvas.width);
@@ -113,10 +111,9 @@ void w2_ui_paint_statusbar() {
free(con_sts);
free(ver_num);
free(bat_sts);
-
+
// w2_ui_pt_sb_connection_status();
// w2_ui_pt_sb_connection_status();
// w2_ui_pt_sb_connection_status();
printf("\n");
}
-