Changeset 2159

Show
Ignore:
Timestamp:
12/26/04 19:23:36 (4 years ago)
Author:
timothy
Message:

More accurately remove marks that have been shifted passed zero in the negative direction. If a positive shift occurs (not likely with the current code) old marks that shifted passed zero wont return.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/JVMarkedScroller.m

    r2153 r2159  
    150150 
    151151- (void) shiftMarksAndShadedAreasBy:(long long) displacement { 
     152        BOOL negative = ( displacement >= 0 ? NO : YES ); 
    152153        NSMutableSet *shiftedMarks = [NSMutableSet set]; 
     154        NSNumber *location = nil; 
     155 
    153156        NSEnumerator *enumerator = [_marks objectEnumerator]; 
    154         NSNumber *location = nil; 
    155  
    156157        while( ( location = [enumerator nextObject] ) ) { 
    157                 long long shifted = ( [location unsignedLongLongValue] + displacement ); 
    158                 [shiftedMarks addObject:[NSNumber numberWithUnsignedLongLong:shifted]]; 
     158                unsigned long long shifted = [location unsignedLongLongValue]; 
     159                if( ! ( negative && shifted < ABS( displacement ) ) ) 
     160                        [shiftedMarks addObject:[NSNumber numberWithUnsignedLongLong:( shifted + displacement )]]; 
    159161        } 
    160162 
     
    162164 
    163165        NSMutableArray *shiftedShades = [NSMutableArray array]; 
     166        NSNumber *start = nil; 
     167        NSNumber *stop = nil; 
     168 
    164169        enumerator = [_shades objectEnumerator]; 
    165         location = nil; 
    166  
    167         while( ( location = [enumerator nextObject] ) ) { 
    168                 long long shifted = ( [location unsignedLongLongValue] + displacement ); 
    169                 [shiftedShades addObject:[NSNumber numberWithUnsignedLongLong:MAX( shifted, 0 )]]; 
     170        while( ( start = [enumerator nextObject] ) && ( ( stop = [enumerator nextObject] ) || YES ) ) { 
     171                unsigned long long shiftedStart = [start unsignedLongLongValue]; 
     172 
     173                if( stop ) { 
     174                        unsigned long long shiftedStop = [stop unsignedLongLongValue]; 
     175                        if( ! ( negative && shiftedStart < ABS( displacement ) ) && ! ( negative && shiftedStop < ABS( displacement ) ) ) { 
     176                                [shiftedShades addObject:[NSNumber numberWithUnsignedLongLong:( shiftedStart + displacement )]]; 
     177                                [shiftedShades addObject:[NSNumber numberWithUnsignedLongLong:( shiftedStop + displacement )]]; 
     178                        } 
     179                } else if( ! ( negative && shiftedStart < ABS( displacement ) ) ) { 
     180                        [shiftedShades addObject:[NSNumber numberWithUnsignedLongLong:( shiftedStart + displacement )]]; 
     181                } 
    170182        } 
    171183