Changeset 2609

Show
Ignore:
Timestamp:
05/03/05 01:06:05 (4 years ago)
Author:
eridius
Message:

Add a red mark to the scrollbar for the current scrollback display mark
Add a new Jump to Mark menuitem to jump to the current scrollback display mark

Files:

Legend:

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

    r2603 r2609  
    464464#pragma mark Highlight/Message Jumping 
    465465 
     466- (IBAction) jumpToMark:(id) sender { 
     467        [display jumpToMark:sender]; 
     468} 
     469 
    466470- (IBAction) jumpToPreviousHighlight:(id) sender { 
    467         [[display verticalMarkedScroller] jumpToPreviousMark:sender]; 
     471        [display jumpToPreviousHighlight:sender]; 
    468472} 
    469473 
    470474- (IBAction) jumpToNextHighlight:(id) sender { 
    471         [[display verticalMarkedScroller] jumpToNextMark:sender]; 
     475        [display jumpToNextHighlight:sender]; 
    472476} 
    473477 
  • trunk/JVMarkedScroller.h

    r2180 r2609  
    1010- (IBAction) jumpToPreviousMark:(id) sender; 
    1111- (IBAction) jumpToNextMark:(id) sender; 
     12- (void) jumpToMarkWithIdentifier:(NSString *) identifier; 
    1213 
    1314- (void) shiftMarksAndShadedAreasBy:(long long) displacement; 
    1415 
    1516- (void) addMarkAt:(unsigned long long) location; 
     17- (void) addMarkAt:(unsigned long long) location withIdentifier:(NSString *) identifier; 
     18- (void) addMarkAt:(unsigned long long) location withColor:(NSColor *) color; 
     19- (void) addMarkAt:(unsigned long long) location 
     20        withIdentifier:(NSString *) identifier 
     21                 withColor:(NSColor *) color; 
    1622- (void) removeMarkAt:(unsigned long long) location; 
     23- (void) removeMarkAt:(unsigned long long) location withIdentifier:(NSString *) identifier; 
     24- (void) removeMarkAt:(unsigned long long) location withColor:(NSColor *) color; 
     25- (void) removeMarkAt:(unsigned long long) location 
     26           withIdentifier:(NSString *) identifier 
     27                        withColor:(NSColor *) color; 
     28- (void) removeMarkWithIdentifier:(NSString *) identifier; 
    1729- (void) removeMarksGreaterThan:(unsigned long long) location; 
    1830- (void) removeMarksLessThan:(unsigned long long) location; 
  • trunk/JVMarkedScroller.m

    r2186 r2609  
    11#import "JVMarkedScroller.h" 
     2 
     3struct _mark { 
     4        unsigned long long location; 
     5        NSString *identifier; 
     6        NSColor *color; 
     7}; 
    28 
    39@implementation JVMarkedScroller 
     
    7884 
    7985        NSBezierPath *lines = [NSBezierPath bezierPath]; 
     86        NSMutableArray *lineArray = [NSMutableArray array]; 
    8087        enumerator = [_marks objectEnumerator]; 
     88        NSValue *currentMark; 
    8189 
    8290        unsigned long long currentPosition = ( _currentMark != NSNotFound ? _currentMark : [self floatValue] * ( NSHeight( [self frame] ) / [self knobProportion] ) ); 
     
    8492        NSRect knobRect = [self rectForPart:NSScrollerKnob]; 
    8593 
    86         while( ( startNum = [enumerator nextObject] ) ) { 
    87                 unsigned long long value = [startNum unsignedLongLongValue]; 
     94        while( ( currentMark = [enumerator nextObject] ) ) { 
     95                struct _mark mark; 
     96                [currentMark getValue:&mark]; 
     97                unsigned long long value = mark.location; 
    8898 
    8999                if( value < currentPosition && ( ! foundPrevious || value > _nearestPreviousMark ) ) { 
     
    101111                point.x = ( sFlags.isHoriz ? roundf( point.x ) + 0.5 : point.x ); 
    102112                point.y = ( sFlags.isHoriz ? point.y : roundf( point.y ) + 0.5 ); 
    103  
     113                 
    104114                if( ! NSPointInRect( point, knobRect ) ) { 
    105                         [lines moveToPoint:point]; 
    106  
    107                         point = NSMakePoint( ( sFlags.isHoriz ? 0. : width ), ( sFlags.isHoriz ? width : 0. ) ); 
    108                         [lines relativeLineToPoint:point]; 
     115                        if( mark.color != nil ) { 
     116                                NSBezierPath *line = [NSBezierPath bezierPath]; 
     117                                [line moveToPoint:point]; 
     118                                 
     119                                point = NSMakePoint( ( sFlags.isHoriz ? 0. : width ), ( sFlags.isHoriz ? width : 0. ) ); 
     120                                [line relativeLineToPoint:point]; 
     121                                [lineArray addObject:mark.color]; 
     122                                [lineArray addObject:line]; 
     123                        } else { 
     124                                [lines moveToPoint:point]; 
     125 
     126                                point = NSMakePoint( ( sFlags.isHoriz ? 0. : width ), ( sFlags.isHoriz ? width : 0. ) ); 
     127                                [lines relativeLineToPoint:point]; 
     128                        } 
    109129                } 
    110130        } 
     
    115135        [[NSColor selectedKnobColor] set]; 
    116136        [lines stroke]; 
     137         
     138        // This is so we can draw the colored lines after the regular lines 
     139        enumerator = [lineArray objectEnumerator]; 
     140        NSColor *lineColor; 
     141        while( lineColor = [enumerator nextObject] ) { 
     142                [lineColor set]; 
     143                [[enumerator nextObject] stroke]; 
     144        } 
    117145} 
    118146 
     
    188216                float scale = NSHeight( [self rectForPart:NSScrollerKnobSlot] ) / ( NSHeight( [self frame] ) / [self knobProportion] ); 
    189217                float shift = ( ( NSHeight( [self rectForPart:NSScrollerKnobSlot] ) * [self knobProportion] ) / 2. ) / scale; 
    190                 [[(NSScrollView *)[self superview] documentView] scrollPoint:NSMakePoint( 0., _nearestPreviousMark - shift )]; 
     218                [[(NSScrollView *)[self superview] documentView] scrollPoint:NSMakePoint( 0., _currentMark - shift )]; 
    191219                _jumpingToMark = NO; 
    192220        } 
     
    199227                float scale = NSHeight( [self rectForPart:NSScrollerKnobSlot] ) / ( NSHeight( [self frame] ) / [self knobProportion] ); 
    200228                float shift = ( ( NSHeight( [self rectForPart:NSScrollerKnobSlot] ) * [self knobProportion] ) / 2. ) / scale; 
    201                 [[(NSScrollView *)[self superview] documentView] scrollPoint:NSMakePoint( 0., _nearestNextMark - shift )]; 
     229                [[(NSScrollView *)[self superview] documentView] scrollPoint:NSMakePoint( 0., _currentMark - shift )]; 
    202230                _jumpingToMark = NO; 
    203231        } 
     232} 
     233 
     234- (void) jumpToMarkWithIdentifier:(NSString *) identifier { 
     235        _jumpingToMark = YES; 
     236        NSEnumerator *e = [_marks objectEnumerator]; 
     237        NSValue *obj; 
     238        BOOL foundMark = NO; 
     239        while( obj = [e nextObject] ) { 
     240                struct _mark mark; 
     241                [obj getValue:&mark]; 
     242                if( [mark.identifier isEqualToString:identifier] ) { 
     243                        _currentMark = mark.location; 
     244                        foundMark = YES; 
     245                        break; 
     246                } 
     247        } 
     248        if( foundMark ) { 
     249                float scale = NSHeight( [self rectForPart:NSScrollerKnobSlot] ) / ( NSHeight( [self frame] ) / [self knobProportion] ); 
     250                float shift = ( ( NSHeight( [self rectForPart:NSScrollerKnobSlot] ) * [self knobProportion] ) / 2. ) / scale; 
     251                [[(NSScrollView *)[self superview] documentView] scrollPoint:NSMakePoint( 0., _currentMark - shift )];           
     252        } 
     253        _jumpingToMark = NO; 
    204254} 
    205255 
     
    209259        BOOL negative = ( displacement >= 0 ? NO : YES ); 
    210260        NSMutableSet *shiftedMarks = [NSMutableSet set]; 
    211         NSNumber *location = nil; 
     261        NSValue *location = nil; 
    212262 
    213263        if( ! ( negative && _nearestPreviousMark < ABS( displacement ) ) ) _nearestPreviousMark += displacement; 
     
    222272        NSEnumerator *enumerator = [_marks objectEnumerator]; 
    223273        while( ( location = [enumerator nextObject] ) ) { 
    224                 unsigned long long shifted = [location unsignedLongLongValue]; 
    225                 if( ! ( negative && shifted < ABS( displacement ) ) ) 
    226                         [shiftedMarks addObject:[NSNumber numberWithUnsignedLongLong:( shifted + displacement )]]; 
     274                struct _mark mark; 
     275                [location getValue:&mark]; 
     276                if( ! ( negative && mark.location < ABS( displacement ) ) ) { 
     277                        mark.location += displacement; 
     278                        [shiftedMarks addObject:[NSValue value:&mark withObjCType:@encode( struct _mark )]]; 
     279                } 
    227280        } 
    228281 
     
    256309 
    257310- (void) addMarkAt:(unsigned long long) location { 
    258         [_marks addObject:[NSNumber numberWithUnsignedLongLong:location]]; 
     311        [self addMarkAt:location withIdentifier:nil withColor:nil]; 
     312
     313 
     314- (void) addMarkAt:(unsigned long long) location withIdentifier:(NSString *) identifier { 
     315        [self addMarkAt:location withIdentifier:identifier withColor:nil]; 
     316
     317 
     318- (void) addMarkAt:(unsigned long long) location withColor:(NSColor *) color { 
     319        [self addMarkAt:location withIdentifier:nil withColor:color]; 
     320
     321 
     322- (void) addMarkAt:(unsigned long long) location 
     323        withIdentifier:(NSString *) identifier 
     324                 withColor:(NSColor *) color { 
     325        struct _mark mark = {location, identifier, color}; 
     326        [_marks addObject:[NSValue value:&mark withObjCType:@encode( struct _mark )]]; 
    259327        [self setNeedsDisplayInRect:[self rectForPart:NSScrollerKnobSlot]]; 
    260328} 
    261329 
    262330- (void) removeMarkAt:(unsigned long long) location { 
    263         [_marks removeObject:[NSNumber numberWithUnsignedLongLong:location]]; 
    264         [self setNeedsDisplayInRect:[self rectForPart:NSScrollerKnobSlot]]; 
     331        [self removeMarkAt:location withIdentifier:nil withColor:nil]; 
     332
     333 
     334- (void) removeMarkAt:(unsigned long long) location withIdentifier:(NSString *) identifier { 
     335        [self removeMarkAt:location withIdentifier:identifier withColor:nil]; 
     336
     337 
     338- (void) removeMarkAt:(unsigned long long) location withColor:(NSColor *) color { 
     339        [self removeMarkAt:location withIdentifier:nil withColor:color]; 
     340
     341 
     342- (void) removeMarkAt:(unsigned long long) location 
     343           withIdentifier:(NSString *) identifier 
     344                        withColor:(NSColor *) color { 
     345        struct _mark mark = {location, identifier, color}; 
     346        [_marks removeObject:[NSValue value:&mark withObjCType:@encode( struct _mark )]]; 
     347        [self setNeedsDisplayInRect:[self rectForPart:NSScrollerKnobSlot]]; 
     348
     349 
     350- (void) removeMarkWithIdentifier:(NSString *) identifier { 
     351        NSEnumerator *e = [[[_marks copy] autorelease] objectEnumerator]; 
     352        NSValue *obj; 
     353        while( obj = [e nextObject] ) { 
     354                struct _mark mark; 
     355                [obj getValue:&mark]; 
     356                if( [mark.identifier isEqualToString:identifier] ) { 
     357                        [_marks removeObject:obj]; 
     358                } 
     359        } 
    265360} 
    266361 
    267362- (void) removeMarksGreaterThan:(unsigned long long) location { 
    268363        NSEnumerator *enumerator = [[[_marks copy] autorelease] objectEnumerator]; 
    269         NSNumber *number = nil; 
    270  
    271         while( ( number = [enumerator nextObject] ) ) 
    272                 if( [number unsignedIntValue] > location ) 
    273                         [_marks removeObject:number]; 
     364        NSValue *obj; 
     365 
     366        while( obj = [enumerator nextObject] ) { 
     367                struct _mark mark; 
     368                [obj getValue:&mark]; 
     369                if( mark.location > location ) 
     370                        [_marks removeObject:obj]; 
     371        } 
    274372 
    275373        [self setNeedsDisplayInRect:[self rectForPart:NSScrollerKnobSlot]]; 
     
    278376- (void) removeMarksLessThan:(unsigned long long) location { 
    279377        NSEnumerator *enumerator = [[[_marks copy] autorelease] objectEnumerator]; 
    280         NSNumber *number = nil; 
    281  
    282         while( ( number = [enumerator nextObject] ) ) 
    283                 if( [number unsignedIntValue] < location ) 
    284                         [_marks removeObject:number]; 
     378        NSValue *obj; 
     379 
     380        while( obj = [enumerator nextObject] ) { 
     381                struct _mark mark; 
     382                [obj getValue:&mark]; 
     383                if( mark.location < location ) 
     384                        [_marks removeObject:obj]; 
     385        } 
    285386 
    286387        [self setNeedsDisplayInRect:[self rectForPart:NSScrollerKnobSlot]]; 
     
    289390- (void) removeMarksInRange:(NSRange) range { 
    290391        NSEnumerator *enumerator = [[[_marks copy] autorelease] objectEnumerator]; 
    291         NSNumber *number = nil; 
    292  
    293         while( ( number = [enumerator nextObject] ) ) 
    294                 if( NSLocationInRange( [number unsignedIntValue], range ) ) 
    295                         [_marks removeObject:number]; 
     392        NSValue *obj; 
     393 
     394        while( obj = [enumerator nextObject] ) { 
     395                struct _mark mark; 
     396                [obj getValue:&mark]; 
     397                if( NSLocationInRange( (unsigned int)mark.location, range ) ) 
     398                        [_marks removeObject:obj]; 
     399        } 
    296400 
    297401        [self setNeedsDisplayInRect:[self rectForPart:NSScrollerKnobSlot]]; 
     
    306410 
    307411- (void) setMarks:(NSSet *) marks { 
    308         [_marks autorelease]; 
    309         _marks = [[NSMutableSet setWithSet:marks] retain]; 
     412        [_marks setSet:marks]; 
    310413        [self setNeedsDisplayInRect:[self rectForPart:NSScrollerKnobSlot]]; 
    311414} 
  • trunk/JVStyleView.h

    r2595 r2609  
    5959 
    6060- (JVMarkedScroller *) verticalMarkedScroller; 
     61- (IBAction) jumpToMark:(id) sender; 
    6162- (IBAction) jumpToPreviousHighlight:(id) sender; 
    6263- (IBAction) jumpToNextHighlight:(id) sender; 
  • trunk/JVStyleView.m

    r2597 r2609  
    261261- (void) mark { 
    262262        if( _webViewReady ) { 
     263                int location; 
    263264#ifdef WebKitVersion146 
    264265                if( _newWebKit ) { 
     
    270271                        [[[doc getElementsByTagName:@"body"] item:0] appendChild:elt]; 
    271272                        [self scrollToBottom]; 
     273                        location = [[elt valueForKey:@"offsetTop"] intValue]; 
    272274                } else { 
    273275#endif 
    274                         [self stringByEvaluatingJavaScriptFromString:@"mark();"]; 
     276                        location = [[self stringByEvaluatingJavaScriptFromString:@"mark();"] intValue]; 
    275277#ifdef WebKitVersion146 
    276278                } 
     279                [[self verticalMarkedScroller] removeMarkWithIdentifier:@"mark"]; 
     280                [[self verticalMarkedScroller] addMarkAt:location 
     281                                                                  withIdentifier:@"mark" 
     282                                                                           withColor:[NSColor redColor]]; 
    277283#endif 
    278284        } else { 
     
    459465 
    460466        return scroller; 
     467} 
     468 
     469- (IBAction) jumpToMark:(id) sender { 
     470        [[self verticalMarkedScroller] jumpToMarkWithIdentifier:@"mark"]; 
    461471} 
    462472 
  • trunk/Languages/Dutch.lproj/Colloquy.nib/classes.nib

    r2602 r2609  
    1313                italic = id;  
    1414                joinRoom = id;  
     15                jumpToMark = id;  
    1516                jumpToNextHighlight = id;  
    1617                jumpToPreviousHighlight = id;  
  • trunk/Languages/English.lproj/Colloquy.nib/classes.nib

    r2602 r2609  
    1313                italic = id;  
    1414                joinRoom = id;  
     15                jumpToMark = id;  
    1516                jumpToNextHighlight = id;  
    1617                jumpToPreviousHighlight = id;  
  • trunk/Languages/German.lproj/Colloquy.nib/classes.nib

    r2602 r2609  
    1313                italic = id;  
    1414                joinRoom = id;  
     15                jumpToMark = id;  
    1516                jumpToNextHighlight = id;  
    1617                jumpToPreviousHighlight = id;