this should complete the work on password mode for BTextView:
* fixed +/- 1 bug in _BTextGapBuffer_::GetString() * used the correct text and offsets in BTextView whenever the visible text is to be used * when copying to the clipboard, copy the bullets * when dragging the text, drag the bullets TODO: * test more with UTF8 chars in the original text (I am unsure if fSelStart and so on is really in bytes rather than glyphs) * test with multiple font styles git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22787 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1233,8 +1233,9 @@ BTextView::Copy(BClipboard *clipboard)
|
||||
|
||||
BMessage *clip = clipboard->Data();
|
||||
if (clip != NULL) {
|
||||
clip->AddData("text/plain", B_MIME_TYPE, Text() + fSelStart,
|
||||
fSelEnd - fSelStart);
|
||||
int32 numBytes = fSelEnd - fSelStart;
|
||||
const char* text = fText->GetString(fSelStart, &numBytes);
|
||||
clip->AddData("text/plain", B_MIME_TYPE, text, numBytes);
|
||||
|
||||
int32 size;
|
||||
if (fStylable) {
|
||||
@@ -2642,8 +2643,9 @@ BTextView::GetDragParameters(BMessage *drag, BBitmap **bitmap, BPoint *point,
|
||||
drag->AddInt32("be_actions", B_TRASH_TARGET);
|
||||
|
||||
// add the text
|
||||
drag->AddData("text/plain", B_MIME_TYPE, fText->RealText() + fSelStart,
|
||||
fSelEnd - fSelStart);
|
||||
int32 numBytes = fSelEnd - fSelStart;
|
||||
const char* text = fText->GetString(fSelStart, &numBytes);
|
||||
drag->AddData("text/plain", B_MIME_TYPE, text, numBytes);
|
||||
|
||||
// add the corresponding styles
|
||||
int32 size = 0;
|
||||
@@ -3422,9 +3424,14 @@ BTextView::_StyledWidth(int32 fromOffset, int32 length, float *outAscent,
|
||||
LockWidthBuffer();
|
||||
result += sWidths->StringWidth(*fText, fromOffset, numChars, font);
|
||||
UnlockWidthBuffer();
|
||||
} else
|
||||
} else {
|
||||
#endif
|
||||
const char* text = fText->GetString(fromOffset, &numChars);
|
||||
result += font->StringWidth(text, numChars);
|
||||
|
||||
#if USE_WIDTHBUFFER
|
||||
}
|
||||
#endif
|
||||
result += font->StringWidth(fText->RealText() + fromOffset, numChars);
|
||||
|
||||
fromOffset += numChars;
|
||||
length -= numChars;
|
||||
|
||||
@@ -217,7 +217,8 @@ _BTextGapBuffer_::GetString(int32 fromOffset, int32 *_numBytes)
|
||||
memcpy(scratchPtr, B_UTF8_BULLET, charLen);
|
||||
scratchPtr += charLen;
|
||||
}
|
||||
*_numBytes = newSize - 1;
|
||||
|
||||
*_numBytes = newSize;
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
@@ -148,7 +148,8 @@ float
|
||||
_BWidthBuffer_::StringWidth(_BTextGapBuffer_ &inBuffer, int32 fromOffset, int32 length,
|
||||
const BFont *inStyle)
|
||||
{
|
||||
return StringWidth(inBuffer.Text(), fromOffset, length, inStyle);
|
||||
const char* text = inBuffer.GetString(fromOffset, &length);
|
||||
return StringWidth(text, 0, length, inStyle);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user