From c1fe77108117eb95b5960e765bdbdd6a21a8caf9 Mon Sep 17 00:00:00 2001 From: June McEnroe Date: Wed, 8 Jun 2022 15:01:08 -0400 Subject: Indicate if still reading or no results --- bin/qf.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/bin/qf.c b/bin/qf.c index ba20483d..1fbf48b9 100644 --- a/bin/qf.c +++ b/bin/qf.c @@ -114,13 +114,17 @@ static void curse(void) { static size_t top; static size_t cur; +static bool reading = true; static void draw(void) { - int y, x; + int y = 0, x = 0; for (int i = 0; i < LINES; ++i) { move(i, 0); clrtoeol(); - if (top + i >= lines.len) continue; + if (top + i >= lines.len) { + addstr(reading ? "..." : !lines.len ? "No results" : ""); + break; + } struct Line line = lines.ptr[top + i]; if (top + i == cur) { getyx(stdscr, y, x); @@ -248,23 +252,23 @@ int main(int argc, char *argv[]) { if (error) errx(EX_USAGE, "invalid pattern"); } curse(); + draw(); struct pollfd fds[2] = { { .fd = STDERR_FILENO, .events = POLLIN }, { .fd = STDIN_FILENO, .events = POLLIN }, }; - int nfds = 2; size_t len = 0; size_t cap = 4096; char *buf = malloc(cap); if (!buf) err(EX_OSERR, "malloc"); - while (poll(fds, nfds, -1)) { + while (poll(fds, (reading ? 2 : 1), -1)) { if (fds[0].revents) { input(); } - if (nfds > 1 && fds[1].revents) { + if (reading && fds[1].revents) { ssize_t n = read(fds[1].fd, &buf[len], cap - len); if (n < 0) err(EX_IOERR, "read"); - if (!n) nfds--; + if (!n) reading = false; len += n; char *ptr = buf; for ( -- cgit 1.4.1 alue='committer'>committer
path: root/txt (unfollow)
Commit message (Expand)Author
2018-07-30Rename linux function in schemeJune McEnroe
2018-07-30Add gfx README and LICENSEJune McEnroe
2018-07-30Move graphical programs out of binJune McEnroe
2018-07-30Add Neckbeard DeathcampJune McEnroe
2018-07-29Just print rs1 in dtch restoreTermJune McEnroe
2018-07-29Fix dtch cmsg sizeJune McEnroe
2018-07-25Fix cfmakeraw callsJune McEnroe
2018-07-23Remove nasm from installJune McEnroe
2018-07-23Add monday.local to sshJune McEnroe
2018-07-23Restore LDLIBS alphabetical orderJune McEnroe
2018-07-23Use EV_SET in watchJune McEnroe
2018-07-23Link with -lcursesJune McEnroe
2018-07-22Fix scheme indentationJune McEnroe
2018-07-16Add -m option to glitchJune McEnroe
2018-07-16malloc deflate buffer in glitchJune McEnroe
2018-07-16malloc the deflate buffer in pngoJune McEnroe
2018-07-05Add shed bloodJune McEnroe