X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fjexer%2FTList.java;h=253e40972a49ab133211bdff156708163b08eec8;hb=6738825512004e0992555778e7124b568dd5044c;hp=f9e721621eda3a76c69f47d33c0132ca37f54722;hpb=9577a9d02a8b04eaf70c26fa33ec721f6e46e9fb;p=nikiroo-utils.git diff --git a/src/jexer/TList.java b/src/jexer/TList.java index f9e7216..253e409 100644 --- a/src/jexer/TList.java +++ b/src/jexer/TList.java @@ -32,6 +32,7 @@ import java.util.ArrayList; import java.util.List; import jexer.bits.CellAttributes; +import jexer.bits.StringUtils; import jexer.event.TKeypressEvent; import jexer.event.TMouseEvent; import static jexer.TKeypress.*; @@ -326,6 +327,31 @@ public class TList extends TScrollableWidget { // TScrollableWidget ------------------------------------------------------ // ------------------------------------------------------------------------ + /** + * Override TWidget's width: we need to set child widget widths. + * + * @param width new widget width + */ + @Override + public void setWidth(final int width) { + super.setWidth(width); + hScroller.setWidth(getWidth() - 1); + vScroller.setX(getWidth() - 1); + } + + /** + * Override TWidget's height: we need to set child widget heights. + * time. + * + * @param height new widget height + */ + @Override + public void setHeight(final int height) { + super.setHeight(height); + hScroller.setY(getHeight() - 1); + vScroller.setHeight(getHeight() - 1); + } + /** * Resize for a new width/height. */ @@ -338,8 +364,9 @@ public class TList extends TScrollableWidget { for (int i = 0; i < strings.size(); i++) { String line = strings.get(i); - if (line.length() > maxLineWidth) { - maxLineWidth = line.length(); + int lineLength = StringUtils.width(line); + if (lineLength > maxLineWidth) { + maxLineWidth = lineLength; } }