ncurses template
This commit is contained in:
+75
-12
@@ -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(¶ms);
|
||||
analyze_args(argc, argv, ¶ms);
|
||||
get_missing_params(¶ms);
|
||||
int sd = init_client();
|
||||
connect_to_server(sd, ¶ms);
|
||||
query_loop(sd, ¶ms);
|
||||
clear_params(¶ms);
|
||||
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(¶ms);
|
||||
// analyze_args(argc, argv, ¶ms);
|
||||
// get_missing_params(¶ms);
|
||||
// int sd = init_client();
|
||||
// connect_to_server(sd, ¶ms);
|
||||
// query_loop(sd, ¶ms);
|
||||
// clear_params(¶ms);
|
||||
// return 0;
|
||||
// }
|
||||
Reference in New Issue
Block a user