Przeglądaj źródła

Exit curses mode while programs run

master
lostd lostd 10 lat temu
rodzic
commit
fdf42ec502
1 zmienionych plików z 27 dodań i 11 usunięć
  1. +27
    -11
      noice.c

+ 27
- 11
noice.c Wyświetl plik

@@ -42,8 +42,8 @@
int die = 0; int die = 0;


struct assoc { struct assoc {
char *ext; char *ext; /* Extension */
char *bin; char *bin; /* Program */
} assocs[] = { } assocs[] = {
{ "avi", "mplayer" }, { "avi", "mplayer" },
{ "mp4", "mplayer" }, { "mp4", "mplayer" },
@@ -88,6 +88,25 @@ dentcmp(const void *va, const void *vb)
return strcmp(a->d_name, b->d_name); return strcmp(a->d_name, b->d_name);
} }


void
initcurses(void)
{
initscr();
cbreak();
noecho();
nonl();
intrflush(stdscr, FALSE);
keypad(stdscr, TRUE);
curs_set(FALSE); /* Hide cursor */
}

void
exitcurses(void)
{
endwin(); /* Restore terminal */
}


/* Warning shows up at the bottom */ /* Warning shows up at the bottom */
void void
printwarn(char *prefix) printwarn(char *prefix)
@@ -318,6 +337,8 @@ nochange:
DPRINTF_S(ext); DPRINTF_S(ext);
DPRINTF_S(bin); DPRINTF_S(bin);


exitcurses();

/* Run program */ /* Run program */
pid = fork(); pid = fork();
if (pid == 0) if (pid == 0)
@@ -325,6 +346,8 @@ nochange:
else else
waitpid(pid, NULL, 0); waitpid(pid, NULL, 0);


initcurses();

free(file); free(file);


/* Screen may be messed up */ /* Screen may be messed up */
@@ -360,18 +383,11 @@ main(int argc, char *argv[])
/* Set locale before curses setup */ /* Set locale before curses setup */
setlocale(LC_ALL, ""); setlocale(LC_ALL, "");


/* Init curses */ initcurses();
initscr();
cbreak();
noecho();
nonl();
intrflush(stdscr, FALSE);
keypad(stdscr, TRUE);
curs_set(FALSE); /* Hide cursor */


browse(ipath); browse(ipath);


endwin(); /* Restore terminal */ exitcurses();


return 0; return 0;
} }

||||||
x
 
000:0
Ładowanie…
Anuluj
Zapisz