X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fjexer%2Fttree%2FTTreeItem.java;h=44c408b2bd3f6095bd8a27d758d76b0b233e3964;hb=505be508ae7d3fb48122be548b310a238cfb91eb;hp=901ce8590a78095bdf00a5831f86331b5b84d9e9;hpb=d6ee0801333ff93dffd851f4c1a44519c96c371d;p=fanfix.git diff --git a/src/jexer/ttree/TTreeItem.java b/src/jexer/ttree/TTreeItem.java index 901ce85..44c408b 100644 --- a/src/jexer/ttree/TTreeItem.java +++ b/src/jexer/ttree/TTreeItem.java @@ -3,7 +3,7 @@ * * The MIT License (MIT) * - * Copyright (C) 2017 Kevin Lamonte + * Copyright (C) 2019 Kevin Lamonte * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -34,6 +34,7 @@ import java.util.List; import jexer.TWidget; import jexer.bits.CellAttributes; import jexer.bits.GraphicsChars; +import jexer.bits.StringUtils; import jexer.event.TKeypressEvent; import jexer.event.TMouseEvent; import static jexer.TKeypress.*; @@ -248,7 +249,7 @@ public class TTreeItem extends TWidget { } // Blank out the background - getScreen().hLineXY(0, 0, getWidth(), ' ', color); + hLineXY(0, 0, getWidth(), ' ', color); String line = prefix; if (level > 0) { @@ -264,20 +265,17 @@ public class TTreeItem extends TWidget { line += " "; } } - getScreen().putStringXY(offset, 0, line, color); + putStringXY(offset, 0, line, color); if (selected) { - getScreen().putStringXY(offset + line.length(), 0, text, - selectedColor); + putStringXY(offset + StringUtils.width(line), 0, text, selectedColor); } else { - getScreen().putStringXY(offset + line.length(), 0, text, textColor); + putStringXY(offset + StringUtils.width(line), 0, text, textColor); } if ((level > 0) && (expandable)) { if (expanded) { - getScreen().putCharXY(offset + getExpanderX(), 0, '-', - expanderColor); + putCharXY(offset + getExpanderX(), 0, '-', expanderColor); } else { - getScreen().putCharXY(offset + getExpanderX(), 0, '+', - expanderColor); + putCharXY(offset + getExpanderX(), 0, '+', expanderColor); } } } @@ -405,10 +403,10 @@ public class TTreeItem extends TWidget { * @return the maximum number of columns for this item or its children */ public int getMaximumColumn() { - int max = prefix.length() + 4 + text.length(); + int max = prefix.length() + 4 + StringUtils.width(text); for (TWidget widget: getChildren()) { TTreeItem item = (TTreeItem) widget; - int n = item.prefix.length() + 4 + item.text.length(); + int n = item.prefix.length() + 4 + StringUtils.width(item.text); if (n > max) { max = n; }