Ignore:
Timestamp:
02/22/08 19:53:07 (17 years ago)
Author:
Nicholas Riley
Message:

APEMain.m: Note missing Xcode 3 support. Add Terminal 2.0 support.

English.lproj/APE Manager plugin.nib:

English.lproj/APEInfo.rtfd:

ICeCoffEE.[hm]: Bring triggering window and app to front if error
dialog displayed in ICCF_HandleException. Remove initial word
selection. Launch preexisting selection if present. Remove 10.3
support. Update for new ICeCoffEETrigger API. Rename downEvent
parameter for consistency.

ICeCoffEE.xcodeproj: Added files.

ICeCoffEEParser.m: Handle multiline URLs.

ICeCoffEETTView.[hm]: Terminal 2.0 support (thank you for having a
usable NSTextInput implementation!)

ICeCoffEETTViewTrigger.[hm]: ICeCoffEETrigger implementation for
TTView. Can't set range as we do for NSTextView because you can't
have an arbitrary empty selection range in Terminal, so we pass it
directly to ICCF_LaunchURLFromTTView.

ICeCoffEETerminal.[hm]: Fix capitalization on ICeCoffEETermSubviewSuper.
Pass downEvent to ICCF_HandleException so it can bring the triggering
window to the front.

ICeCoffEETextViewTrigger.[hm]: Moved from ICeCoffEETrigger.

ICeCoffEETrigger.[hm]: Now an abstract superclass. Replace direct
access to ICCF_sharedTrigger with +cancel. Create 0-character range
(if click outside selectedRange) or save selectedRange. Move
debugging logs here from ICeCoffEE.m. Add description method.

ICeCoffEEWebKit.m: Pass downEvent to ICCF_HandleException so it can
bring the triggering window to the front.

Installer components/ui/ui.plist: Updated for 1.5d3.

TestParser.m: Handle multiline URLs; newlines are printed as \ and
tabs as >. Implement ICCF_StringByRemovingCharactersInSet, which will
move elsewhere once Internet Config support is removed.

VERSION.xcconfig: Updated for 1.5d3.

