2023-01-29 13:08:48 +08:00
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
#include <inttypes.h>
|
|
|
|
|
#include <errno.h>
|
|
|
|
|
#include <fcntl.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <locale.h>
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
#include <assert.h>
|
|
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
|
#include <tui.h>
|
|
|
|
|
|
|
|
|
|
int redraw_screen() {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int destroy_window() {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int init_window() {
|
|
|
|
|
setlocale(LC_ALL, NULL);
|
2023-02-05 02:42:12 +08:00
|
|
|
if (getenv("NEWT_COLORS") == NULL)
|
|
|
|
|
putenv(
|
|
|
|
|
"NEWT_COLORS=root=,black\n"
|
2023-02-05 03:13:20 +08:00
|
|
|
"border=lightgray,black\n"
|
|
|
|
|
"title=lightgray,black\n"
|
2023-02-05 02:42:12 +08:00
|
|
|
"roottext=red,black\n"
|
2023-02-05 03:13:20 +08:00
|
|
|
"label=lightgray,black\n"
|
2023-02-05 03:25:12 +08:00
|
|
|
"entry=lightgray,black\n"
|
2023-02-05 02:42:12 +08:00
|
|
|
"window=red,black\n"
|
2023-02-05 03:13:20 +08:00
|
|
|
"textbox=lightgray,black\n"
|
|
|
|
|
"button=black,lightgray\n"
|
|
|
|
|
"compactbutton=lightgray,black\n"
|
|
|
|
|
"listbox=lightgray,black\n"
|
|
|
|
|
"actlistbox=black,lightgray\n"
|
|
|
|
|
"actsellistbox=black,lightgray\n"
|
|
|
|
|
"checkbox=lightgray,black\n"
|
|
|
|
|
"actcheckbox=black,lightgray\n");
|
2023-02-05 02:42:12 +08:00
|
|
|
|
2023-02-05 16:16:19 +08:00
|
|
|
tui_started = true;
|
2023-02-04 21:29:49 +08:00
|
|
|
newtInit();
|
|
|
|
|
newtCls();
|
2023-02-05 14:37:01 +08:00
|
|
|
newtSetColor(PI_LOG_COLOR, "yellow", "black");
|
|
|
|
|
newtSetColor(PI_STEP_CURRENT, "lightgray", "black");
|
|
|
|
|
newtSetColor(PI_STEP_OTHER, "gray", "black");
|
2023-02-05 03:00:29 +08:00
|
|
|
newtDrawRootText(0, 0, "palera1n version 2.0.0");
|
2023-02-04 21:29:49 +08:00
|
|
|
newtPushHelpLine(NULL);
|
2023-01-29 13:08:48 +08:00
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int tui() {
|
|
|
|
|
init_window();
|
2023-02-04 21:29:49 +08:00
|
|
|
int ret = MAIN_SCREEN;
|
2023-01-29 13:08:48 +08:00
|
|
|
while (1) {
|
|
|
|
|
switch (ret) {
|
2023-02-04 21:29:49 +08:00
|
|
|
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;
|
2023-01-29 13:08:48 +08:00
|
|
|
}
|
2023-02-04 21:29:49 +08:00
|
|
|
newtPopWindow();
|
2023-01-29 13:08:48 +08:00
|
|
|
}
|
|
|
|
|
out:
|
2023-02-04 21:29:49 +08:00
|
|
|
newtFinished();
|
2023-02-05 16:19:54 +08:00
|
|
|
tui_started = false;
|
2023-02-04 21:29:49 +08:00
|
|
|
return 0;
|
|
|
|
|
|
2023-01-29 13:08:48 +08:00
|
|
|
}
|