aboutsummaryrefslogtreecommitdiff
path: root/teensy/teensy_context.c
diff options
context:
space:
mode:
authoriamcheeseman <[email protected]>2026-05-15 07:23:41 -0400
committeriamcheeseman <[email protected]>2026-05-15 07:23:41 -0400
commitbea8415263dddc1cb892c121446194688703bf27 (patch)
tree8f837d89fe4fc78a67b6fc51042f86ab5a9f2be4 /teensy/teensy_context.c
parentcfde830b98e235cd2b5a72dca68160c2c1ff3b68 (diff)
allow tyui to format text
Diffstat (limited to 'teensy/teensy_context.c')
-rw-r--r--teensy/teensy_context.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/teensy/teensy_context.c b/teensy/teensy_context.c
index 91b9b90..ad7c79e 100644
--- a/teensy/teensy_context.c
+++ b/teensy/teensy_context.c
@@ -1,6 +1,7 @@
#include "teensy_context.h"
#include <math.h>
+#include <stdarg.h>
#include <time.h>
#include "teensy_platform.h"
@@ -99,3 +100,27 @@ void ty_sleep(uint64_t ms)
ts.tv_nsec = (ms % 1000) * 1000000;
nanosleep(&ts, NULL);
}
+
+char *ty_format_args(const char *fmt, va_list list)
+{
+ va_list args;
+ va_copy(args, list);
+ int len = vsnprintf(NULL, 0, fmt, args);
+ char *text = ty_talloc(sizeof(char) * (len + 1));
+ va_end(args);
+
+ va_copy(args, list);
+ vsnprintf(text, len + 1, fmt, args);
+ va_end(args);
+
+ return text;
+}
+
+char *ty_format(const char *fmt, ...)
+{
+ va_list args;
+ va_start(args, fmt);
+ char *text = ty_format_args(fmt, args);
+ va_end(args);
+ return text;
+}