urls.plist: Test for multiline URLs.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ICeCoffEE/ICeCoffEE/ICeCoffEE.m

    r381 r388  
    77#import "ICeCoffEESuper.h"
    88#import "ICeCoffEEServices.h"
    9 #import "ICeCoffEETrigger.h"
     9#import "ICeCoffEETextViewTrigger.h"
    1010#import "ICeCoffEEParser.h"
    1111
     
    190190Boolean ICCF_enabled = true;
    191191
    192 BOOL ICCF_HandleException(NSException *e) {
     192BOOL ICCF_HandleException(NSException *e, NSEvent *event) {
    193193    if ([e reason] == nil || [[e reason] length] == 0)
    194194        return NO;
     
    196196    if (ICCF_prefs.errorSoundEnabled) NSBeep();
    197197    if (!ICCF_prefs.errorDialogEnabled) return YES;
     198   
     199    [[NSApplication sharedApplication] activateIgnoringOtherApps: YES];
     200    [[event window] makeKeyAndOrderFront: nil];
    198201   
    199202    int result = NSRunAlertPanel(ICCF_LocalizedString(@"AlertTitle"), ICCF_LocalizedString(@"AlertMessage%@"), nil, nil, ICCF_LocalizedString(@"AlertDisableButton"), e);
     
    208211
    209212void ICCF_LaunchURLFromTextView(NSTextView *self, NSEvent *triggeringEvent) {
    210     NSRange range = [self selectedRange];
    211213    NSColor *insertionPointColor = [self insertionPointColor];
    212     NSString *s = [[self textStorage] string]; // according to the class documentation, sending 'string' is guaranteed to be O(1)
    213     int i;
    214214
    215215    NS_DURING
    216216
     217        NSString *s = [[self textStorage] string]; // according to the class documentation, sending 'string' is guaranteed to be O(1)
     218        unsigned length = [s length];
     219        NSCAssert(s != nil, ICCF_LocalizedString(@"Sorry, ICeCoffEE is unable to locate the insertion point or selection"));
     220        NSCAssert(length != 0, ICCF_LocalizedString(@"No text was found"));
     221
     222        ICCF_StartIC();
     223
     224        NSRange range = [self selectedRange];
    217225        NSCAssert(range.location != NSNotFound, ICCF_LocalizedString(@"There is no insertion point or selection in the text field where you clicked"));
    218         NSCAssert(s != nil, ICCF_LocalizedString(@"Sorry, ICeCoffEE is unable to locate the insertion point or selection"));
    219 
    220         ICCF_StartIC();
    221 
    222         NSCAssert([s length] != 0, ICCF_LocalizedString(@"No text was found"));
    223 
    224         if (range.location == [s length]) range.location--; // work around bug in selectionRangeForProposedRange (r. 2845418)
    225 
    226         // XXX is this even worth it to get a starting range?  Can just grab back and forth ICCF_MAX_URL_LEN (will need to remove some ICCF_CheckRange calls though)
    227         range = [self selectionRangeForProposedRange: range granularity: NSSelectByWord];
    228 
    229         // However, NSSelectByWord does not capture even the approximate boundaries of a URL
    230         // (text to a space/line ending character); it'll stop at a period in the middle of a hostname.
    231         // So, we expand it as follows:
    232        
    233         range = ICCF_URLEnclosingRange(s, range);
    234 
    235         [self setSelectedRange: range affinity: NSSelectionAffinityDownstream stillSelecting: NO];
    236         [self display];
     226   
     227        if (range.length == 0) {
     228            if (range.location == length) range.location--;
     229            range.length = 1;
     230            range = ICCF_URLEnclosingRange(s, range);
     231            [self setSelectedRange: range affinity: NSSelectionAffinityDownstream stillSelecting: NO];
     232        }
    237233
    238234        if (ICCF_LaunchURL([s substringWithRange: range], ICCF_KeyboardAction(triggeringEvent)) && ICCF_prefs.textBlinkEnabled) {
    239             for (i = 0 ; i < ICCF_prefs.textBlinkCount ; i++) {
     235            for (unsigned i = 0 ; i < ICCF_prefs.textBlinkCount ; i++) {
    240236                NSRange emptyRange = {range.location, 0};
    241237                [self setSelectedRange: emptyRange affinity: NSSelectionAffinityDownstream stillSelecting: YES];
     
    250246
    251247    NS_HANDLER
    252         ICCF_HandleException(localException);
     248        ICCF_HandleException(localException, triggeringEvent);
    253249    NS_ENDHANDLER
    254250
     
    418414}
    419415
    420 - (void)mouseDown:(NSEvent *)e;
     416- (void)mouseDown:(NSEvent *)downEvent;
    421417{
    422418#if ICCF_DEBUG
     
    427423    }
    428424    down = YES;
    429     ICLog(@"ICeCoffEE down: %@", e);
     425    ICLog(@"ICeCoffEE down: %@", downEvent);
    430426#endif
    431     if (ICCF_sharedTrigger != nil) {
    432         ICLog(@"%@ cancelling", ICCF_sharedTrigger);
    433         [ICCF_sharedTrigger cancel];
    434     }
    435     if (ICCF_enabled && ICCF_prefs.commandClickEnabled && ICCF_EventIsCommandMouseDown(e)) {
    436         BOOL inheritModifierFlags;
    437         if ([self respondsToSelector: @selector(selectedRanges)]) {
    438             // Command-multiple-click or -drag for discontiguous selection, Mac OS X 10.4 or later
    439             inheritModifierFlags = YES;
    440         } else {
    441             // don't want to trigger selection extension or anything else; pass through as a plain click
    442             // (on Mac OS X 10.3, command does not modify behavior)
    443             inheritModifierFlags = NO;
    444         }
    445         [super mouseDown: ICCF_MouseDownEventWithModifierFlags(e, inheritModifierFlags)];
     427    [ICeCoffEETrigger cancel];
     428
     429    if (ICCF_enabled && ICCF_prefs.commandClickEnabled && ICCF_EventIsCommandMouseDown(downEvent)) {
     430        [super mouseDown: ICCF_MouseDownEventWithModifierFlags(downEvent, YES)];
    446431        // we don't actually get a mouseUp event, just wait for mouseDown to return
    447432        NSEvent *upEvent = [[self window] currentEvent];
    448         NSPoint downPt = [e locationInWindow];
     433        NSPoint downPt = [downEvent locationInWindow];
    449434        NSPoint upPt = [upEvent locationInWindow];
    450435        ICLog(@"next: %@", upEvent);
    451436        NSAssert([upEvent type] == NSLeftMouseUp, @"NSTextView mouseDown: did not return with current event as mouse up!");
    452437        if (abs(downPt.x - upPt.x) <= kICHysteresisPixels && abs(downPt.y - upPt.y) <= kICHysteresisPixels) {
    453             if (inheritModifierFlags) {
    454                 // Mac OS X 10.4 and later: make sure we don't have a command-double-click
    455                 [ICeCoffEETrigger setTriggerForEvent: e onTarget: self]; // gets stored in ICCF_sharedTrigger; the reason for this weird calling pattern is that we don't want to add methods to NSTextView, and we don't want to add a method call on every mouseDown
    456                 ICLog(@"%@ set", ICCF_sharedTrigger);
    457             } else {
    458                 // Mac OS X 10.3
    459                 ICCF_LaunchURLFromTextView(self, e);
    460             }
     438            // make sure we don't have a Command-double-click
     439            [ICeCoffEETextViewTrigger setTriggerForEvent: downEvent onTarget: self]; // gets stored in ICCF_sharedTrigger; the reason for this weird calling pattern is that we don't want to add methods to NSTextView, and we don't want to add a method call on every mouseDown
    461440        }
    462441    } else {
    463         [super mouseDown: e];
     442        [super mouseDown: downEvent];
    464443    }
    465444#if ICCF_DEBUG
Note: See TracChangeset for help on using the changeset viewer.