Automatic whitespace cleanup, no functional change.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36301 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -48,18 +48,18 @@ TextGapBuffer::InsertText(const char *inText, int32 inNumItems, int32 inAtIndex)
|
|||||||
{
|
{
|
||||||
if (inNumItems < 1)
|
if (inNumItems < 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
inAtIndex = (inAtIndex > fItemCount) ? fItemCount : inAtIndex;
|
inAtIndex = (inAtIndex > fItemCount) ? fItemCount : inAtIndex;
|
||||||
inAtIndex = (inAtIndex < 0) ? 0 : inAtIndex;
|
inAtIndex = (inAtIndex < 0) ? 0 : inAtIndex;
|
||||||
|
|
||||||
if (inAtIndex != fGapIndex)
|
if (inAtIndex != fGapIndex)
|
||||||
MoveGapTo(inAtIndex);
|
MoveGapTo(inAtIndex);
|
||||||
|
|
||||||
if (fGapCount < inNumItems)
|
if (fGapCount < inNumItems)
|
||||||
SizeGapTo(inNumItems + fExtraCount);
|
SizeGapTo(inNumItems + fExtraCount);
|
||||||
|
|
||||||
memcpy(fBuffer + fGapIndex, inText, inNumItems);
|
memcpy(fBuffer + fGapIndex, inText, inNumItems);
|
||||||
|
|
||||||
fGapCount -= inNumItems;
|
fGapCount -= inNumItems;
|
||||||
fGapIndex += inNumItems;
|
fGapIndex += inNumItems;
|
||||||
fItemCount += inNumItems;
|
fItemCount += inNumItems;
|
||||||
@@ -74,7 +74,7 @@ TextGapBuffer::InsertText(BFile *file, int32 fileOffset, int32 inNumItems, int32
|
|||||||
if (file->GetSize(&fileSize) != B_OK
|
if (file->GetSize(&fileSize) != B_OK
|
||||||
|| !file->IsReadable())
|
|| !file->IsReadable())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Clamp the text length to the file size
|
// Clamp the text length to the file size
|
||||||
fileSize -= fileOffset;
|
fileSize -= fileOffset;
|
||||||
|
|
||||||
@@ -86,13 +86,13 @@ TextGapBuffer::InsertText(BFile *file, int32 fileOffset, int32 inNumItems, int32
|
|||||||
|
|
||||||
inAtIndex = (inAtIndex > fItemCount) ? fItemCount : inAtIndex;
|
inAtIndex = (inAtIndex > fItemCount) ? fItemCount : inAtIndex;
|
||||||
inAtIndex = (inAtIndex < 0) ? 0 : inAtIndex;
|
inAtIndex = (inAtIndex < 0) ? 0 : inAtIndex;
|
||||||
|
|
||||||
if (inAtIndex != fGapIndex)
|
if (inAtIndex != fGapIndex)
|
||||||
MoveGapTo(inAtIndex);
|
MoveGapTo(inAtIndex);
|
||||||
|
|
||||||
if (fGapCount < inNumItems)
|
if (fGapCount < inNumItems)
|
||||||
SizeGapTo(inNumItems + fExtraCount);
|
SizeGapTo(inNumItems + fExtraCount);
|
||||||
|
|
||||||
// Finally, read the data and put it into the buffer
|
// Finally, read the data and put it into the buffer
|
||||||
if (file->ReadAt(fileOffset, fBuffer + fGapIndex, inNumItems) > 0) {
|
if (file->ReadAt(fileOffset, fBuffer + fGapIndex, inNumItems) > 0) {
|
||||||
fGapCount -= inNumItems;
|
fGapCount -= inNumItems;
|
||||||
@@ -107,20 +107,20 @@ TextGapBuffer::RemoveRange(int32 start, int32 end)
|
|||||||
{
|
{
|
||||||
long inAtIndex = start;
|
long inAtIndex = start;
|
||||||
long inNumItems = end - start;
|
long inNumItems = end - start;
|
||||||
|
|
||||||
if (inNumItems < 1)
|
if (inNumItems < 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
inAtIndex = (inAtIndex > fItemCount - 1) ? (fItemCount - 1) : inAtIndex;
|
inAtIndex = (inAtIndex > fItemCount - 1) ? (fItemCount - 1) : inAtIndex;
|
||||||
inAtIndex = (inAtIndex < 0) ? 0 : inAtIndex;
|
inAtIndex = (inAtIndex < 0) ? 0 : inAtIndex;
|
||||||
|
|
||||||
MoveGapTo(inAtIndex);
|
MoveGapTo(inAtIndex);
|
||||||
|
|
||||||
fGapCount += inNumItems;
|
fGapCount += inNumItems;
|
||||||
fItemCount -= inNumItems;
|
fItemCount -= inNumItems;
|
||||||
|
|
||||||
if (fGapCount > fExtraCount)
|
if (fGapCount > fExtraCount)
|
||||||
SizeGapTo(fExtraCount);
|
SizeGapTo(fExtraCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -129,7 +129,7 @@ TextGapBuffer::MoveGapTo(int32 toIndex)
|
|||||||
{
|
{
|
||||||
if (toIndex == fGapIndex)
|
if (toIndex == fGapIndex)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
long gapEndIndex = fGapIndex + fGapCount;
|
long gapEndIndex = fGapIndex + fGapCount;
|
||||||
long srcIndex = 0;
|
long srcIndex = 0;
|
||||||
long dstIndex = 0;
|
long dstIndex = 0;
|
||||||
@@ -145,9 +145,9 @@ TextGapBuffer::MoveGapTo(int32 toIndex)
|
|||||||
dstIndex = toIndex + (gapEndIndex - fGapIndex);
|
dstIndex = toIndex + (gapEndIndex - fGapIndex);
|
||||||
count = gapEndIndex - dstIndex;
|
count = gapEndIndex - dstIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count > 0)
|
if (count > 0)
|
||||||
memmove(fBuffer + dstIndex, fBuffer + srcIndex, count);
|
memmove(fBuffer + dstIndex, fBuffer + srcIndex, count);
|
||||||
|
|
||||||
fGapIndex = toIndex;
|
fGapIndex = toIndex;
|
||||||
}
|
}
|
||||||
@@ -158,10 +158,10 @@ TextGapBuffer::SizeGapTo(long inCount)
|
|||||||
{
|
{
|
||||||
if (inCount == fGapCount)
|
if (inCount == fGapCount)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
fBuffer = (char *)realloc(fBuffer, fItemCount + inCount);
|
fBuffer = (char *)realloc(fBuffer, fItemCount + inCount);
|
||||||
memmove(fBuffer + fGapIndex + inCount,
|
memmove(fBuffer + fGapIndex + inCount,
|
||||||
fBuffer + fGapIndex + fGapCount,
|
fBuffer + fGapIndex + fGapCount,
|
||||||
fBufferCount - (fGapIndex + fGapCount));
|
fBufferCount - (fGapIndex + fGapCount));
|
||||||
|
|
||||||
fGapCount = inCount;
|
fGapCount = inCount;
|
||||||
@@ -179,7 +179,7 @@ TextGapBuffer::GetString(int32 fromOffset, int32 *_numBytes)
|
|||||||
int32 numBytes = *_numBytes;
|
int32 numBytes = *_numBytes;
|
||||||
if (numBytes < 1)
|
if (numBytes < 1)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
bool isStartBeforeGap = (fromOffset < fGapIndex);
|
bool isStartBeforeGap = (fromOffset < fGapIndex);
|
||||||
bool isEndBeforeGap = ((fromOffset + numBytes - 1) < fGapIndex);
|
bool isEndBeforeGap = ((fromOffset + numBytes - 1) < fGapIndex);
|
||||||
|
|
||||||
@@ -187,13 +187,13 @@ TextGapBuffer::GetString(int32 fromOffset, int32 *_numBytes)
|
|||||||
result = fBuffer + fromOffset;
|
result = fBuffer + fromOffset;
|
||||||
if (!isStartBeforeGap)
|
if (!isStartBeforeGap)
|
||||||
result += fGapCount;
|
result += fGapCount;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (fScratchSize < numBytes) {
|
if (fScratchSize < numBytes) {
|
||||||
fScratchBuffer = (char *)realloc(fScratchBuffer, numBytes);
|
fScratchBuffer = (char *)realloc(fScratchBuffer, numBytes);
|
||||||
fScratchSize = numBytes;
|
fScratchSize = numBytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (long i = 0; i < numBytes; i++)
|
for (long i = 0; i < numBytes; i++)
|
||||||
fScratchBuffer[i] = RealCharAt(fromOffset + i);
|
fScratchBuffer[i] = RealCharAt(fromOffset + i);
|
||||||
|
|
||||||
@@ -219,14 +219,14 @@ TextGapBuffer::GetString(int32 fromOffset, int32 *_numBytes)
|
|||||||
scratchPtr += charLen;
|
scratchPtr += charLen;
|
||||||
}
|
}
|
||||||
|
|
||||||
*_numBytes = newSize;
|
*_numBytes = newSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
TextGapBuffer::FindChar(char inChar, long fromIndex, long *ioDelta)
|
TextGapBuffer::FindChar(char inChar, long fromIndex, long *ioDelta)
|
||||||
{
|
{
|
||||||
long numChars = *ioDelta;
|
long numChars = *ioDelta;
|
||||||
@@ -239,7 +239,7 @@ TextGapBuffer::FindChar(char inChar, long fromIndex, long *ioDelta)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -248,17 +248,17 @@ const char *
|
|||||||
TextGapBuffer::Text()
|
TextGapBuffer::Text()
|
||||||
{
|
{
|
||||||
const char *realText = RealText();
|
const char *realText = RealText();
|
||||||
|
|
||||||
if (fPasswordMode) {
|
if (fPasswordMode) {
|
||||||
const uint32 numChars = UTF8CountChars(realText, Length());
|
const uint32 numChars = UTF8CountChars(realText, Length());
|
||||||
const uint32 bulletCharLen = UTF8CountBytes(B_UTF8_BULLET, 1);
|
const uint32 bulletCharLen = UTF8CountBytes(B_UTF8_BULLET, 1);
|
||||||
uint32 newSize = numChars * bulletCharLen + 1;
|
uint32 newSize = numChars * bulletCharLen + 1;
|
||||||
|
|
||||||
if ((uint32)fScratchSize < newSize) {
|
if ((uint32)fScratchSize < newSize) {
|
||||||
fScratchBuffer = (char *)realloc(fScratchBuffer, newSize);
|
fScratchBuffer = (char *)realloc(fScratchBuffer, newSize);
|
||||||
fScratchSize = newSize;
|
fScratchSize = newSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *scratchPtr = fScratchBuffer;
|
char *scratchPtr = fScratchBuffer;
|
||||||
for (uint32 i = 0; i < numChars; i++) {
|
for (uint32 i = 0; i < numChars; i++) {
|
||||||
memcpy(scratchPtr, B_UTF8_BULLET, bulletCharLen);
|
memcpy(scratchPtr, B_UTF8_BULLET, bulletCharLen);
|
||||||
@@ -268,7 +268,7 @@ TextGapBuffer::Text()
|
|||||||
|
|
||||||
return fScratchBuffer;
|
return fScratchBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
return realText;
|
return realText;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -278,7 +278,7 @@ TextGapBuffer::RealText()
|
|||||||
{
|
{
|
||||||
MoveGapTo(fItemCount);
|
MoveGapTo(fItemCount);
|
||||||
fBuffer[fItemCount] = '\0';
|
fBuffer[fItemCount] = '\0';
|
||||||
|
|
||||||
return fBuffer;
|
return fBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -290,12 +290,12 @@ TextGapBuffer::GetString(int32 offset, int32 length, char *buffer)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
int32 textLen = Length();
|
int32 textLen = Length();
|
||||||
|
|
||||||
if (offset < 0 || offset > (textLen - 1) || length < 1) {
|
if (offset < 0 || offset > (textLen - 1) || length < 1) {
|
||||||
buffer[0] = '\0';
|
buffer[0] = '\0';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
length = ((offset + length) > textLen) ? textLen - offset : length;
|
length = ((offset + length) > textLen) ? textLen - offset : length;
|
||||||
|
|
||||||
bool isStartBeforeGap = (offset < fGapIndex);
|
bool isStartBeforeGap = (offset < fGapIndex);
|
||||||
@@ -305,10 +305,10 @@ TextGapBuffer::GetString(int32 offset, int32 length, char *buffer)
|
|||||||
char *source = fBuffer + offset;
|
char *source = fBuffer + offset;
|
||||||
if (!isStartBeforeGap)
|
if (!isStartBeforeGap)
|
||||||
source += fGapCount;
|
source += fGapCount;
|
||||||
|
|
||||||
memcpy(buffer, source, length);
|
memcpy(buffer, source, length);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// if we are here, it can only be that start is before gap,
|
// if we are here, it can only be that start is before gap,
|
||||||
// and the end is after gap.
|
// and the end is after gap.
|
||||||
|
|
||||||
@@ -317,9 +317,9 @@ TextGapBuffer::GetString(int32 offset, int32 length, char *buffer)
|
|||||||
|
|
||||||
memcpy(buffer, fBuffer + offset, beforeLen);
|
memcpy(buffer, fBuffer + offset, beforeLen);
|
||||||
memcpy(buffer + beforeLen, fBuffer + fGapIndex, afterLen);
|
memcpy(buffer + beforeLen, fBuffer + fGapIndex, afterLen);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer[length] = '\0';
|
buffer[length] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ virtual ~TextGapBuffer();
|
|||||||
void InsertText(BFile *file, int32 fileOffset, int32 amount,
|
void InsertText(BFile *file, int32 fileOffset, int32 amount,
|
||||||
int32 atIndex);
|
int32 atIndex);
|
||||||
void RemoveRange(int32 start, int32 end);
|
void RemoveRange(int32 start, int32 end);
|
||||||
|
|
||||||
void MoveGapTo(int32 toIndex);
|
void MoveGapTo(int32 toIndex);
|
||||||
void SizeGapTo(int32 inCount);
|
void SizeGapTo(int32 inCount);
|
||||||
|
|
||||||
@@ -36,12 +36,12 @@ virtual ~TextGapBuffer();
|
|||||||
const char *Text();
|
const char *Text();
|
||||||
const char *RealText();
|
const char *RealText();
|
||||||
int32 Length() const;
|
int32 Length() const;
|
||||||
|
|
||||||
const char *GetString(int32 fromOffset, int32 *numBytes);
|
const char *GetString(int32 fromOffset, int32 *numBytes);
|
||||||
void GetString(int32 offset, int32 length, char *buffer);
|
void GetString(int32 offset, int32 length, char *buffer);
|
||||||
|
|
||||||
char RealCharAt(int32 offset) const;
|
char RealCharAt(int32 offset) const;
|
||||||
|
|
||||||
bool PasswordMode() const;
|
bool PasswordMode() const;
|
||||||
void SetPasswordMode(bool);
|
void SetPasswordMode(bool);
|
||||||
|
|
||||||
@@ -60,14 +60,14 @@ protected:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
inline int32
|
inline int32
|
||||||
TextGapBuffer::Length() const
|
TextGapBuffer::Length() const
|
||||||
{
|
{
|
||||||
return fItemCount;
|
return fItemCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline char
|
inline char
|
||||||
TextGapBuffer::RealCharAt(long index) const
|
TextGapBuffer::RealCharAt(long index) const
|
||||||
{
|
{
|
||||||
return (index < fGapIndex) ? fBuffer[index] : fBuffer[index + fGapCount];
|
return (index < fGapIndex) ? fBuffer[index] : fBuffer[index + fGapCount];
|
||||||
|
|||||||
Reference in New Issue
Block a user