mirror of
https://github.com/hmaxnl/netex.git
synced 2025-01-18 15:34:20 +01:00
Testing ncurses for TUI
This commit is contained in:
parent
7a1808f8c6
commit
47f5ce53d6
|
@ -21,7 +21,7 @@ void netex_init(void)
|
||||||
if (has_colors() && can_change_color())
|
if (has_colors() && can_change_color())
|
||||||
{
|
{
|
||||||
start_color();
|
start_color();
|
||||||
PRINT_LINE("%i colors available, %i color pairs available.", COLORS, COLOR_PAIRS);
|
//PRINT_LINE("%i colors available, %i color pairs available.", COLORS, COLOR_PAIRS);
|
||||||
//TODO: Make color pairs
|
//TODO: Make color pairs
|
||||||
}
|
}
|
||||||
// OpenSSL
|
// OpenSSL
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
add_executable(netex_svr
|
add_executable(netex_svr
|
||||||
"main.c"
|
"main.c"
|
||||||
"server.c"
|
"server.c"
|
||||||
server.h)
|
"srv_tui.c"
|
||||||
|
"server.h")
|
||||||
|
|
||||||
target_include_directories(netex_svr PRIVATE ${CMAKE_SOURCE_DIR}/src/net/include)
|
target_include_directories(netex_svr PRIVATE ${CMAKE_SOURCE_DIR}/src/net/include)
|
||||||
target_link_libraries(netex_svr netex)
|
target_link_libraries(netex_svr netex)
|
|
@ -12,6 +12,8 @@
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
netex_init();
|
netex_init();
|
||||||
|
setup_windows();
|
||||||
|
getch();
|
||||||
const int init_result = initialize_server(argc, argv);
|
const int init_result = initialize_server(argc, argv);
|
||||||
if (init_result)
|
if (init_result)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
#include "server.h"
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
@ -40,7 +42,6 @@ int initialize_server(int argc, char* argv[])
|
||||||
WARN("Failed to save configuration to disk, default config is only available in memory!");
|
WARN("Failed to save configuration to disk, default config is only available in memory!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Socket
|
// Socket
|
||||||
const int64_t portnum = config_get_int(srv_configuration, "Connection.Port");
|
const int64_t portnum = config_get_int(srv_configuration, "Connection.Port");
|
||||||
char* hostname = config_get_string(srv_configuration, "Connection.BindIP");
|
char* hostname = config_get_string(srv_configuration, "Connection.BindIP");
|
||||||
|
|
|
@ -4,4 +4,6 @@
|
||||||
int initialize_server(int argc, char* argv[]);
|
int initialize_server(int argc, char* argv[]);
|
||||||
int server_execute(void);
|
int server_execute(void);
|
||||||
|
|
||||||
|
int setup_windows(void);
|
||||||
|
|
||||||
#endif //SERVER_H
|
#endif //SERVER_H
|
||||||
|
|
40
src/server/srv_tui.c
Normal file
40
src/server/srv_tui.c
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
//
|
||||||
|
// Created by max on 28-1-24.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include <ncurses.h>
|
||||||
|
|
||||||
|
#include "server.h"
|
||||||
|
|
||||||
|
// INFO
|
||||||
|
// https://tldp.org/HOWTO/NCURSES-Programming-HOWTO/
|
||||||
|
//
|
||||||
|
|
||||||
|
WINDOW *info_win, *log_win;
|
||||||
|
|
||||||
|
int setup_windows(void)
|
||||||
|
{
|
||||||
|
int ymax,xmax;
|
||||||
|
getmaxyx(stdscr, ymax, xmax);
|
||||||
|
info_win = newwin(15, xmax-1, 1, 1);
|
||||||
|
/*int half_scr = xmax * 100 / 50; = add 50 percent of num -> 100 + 50% = 150
|
||||||
|
half_scr = xmax * 50 / 100; = get 50 percent of num -> 100 - 50% = 50
|
||||||
|
*/
|
||||||
|
log_win = newwin(ymax-16, xmax * 50 / 100, 16, 1);
|
||||||
|
refresh();
|
||||||
|
box(info_win, 0, 0);
|
||||||
|
box(log_win, 0, 0);
|
||||||
|
mvwprintw(info_win, 0, 1, " Info window ");
|
||||||
|
mvwprintw(log_win, 0, 1, " Log window ");
|
||||||
|
for (int i = 0; i != 15; i++)
|
||||||
|
{
|
||||||
|
mvwprintw(log_win, i + 1, 1, "Test!");
|
||||||
|
}
|
||||||
|
wrefresh(info_win);
|
||||||
|
wrefresh(log_win);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
void calculate_wind_sizes(void)
|
||||||
|
{
|
||||||
|
//TODO: calculate the size of the windows on the screen, called when first start and on screen resize.
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user