mirror of
https://github.com/dankamongmen/notcurses
synced 2025-03-09 09:09:03 -04:00
notcurses_init: stash away ttyfd
This commit is contained in:
parent
c1f4219dc1
commit
4a406a8d8a
@ -8,7 +8,7 @@
|
||||
#include "version.h"
|
||||
|
||||
typedef struct notcurses {
|
||||
int ttyfd; // file descriptor for controlling tty
|
||||
int ttyfd; // file descriptor for controlling tty (takes stdin)
|
||||
} notcurses;
|
||||
|
||||
static const char NOTCURSES_VERSION[] =
|
||||
@ -37,17 +37,19 @@ notcurses* notcurses_init(void){
|
||||
if(ret == NULL){
|
||||
return ret;
|
||||
}
|
||||
// FIXME should we maybe use stdout if stdin was redirected?
|
||||
ret->ttyfd = STDIN_FILENO;
|
||||
return ret;
|
||||
}
|
||||
|
||||
int notcurses_stop(notcurses* nc){
|
||||
int ret = 0;
|
||||
if(nc){
|
||||
if(close(nc->ttyfd)){
|
||||
/*if(close(nc->ttyfd)){
|
||||
fprintf(stderr, "Error closing TTY file descriptor %d (%s)\n",
|
||||
nc->ttyfd, strerror(errno));
|
||||
ret = -1;
|
||||
}
|
||||
}*/
|
||||
free(nc);
|
||||
}
|
||||
return ret;
|
||||
|
Loading…
x
Reference in New Issue
Block a user