ui: file list

This commit is contained in:
2025-12-26 17:34:51 +02:00
parent e3fbe1b40a
commit b669b4be8a
16 changed files with 164 additions and 49 deletions
+20 -6
View File
@@ -7,16 +7,19 @@
// #include "modals/server_message.h"
// #include "action.h"
#include <ncurses.h>
#include <netinet/in.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <unistd.h>
void ac_file(WINDOW *win, int is_action_w);
app_t *init_app() {
/* get values from terminal size */
int y_max, x_max;
int32_t y_max, x_max;
getmaxyx(stdscr, y_max, x_max);
/* allocate app struct memory */
@@ -29,7 +32,7 @@ app_t *init_app() {
_app->win = newwin(_app->coordinates.cur_y, _app->coordinates.cur_x, 0, 0);
/* define the width for each sub window */
int32_t left_w_x = x_max / 3;
int32_t left_w_x = x_max / 10 * 4;
int32_t right_w_x = x_max - left_w_x - 2;
/* create the menu window */
@@ -43,7 +46,7 @@ app_t *init_app() {
_app->modal.is_initiated = 0;
/* default win */
_app->active_win = aw_left;
_app->active_win_type = aw_left;
/* print decorative bars */
print_bars(_app);
@@ -93,6 +96,8 @@ void draw_borders(app_t *app) {
}
void print_bars(app_t *app) {
char top_text[64] = "Hello!";
wattrset(app->win, A_REVERSE);
/* print top and bottom bars */
@@ -102,9 +107,14 @@ void print_bars(app_t *app) {
}
/* add content to the top bar */
mvwprintw(app->win, 1, 2, "example cprint_barsurses app | ");
mvwprintw(app->win, 1, sizeof "example cprint_barsurses app | " + 1,
"size %d, %d", app->coordinates.cur_x, app->coordinates.cur_y);
if (app->params && app->params->is_connected) {
uint32_t ip_address = app->params->addr;
u_char ip_addr[4];
mempcpy(ip_addr, &ip_address, 4);
sprintf(top_text, "Connected to %u.%u.%u.%u, user: %s", ip_addr[0],
ip_addr[1], ip_addr[2], ip_addr[3], app->params->uname);
}
mvwprintw(app->win, 1, 2, "%s", top_text);
/* add content to the bottom bar */
mvwprintw(app->win, app->coordinates.cur_y - 2, 2, "F1 - Help | F9 - Quit");
@@ -160,6 +170,10 @@ void app_draw_modal(app_t *app) {
case S_NEXT_ACTION:
return;
}
app->active_callback = app->modal.w.callback;
app->active_win = app->modal.win;
app->active_win_type = aw_modal;
app->active_widget = &(app->modal);
}
draw_dialogue(&(app->modal));
}