diff --git a/renderers/termbox2/clay_renderer_termbox2.c b/renderers/termbox2/clay_renderer_termbox2.c index 338b88b..4aed916 100644 --- a/renderers/termbox2/clay_renderer_termbox2.c +++ b/renderers/termbox2/clay_renderer_termbox2.c @@ -3,6 +3,8 @@ Copyright (c) 2025 Mivirl + altered by Godje (Sep 2025) + This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. @@ -1616,6 +1618,20 @@ void Clay_Termbox_Render(Clay_RenderCommandArray commands) Clay_StringSlice *text = &render_data.stringContents; int32_t i = 0; + + // culling text characters that are outside of the layout + int h_clip = 0 - cell_box.x; + while(h_clip > 0 && i < text->length){ + uint32_t ch = ' '; + int codepoint_length = tb_utf8_char_to_unicode(&ch, text->chars + i); + if (0 > codepoint_length) { + clay_tb_assert(false, "Invalid utf8"); + } + i += codepoint_length; + h_clip -= 1; + } + + // printing the rest of the characters for (int y = box_begin_y; y < box_end_y; ++y) { for (int x = box_begin_x; x < box_end_x;) { uint32_t ch = ' ';