Skip to content

Commit

Permalink
[drone] try and get some useful logs
Browse files Browse the repository at this point in the history
  • Loading branch information
dankamongmen committed Jan 6, 2022
1 parent 5cd0959 commit 2bb645c
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 8 deletions.
8 changes: 7 additions & 1 deletion .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ steps:
- cd build
- cmake .. -DCMAKE_BUILD_TYPE=Release -DUSE_STATIC=off -DUSE_GPM=on -DUSE_QRCODEGEN=on -DDFSG_BUILD=on
- make -j2
- ./notcurses-input < /dev/null
- env NOTCURSES_LOGLEVEL=7 ./notcurses-input < notcurses-input
- ./notcurses-input < notcurses-input
#- ./notcurses-info
#- ctest --output-on-failure
#- make install
Expand All @@ -37,7 +39,11 @@ steps:
- cd build
- cmake -DCMAKE_BUILD_TYPE=Release -DUSE_DEFLATE=off -DUSE_MULTIMEDIA=oiio -DUSE_QRCODEGEN=on ..
- make -j2
- ctest --output-on-failure
- echo "blockdev -v" | ./notcurses-input
- ./notcurses-input < /dev/null
- env NOTCURSES_LOGLEVEL=7 ./notcurses-input < notcurses-input
- ./notcurses-input < notcurses-input
- env NOTCURSES_LOGLEVEL=7 ctest --output-on-failure
- make install
- ldconfig
- cd ../cffi
Expand Down
17 changes: 12 additions & 5 deletions src/lib/direct.c
Original file line number Diff line number Diff line change
Expand Up @@ -973,7 +973,11 @@ int ncdirect_stop(ncdirect* nc){
char* ncdirect_readline(ncdirect* n, const char* prompt){
const char* u7 = get_escape(&n->tcache, ESCAPE_U7);
if(!u7){ // we probably *can*, but it would be a pita; screw it
logerror("can't readline without u7\n");
logerror("can't readline without u7");
return NULL;
}
if(n->eof){
logerror("already got EOF");
return NULL;
}
if(fprintf(n->ttyfp, "%s", prompt) < 0){
Expand Down Expand Up @@ -1005,15 +1009,18 @@ char* ncdirect_readline(ncdirect* n, const char* prompt){
if(ni.evtype == NCTYPE_RELEASE){
continue;
}
if(id == NCKEY_EOF || id == NCKEY_ENTER){
if(id == NCKEY_EOF || id == NCKEY_ENTER || (ncinput_ctrl_p(&ni) && id == 'd')){
if(id == NCKEY_ENTER){
if(fputc('\n', n->ttyfp) < 0){
free(str);
return NULL;
}
}else if(wused == 1){ // NCKEY_EOF without input returns NULL
free(str);
return NULL;
}else{
n->eof = 1;
if(wused == 1){ // NCKEY_EOF without input returns NULL
free(str);
return NULL;
}
}
char* ustr = ncwcsrtombs(str);
free(str);
Expand Down
16 changes: 15 additions & 1 deletion src/lib/in.c
Original file line number Diff line number Diff line change
Expand Up @@ -2303,6 +2303,7 @@ read_inputs_nblock(inputctx* ictx){
if(!eof && ictx->stdineof){
// we hit EOF; write an event to the readiness fd
mark_pipe_ready(ictx->readypipes);
pthread_cond_broadcast(&ictx->icond);
}
}
}
Expand Down Expand Up @@ -2380,7 +2381,9 @@ internal_get(inputctx* ictx, const struct timespec* ts, ncinput* ni){
return (uint32_t)-1;
}
pthread_mutex_lock(&ictx->ilock);
fprintf(stderr, "IVALID: %u EOF: %u IREAD: %u\n", ictx->ivalid, ictx->stdineof, ictx->iread);
while(!ictx->ivalid){
fprintf(stderr, "WHILE IVALID: %u EOF: %u IREAD: %u\n", ictx->ivalid, ictx->stdineof, ictx->iread);
if(ictx->stdineof){
pthread_mutex_unlock(&ictx->ilock);
logwarn("read eof on stdin");
Expand All @@ -2391,7 +2394,9 @@ internal_get(inputctx* ictx, const struct timespec* ts, ncinput* ni){
return NCKEY_EOF;
}
if(ts == NULL){
fprintf(stderr, "WAITING\n");
pthread_cond_wait(&ictx->icond, &ictx->ilock);
fprintf(stderr, "DONE WAITING\n");
}else{
int r = pthread_cond_timedwait(&ictx->icond, &ictx->ilock, ts);
if(r == ETIMEDOUT){
Expand All @@ -2411,6 +2416,7 @@ internal_get(inputctx* ictx, const struct timespec* ts, ncinput* ni){
}
}
id = ictx->inputs[ictx->iread].id;
fprintf(stderr, "GOT ID 0x%08x IREAD: %u\n", id, ictx->iread);
if(ni){
memcpy(ni, &ictx->inputs[ictx->iread], sizeof(*ni));
if(notcurses_ucs32_to_utf8(&ni->id, 1, (unsigned char*)ni->utf8, sizeof(ni->utf8)) < 0){
Expand Down Expand Up @@ -2470,7 +2476,15 @@ int notcurses_getvec(notcurses* n, const struct timespec* absdl,
}

uint32_t ncdirect_get(ncdirect* n, const struct timespec* absdl, ncinput* ni){
return internal_get(n->tcache.ictx, absdl, ni);
if(n->eof){
logerror("already got EOF");
return -1;
}
uint32_t r = internal_get(n->tcache.ictx, absdl, ni);
if(r == NCKEY_EOF){
n->eof = 1;
}
return r;
}

int get_cursor_location(inputctx* ictx, const char* u7, unsigned* y, unsigned* x){
Expand Down
1 change: 1 addition & 0 deletions src/lib/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ typedef struct ncdirect {
uint16_t stylemask; // current styles
uint64_t flags; // copied in ncdirect_init() from param
ncsharedstats stats; // stats! not as broadly used as in notcurses
unsigned eof; // have we seen EOF on stdin?
} ncdirect;

// Extracellular state for a cell during the render process. There is one
Expand Down
2 changes: 1 addition & 1 deletion src/lib/termdesc.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ extern "C" {
// disable key modifier options; this corresponds to a resource value of
// "-1", which cannot be set with the [>m sequence. supposedly, "[>m" by
// itself ought reset all of them, but this doesn't seem to work FIXME.
#define XTMODKEYSUNDO "\x1b[>2n\x1b[>4n"
#define XTMODKEYSUNDO "\x1b[>2m\x1b[>4m"

struct ncpile;
struct sprixel;
Expand Down

0 comments on commit 2bb645c

Please sign in to comment.