added a parameter to _BTextGapBuffer_::GetString() so that the caller knows how many bytes are really returned. password mode looks better now
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18965 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -3661,11 +3661,9 @@ BTextView::DrawLines(int32 startLine, int32 endLine, int32 startOffset, bool era
|
||||
view->PopState();
|
||||
}
|
||||
|
||||
const char *string = fText->GetString(offset, tabChars);
|
||||
// TODO: GetString() could return less or more bytes than requested
|
||||
// Improve the backend api so it's more robust and pass back the returned
|
||||
// bytes
|
||||
view->DrawString(string, tabChars);
|
||||
int32 returnedBytes = 0;
|
||||
const char *string = fText->GetString(offset, tabChars, &returnedBytes);
|
||||
view->DrawString(string, returnedBytes);
|
||||
|
||||
if (foundTab) {
|
||||
float penPos = PenLocation().x - fTextRect.left;
|
||||
|
||||
@@ -169,15 +169,15 @@ _BTextGapBuffer_::SizeGapTo(long inCount)
|
||||
|
||||
|
||||
const char *
|
||||
_BTextGapBuffer_::GetString(int32 fromOffset, int32 numBytes)
|
||||
_BTextGapBuffer_::GetString(int32 fromOffset, int32 numBytes, int32 *returnedBytes)
|
||||
{
|
||||
// numBytes won't necessarily be honored. This function could return more
|
||||
// bytes than specified (for example when in password mode)
|
||||
// TODO: Fix this, it's not very nice.
|
||||
char *result = "";
|
||||
|
||||
if (numBytes < 1)
|
||||
if (numBytes < 1) {
|
||||
if (returnedBytes != NULL)
|
||||
*returnedBytes = 0;
|
||||
return result;
|
||||
}
|
||||
|
||||
bool isStartBeforeGap = (fromOffset < fGapIndex);
|
||||
bool isEndBeforeGap = ((fromOffset + numBytes - 1) < fGapIndex);
|
||||
@@ -198,7 +198,10 @@ _BTextGapBuffer_::GetString(int32 fromOffset, int32 numBytes)
|
||||
|
||||
result = fScratchBuffer;
|
||||
}
|
||||
|
||||
|
||||
if (returnedBytes != NULL)
|
||||
*returnedBytes = numBytes;
|
||||
|
||||
// TODO: this could be improved. We are overwriting what we did some lines ago,
|
||||
// we could just avoid to do that.
|
||||
if (fPasswordMode) {
|
||||
@@ -216,7 +219,9 @@ _BTextGapBuffer_::GetString(int32 fromOffset, int32 numBytes)
|
||||
memcpy(scratchPtr, B_UTF8_BULLET, charLen);
|
||||
scratchPtr += charLen;
|
||||
}
|
||||
scratchPtr = '\0';
|
||||
scratchPtr = '\0';
|
||||
if (returnedBytes != NULL)
|
||||
*returnedBytes = newSize - 1;
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
|
||||
|
||||
class BFile;
|
||||
// _BTextGapBuffer_ class ------------------------------------------------------
|
||||
class _BTextGapBuffer_ {
|
||||
|
||||
public:
|
||||
@@ -27,32 +26,31 @@ virtual ~_BTextGapBuffer_();
|
||||
void MoveGapTo(int32 toIndex);
|
||||
void SizeGapTo(int32 inCount);
|
||||
|
||||
const char *GetString(int32 fromOffset, int32 numChars);
|
||||
bool FindChar(char inChar, int32 fromIndex, int32 *ioDelta);
|
||||
|
||||
const char *Text();
|
||||
const char *Text();
|
||||
int32 Length() const;
|
||||
char operator[](int32 index) const;
|
||||
|
||||
|
||||
// char *RealText();
|
||||
void GetString(int32 offset, int32 length, char *buffer);
|
||||
// void GetString(int32, int32 *);
|
||||
// char *RealText();
|
||||
const char *GetString(int32 fromOffset, int32 numBytes, int32 *returnedBytes);
|
||||
void GetString(int32 offset, int32 length, char *buffer);
|
||||
|
||||
char RealCharAt(int32 offset) const;
|
||||
char RealCharAt(int32 offset) const;
|
||||
|
||||
bool PasswordMode() const;
|
||||
void SetPasswordMode(bool);
|
||||
bool PasswordMode() const;
|
||||
void SetPasswordMode(bool);
|
||||
|
||||
// void Resize(int32 size);
|
||||
// void Resize(int32 size);
|
||||
|
||||
protected:
|
||||
int32 fExtraCount; // when realloc()-ing
|
||||
int32 fItemCount; // logical count
|
||||
char *fBuffer; // allocated memory
|
||||
int32 fItemCount; // logical count
|
||||
char *fBuffer; // allocated memory
|
||||
int32 fBufferCount; // physical count
|
||||
int32 fGapIndex; // gap position
|
||||
int32 fGapCount; // gap count
|
||||
int32 fGapIndex; // gap position
|
||||
int32 fGapCount; // gap count
|
||||
char *fScratchBuffer; // for GetString
|
||||
int32 fScratchSize; // scratch size
|
||||
bool fPasswordMode;
|
||||
|
||||
Reference in New Issue
Block a user