git://git.nikiroo.be
/
fanfix.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
stubs for editor copy/paste
[fanfix.git]
/
src
/
jexer
/
TPasswordField.java
diff --git
a/src/jexer/TPasswordField.java
b/src/jexer/TPasswordField.java
index 696598b94339ac77935b6ff5a51f018244ca6c25..9c200d7dc7dcfea44a2fef0d3f59f8df9505ec81 100644
(file)
--- a/
src/jexer/TPasswordField.java
+++ b/
src/jexer/TPasswordField.java
@@
-3,7
+3,7
@@
*
* The MIT License (MIT)
*
*
* The MIT License (MIT)
*
- * Copyright (C) 201
7
Kevin Lamonte
+ * Copyright (C) 201
9
Kevin Lamonte
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@
-30,9
+30,11
@@
package jexer;
import jexer.bits.CellAttributes;
import jexer.bits.GraphicsChars;
import jexer.bits.CellAttributes;
import jexer.bits.GraphicsChars;
+import jexer.bits.StringUtils;
/**
/**
- * TField implements an editable text field.
+ * TPasswordField implements an editable text field that displays
+ * stars/asterisks when it is not active.
*/
public class TPasswordField extends TField {
*/
public class TPasswordField extends TField {
@@
-111,17
+113,16
@@
public class TPasswordField extends TField {
}
int end = windowStart + getWidth();
}
int end = windowStart + getWidth();
- if (end >
text.length(
)) {
- end =
text.length(
);
+ if (end >
StringUtils.width(text
)) {
+ end =
StringUtils.width(text
);
}
}
-
getScreen().hLineXY(0, 0, getWidth(), GraphicsChars.HATCH
, fieldColor);
+
hLineXY(0, 0, getWidth(), backgroundChar
, fieldColor);
if (showStars) {
if (showStars) {
- getScreen().hLineXY(0, 0, getWidth() - 2, '*',
- fieldColor);
+ hLineXY(0, 0, getWidth() - 2, '*', fieldColor);
} else {
} else {
-
getScreen().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().
}
// Fix the cursor, it will be rendered by TApplication.drawAll().