From ec7d16808176099e6cdac7c0780e2d0946ba0236 Mon Sep 17 00:00:00 2001 From: Michael Lotz Date: Thu, 15 Apr 2010 15:48:48 +0000 Subject: [PATCH] Automatic whitespace cleanup, no functional change. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36301 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../textview_support/TextGapBuffer.cpp | 78 +++++++++---------- .../textview_support/TextGapBuffer.h | 12 +-- 2 files changed, 45 insertions(+), 45 deletions(-) diff --git a/src/kits/interface/textview_support/TextGapBuffer.cpp b/src/kits/interface/textview_support/TextGapBuffer.cpp index 1310c5c96b..d36ff7475e 100644 --- a/src/kits/interface/textview_support/TextGapBuffer.cpp +++ b/src/kits/interface/textview_support/TextGapBuffer.cpp @@ -48,18 +48,18 @@ TextGapBuffer::InsertText(const char *inText, int32 inNumItems, int32 inAtIndex) { if (inNumItems < 1) return; - + inAtIndex = (inAtIndex > fItemCount) ? fItemCount : inAtIndex; inAtIndex = (inAtIndex < 0) ? 0 : inAtIndex; - + if (inAtIndex != fGapIndex) MoveGapTo(inAtIndex); - + if (fGapCount < inNumItems) SizeGapTo(inNumItems + fExtraCount); - + memcpy(fBuffer + fGapIndex, inText, inNumItems); - + fGapCount -= inNumItems; fGapIndex += inNumItems; fItemCount += inNumItems; @@ -74,7 +74,7 @@ TextGapBuffer::InsertText(BFile *file, int32 fileOffset, int32 inNumItems, int32 if (file->GetSize(&fileSize) != B_OK || !file->IsReadable()) return; - + // Clamp the text length to the file size fileSize -= fileOffset; @@ -86,13 +86,13 @@ TextGapBuffer::InsertText(BFile *file, int32 fileOffset, int32 inNumItems, int32 inAtIndex = (inAtIndex > fItemCount) ? fItemCount : inAtIndex; inAtIndex = (inAtIndex < 0) ? 0 : inAtIndex; - + if (inAtIndex != fGapIndex) MoveGapTo(inAtIndex); - + if (fGapCount < inNumItems) SizeGapTo(inNumItems + fExtraCount); - + // Finally, read the data and put it into the buffer if (file->ReadAt(fileOffset, fBuffer + fGapIndex, inNumItems) > 0) { fGapCount -= inNumItems; @@ -107,20 +107,20 @@ TextGapBuffer::RemoveRange(int32 start, int32 end) { long inAtIndex = start; long inNumItems = end - start; - + if (inNumItems < 1) return; - + inAtIndex = (inAtIndex > fItemCount - 1) ? (fItemCount - 1) : inAtIndex; inAtIndex = (inAtIndex < 0) ? 0 : inAtIndex; - + MoveGapTo(inAtIndex); - + fGapCount += inNumItems; fItemCount -= inNumItems; - + if (fGapCount > fExtraCount) - SizeGapTo(fExtraCount); + SizeGapTo(fExtraCount); } @@ -129,7 +129,7 @@ TextGapBuffer::MoveGapTo(int32 toIndex) { if (toIndex == fGapIndex) return; - + long gapEndIndex = fGapIndex + fGapCount; long srcIndex = 0; long dstIndex = 0; @@ -145,9 +145,9 @@ TextGapBuffer::MoveGapTo(int32 toIndex) dstIndex = toIndex + (gapEndIndex - fGapIndex); count = gapEndIndex - dstIndex; } - + if (count > 0) - memmove(fBuffer + dstIndex, fBuffer + srcIndex, count); + memmove(fBuffer + dstIndex, fBuffer + srcIndex, count); fGapIndex = toIndex; } @@ -158,10 +158,10 @@ TextGapBuffer::SizeGapTo(long inCount) { if (inCount == fGapCount) return; - + fBuffer = (char *)realloc(fBuffer, fItemCount + inCount); - memmove(fBuffer + fGapIndex + inCount, - fBuffer + fGapIndex + fGapCount, + memmove(fBuffer + fGapIndex + inCount, + fBuffer + fGapIndex + fGapCount, fBufferCount - (fGapIndex + fGapCount)); fGapCount = inCount; @@ -179,7 +179,7 @@ TextGapBuffer::GetString(int32 fromOffset, int32 *_numBytes) int32 numBytes = *_numBytes; if (numBytes < 1) return result; - + bool isStartBeforeGap = (fromOffset < fGapIndex); bool isEndBeforeGap = ((fromOffset + numBytes - 1) < fGapIndex); @@ -187,13 +187,13 @@ TextGapBuffer::GetString(int32 fromOffset, int32 *_numBytes) result = fBuffer + fromOffset; if (!isStartBeforeGap) result += fGapCount; - + } else { if (fScratchSize < numBytes) { fScratchBuffer = (char *)realloc(fScratchBuffer, numBytes); fScratchSize = numBytes; } - + for (long i = 0; i < numBytes; i++) fScratchBuffer[i] = RealCharAt(fromOffset + i); @@ -219,14 +219,14 @@ TextGapBuffer::GetString(int32 fromOffset, int32 *_numBytes) scratchPtr += charLen; } - *_numBytes = newSize; + *_numBytes = newSize; } return result; } -bool +bool TextGapBuffer::FindChar(char inChar, long fromIndex, long *ioDelta) { long numChars = *ioDelta; @@ -239,7 +239,7 @@ TextGapBuffer::FindChar(char inChar, long fromIndex, long *ioDelta) return true; } } - + return false; } @@ -248,17 +248,17 @@ const char * TextGapBuffer::Text() { const char *realText = RealText(); - + if (fPasswordMode) { const uint32 numChars = UTF8CountChars(realText, Length()); const uint32 bulletCharLen = UTF8CountBytes(B_UTF8_BULLET, 1); uint32 newSize = numChars * bulletCharLen + 1; - + if ((uint32)fScratchSize < newSize) { fScratchBuffer = (char *)realloc(fScratchBuffer, newSize); fScratchSize = newSize; } - + char *scratchPtr = fScratchBuffer; for (uint32 i = 0; i < numChars; i++) { memcpy(scratchPtr, B_UTF8_BULLET, bulletCharLen); @@ -268,7 +268,7 @@ TextGapBuffer::Text() return fScratchBuffer; } - + return realText; } @@ -278,7 +278,7 @@ TextGapBuffer::RealText() { MoveGapTo(fItemCount); fBuffer[fItemCount] = '\0'; - + return fBuffer; } @@ -290,12 +290,12 @@ TextGapBuffer::GetString(int32 offset, int32 length, char *buffer) return; int32 textLen = Length(); - + if (offset < 0 || offset > (textLen - 1) || length < 1) { buffer[0] = '\0'; return; } - + length = ((offset + length) > textLen) ? textLen - offset : length; bool isStartBeforeGap = (offset < fGapIndex); @@ -305,10 +305,10 @@ TextGapBuffer::GetString(int32 offset, int32 length, char *buffer) char *source = fBuffer + offset; if (!isStartBeforeGap) source += fGapCount; - + memcpy(buffer, source, length); - - } else { + + } else { // if we are here, it can only be that start is before 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 + beforeLen, fBuffer + fGapIndex, afterLen); - + } - + buffer[length] = '\0'; } diff --git a/src/kits/interface/textview_support/TextGapBuffer.h b/src/kits/interface/textview_support/TextGapBuffer.h index 81f4e27248..8f4702f4f7 100644 --- a/src/kits/interface/textview_support/TextGapBuffer.h +++ b/src/kits/interface/textview_support/TextGapBuffer.h @@ -27,7 +27,7 @@ virtual ~TextGapBuffer(); void InsertText(BFile *file, int32 fileOffset, int32 amount, int32 atIndex); void RemoveRange(int32 start, int32 end); - + void MoveGapTo(int32 toIndex); void SizeGapTo(int32 inCount); @@ -36,12 +36,12 @@ virtual ~TextGapBuffer(); const char *Text(); const char *RealText(); int32 Length() const; - + const char *GetString(int32 fromOffset, int32 *numBytes); void GetString(int32 offset, int32 length, char *buffer); - + char RealCharAt(int32 offset) const; - + bool PasswordMode() const; void SetPasswordMode(bool); @@ -60,14 +60,14 @@ protected: }; -inline int32 +inline int32 TextGapBuffer::Length() const { return fItemCount; } -inline char +inline char TextGapBuffer::RealCharAt(long index) const { return (index < fGapIndex) ? fBuffer[index] : fBuffer[index + fGapCount];