shithub: libacme

Download patch

ref: 15b9d1f9b76b6c3b0240f535c452b4023353b227
parent: 0f9a8ea6531e5ae44671a24c82d3b2f7e4c64be8
author: james palmer <foura@biobuf.link>
date: Wed Jun 2 13:30:15 EDT 2021

add utility functions for writing to the body and errors

--- a/acme.h
+++ b/acme.h
@@ -19,6 +19,9 @@
 void	wintitle(Win *, char *, ...);
 void	winctl(Win *, char *, ...);
 void	winclear(Win *);
+void	winappend(Win *, char *, ...);
+void	winerror(Win *, char *,	...);
+
 
 typedef struct Event Event;
 struct Event {
--- a/window.c
+++ b/window.c
@@ -78,3 +78,28 @@
 	fprint(w->addr, ",");
 	fprint(w->data, "");
 }
+
+void
+winappend(Win *w, char *fmt, ...)
+{
+	va_list args;
+	
+	va_start(args, fmt);
+	vfprint(w->body, fmt, args);
+	va_end(args);
+}
+
+void
+winerror(Win *w, char *fmt, ...)
+{
+	int errorfd;
+	va_list args;
+	
+	errorfd = winopen(w, "errors", OWRITE);
+	
+	va_start(args, fmt);
+	vfprint(w->body, fmt, args);
+	va_end(args);
+	
+	close(errorfd);
+}