is_test_tty: check for /dev/tty #1668

pull/1670/head
nick black 3 years ago committed by Nick Black
parent a903f32cd6
commit 0b197fe19b

@ -1293,9 +1293,6 @@ void nclog(const char* fmt, ...);
bool is_linux_console(const notcurses* nc, unsigned no_font_changes);
// get a file descriptor for the controlling tty device, -1 on error
int get_controlling_tty(FILE* fp);
// logging
#define logerror(nc, fmt, ...) do{ \
if(nc){ if((nc)->loglevel >= NCLOGLEVEL_ERROR){ \

@ -105,7 +105,7 @@ TEST_CASE("DirectMode") {
}
SUBCASE("CursorPostGlyphRender") {
if(is_test_tty(stdout)){
if(is_test_tty()){
auto dirf = ncdirectf_from_file(nc_, find_data("worldmap.png"));
REQUIRE(nullptr != dirf);
auto ncdv = ncdirectf_render(nc_, dirf, NCBLIT_1x1, NCSCALE_NONE, 0, 0);
@ -124,7 +124,7 @@ TEST_CASE("DirectMode") {
}
SUBCASE("CursorPostSprixel") {
if(is_test_tty(stdout)){
if(is_test_tty()){
if(ncdirect_check_pixel_support(nc_) > 0){
auto dirf = ncdirectf_from_file(nc_, find_data("worldmap.png"));
REQUIRE(nullptr != dirf);

@ -31,14 +31,13 @@ auto find_data(const char* datum) -> char* {
return strdup(p.c_str());
}
auto is_test_tty(FILE* fp) -> bool {
int fd = fileno(fp);
if(fd >= 0){
if(isatty(fd)){
return true;
}
auto is_test_tty() -> bool {
int fd = open("/dev/tty", O_RDWR);
if(fd < 0){
return false;
}
return false;
close(fd);
return true;
}
static void

@ -10,7 +10,7 @@
#include <ncpp/_exceptions.hh>
#include "internal.h"
auto is_test_tty(FILE* fp) -> bool;
auto is_test_tty() -> bool;
auto find_data(const char* datum) -> char*;
auto testing_notcurses() -> struct notcurses*;
auto ncreel_validate(const ncreel* n) -> bool;

Loading…
Cancel
Save