Changeset 2609
- Timestamp:
- 05/03/05 01:06:05 (4 years ago)
- Files:
-
- trunk/JVChatTranscriptPanel.m (modified) (1 diff)
- trunk/JVMarkedScroller.h (modified) (1 diff)
- trunk/JVMarkedScroller.m (modified) (13 diffs)
- trunk/JVStyleView.h (modified) (1 diff)
- trunk/JVStyleView.m (modified) (3 diffs)
- trunk/Languages/Dutch.lproj/Colloquy.nib/classes.nib (modified) (1 diff)
- trunk/Languages/Dutch.lproj/Colloquy.nib/keyedobjects.nib (modified) (previous)
- trunk/Languages/English.lproj/Colloquy.nib/classes.nib (modified) (1 diff)
- trunk/Languages/English.lproj/Colloquy.nib/keyedobjects.nib (modified) (previous)
- trunk/Languages/German.lproj/Colloquy.nib/classes.nib (modified) (1 diff)
- trunk/Languages/German.lproj/Colloquy.nib/keyedobjects.nib (modified) (previous)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/JVChatTranscriptPanel.m
r2603 r2609 464 464 #pragma mark Highlight/Message Jumping 465 465 466 - (IBAction) jumpToMark:(id) sender { 467 [display jumpToMark:sender]; 468 } 469 466 470 - (IBAction) jumpToPreviousHighlight:(id) sender { 467 [ [display verticalMarkedScroller] jumpToPreviousMark:sender];471 [display jumpToPreviousHighlight:sender]; 468 472 } 469 473 470 474 - (IBAction) jumpToNextHighlight:(id) sender { 471 [ [display verticalMarkedScroller] jumpToNextMark:sender];475 [display jumpToNextHighlight:sender]; 472 476 } 473 477 trunk/JVMarkedScroller.h
r2180 r2609 10 10 - (IBAction) jumpToPreviousMark:(id) sender; 11 11 - (IBAction) jumpToNextMark:(id) sender; 12 - (void) jumpToMarkWithIdentifier:(NSString *) identifier; 12 13 13 14 - (void) shiftMarksAndShadedAreasBy:(long long) displacement; 14 15 15 16 - (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; 16 22 - (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; 17 29 - (void) removeMarksGreaterThan:(unsigned long long) location; 18 30 - (void) removeMarksLessThan:(unsigned long long) location; trunk/JVMarkedScroller.m
r2186 r2609 1 1 #import "JVMarkedScroller.h" 2 3 struct _mark { 4 unsigned long long location; 5 NSString *identifier; 6 NSColor *color; 7 }; 2 8 3 9 @implementation JVMarkedScroller … … 78 84 79 85 NSBezierPath *lines = [NSBezierPath bezierPath]; 86 NSMutableArray *lineArray = [NSMutableArray array]; 80 87 enumerator = [_marks objectEnumerator]; 88 NSValue *currentMark; 81 89 82 90 unsigned long long currentPosition = ( _currentMark != NSNotFound ? _currentMark : [self floatValue] * ( NSHeight( [self frame] ) / [self knobProportion] ) ); … … 84 92 NSRect knobRect = [self rectForPart:NSScrollerKnob]; 85 93 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; 88 98 89 99 if( value < currentPosition && ( ! foundPrevious || value > _nearestPreviousMark ) ) { … … 101 111 point.x = ( sFlags.isHoriz ? roundf( point.x ) + 0.5 : point.x ); 102 112 point.y = ( sFlags.isHoriz ? point.y : roundf( point.y ) + 0.5 ); 103 113 104 114 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 } 109 129 } 110 130 } … … 115 135 [[NSColor selectedKnobColor] set]; 116 136 [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 } 117 145 } 118 146 … … 188 216 float scale = NSHeight( [self rectForPart:NSScrollerKnobSlot] ) / ( NSHeight( [self frame] ) / [self knobProportion] ); 189 217 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 )]; 191 219 _jumpingToMark = NO; 192 220 } … … 199 227 float scale = NSHeight( [self rectForPart:NSScrollerKnobSlot] ) / ( NSHeight( [self frame] ) / [self knobProportion] ); 200 228 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 )]; 202 230 _jumpingToMark = NO; 203 231 } 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; 204 254 } 205 255 … … 209 259 BOOL negative = ( displacement >= 0 ? NO : YES ); 210 260 NSMutableSet *shiftedMarks = [NSMutableSet set]; 211 NS Number*location = nil;261 NSValue *location = nil; 212 262 213 263 if( ! ( negative && _nearestPreviousMark < ABS( displacement ) ) ) _nearestPreviousMark += displacement; … … 222 272 NSEnumerator *enumerator = [_marks objectEnumerator]; 223 273 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 } 227 280 } 228 281 … … 256 309 257 310 - (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 )]]; 259 327 [self setNeedsDisplayInRect:[self rectForPart:NSScrollerKnobSlot]]; 260 328 } 261 329 262 330 - (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 } 265 360 } 266 361 267 362 - (void) removeMarksGreaterThan:(unsigned long long) location { 268 363 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 } 274 372 275 373 [self setNeedsDisplayInRect:[self rectForPart:NSScrollerKnobSlot]]; … … 278 376 - (void) removeMarksLessThan:(unsigned long long) location { 279 377 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 } 285 386 286 387 [self setNeedsDisplayInRect:[self rectForPart:NSScrollerKnobSlot]]; … … 289 390 - (void) removeMarksInRange:(NSRange) range { 290 391 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 } 296 400 297 401 [self setNeedsDisplayInRect:[self rectForPart:NSScrollerKnobSlot]]; … … 306 410 307 411 - (void) setMarks:(NSSet *) marks { 308 [_marks autorelease]; 309 _marks = [[NSMutableSet setWithSet:marks] retain]; 412 [_marks setSet:marks]; 310 413 [self setNeedsDisplayInRect:[self rectForPart:NSScrollerKnobSlot]]; 311 414 } trunk/JVStyleView.h
r2595 r2609 59 59 60 60 - (JVMarkedScroller *) verticalMarkedScroller; 61 - (IBAction) jumpToMark:(id) sender; 61 62 - (IBAction) jumpToPreviousHighlight:(id) sender; 62 63 - (IBAction) jumpToNextHighlight:(id) sender; trunk/JVStyleView.m
r2597 r2609 261 261 - (void) mark { 262 262 if( _webViewReady ) { 263 int location; 263 264 #ifdef WebKitVersion146 264 265 if( _newWebKit ) { … … 270 271 [[[doc getElementsByTagName:@"body"] item:0] appendChild:elt]; 271 272 [self scrollToBottom]; 273 location = [[elt valueForKey:@"offsetTop"] intValue]; 272 274 } else { 273 275 #endif 274 [self stringByEvaluatingJavaScriptFromString:@"mark();"];276 location = [[self stringByEvaluatingJavaScriptFromString:@"mark();"] intValue]; 275 277 #ifdef WebKitVersion146 276 278 } 279 [[self verticalMarkedScroller] removeMarkWithIdentifier:@"mark"]; 280 [[self verticalMarkedScroller] addMarkAt:location 281 withIdentifier:@"mark" 282 withColor:[NSColor redColor]]; 277 283 #endif 278 284 } else { … … 459 465 460 466 return scroller; 467 } 468 469 - (IBAction) jumpToMark:(id) sender { 470 [[self verticalMarkedScroller] jumpToMarkWithIdentifier:@"mark"]; 461 471 } 462 472 trunk/Languages/Dutch.lproj/Colloquy.nib/classes.nib
r2602 r2609 13 13 italic = id; 14 14 joinRoom = id; 15 jumpToMark = id; 15 16 jumpToNextHighlight = id; 16 17 jumpToPreviousHighlight = id; trunk/Languages/English.lproj/Colloquy.nib/classes.nib
r2602 r2609 13 13 italic = id; 14 14 joinRoom = id; 15 jumpToMark = id; 15 16 jumpToNextHighlight = id; 16 17 jumpToPreviousHighlight = id; trunk/Languages/German.lproj/Colloquy.nib/classes.nib
r2602 r2609 13 13 italic = id; 14 14 joinRoom = id; 15 jumpToMark = id; 15 16 jumpToNextHighlight = id; 16 17 jumpToPreviousHighlight = id;
