X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fjexer%2FTPasswordField.java;h=9c200d7dc7dcfea44a2fef0d3f59f8df9505ec81;hb=12b90437b5f22c2ae6e9b9b14c3b62b60f6143e5;hp=6b00f4a6653d3ba5bef763b1b66b10ba6c56d265;hpb=382bc294dd88b71639fdd6c73216d2519635a080;p=fanfix.git diff --git a/src/jexer/TPasswordField.java b/src/jexer/TPasswordField.java index 6b00f4a..9c200d7 100644 --- a/src/jexer/TPasswordField.java +++ b/src/jexer/TPasswordField.java @@ -30,6 +30,7 @@ package jexer; import jexer.bits.CellAttributes; import jexer.bits.GraphicsChars; +import jexer.bits.StringUtils; /** * TPasswordField implements an editable text field that displays @@ -112,15 +113,16 @@ public class TPasswordField extends TField { } int end = windowStart + getWidth(); - if (end > text.length()) { - end = text.length(); + if (end > StringUtils.width(text)) { + end = StringUtils.width(text); } hLineXY(0, 0, getWidth(), backgroundChar, fieldColor); if (showStars) { hLineXY(0, 0, getWidth() - 2, '*', fieldColor); } else { - putStringXY(0, 0, text.substring(windowStart, end), fieldColor); + putStringXY(0, 0, text.substring(screenToTextPosition(windowStart), + screenToTextPosition(end)), fieldColor); } // Fix the cursor, it will be rendered by TApplication.drawAll().