From ded2b6afb602719a52c3b4934cec5327dc8d3d1a Mon Sep 17 00:00:00 2001 From: C. McEnroe Date: Tue, 1 Sep 2020 20:35:17 -0400 Subject: Factor buffer out of ui In preparation for doing line wrapping outside of ncurses. --- chat.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'chat.h') diff --git a/chat.h b/chat.h index 3668bcd..d53c7fe 100644 --- a/chat.h +++ b/chat.h @@ -276,6 +276,23 @@ void uiFormat( void uiLoad(const char *name); int uiSave(const char *name); +enum { BufferCap = 1024 }; +struct Buffer; +struct Line { + enum Heat heat; + time_t time; + char *str; +}; +struct Buffer *bufferAlloc(void); +void bufferFree(struct Buffer *buffer); +const struct Line *bufferSoft(const struct Buffer *buffer, size_t i); +const struct Line *bufferHard(const struct Buffer *buffer, size_t i); +void bufferPush( + struct Buffer *buffer, int cols, + enum Heat heat, time_t time, const char *str +); +void bufferReflow(struct Buffer *buffer, int cols); + enum Edit { EditHead, EditTail, -- cgit 1.4.1-2-gfad0