From: Kevin Lamonte Date: Tue, 6 Aug 2019 12:28:13 +0000 (-0500) Subject: #35 wip X-Git-Url: https://git.nikiroo.be/?a=commitdiff_plain;h=97bc3f29f12d64d27d49b0d61947d15dfa64d156;p=fanfix-jexer.git #35 wip --- diff --git a/src/jexer/TWindow.java b/src/jexer/TWindow.java index b8513c4..77bd2b3 100644 --- a/src/jexer/TWindow.java +++ b/src/jexer/TWindow.java @@ -34,6 +34,7 @@ import java.util.Set; import jexer.backend.Screen; import jexer.bits.CellAttributes; import jexer.bits.GraphicsChars; +import jexer.bits.StringUtils; import jexer.event.TCommandEvent; import jexer.event.TKeypressEvent; import jexer.event.TMenuEvent; @@ -886,10 +887,11 @@ public class TWindow extends TWidget { true); // Draw the title - int titleLeft = (getWidth() - title.length() - 2) / 2; + int titleLength = StringUtils.width(title); + int titleLeft = (getWidth() - titleLength - 2) / 2; putCharXY(titleLeft, 0, ' ', border); - putStringXY(titleLeft + 1, 0, title); - putCharXY(titleLeft + title.length() + 1, 0, ' ', border); + putStringXY(titleLeft + 1, 0, title, border); + putCharXY(titleLeft + titleLength + 1, 0, ' ', border); if (isActive()) { diff --git a/src/jexer/backend/LogicalScreen.java b/src/jexer/backend/LogicalScreen.java index 3149e68..9af633d 100644 --- a/src/jexer/backend/LogicalScreen.java +++ b/src/jexer/backend/LogicalScreen.java @@ -523,7 +523,7 @@ public class LogicalScreen implements Screen { for (int j = 0; j < str.length(); j++) { char ch = str.charAt(j); putCharXY(i, y, ch, attr); - i++; + i += StringUtils.width(ch); if (i == width) { break; } @@ -544,7 +544,7 @@ public class LogicalScreen implements Screen { for (int j = 0; j < str.length(); j++) { char ch = str.charAt(j); putCharXY(i, y, ch); - i++; + i += StringUtils.width(ch); if (i == width) { break; }