Some fixes/improvements for core Help viewing (#1022)
* Don't hang on help files when fb_terminal=0 * Setup process so hotkeys work in less. Some changes to help improve pdf performance
This commit is contained in:
56
menu.cpp
56
menu.cpp
@@ -130,6 +130,8 @@ enum MENU
|
||||
|
||||
MENU_DOC_FILE_SELECTED,
|
||||
MENU_DOC_FILE_SELECTED_2,
|
||||
MENU_DOC_NO_FBTERM,
|
||||
MENU_DOC_NO_FBTERM2,
|
||||
|
||||
MENU_CHEATS1,
|
||||
MENU_CHEATS2,
|
||||
@@ -769,6 +771,7 @@ const char* get_rbf_name_bootcore(char *str)
|
||||
return p + 1;
|
||||
}
|
||||
|
||||
|
||||
static void vga_nag()
|
||||
{
|
||||
if (video_fb_state())
|
||||
@@ -974,6 +977,7 @@ void HandleUI(void)
|
||||
static uint8_t card_cid[32];
|
||||
static uint32_t hdmask = 0;
|
||||
static pid_t ttypid = 0;
|
||||
static int ttystatus = 0;
|
||||
static int has_fb_terminal = 0;
|
||||
static unsigned long flash_timer = 0;
|
||||
static int flash_state = 0;
|
||||
@@ -3062,32 +3066,41 @@ void HandleUI(void)
|
||||
if (strlen(path) > 4) ext = path + strlen(path) - 4;
|
||||
static char binary[1024*2];
|
||||
printf("extension: [%s]\n",ext);
|
||||
strcpy(binary,"/media/fat/linux/pdfviewer");
|
||||
strcpy(binary,"/media/fat/linux/pdfviewer --cache_size=1");
|
||||
if (!strcasecmp(ext,".pdf")) {
|
||||
sprintf(binary,"/media/fat/linux/pdfviewer --zoom_to_fit \"%s\"",path);
|
||||
sprintf(binary,"/media/fat/linux/pdfviewer --zoom_to_fit --cache_size=1 \"%s\"",path);
|
||||
} else if (!strcasecmp(ext,".txt")) {
|
||||
sprintf(binary,"less \"%s\"",path);
|
||||
} else if (!strcasecmp(ext+1,".md")) {
|
||||
sprintf(binary,"/media/fat/linux/glow --style dark \"%s\" | less -R",path);
|
||||
}
|
||||
|
||||
sprintf(cmd, "#!/bin/bash\nexport LC_ALL=en_US.UTF-8\nexport HOME=/root\nexport LESSKEY=/media/fat/linux/lesskey\ncd $(dirname \"%s\")\n%s \necho \"Press any key to continue\"\n", path, binary );
|
||||
sprintf(cmd, "#!/bin/bash\nexport LC_ALL=en_US.UTF-8\nexport HOME=/root\nexport LESSKEY=/media/fat/linux/lesskey\n cd $(dirname \"%s\")\n%s \nEXITSTATUS=$? \necho \"Press any key to continue\"\nexit $EXITSTATUS\n", path, binary );
|
||||
printf("CMD [%s]\n",cmd);
|
||||
unlink("/tmp/script");
|
||||
FileSave("/tmp/script", cmd, strlen(cmd));
|
||||
ttypid = fork();
|
||||
ttystatus = 0;
|
||||
if (!ttypid)
|
||||
{
|
||||
execl("/sbin/agetty", "/sbin/agetty", "-a", "root", "-l", "/tmp/script", "--nohostname", "-L", "tty2", "linux", NULL);
|
||||
exit(0); //should never be reached
|
||||
cpu_set_t set;
|
||||
CPU_ZERO(&set);
|
||||
CPU_SET(0, &set);
|
||||
sched_setaffinity(0, sizeof(set), &set);
|
||||
setsid();
|
||||
execl("/sbin/agetty", "/sbin/agetty", "-a", "root", "-l", "/tmp/script", "--nohostname", "-L", "tty2", "linux", NULL);
|
||||
exit(1); //should never be reached
|
||||
}
|
||||
} else {
|
||||
menustate = MENU_DOC_NO_FBTERM;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case MENU_DOC_FILE_SELECTED_2:
|
||||
if (ttypid)
|
||||
{
|
||||
if (waitpid(ttypid, 0, WNOHANG) > 0)
|
||||
if (waitpid(ttypid, &ttystatus, WNOHANG) > 0)
|
||||
{
|
||||
ttypid = 0;
|
||||
user_io_osd_key_enable(1);
|
||||
@@ -3095,7 +3108,7 @@ void HandleUI(void)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (c & UPSTROKE)
|
||||
if ((WIFEXITED(ttystatus) && !WEXITSTATUS(ttystatus)) || (c & UPSTROKE))
|
||||
{
|
||||
video_menu_bg(user_io_status_get("[3:1]"));
|
||||
video_fb_enable(0);
|
||||
@@ -3107,6 +3120,34 @@ void HandleUI(void)
|
||||
}
|
||||
break;
|
||||
|
||||
case MENU_DOC_NO_FBTERM:
|
||||
{
|
||||
int n = 0;
|
||||
menustate = MENU_DOC_NO_FBTERM2;
|
||||
OsdSetSize(18);
|
||||
OsdSetTitle("Help");
|
||||
OsdWrite(n++, "");
|
||||
OsdWrite(n++, "");
|
||||
OsdWrite(n++, "");
|
||||
OsdWrite(n++, "");
|
||||
OsdWrite(n++, "");
|
||||
OsdWrite(n++, "");
|
||||
OsdWrite(n++," Help requires");
|
||||
OsdWrite(n++," fb_terminal=1");
|
||||
for (; n < OsdGetSize(); n++) OsdWrite(n);
|
||||
MenuWrite(n, STD_EXIT, true, 0);
|
||||
}
|
||||
break;
|
||||
|
||||
case MENU_DOC_NO_FBTERM2:
|
||||
if (select)
|
||||
{
|
||||
menustate = MENU_NONE1;
|
||||
menusub = 3;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case MENU_ARCADE_DIP1:
|
||||
helptext_idx = 0;
|
||||
menumask = 0;
|
||||
@@ -6629,6 +6670,7 @@ void HandleUI(void)
|
||||
|
||||
unlink("/tmp/script");
|
||||
FileSave("/tmp/script", cmd, strlen(cmd));
|
||||
ttystatus = 0;
|
||||
ttypid = fork();
|
||||
if (!ttypid)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user