From de20f0facaa2afcc46cde051e683bd65af8e3f84 Mon Sep 17 00:00:00 2001 From: Stefano Ceccherini Date: Mon, 2 Oct 2006 12:23:38 +0000 Subject: [PATCH] some changes, fixed a rendering bug git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18987 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/interface/TextView.cpp | 29 +++++++++---------- .../textview_support/TextGapBuffer.cpp | 21 +++++--------- .../textview_support/TextGapBuffer.h | 2 +- 3 files changed, 23 insertions(+), 29 deletions(-) diff --git a/src/kits/interface/TextView.cpp b/src/kits/interface/TextView.cpp index 0da1d0a7d6..4fefdea091 100644 --- a/src/kits/interface/TextView.cpp +++ b/src/kits/interface/TextView.cpp @@ -3574,18 +3574,18 @@ BTextView::DrawLines(int32 startLine, int32 endLine, int32 startOffset, bool era BRegion inputRegion; if (fInline != NULL && fInline->IsActive()) GetTextRegion(fInline->Offset(), fInline->Offset() + fInline->Length(), &inputRegion); - - float startLeft = fTextRect.left; - if (startOffset != -1) { - startLeft = PointAt(startOffset).x; - if (ByteAt(startOffset) == B_ENTER) { - // StartOffset is a newline - startLeft = PointAt((*fLines)[startLine]->offset).x; - } - } - BPoint leftTop(startLeft, line->origin); + //BPoint leftTop(startLeft, line->origin); for (long i = startLine; i <= endLine; i++) { + float startLeft = fTextRect.left; + if (startOffset != -1) { + startLeft = PointAt(startOffset).x; + if (ByteAt(startOffset) == B_ENTER) { + // StartOffset is a newline + startLeft = PointAt((*fLines)[i]->offset).x; + } + } + long length = (line + 1)->offset; if (startOffset != -1) length -= startOffset; @@ -3665,9 +3665,8 @@ BTextView::DrawLines(int32 startLine, int32 endLine, int32 startOffset, bool era view->PopState(); } - int32 returnedBytes = 0; - const char *string = fText->GetString(offset, tabChars, &returnedBytes); - view->DrawString(string, returnedBytes); + int32 returnedBytes = tabChars; + view->DrawString(fText->GetString(offset, &returnedBytes), returnedBytes); if (foundTab) { float penPos = PenLocation().x - fTextRect.left; @@ -3705,9 +3704,9 @@ BTextView::DrawLines(int32 startLine, int32 endLine, int32 startOffset, bool era if (fOffscreen != NULL) { view->Sync(); - BPoint penLocation = view->PenLocation(); + /*BPoint penLocation = view->PenLocation(); BRect drawRect(leftTop.x, leftTop.y, penLocation.x, penLocation.y); - DrawBitmap(fOffscreen, drawRect, drawRect); + DrawBitmap(fOffscreen, drawRect, drawRect);*/ fOffscreen->Unlock(); } diff --git a/src/kits/interface/textview_support/TextGapBuffer.cpp b/src/kits/interface/textview_support/TextGapBuffer.cpp index 582340403f..2df8fe94f4 100644 --- a/src/kits/interface/textview_support/TextGapBuffer.cpp +++ b/src/kits/interface/textview_support/TextGapBuffer.cpp @@ -42,8 +42,7 @@ _BTextGapBuffer_::~_BTextGapBuffer_() void -_BTextGapBuffer_::InsertText(const char *inText, int32 inNumItems, - int32 inAtIndex) +_BTextGapBuffer_::InsertText(const char *inText, int32 inNumItems, int32 inAtIndex) { if (inNumItems < 1) return; @@ -169,15 +168,15 @@ _BTextGapBuffer_::SizeGapTo(long inCount) const char * -_BTextGapBuffer_::GetString(int32 fromOffset, int32 numBytes, int32 *returnedBytes) +_BTextGapBuffer_::GetString(int32 fromOffset, int32 *_numBytes) { char *result = ""; - - if (numBytes < 1) { - if (returnedBytes != NULL) - *returnedBytes = 0; + if (_numBytes == NULL) + return result; + + int32 numBytes = *_numBytes; + if (numBytes < 1) return result; - } bool isStartBeforeGap = (fromOffset < fGapIndex); bool isEndBeforeGap = ((fromOffset + numBytes - 1) < fGapIndex); @@ -199,9 +198,6 @@ _BTextGapBuffer_::GetString(int32 fromOffset, int32 numBytes, int32 *returnedByt 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) { @@ -220,8 +216,7 @@ _BTextGapBuffer_::GetString(int32 fromOffset, int32 numBytes, int32 *returnedByt scratchPtr += charLen; } scratchPtr = '\0'; - if (returnedBytes != NULL) - *returnedBytes = newSize - 1; + *_numBytes = newSize - 1; } return result; diff --git a/src/kits/interface/textview_support/TextGapBuffer.h b/src/kits/interface/textview_support/TextGapBuffer.h index 0ddce9b989..81a6f5e5e0 100644 --- a/src/kits/interface/textview_support/TextGapBuffer.h +++ b/src/kits/interface/textview_support/TextGapBuffer.h @@ -34,7 +34,7 @@ virtual ~_BTextGapBuffer_(); // char *RealText(); - const char *GetString(int32 fromOffset, int32 numBytes, int32 *returnedBytes); + const char *GetString(int32 fromOffset, int32 *numBytes); void GetString(int32 offset, int32 length, char *buffer); char RealCharAt(int32 offset) const;