mirror of
https://github.com/palera1n/palera1n.git
synced 2026-12-05 15:54:30 +01:00
newt ui
This commit is contained in:
1 parent
ad2cb43392
commit
f22bee6870
9 files changed
+102
-287
No files matched your search
+33
-56
@@ -1,8 +1,3 @@
|
||||
#define NCURSES_WIDECHAR 1
|
||||
|
||||
#include <ncurses.h>
|
||||
#include <form.h>
|
||||
#include <menu.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
@@ -18,74 +13,56 @@
|
||||
#include <tui.h>
|
||||
|
||||
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;
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user