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:
Stephan Aßmus
2007-11-01 15:58:07 +00:00
parent 6a0f79107d
commit 23b6ac7e15
3 changed files with 20 additions and 11 deletions
+13 -6
View File
@@ -1233,8 +1233,9 @@ BTextView::Copy(BClipboard *clipboard)
BMessage *clip = clipboard->Data(); BMessage *clip = clipboard->Data();
if (clip != NULL) { if (clip != NULL) {
clip->AddData("text/plain", B_MIME_TYPE, Text() + fSelStart, int32 numBytes = fSelEnd - fSelStart;
fSelEnd - fSelStart); const char* text = fText->GetString(fSelStart, &numBytes);
clip->AddData("text/plain", B_MIME_TYPE, text, numBytes);
int32 size; int32 size;
if (fStylable) { if (fStylable) {
@@ -2642,8 +2643,9 @@ BTextView::GetDragParameters(BMessage *drag, BBitmap **bitmap, BPoint *point,
drag->AddInt32("be_actions", B_TRASH_TARGET); drag->AddInt32("be_actions", B_TRASH_TARGET);
// add the text // add the text
drag->AddData("text/plain", B_MIME_TYPE, fText->RealText() + fSelStart, int32 numBytes = fSelEnd - fSelStart;
fSelEnd - fSelStart); const char* text = fText->GetString(fSelStart, &numBytes);
drag->AddData("text/plain", B_MIME_TYPE, text, numBytes);
// add the corresponding styles // add the corresponding styles
int32 size = 0; int32 size = 0;
@@ -3422,9 +3424,14 @@ BTextView::_StyledWidth(int32 fromOffset, int32 length, float *outAscent,
LockWidthBuffer(); LockWidthBuffer();
result += sWidths->StringWidth(*fText, fromOffset, numChars, font); result += sWidths->StringWidth(*fText, fromOffset, numChars, font);
UnlockWidthBuffer(); UnlockWidthBuffer();
} else } else {
#endif
const char* text = fText->GetString(fromOffset, &numChars);
result += font->StringWidth(text, numChars);
#if USE_WIDTHBUFFER
}
#endif #endif
result += font->StringWidth(fText->RealText() + fromOffset, numChars);
fromOffset += numChars; fromOffset += numChars;
length -= numChars; length -= numChars;
@@ -217,7 +217,8 @@ _BTextGapBuffer_::GetString(int32 fromOffset, int32 *_numBytes)
memcpy(scratchPtr, B_UTF8_BULLET, charLen); memcpy(scratchPtr, B_UTF8_BULLET, charLen);
scratchPtr += charLen; scratchPtr += charLen;
} }
*_numBytes = newSize - 1;
*_numBytes = newSize;
} }
return result; return result;
@@ -148,7 +148,8 @@ float
_BWidthBuffer_::StringWidth(_BTextGapBuffer_ &inBuffer, int32 fromOffset, int32 length, _BWidthBuffer_::StringWidth(_BTextGapBuffer_ &inBuffer, int32 fromOffset, int32 length,
const BFont *inStyle) const BFont *inStyle)
{ {
return StringWidth(inBuffer.Text(), fromOffset, length, inStyle); const char* text = inBuffer.GetString(fromOffset, &length);
return StringWidth(text, 0, length, inStyle);
} }