ncurses template

This commit is contained in:
2025-11-26 17:57:34 +02:00
parent 2cd9455f7e
commit c524ece546
5 changed files with 225 additions and 14 deletions
+75 -12
View File
@@ -1,23 +1,86 @@
#include "main.h"
#include <arpa/inet.h>
#include <netinet/in.h>
#include <stdlib.h>
#include <sys/select.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <termios.h>
#include <unistd.h>
/* TODO: перед загрузкой файла спрашивать права доступа
TODO: сделать при интерфес выбора по пунктам меню */
#include "ui/app.h"
#include <ncurses.h>
void event_loop(app_t *app);
int main(int argc, char **argv) {
app_t *app;
app = calloc(1, sizeof(app_t));
init_nc();
app = init_app();
wrefresh(app->menu_win);
wrefresh(app->action_win);
event_loop(app);
destroy_app(app);
endwin();
int main(int argc, char *argv[]) {
params_t params;
init_params(&params);
analyze_args(argc, argv, &params);
get_missing_params(&params);
int sd = init_client();
connect_to_server(sd, &params);
query_loop(sd, &params);
clear_params(&params);
return 0;
}
}
void event_loop(app_t *app) {
int c;
for (;;) {
c = wgetch(app->win);
switch (c) {
// 113 is q key. This exits the program
case 113:
return;
case KEY_F(9):
return;
case 'e':
// ac_edit(app);
break;
// 27 is ESC key. Usage of ESC is not recommended, but for now this clears
// the menus
case 27:
// app->menu_bar->selected_menu = -1;
break;
// 9 or \t is horizontal tab
case 9:
// if (app->active == N_MENU) {
// app->active = N_ACTION;
// } else {
// app->active = N_MENU;
// }
break;
default:
break;
}
draw_borders(app);
wnoutrefresh(app->win);
wnoutrefresh(app->menu_win);
wnoutrefresh(app->action_win);
doupdate();
};
}
// int main(int argc, char *argv[]) {
// params_t params;
// init_params(&params);
// analyze_args(argc, argv, &params);
// get_missing_params(&params);
// int sd = init_client();
// connect_to_server(sd, &params);
// query_loop(sd, &params);
// clear_params(&params);
// return 0;
// }