9 #include "../../../common/utilities/imgui/wrap.h" 10 #include "../../../third-party/imgui/imgui.h" 16 const char * text_end,
17 bool hide_text_after_double_hash,
20 if (!text)
return ImVec2(0.0
f, 0.0
f);
22 float total_size = 0.0f;
25 if( *text ==
'i' || *text ==
'j' )
31 return ImVec2( total_size, 0.0
f );
44 CHECK(
wrap(
"abc\nabc", 0 ) ==
"abc\nabc" );
45 CHECK(
wrap(
"abc abc", 5 ) ==
"abc abc" );
50 CHECK(
wrap(
"abc\nabc", 100 ) ==
"abc\nabc" );
51 CHECK(
wrap(
"abc abc a", 100 ) ==
"abc abc a" );
54 CHECK(
wrap(
"abcdefgh", 40 ) ==
"abcdefgh" );
55 CHECK(
wrap(
"aabbccddff das ds fr", 50 ) ==
"aabbccddff\ndas\nds fr" );
56 CHECK(
wrap(
"das aabbccddff ds fr", 50 ) ==
"das\naabbccddff\nds fr" );
59 CHECK(
wrap(
"abcde abcde", 50 ) ==
"abcde\nabcde" );
62 CHECK(
wrap(
"aaaa bbbb cc", 100) ==
"aaaa bbbb\ncc");
64 CHECK(
wrap(
"aaaa iijj cc", 100) ==
"aaaa iijj cc");
68 CHECK(
wrap(
"this is the first line\nthis is the second line\nthis is the last line", 150 )
69 ==
"this is the\nfirst line\nthis is the\nsecond line\nthis is the last\nline" );
71 CHECK(
wrap(
"this is the first line\nthis is the second line\nthis is the last line", 60 )
72 ==
"this is\nthe\nfirst\nline\nthis is\nthe\nsecond\nline\nthis is\nthe\nlast\nline" );
IMGUI_API ImVec2 CalcTextSize(const char *text, const char *text_end=NULL, bool hide_text_after_double_hash=false, float wrap_width=-1.0f)
TEST_CASE("wrap-text","[string]")
std::string wrap(const std::string &text, int wrap_pixels_width)