mirror of
https://github.com/hmaxnl/netex.git
synced 2025-01-18 15:34:20 +01:00
Working on ncurses TUI
This commit is contained in:
parent
47f5ce53d6
commit
e6e43fc9f0
|
@ -10,6 +10,8 @@
|
|||
#define WARN(msg, args...) printw("[Warning]: " msg "\n", ##args); refresh()
|
||||
#define ERROR(msg, args...) printw("[ERROR]: " msg "\n", ##args); refresh()
|
||||
|
||||
#define GET_PERC(num, perc) num * perc / 100
|
||||
|
||||
typedef enum socket_ipv
|
||||
{
|
||||
IPv4,
|
||||
|
|
|
@ -21,7 +21,7 @@ void netex_init(void)
|
|||
if (has_colors() && can_change_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
|
||||
}
|
||||
// OpenSSL
|
||||
|
|
|
@ -4,26 +4,34 @@
|
|||
|
||||
#include <ncurses.h>
|
||||
|
||||
#include "netex.h"
|
||||
#include "server.h"
|
||||
|
||||
// INFO
|
||||
// https://tldp.org/HOWTO/NCURSES-Programming-HOWTO/
|
||||
//
|
||||
|
||||
#define PAIR_BG_WIN_COLOR 2
|
||||
|
||||
WINDOW *info_win, *log_win;
|
||||
|
||||
int setup_windows(void)
|
||||
{
|
||||
// Color pairs
|
||||
init_pair(PAIR_BG_WIN_COLOR, COLOR_GREEN, COLOR_BLACK);
|
||||
|
||||
// Windows
|
||||
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);
|
||||
info_win = newwin(GET_PERC(ymax, 20), xmax-1, 1, 0);
|
||||
log_win = newwin(ymax-16, GET_PERC(xmax, 50), GET_PERC(ymax, 20) + 1, 0);
|
||||
refresh();
|
||||
wattron(info_win, COLOR_PAIR(PAIR_BG_WIN_COLOR));
|
||||
box(info_win, 0, 0);
|
||||
wattroff(info_win, COLOR_PAIR(PAIR_BG_WIN_COLOR));
|
||||
wattron(log_win, COLOR_PAIR(PAIR_BG_WIN_COLOR));
|
||||
box(log_win, 0, 0);
|
||||
wattroff(log_win, COLOR_PAIR(PAIR_BG_WIN_COLOR));
|
||||
mvwprintw(info_win, 0, 1, " Info window ");
|
||||
mvwprintw(log_win, 0, 1, " Log window ");
|
||||
for (int i = 0; i != 15; i++)
|
||||
|
@ -32,9 +40,11 @@ int setup_windows(void)
|
|||
}
|
||||
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