Skip to content

Commit

Permalink
directvt#396 Implement word wrapping in window titles and in dtvt-apps
Browse files Browse the repository at this point in the history
  • Loading branch information
o-sdn-o committed Oct 16, 2023
1 parent 6885f4a commit 48035bd
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions src/netxs/desktopio/richtext.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,28 @@ namespace netxs::ui
outwidth = printout.coor.x + printout.size.x - textline.coor.x;

if constexpr (!Split)
if (printout.size.x > 1)
if (printout.size.x > 1 && textline.size.x > printout.size.x)
{
auto p = curpoint + printout.size.x - 1;
if (block.at(p).wdt() == 2)
auto n = printout.size.x - 1;
auto p = curpoint + n;
while (n)
{
--printout.size.x;
auto& c = block.at(p);
if (c.isspc() || c.wdt() == 3) break;
n--;
p--;
}
if (n > 0) // Cut by whitespace.
{
printout.size.x = n + 1;
}
else // Cut on a widechar boundary (CJK/Emoji).
{
auto p = curpoint + printout.size.x - 1;
if (block.at(p).wdt() == 2)
{
--printout.size.x;
}
}
}
}
Expand Down

0 comments on commit 48035bd

Please sign in to comment.