From 5f5210b08d7e0da3b051aca66ebe8f940654c29b Mon Sep 17 00:00:00 2001 From: Nick Chan Date: Sun, 5 Feb 2023 02:42:12 +0800 Subject: [PATCH] make tui bigger but within 80x24 --- include/tui.h | 6 ++---- src/Makefile | 2 +- src/tui_main.c | 16 ++++++++++++++++ src/tui_screen_main.c | 9 +++++---- src/tui_screen_options.c | 15 ++++++++++++--- 5 files changed, 36 insertions(+), 12 deletions(-) diff --git a/include/tui.h b/include/tui.h index cc6ae58..18407ca 100644 --- a/include/tui.h +++ b/include/tui.h @@ -12,10 +12,8 @@ #include #include -#define MAIN_OPTIONS "Options" -#define MAIN_START "Start" -#define MAIN_EXIT "Exit" -#define BACK_BUTTON "Back" +#define WIDTH 76 +#define HEIGHT 19 #define MSG_COLOR 1 #define ICON_COLOR 2 diff --git a/src/Makefile b/src/Makefile index abbb179..a72463c 100644 --- a/src/Makefile +++ b/src/Makefile @@ -42,7 +42,7 @@ endif xxd-%.c: % xxd -iC $< > $@ -%.o: %.c +%.o: %.c $(wildcard ../include/*.h) $(CC) -c $(CFLAGS) $< palera1n: $(OBJECTS) diff --git a/src/tui_main.c b/src/tui_main.c index ca5f05d..f2de6a1 100644 --- a/src/tui_main.c +++ b/src/tui_main.c @@ -22,6 +22,22 @@ int destroy_window() { int init_window() { setlocale(LC_ALL, NULL); + if (getenv("NEWT_COLORS") == NULL) + putenv( + "NEWT_COLORS=root=,black\n" + "border=white,black\n" + "title=white,black\n" + "roottext=red,black\n" + "window=red,black\n" + "textbox=white,black\n" + "button=black,green\n" + "compactbutton=white,black\n" + "listbox=white,black\n" + "actlistbox=black,white\n" + "actsellistbox=black,green\n" + "checkbox=green,black\n" + "actcheckbox=black,green\n"); + newtInit(); newtCls(); newtDrawRootText(0, 0, "Package Configuration"); diff --git a/src/tui_screen_main.c b/src/tui_screen_main.c index b2b95a8..ff5b44e 100644 --- a/src/tui_screen_main.c +++ b/src/tui_screen_main.c @@ -15,10 +15,10 @@ tui_screen_t tui_screen_main() { int ret = MAIN_SCREEN; bool can_start = false; - newtCenteredWindow(60, 16, "palera1n version 2.0.0"); - newtComponent optionsButton = newtCompactButton(30, 14, "Options"); - newtComponent startButton = newtCompactButton(41, 14, "Start"); - newtComponent exitButton = newtCompactButton(50, 14, "Exit"); + newtCenteredWindow(WIDTH, HEIGHT, "palera1n version 2.0.0"); + newtComponent optionsButton = newtCompactButton(46, 17, "Options"); + newtComponent startButton = newtCompactButton(57, 17, "Start"); + newtComponent exitButton = newtCompactButton(66, 17, "Exit"); newtComponent welcome = newtLabel(1, 0, "Welcome to palera1n!"); newtComponent form = newtForm(NULL, NULL, 0); newtFormAddComponents(form, optionsButton, startButton, exitButton, welcome, NULL); @@ -35,5 +35,6 @@ tui_screen_t tui_screen_main() { } else if (buttonPressed == exitButton) { ret = EXIT_SCREEN; } + newtFormDestroy(form); return ret; } diff --git a/src/tui_screen_options.c b/src/tui_screen_options.c index 4053d33..a3ad1b0 100644 --- a/src/tui_screen_options.c +++ b/src/tui_screen_options.c @@ -26,11 +26,12 @@ tui_screen_t tui_screen_options() { tui_bit_info_t setup_rootful_info = { &palerain_flags, palerain_option_setup_rootful }; tui_bit_info_t force_revert_info = { &checkrain_flags, checkrain_option_force_revert }; tui_bit_info_t safemode_info = { &checkrain_flags, checkrain_option_safemode }; + const char* bootargs_entered = NULL; int ret = MAIN_SCREEN; - newtCenteredWindow(60, 16, "palera1n version 2.0.0"); - newtComponent backButton = newtCompactButton(50, 14, "Back"); + newtCenteredWindow(WIDTH, HEIGHT, "palera1n version 2.0.0"); + newtComponent backButton = newtCompactButton(66, 17, "Back"); newtComponent verboseBootBox = newtCheckbox(1, 1, "Verbose boot", CHECKBOX_STATE(kpf_flags, checkrain_option_verbose_boot), NULL, NULL); newtComponent rootfulBox = newtCheckbox(1, 2, "Rootful", CHECKBOX_STATE(palerain_flags, palerain_option_rootful), NULL, NULL); @@ -38,6 +39,11 @@ tui_screen_t tui_screen_options() { newtComponent forceRevertBox = newtCheckbox(1, 4, "Restore system", CHECKBOX_STATE(checkrain_flags, checkrain_option_force_revert), NULL, NULL); newtComponent safeModeBox = newtCheckbox(1, 5, "Safe mode", CHECKBOX_STATE(checkrain_flags, checkrain_option_safemode), NULL, NULL); + newtComponent bootCmdlineLabel = newtLabel(1, 6, "Kernel command line:"); + newtComponent bootCmdlineEntry = newtEntry(1, 7, NULL, WIDTH - 2, &bootargs_entered, NEWT_ENTRY_SCROLL); + + newtComponent flowerChainBox /* dark blockchain */ = newtCheckbox(1, 8, "Flower chain", ' ', NULL, NULL); + newtComponentAddCallback(verboseBootBox, bitfield_check_cb, &verbose_info); newtComponentAddCallback(rootfulBox, bitfield_check_cb, &rootful_info); newtComponentAddCallback(rootfulSetupBox, bitfield_check_cb, &setup_rootful_info); @@ -46,12 +52,15 @@ tui_screen_t tui_screen_options() { newtComponent form = newtForm(NULL, NULL, 0); newtFormAddComponents(form, backButton, verboseBootBox, rootfulBox, - rootfulSetupBox, forceRevertBox, safeModeBox, NULL); + rootfulSetupBox, forceRevertBox, safeModeBox, bootCmdlineLabel, + bootCmdlineEntry, flowerChainBox, NULL); newtRunForm(form); newtRefresh(); + snprintf(xargs_cmd, 0x270, "xargs %s", bootargs_entered); newtComponent buttonPressed = newtFormGetCurrent(form); if (buttonPressed == backButton) { ret = MAIN_SCREEN; } else assert(0); + newtFormDestroy(form); return ret; }