Truncate background image name in multibyte-aware way
This commit is contained in:
@@ -561,16 +561,15 @@ Image::Image(BPath path)
|
|||||||
fBitmap(NULL),
|
fBitmap(NULL),
|
||||||
fPath(path)
|
fPath(path)
|
||||||
{
|
{
|
||||||
const int32 kMaxWidth = 40;
|
const int32 kMaxNameChars = 40;
|
||||||
fName = path.Leaf();
|
fName = path.Leaf();
|
||||||
int extra = fName.Length() - kMaxWidth;
|
int extra = fName.CountChars() - kMaxNameChars;
|
||||||
if (extra > 0) {
|
if (extra > 0) {
|
||||||
|
BString extension;
|
||||||
int offset = fName.FindLast('.');
|
int offset = fName.FindLast('.');
|
||||||
if (offset > 0) {
|
if (offset > 0)
|
||||||
offset++;
|
fName.CopyInto(extension, ++offset, -1);
|
||||||
fName.Truncate(offset - extra) << B_UTF8_ELLIPSIS;
|
fName.TruncateChars(kMaxNameChars) << B_UTF8_ELLIPSIS << extension;
|
||||||
fName.Append(path.Leaf() + offset);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user