From 0d90e8abd785ed897eb2ddccc1e97e8b32fef616 Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Tue, 19 Nov 2024 04:01:12 +0100 Subject: Add Tab keybind - Do not let chatty send empty messages - Add option to `markdown_to_raw()` to only get length of raw text --- ui.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'ui.c') diff --git a/ui.c b/ui.c index ed2aa24..c2e0ac9 100644 --- a/ui.c +++ b/ui.c @@ -207,20 +207,27 @@ tb_print_wrapped_with_markdown(u32 XOffset, u32 YOffset, u32 fg, u32 bg, // Return string without markdown markup characters using `is_markdown()` // ScratchArena is used to allocate space for the raw text +// If ScratchArena is null then it will only return then length of the raw string // Len should be characters + null terminator // Copies the null terminator as well raw_result markdown_to_raw(Arena* ScratchArena, u32* Text, u32 Len) { raw_result Result = {0}; - Result.Text = ScratchArena->addr; + if (ScratchArena) + { + Result.Text = ScratchArena->addr; + } for (u32 i = 0; i < Len; i++) { if (!is_markdown(Text[i])) { - u32* ch = ArenaPush(ScratchArena, sizeof(*ch)); - *ch = Text[i]; + if (ScratchArena) + { + u32* ch = ArenaPush(ScratchArena, sizeof(*ch)); + *ch = Text[i]; + } Result.Len++; } } -- cgit v1.2.3