mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-06-26 10:54:28 +02:00
Only show tag in chart if utf8 character width is within the width
- Closes #309 Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
This commit is contained in:
parent
06a4235b10
commit
cea2e5d13f
1 changed files with 18 additions and 1 deletions
|
@ -35,6 +35,7 @@
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <timew.h>
|
#include <timew.h>
|
||||||
#include <Chart.h>
|
#include <Chart.h>
|
||||||
|
#include <utf8.h>
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
Chart::Chart (const ChartConfig& configuration) :
|
Chart::Chart (const ChartConfig& configuration) :
|
||||||
|
@ -493,7 +494,23 @@ void Chart::renderInterval (
|
||||||
if (width)
|
if (width)
|
||||||
{
|
{
|
||||||
std::vector<std::string> text_lines;
|
std::vector<std::string> text_lines;
|
||||||
|
|
||||||
|
// --
|
||||||
|
// The hang/memory consumption in #309 is due to a bug in libshared's wrapText
|
||||||
|
// It would be best to make wrapText/extractText width be the count of characters on the screen (and not a byte width).
|
||||||
|
// This fix will only show the tag if the utf8 character width is within the width (and it won't try to wrap),
|
||||||
|
// but otherwise functions normally for text where the utf-8 width matches the byte length of the label.
|
||||||
|
//
|
||||||
|
size_t utf8_characters = utf8_text_width (label);
|
||||||
|
if (static_cast <size_t>(width) >= utf8_characters)
|
||||||
|
{
|
||||||
|
text_lines.push_back (label);
|
||||||
|
}
|
||||||
|
else if (utf8_characters == label.size ())
|
||||||
|
{
|
||||||
wrapText (text_lines, label, width, false);
|
wrapText (text_lines, label, width, false);
|
||||||
|
}
|
||||||
|
// --
|
||||||
|
|
||||||
for (unsigned int i = 0; i < lines.size (); ++i)
|
for (unsigned int i = 0; i < lines.size (); ++i)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue