From 279f3336a8f6b31ca38bdd272c73aebd68fa88fe Mon Sep 17 00:00:00 2001 From: Miguel Date: Sat, 13 Oct 2018 00:57:28 +0200 Subject: ncurses arrow keys working etc --- fs/fd.c | 8 ++++++++ fs/fifo.c | 4 ++++ fs/fifo.h | 2 ++ fs/stdstreams.c | 1 + 4 files changed, 15 insertions(+) (limited to 'fs') diff --git a/fs/fd.c b/fs/fd.c index 740bf35..a9ca63a 100644 --- a/fs/fd.c +++ b/fs/fd.c @@ -246,6 +246,8 @@ int fds_from_pipe(fd pipefds[2]) mem+=4; *mem=1; + read.can_write=0; + read.read=pipe_get; wrt.read=0; @@ -312,6 +314,11 @@ fd fd_from_sysfs(void(*g)(ringbuffer *r,void (*f)(ringbuffer *r,char *fmt, ...)) return f; } +bool fifo_can_write(fifo *f) +{ + return !(f->full(f->data)); +} + fd fd_from_fifo(fifo* fif) { fd f; @@ -323,5 +330,6 @@ fd fd_from_fifo(fifo* fif) f.has=fifo_has; f.dupl=default_dupl; f.close=default_close; + f.can_write=fifo_can_write; return f; } diff --git a/fs/fifo.c b/fs/fifo.c index abd6c46..e5e071d 100644 --- a/fs/fifo.c +++ b/fs/fifo.c @@ -14,3 +14,7 @@ bool fifo_has(fifo* f) { return f->has(f->data); } +bool fifo_full(fifo* f) +{ + return f->full(f->data); +} diff --git a/fs/fifo.h b/fs/fifo.h index 92f3b75..27af389 100644 --- a/fs/fifo.h +++ b/fs/fifo.h @@ -11,6 +11,7 @@ typedef struct fifo_struct bool (*put)(struct fifo_struct*,uint8_t); uint8_t (*get)(struct fifo_struct*); bool (*has)(struct fifo_struct*); + bool (*full)(struct fifo_struct*); void *data; // opaque data }fifo; @@ -18,6 +19,7 @@ typedef struct fifo_struct bool fifo_put(fifo*,uint8_t); uint8_t fifo_get(fifo*); bool fifo_has(fifo*); +bool fifo_full(fifo*); fifo fifo_create_buffered(uint8_t size); #endif diff --git a/fs/stdstreams.c b/fs/stdstreams.c index 1cb9402..e5a2a08 100644 --- a/fs/stdstreams.c +++ b/fs/stdstreams.c @@ -52,5 +52,6 @@ fd fd_from_ringbuffer() f->put=ringbuffer_put; f->get=ringbuffer_get; f->has=ringbuffer_has; + f->full=ringbuffer_full; return fd_from_fifo(f); } -- cgit v1.2.3