Ticket #2209: TextView.diff

File TextView.diff, 3.9 kB (added by shinta, 2 weeks ago)
  • src/kits/interface/TextView.cpp

    old new  
    35763576                                } while ((tabChars + numTabs) < numBytes); 
    35773577                        } 
    35783578 
    3579                         if (inputRegion.CountRects() > 0) { 
     3579                        int32 returnedBytes; 
     3580                        const char* stringToDraw; 
     3581 
     3582                        if (inputRegion.CountRects() > 0 
     3583                                && (offset <= fInline->Offset() && fInline->Offset() < offset + tabChars 
     3584                                || fInline->Offset() <= offset && offset < fInline->Offset() + fInline->Length())) { 
    35803585                                BRegion textRegion; 
    35813586                                GetTextRegion(offset, offset + length, &textRegion); 
    3582  
    35833587                                textRegion.IntersectWith(&inputRegion); 
    3584                                 view->PushState();       
    35853588 
     3589                                rgb_color viewColor = view->ViewColor(); 
     3590 
    35863591                                // Highlight in blue the inputted text 
    35873592                                view->SetHighColor(kBlueInputColor); 
    35883593                                view->FillRect(textRegion.Frame()); 
     
    35943599                                                + fInline->SelectionOffset(), fInline->Offset() 
    35953600                                                + fInline->SelectionOffset() 
    35963601                                                + fInline->SelectionLength(), &selectedRegion); 
    3597  
    35983602                                        textRegion.IntersectWith(&selectedRegion); 
    35993603 
    36003604                                        view->SetHighColor(kRedInputColor); 
    36013605                                        view->FillRect(textRegion.Frame()); 
    36023606                                } 
     3607                                 
     3608                                int32 drawnBytes = 0; 
     3609                                view->SetHighColor(*color); 
    36033610 
    3604                                 view->PopState(); 
     3611                                // before inputted text 
     3612                                _DrawLineInlucdeInputted(view, offset, min_c(fInline->Offset(), offset + tabChars), 
     3613                                                viewColor, &drawnBytes); 
     3614 
     3615                                // blue inputted text 
     3616                                _DrawLineInlucdeInputted(view, offset, 
     3617                                        min_c(fInline->Offset() + fInline->SelectionOffset(), offset + tabChars), 
     3618                                        kBlueInputColor, &drawnBytes); 
     3619 
     3620                                // red inputted text 
     3621                                int32 afterSelectionOffset = fInline->Offset() + fInline->SelectionOffset() 
     3622                                        + fInline->SelectionLength(); 
     3623                                _DrawLineInlucdeInputted(view, offset, min_c(afterSelectionOffset, offset + tabChars), 
     3624                                        kRedInputColor, &drawnBytes); 
     3625 
     3626                                // blue inputted text 
     3627                                int32 afterInputted = fInline->Offset() + fInline->Length(); 
     3628                                _DrawLineInlucdeInputted(view, offset, min_c(afterInputted, offset + tabChars), 
     3629                                        kBlueInputColor, &drawnBytes); 
     3630 
     3631                                // after inputted text 
     3632                                _DrawLineInlucdeInputted(view, offset, offset + tabChars, viewColor, &drawnBytes); 
     3633                                view->SetLowColor(viewColor); 
     3634                                view->SetViewColor(viewColor); 
     3635                        } else { 
     3636                                returnedBytes = tabChars; 
     3637                                stringToDraw = fText->GetString(offset, &returnedBytes); 
     3638                                view->DrawString(stringToDraw, returnedBytes); 
    36053639                        } 
    36063640 
    3607                         int32 returnedBytes = tabChars; 
    3608                         const char *stringToDraw = fText->GetString(offset, 
    3609                                 &returnedBytes); 
    3610  
    3611                         view->DrawString(stringToDraw, returnedBytes); 
    36123641                        if (foundTab) { 
    36133642                                float penPos = PenLocation().x - fTextRect.left; 
    36143643                                float tabWidth = _ActualTabWidth(penPos); 
     
    36303659 
    36313660 
    36323661void 
     3662BTextView::_DrawLineInlucdeInputted(BView* view, int32 offset, int32 end, const rgb_color& bgColor, 
     3663        int32* drawnBytes) 
     3664{ 
     3665        if (offset + *drawnBytes >= end) 
     3666                return; 
     3667        SetLowColor(bgColor); 
     3668        SetViewColor(bgColor); 
     3669 
     3670        int32 returnedBytes = end - (offset + *drawnBytes); 
     3671        const char* stringToDraw = fText->GetString(offset + *drawnBytes, &returnedBytes); 
     3672        view->DrawString(stringToDraw, returnedBytes); 
     3673        *drawnBytes += returnedBytes; 
     3674} 
     3675 
     3676 
     3677void 
    36333678BTextView::_DrawLines(int32 startLine, int32 endLine, int32 startOffset, 
    36343679        bool erase) 
    36353680{ 
  • headers/os/interface/TextView.h

    old new  
    254254                void _DrawLine(BView* view, const int32 &startLine, 
    255255                        const int32& startOffset, const bool& erase, BRect& eraseRect, 
    256256                        BRegion& inputRegion); 
     257                void _DrawLineInlucdeInputted(BView* view, int32 offset, int32 end, const rgb_color& bgColor, 
     258                        int32* drawnBytes); 
    257259 
    258260                void _DrawLines(int32 startLine, int32 endLine, int32 startOffset = -1, 
    259261                        bool erase = false);