aboutsummaryrefslogtreecommitdiff
path: root/client/ui_tabbar.c
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2022-06-06 19:48:09 +0200
committerlonkaars <loek@pipeframe.xyz>2022-06-06 19:48:09 +0200
commitae8beb20a2a837824cfda4d748fbe07b26a161f0 (patch)
treea7c2bf5fc6cbddc1ae62107050dcc6aa793cc7ae /client/ui_tabbar.c
parent8c1d31ef16745cee07059788386cd88c718092ac (diff)
tab bar working
Diffstat (limited to 'client/ui_tabbar.c')
-rw-r--r--client/ui_tabbar.c29
1 files changed, 21 insertions, 8 deletions
diff --git a/client/ui_tabbar.c b/client/ui_tabbar.c
index fc43db9..9f5707a 100644
--- a/client/ui_tabbar.c
+++ b/client/ui_tabbar.c
@@ -1,6 +1,7 @@
#include <stdlib.h>
#include <string.h>
+#include "strings.h"
#include "ui.h"
unsigned int g_w2_ui_tabbar_scroll = 0;
@@ -9,17 +10,29 @@ void (*g_w2_tab_ptrs[W2_UI_TAB_COUNT])(bool first);
void w2_ui_tabbar_init() {
g_w2_tab_ptrs[W2_UI_TAB_START] = &w2_ui_tab_start;
- g_w2_tab_ptrs[W2_UI_TAB_DIRC] = &w2_ui_tab_dirc;
+ g_w2_tab_ptrs[W2_UI_TAB_DIRC] = &w2_ui_tab_dirc;
}
-char* w2_ui_tabbar_format_tab(char* name, bool selected) {
- char* ret_val = malloc(strlen(name) + 3);
- printf("%c%s%c", selected ? '[' : ' ', name, selected ? ']' : ' ');
- return ret_val;
+void w2_ui_switch_tab(w2_e_ui_tabs next_tab) {
+ g_w2_ui_current_tab = next_tab % W2_UI_TAB_COUNT;
+ wclear(g_w2_ui_pad_body);
+}
+
+void w2_ui_tabbar_logic() {
+ int ch;
+ while ((ch = getch()) != -1) {
+ if (ch == '\t') w2_ui_switch_tab(g_w2_ui_current_tab + 1);
+ }
}
void w2_ui_paint_tabbar() {
- char temp[g_w2_ui_width];
- sprintf(temp, "-- tab bar here --");
- w2_wmvaddstr(g_w2_ui_pad_tabbar, 0, g_w2_ui_width / 2 - strlen(temp) / 2, temp);
+ w2_ui_tabbar_logic();
+ wmove(g_w2_ui_pad_tabbar, 0, 0);
+ for (unsigned int i = 0; i < W2_UI_TAB_COUNT; i++) {
+ g_w2_ui_tabbar_lengths[i] += 2 + strlen(g_w2_tab_strings[i]);
+
+ wprintw(g_w2_ui_pad_tabbar, " %c%s%c", g_w2_ui_current_tab == i ? '[' : ' ',
+ g_w2_tab_strings[i], g_w2_ui_current_tab == i ? ']' : ' ');
+ }
+ wprintw(g_w2_ui_pad_tabbar, " ");
}