diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 01e0beb..0d20a91 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -27,7 +27,6 @@ jobs: MBEDTLS_VERSION: 3.3.0 LIBUSB_VERSION: 1.0.26 READLINE_VERSION: 8.2 - NCURSES_VERSION: 6.4 SLANG_VERSION: 2.3.3 NEWT_VERSION: 0.52.23 POPT_VERSION: 1.19 @@ -41,7 +40,7 @@ jobs: - name: Install dependencies (packages) run: | sudo /usr/local/bin/pip3 install jsonschema jinja2 - brew install make autoconf automake pkg-config gnu-sed ncurses gettext + brew install make autoconf automake pkg-config gnu-sed gettext sudo rm -rf /usr/local/Frameworks/Python* curl -LO https://github.com/ProcursusTeam/ldid/releases/download/v2.1.5-procursus7/ldid_macosx_x86_64 sudo install -m755 ldid_macosx_x86_64 /usr/local/bin/ldid @@ -57,7 +56,6 @@ jobs: https://github.com/Mbed-TLS/mbedtls/archive/refs/tags/v${{ env.MBEDTLS_VERSION }}.tar.gz \ https://github.com/libusb/libusb/releases/download/v${{ env.LIBUSB_VERSION }}/libusb-${{ env.LIBUSB_VERSION }}.tar.bz2 \ https://mirror-hk.koddos.net/gnu/readline/readline-${{ env.READLINE_VERSION }}.tar.gz \ - https://mirror-hk.koddos.net/gnu/ncurses/ncurses-${{ env.NCURSES_VERSION }}.tar.gz \ https://www.jedsoft.org/releases/slang/slang-${{ env.SLANG_VERSION }}.tar.bz2 \ https://releases.pagure.org/newt/newt-${{ env.NEWT_VERSION }}.tar.gz \ https://github.com/rpm-software-management/popt/archive/refs/tags/popt-${{ env.POPT_VERSION }}-release.tar.gz @@ -65,7 +63,6 @@ jobs: tar -xf v${{ env.MBEDTLS_VERSION }}.tar.gz tar -xjf libusb-${{ env.LIBUSB_VERSION }}.tar.bz2 tar -xf readline-${{ env.READLINE_VERSION }}.tar.gz - tar -xf ncurses-${{ env.NCURSES_VERSION }}.tar.gz tar -xjf slang-${{ env.SLANG_VERSION }}.tar.bz2 tar -xf newt-${{ env.NEWT_VERSION }}.tar.gz tar -xf popt-${{ env.POPT_VERSION }}-release.tar.gz @@ -93,7 +90,6 @@ jobs: echo "CXXFLAGS_FOR_BUILD=-stdlib=libc++ -arch $(uname -m) -isysroot $(xcrun -sdk macosx --show-sdk-path)" >> $GITHUB_ENV echo "CPPFLAGS_FOR_BUILD=-arch $(uname -m) -isysroot $(xcrun -sdk macosx --show-sdk-path) -Wno-error-implicit-function-declaration" >> $GITHUB_ENV echo "LDFLAGS_FOR_BUILD=-Wl,-dead_strip" >> $GITHUB_ENV - echo $(echo $(brew --cellar)/ncurses/*/bin/tic | sed 's|/tic||') >> $GITHUB_PATH mkdir -p $(pwd)/sysroot/usr/local/lib ln -sf $(pwd)/sysroot/usr/local/lib{,64} @@ -129,43 +125,6 @@ jobs: gsed -E /'__API_UNAVAILABLE'/d < ${TARGET_SYSROOT}/usr/include/pthread.h > sysroot/usr/local/include/pthread.h gsed -i -E s/'__API_UNAVAILABLE\(.*\)'// sysroot/usr/local/include/IOKit/IOKitLib.h - - name: Build ncurses - run: | - cd ncurses-${{ env.NCURSES_VERSION }} - ./configure \ - ${{ env.CONFIGURE_ARGS }} \ - --with-build-cc="${{ env.CC }}" \ - --with-build-cflags="${{ env.CFLAGS_FOR_NUILD }}" \ - --with-build-cpp="${{ env.CC }} -E" \ - --with-build-cppflags="${{ env.CPPFLAGS_FOR_BUILD }}" \ - --with-build-ldflags="${{ env.LDFLAGS_FOR_BUILD }}" \ - --with-pthread \ - --enable-const \ - --enable-ext-colors \ - --enable-ext-mouse \ - --enable-ext-putwin \ - --enable-wattr-macros \ - --disable-overwrite \ - --without-debug \ - --without-tests \ - --enable-sigwinch \ - --enable-const \ - --enable-symlinks \ - --enable-termcap \ - --enable-pc-files \ - --without-x11-rgb \ - --with-tic-path=$(echo $(brew --cellar)/ncurses/*/bin/tic) \ - --includedir="${{ env.PREFIX }}/include" \ - --with-pkg-config-libdir="${{ env.PREFIX }}/lib/pkgconfig" \ - --enable-widec \ - --with-default-terminfo-dir="/opt/procursus/share/terminfo" \ - --with-terminfo-dirs="/var/jb/usr/share/terminfo:/opt/procursus/share/terminfo:/opt/local/share/terminfo:/opt/homebrew/share/terminfo:/usr/local/share/terminfo:/opt/sw/share/terminfo:/sw/share/terminfo:/usr/share/terminfo" \ - LDFLAGS="${{ env.LDFLAGS }}" \ - PKG_CONFIG_LIBDIR="${{ env.PREFIX }}/lib/pkgconfig" || (cat config.log && exit 1) - gmake -j$(sysctl -n hw.ncpu) - gmake -j$(sysctl -n hw.ncpu) install DESTDIR=${{ env.DESTDIR }} - cd .. - - name: Build Mbed TLS run: | cd mbedtls-${{ env.MBEDTLS_VERSION }} @@ -310,6 +269,8 @@ jobs: - name: Build palera1n run: | cp -a sysroot/${{ env.PREFIX }}/{include,lib} dep_root + find dep_root -name '*.dylib' -delete + find dep_root -name '*.la' -delete if [ "${{ matrix.os }}" = "macosx" ]; then gmake -j$(sysctl -n hw.ncpu) elif [ "${{ matrix.os }}" = "iphoneos" ]; then @@ -419,7 +380,6 @@ jobs: MBEDTLS_VERSION: 3.3.0 LIBUSB_VERSION: 1.0.26 READLINE_VERSION: 8.2 - NCURSES_VERSION: 6.4 SLANG_VERSION: 2.3.3 NEWT_VERSION: 0.52.23 GPM_VERSION: 1.20.7 @@ -495,7 +455,6 @@ jobs: https://github.com/Mbed-TLS/mbedtls/archive/refs/tags/v${{ env.MBEDTLS_VERSION }}.tar.gz \ https://github.com/libusb/libusb/releases/download/v${{ env.LIBUSB_VERSION }}/libusb-${{ env.LIBUSB_VERSION }}.tar.bz2 \ https://mirror-hk.koddos.net/gnu/readline/readline-${{ env.READLINE_VERSION }}.tar.gz \ - https://mirror-hk.koddos.net/gnu/ncurses/ncurses-${{ env.NCURSES_VERSION }}.tar.gz \ https://www.jedsoft.org/releases/slang/slang-${{ env.SLANG_VERSION }}.tar.bz2 \ https://releases.pagure.org/newt/newt-${{ env.NEWT_VERSION }}.tar.gz \ http://www.nico.schottelius.org/software/gpm/archives/gpm-${{ env.GPM_VERSION }}.tar.gz \ @@ -504,7 +463,6 @@ jobs: tar -xf v${{ env.MBEDTLS_VERSION }}.tar.gz tar -xjf libusb-${{ env.LIBUSB_VERSION }}.tar.bz2 tar -xf readline-${{ env.READLINE_VERSION }}.tar.gz - tar -xf ncurses-${{ env.NCURSES_VERSION }}.tar.gz tar -xjf slang-${{ env.SLANG_VERSION }}.tar.bz2 tar -xf newt-${{ env.NEWT_VERSION }}.tar.gz tar -xf gpm-${{ env.GPM_VERSION }}.tar.gz @@ -515,42 +473,6 @@ jobs: git clone --depth=1 https://github.com/libimobiledevice/libusbmuxd git clone --depth=1 https://github.com/libimobiledevice/libimobiledevice - - name: Build ncurses - run: | - cd ncurses-${{ env.NCURSES_VERSION }} - ./configure \ - ${{ env.CONFIGURE_ARGS }} \ - --with-build-cc="cc" \ - --with-build-cflags=" " \ - --with-build-cpp="cc -E" \ - --with-build-cppflags=" " \ - --with-build-ldflags=" " \ - --enable-const \ - --enable-ext-colors \ - --enable-ext-mouse \ - --enable-ext-putwin \ - --enable-wattr-macros \ - --with-pthread \ - --disable-overwrite \ - --without-debug \ - --without-tests \ - --enable-sigwinch \ - --enable-const \ - --enable-symlinks \ - --enable-termcap \ - --enable-pc-files \ - --without-x11-rgb \ - --with-pkg-config-libdir="${{ env.PREFIX }}/lib/pkgconfig" \ - --includedir="${{ env.PREFIX }}/include" \ - --enable-widec \ - --with-default-terminfo-dir="/usr/share/terminfo" \ - --with-terminfo-dirs="/usr/share/terminfo:/lib/terminfo:/usr/lib/terminfo:/usr/local/share/terminfo:/usr/local/lib/terminfo:/data/data/com.termux/files/usr/share/terminfo" \ - LDFLAGS="${{ env.LDFLAGS }}" \ - PKG_CONFIG_LIBDIR="${{ env.PREFIX }}/lib/pkgconfig" - gmake -j$(sysctl -n hw.ncpu) - gmake -j$(sysctl -n hw.ncpu) install DESTDIR=${{ env.DESTDIR }} - cd .. - - name: Build Mbed TLS run: | cd mbedtls-${{ env.MBEDTLS_VERSION }} diff --git a/Makefile b/Makefile index f7a5fad..05a454f 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ SRC = $(shell pwd) DEP = $(SRC)/dep_root STRIP = strip CC ?= cc -CFLAGS += -I$(DEP)/include -I$(DEP)/include/ncursestw -I$(SRC)/include -I$(SRC) +CFLAGS += -I$(DEP)/include -I$(SRC)/include -I$(SRC) CFLAGS += -Wall -Wextra -DPALERAIN_VERSION=\"2.0.0\" -Wall -Wextra -Wno-unused-parameter CFLAGS += -Wno-unused-variable -I$(SRC)/src LIBS += $(DEP)/lib/libimobiledevice-1.0.a $(DEP)/lib/libirecovery-1.0.a $(DEP)/lib/libusbmuxd-2.0.a @@ -24,7 +24,7 @@ LIBS += $(DEP)/lib/libmbedtls.a $(DEP)/lib/libmbedcrypto.a $(DEP)/lib/libmbedx50 LIBS += $(DEP)/lib/libusb-1.0.a ifeq ($(DEV_BUILD),1) -LIBS += $(DEP)/lib/libmenutw.a $(DEP)/lib/libncursestw.a +LIBS += $(DEP)/lib/libnewt.a $(DEP)/lib/libpopt.a $(DEP)/lib/libslang.a CFLAGS += -O0 -g -DDEV_BUILD -fno-omit-frame-pointer ifeq ($(ASAN),1) BUILD_STYLE=ASAN diff --git a/include/tui.h b/include/tui.h index 5b6f1b9..cc6ae58 100644 --- a/include/tui.h +++ b/include/tui.h @@ -1,8 +1,5 @@ #ifndef TUI_H #define TUI_H -#define NCURSES_WIDECHAR 1 - -#include #include #include #include @@ -13,6 +10,7 @@ #include #include #include +#include #define MAIN_OPTIONS "Options" #define MAIN_START "Start" @@ -22,6 +20,8 @@ #define MSG_COLOR 1 #define ICON_COLOR 2 +#define CHECKBOX_STATE(flags, opt) checkrain_option_enabled(flags, opt) ? '*' : ' ' + typedef enum tui_screens { ERROR_SCREEN = -1, EXIT_SCREEN = 0, @@ -32,6 +32,11 @@ typedef enum tui_screens { ENTER_RECOVERY_SCREEN = 5 } tui_screen_t; +typedef struct bitfield_checkbox_info { + checkrain_option_p flags_p; + checkrain_option_t opt; +} tui_bit_info_t; + tui_screen_t tui_screen_main(); tui_screen_t tui_screen_options(); tui_screen_t tui_screen_enter_recovery(); diff --git a/src/tui_main.c b/src/tui_main.c index 2054718..ca5f05d 100644 --- a/src/tui_main.c +++ b/src/tui_main.c @@ -1,8 +1,3 @@ -#define NCURSES_WIDECHAR 1 - -#include -#include -#include #include #include #include @@ -18,74 +13,56 @@ #include int redraw_screen() { - erase(); - resizeterm(24, 80); - box(stdscr, 0, 0); - mvaddstr(0, 80 - strlen("[palera1n version " PALERAIN_VERSION "]") - 2 , "[palera1n version " PALERAIN_VERSION "]"); return 0; } int destroy_window() { - endwin(); return 0; } int init_window() { setlocale(LC_ALL, NULL); - initscr(); - if (has_colors() == TRUE) { - start_color(); - init_pair(MSG_COLOR, COLOR_YELLOW, COLOR_BLACK); - init_pair(ICON_COLOR, COLOR_WHITE, COLOR_BLACK); - } - int height, width; - getmaxyx(stdscr, height, width); - if (width < 80 || height < 24) { - LOG(LOG_ERROR, "Terminal size must be at least 80x24"); - return -1; - } - if (has_colors() == FALSE) { - LOG(LOG_VERBOSE2, "Terminal without color support detected"); - } - cbreak(); - noecho(); - keypad(stdscr, TRUE); + newtInit(); + newtCls(); + newtDrawRootText(0, 0, "Package Configuration"); + newtPushHelpLine(NULL); return 0; } int tui() { - int ret = MAIN_SCREEN; init_window(); + int ret = MAIN_SCREEN; while (1) { - redraw_screen(); switch (ret) { - case ERROR_SCREEN: - goto out; - break; - case EXIT_SCREEN: - goto out; - break; - case MAIN_SCREEN: - ret = tui_screen_main(); - break; - case OPTIONS_SCREEN: - ret = tui_screen_options(); - break; - case ENTER_RECOVERY_SCREEN: - ret = tui_screen_enter_recovery(); - break; - case ENTER_DFU_SCREEN: - ret = tui_screen_enter_dfu(); - break; - case JAILBREAKING_SCREEN: - ret = tui_screen_jailbreak(); - break; - default: - assert(0); - goto out; + case ERROR_SCREEN: + goto out; + break; + case EXIT_SCREEN: + goto out; + break; + case MAIN_SCREEN: + ret = tui_screen_main(); + break; + case OPTIONS_SCREEN: + ret = tui_screen_options(); + break; + case ENTER_RECOVERY_SCREEN: + ret = tui_screen_enter_recovery(); + break; + case ENTER_DFU_SCREEN: + ret = tui_screen_enter_dfu(); + break; + case JAILBREAKING_SCREEN: + ret = tui_screen_jailbreak(); + break; + default: + assert(0); + goto out; } + newtPopWindow(); } out: - destroy_window(); - return ret; + newtFinished(); + return 0; + } diff --git a/src/tui_screen_enter_dfu.c b/src/tui_screen_enter_dfu.c index 19cd2a4..3df0fc1 100644 --- a/src/tui_screen_enter_dfu.c +++ b/src/tui_screen_enter_dfu.c @@ -1,8 +1,3 @@ -#define NCURSES_WIDECHAR 1 - -#include -#include -#include #include #include #include diff --git a/src/tui_screen_enter_recovery.c b/src/tui_screen_enter_recovery.c index 96ada19..fbac411 100644 --- a/src/tui_screen_enter_recovery.c +++ b/src/tui_screen_enter_recovery.c @@ -1,8 +1,3 @@ -#define NCURSES_WIDECHAR 1 - -#include -#include -#include #include #include #include diff --git a/src/tui_screen_jailbreak.c b/src/tui_screen_jailbreak.c index 5e40724..c94d257 100644 --- a/src/tui_screen_jailbreak.c +++ b/src/tui_screen_jailbreak.c @@ -1,8 +1,3 @@ -#define NCURSES_WIDECHAR 1 - -#include -#include -#include #include #include #include diff --git a/src/tui_screen_main.c b/src/tui_screen_main.c index cb4aaf9..b2b95a8 100644 --- a/src/tui_screen_main.c +++ b/src/tui_screen_main.c @@ -1,8 +1,3 @@ -#define NCURSES_WIDECHAR 1 - -#include -#include -#include #include #include #include @@ -18,93 +13,27 @@ #include tui_screen_t tui_screen_main() { - int ret = -1; - mvaddstr(1, 2, "Welcome to palera1n!"); - move(2,1); - whline(stdscr, ACS_HLINE, 80 - 2); - move(5,2); - attron(COLOR_PAIR(MSG_COLOR)); - mvaddstr(4,2, "Connect your iPhone, iPad, or iPod Touch"); - mvaddstr(5,2, "to begin."); - attroff(COLOR_PAIR(MSG_COLOR)); - attron(COLOR_PAIR(ICON_COLOR)); - mvaddwstr(2, 43, L" MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM "); - mvaddwstr(3, 44, L"MMMMMMMMMMMMMWNOddONWMMMMMMMMMMMMM"); - mvaddwstr(4, 44, L"MMMMMMMMMMMMWNx. .xNWMMMMMMMMMMMM"); - mvaddwstr(5, 44, L"MMMMMMMMMMMMW0;....;OWMMMMMMMMMMMM"); - mvaddwstr(6, 44, L"MMMMMMMMMMMMW0;....;OWMMMMMMMMMMMM"); - mvaddwstr(7, 44, L"MMMMMMMMMMMWXo'.....lKWMMMMMMMMMMM"); - mvaddwstr(8, 44, L"MMMMMMMMMMWNkc;'....'dNWMMMMMMMMMM"); - mvaddwstr(9, 44, L"MMMMMMMMMMN0dc:,''''.:ONWMMMMMMMMM"); - mvaddwstr(10, 44, L"MMMMMMMMMWKxllc;,'''',lKWMMMMMMMMM"); - mvaddwstr(11, 44, L"MMMMMMMMWNkoolc;,,,,;;:xXWMMMMMMMM"); - mvaddwstr(12, 44, L"MMMMMMMMW0olllc;,,,,,,,:OWMMMMMMMM"); - mvaddwstr(13, 44, L"MMMMMMMMNOollc:,'....'';xNMMMMMMMM"); - mvaddwstr(14, 44, L"MMMMMMMMW0dllc:,''''''':OWMMMMMMMM"); - mvaddwstr(15, 44, L"MMMMMMMMWN0dc::;;,,,,,cONWMMMMMMMM"); - mvaddwstr(16, 44, L"MMMMMMMMMMWXOxoc::cldkXWMMMMMMMMMM"); - mvaddwstr(17, 44, L"MMMMMMMMMMMMWWNNXXNNWWMMMMMMMMMMMM"); - mvaddwstr(18, 44, L"MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM"); - mvaddstr(7, 2, "Made by: Nick Chan, Mineek, Tom, Nebula,"); - mvaddstr(8, 2, "llsc12, Nathan"); - move(9, 2); - whline(stdscr, ACS_HLINE, 40); - mvaddstr(10, 2, "Thanks to: nyuszika7h, Procursus Team"); - mvaddstr(11, 2, "dora2ios, m1sta, Serena, xerub, tihmstar"); - mvaddstr(12, 2, "sbingner, checkra1n team (Siguza, Axi0mx"); - mvaddstr(13, 2, "argp et al.)"); - move(14, 2); - whline(stdscr, ACS_HLINE, 40); - mvaddstr(19, 2, "palera1n is NOT affinated with checkra1n"); - mvaddstr(20, 2, "Note: Backup your stuff. Use at your own risk."); - mvaddstr(19, 78 - strlen("@palera1n"), "@palera1n"); - mvaddstr(20, 78 - strlen("https://palera.in"), "https://palera.in"); - attroff(COLOR_PAIR(ICON_COLOR)); - move(21,1); - whline(stdscr, ACS_HLINE, 80 - 2); - move(22, 40); - - ITEM* main_buttons[4]; - MENU* main_menu; - - main_buttons[0] = new_item(MAIN_OPTIONS, ""); - main_buttons[1] = new_item(MAIN_START, ""); - main_buttons[2] = new_item(MAIN_EXIT, ""); - main_buttons[3] = NULL; - main_menu = new_menu(main_buttons); - item_opts_off(main_buttons[1], O_SELECTABLE); - - set_menu_format(main_menu, 1, 40); - set_menu_sub(main_menu, derwin(stdscr, 0, 0, 22, 50)); - post_menu(main_menu); - raw(); - refresh(); - while (1) { - int ch = getch(); - if (ch == KEY_LEFT) { - menu_driver(main_menu, REQ_LEFT_ITEM); - } else if (ch == KEY_RIGHT) { - menu_driver(main_menu, REQ_RIGHT_ITEM); - } else if (ch == 10) { - if (!(item_opts(current_item(main_menu)) & O_SELECTABLE)) continue; - // fprintf(stderr, "Button %s pressed\n", current_item(main_menu)->name.str); - if (!strcmp(current_item(main_menu)->name.str, MAIN_EXIT)) { - ret = EXIT_SCREEN; - } else if (!strcmp(current_item(main_menu)->name.str, MAIN_START)) { - ret = ENTER_RECOVERY_SCREEN; - } else if (!strcmp(current_item(main_menu)->name.str, MAIN_OPTIONS)) { - ret = OPTIONS_SCREEN; - } - goto end; - } - refresh(); + 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"); + newtComponent welcome = newtLabel(1, 0, "Welcome to palera1n!"); + newtComponent form = newtForm(NULL, NULL, 0); + newtFormAddComponents(form, optionsButton, startButton, exitButton, welcome, NULL); + newtRunForm(form); + newtRefresh(); + newtComponent buttonPressed = newtFormGetCurrent(form); + if (buttonPressed == optionsButton) { + ret = OPTIONS_SCREEN; + } else if (buttonPressed == startButton) { + if (can_start) + ret = ENTER_RECOVERY_SCREEN; + else + ret = MAIN_SCREEN; + } else if (buttonPressed == exitButton) { + ret = EXIT_SCREEN; } -end: - noraw(); - unpost_menu(main_menu); - free_menu(main_menu); - free_item(main_buttons[0]); - free_item(main_buttons[1]); - free_item(main_buttons[2]); return ret; } diff --git a/src/tui_screen_options.c b/src/tui_screen_options.c index c63922e..4053d33 100644 --- a/src/tui_screen_options.c +++ b/src/tui_screen_options.c @@ -1,8 +1,3 @@ -#define NCURSES_WIDECHAR 1 - -#include -#include -#include #include #include #include @@ -17,44 +12,46 @@ #include #include +void bitfield_check_cb(newtComponent box, void* data) { + if (newtCheckboxGetValue(box) == ' ') { + *((tui_bit_info_t*)data)->flags_p = *((tui_bit_info_t*)data)->flags_p &~ ((tui_bit_info_t*)data)->opt; + } else if (newtCheckboxGetValue(box) == '*') { + *((tui_bit_info_t*)data)->flags_p |= ((tui_bit_info_t*)data)->opt; + } else assert(0); +} + tui_screen_t tui_screen_options() { - tui_screen_t ret = EXIT_SCREEN; - ITEM* back_button[2]; - MENU* back_menu; - back_button[0] = new_item("Back", ""); - back_button[1] = NULL; - back_menu = new_menu(back_button); + tui_bit_info_t verbose_info = { &kpf_flags, checkrain_option_verbose_boot }; + tui_bit_info_t rootful_info = { &palerain_flags, palerain_option_rootful }; + 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 }; - move(21, 1); - hline(ACS_HLINE, 80 - 2); + int ret = MAIN_SCREEN; - set_menu_format(back_menu, 1, 10); - set_menu_sub(back_menu, derwin(stdscr, 0, 0, 22, 68)); - post_menu(back_menu); + newtCenteredWindow(60, 16, "palera1n version 2.0.0"); + newtComponent backButton = newtCompactButton(50, 14, "Back"); - FORM* options_form; - FIELD* options[3]; - - options[0] = new_field(2, 2, 2, 2); - options[1] = new_field(); - options[2] = NULL; + 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); + newtComponent rootfulSetupBox = newtCheckbox(1, 3, "Setup fakefs", CHECKBOX_STATE(palerain_flags, palerain_option_setup_rootful), NULL, NULL); + 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); - refresh(); + newtComponentAddCallback(verboseBootBox, bitfield_check_cb, &verbose_info); + newtComponentAddCallback(rootfulBox, bitfield_check_cb, &rootful_info); + newtComponentAddCallback(rootfulSetupBox, bitfield_check_cb, &setup_rootful_info); + newtComponentAddCallback(forceRevertBox, bitfield_check_cb, &force_revert_info); + newtComponentAddCallback(safeModeBox, bitfield_check_cb, &safemode_info); - while(1) { - int ch = getch(); - if (ch == 10) { - if (!(item_opts(current_item(back_menu)) & O_SELECTABLE)) continue; - if (!strcmp(current_item(back_menu)->name.str, BACK_BUTTON)) { - ret = MAIN_SCREEN; - } - goto end; - } - refresh(); - } -end: - unpost_menu(back_menu); - free_item(back_button[0]); - free_menu(back_menu); + newtComponent form = newtForm(NULL, NULL, 0); + newtFormAddComponents(form, backButton, verboseBootBox, rootfulBox, + rootfulSetupBox, forceRevertBox, safeModeBox, NULL); + newtRunForm(form); + newtRefresh(); + newtComponent buttonPressed = newtFormGetCurrent(form); + if (buttonPressed == backButton) { + ret = MAIN_SCREEN; + } else assert(0); return ret; }