Ignore:
Timestamp:
05/14/05 20:11:04 (19 years ago)
Author:
Nicholas Riley
Message:

ICeCoffEE 1.4.2b1

VERSION, ui.plist, Info*.plist, InfoPlist.strings: Updated for 1.4.2b1.

APEMain.m: Removed PBX support.

ICeCoffEE.[hm]: Don't ICCF_OSErr(C)Assert if we get userCanceledErr:
part of fixing extraneous exception when not selecting anything from
the helper app menu. ICCF_KeyboardAction() and
ICCF_LaunchURLFromTextView() now take an event parameter - since we
have stuff on a timer now, means we get the key modifier state at
mousedown time, rather than some arbitrary time later.
ICCF_LaunchURL() returns NO if the user cancelled, so we don't need to
throw an exception to stop the URL blinking. Moved sanitized mouse
down event generation to ICCF_MouseDownEventWithModifierFlags(). Only
update Services menu at app launch on Panther. Use a timer to delay
URL launching in NSTextView on Tiger, so we accommodate
command-multiple clicking for discontiguous selection. Remove that
ugly goto.

ICeCoffEEShared.h: Turn off debugging in preparation for (beta)
release.

ICeCoffEETerminal.m: Update for new ICCF_LaunchURL() return.

ICeCoffEETrigger.[hm]: Singleton timer wrapper for discontiguous
selection compatibility on Tiger. Singleton global is exported for
efficiency since we have to check it on every mouse down.

ICeCoffEEWebKit.m: Removed incorrect comment (what was I thinking?)
Update for new ICCF_LaunchURL() return. Properly highlight before
ICCF_LaunchURL(), especially noticable with menu.

APEInfo.rtfd: More fixes and updates, final for 1.4.2b1.

File:
1 edited

Legend:

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

    r182 r183  
    1313#import "ICeCoffEESuper.h"
    1414#import "ICeCoffEESetServicesMenu.h"
     15#import "ICeCoffEETrigger.h"
    1516
    1617iccfPrefRec ICCF_prefs;
     
    5960}
    6061
    61 iccfURLAction ICCF_KeyboardAction() {
    62     unsigned int modifierFlags = [[NSApp currentEvent] modifierFlags];
     62iccfURLAction ICCF_KeyboardAction(NSEvent *e) {
     63    unsigned int modifierFlags = [e modifierFlags];
    6364    iccfURLAction action;
    6465    action.presentMenu = (modifierFlags & NSAlternateKeyMask) != 0;
     
    239240}
    240241
    241 void ICCF_LaunchURL(NSString *string, iccfURLAction action) {
    242     OSStatus err;
     242BOOL ICCF_LaunchURL(NSString *string, iccfURLAction action) {
     243    OSStatus err = noErr;
    243244    long selStart, selEnd;
    244245    unsigned len = [string length];
     
    273274    NS_ENDHANDLER
    274275
    275     DisposeHandle(h);   
     276    DisposeHandle(h);
     277
     278    return (err == noErr);
    276279}
    277280
     
    303306}
    304307
    305 void ICCF_LaunchURLFromTextView(NSTextView *self) {
     308void ICCF_LaunchURLFromTextView(NSTextView *self, NSEvent *triggeringEvent) {
    306309    NSCharacterSet *urlLeftDelimiters = nil, *urlRightDelimiters = nil;
    307310    NSRange range = [self selectedRange], delimiterRange;
     
    371374        [self display];
    372375
    373         ICCF_LaunchURL([s substringWithRange: range], ICCF_KeyboardAction());
    374 
    375         if (ICCF_prefs.textBlinkEnabled) {
     376        if (ICCF_LaunchURL([s substringWithRange: range], ICCF_KeyboardAction(triggeringEvent)) && ICCF_prefs.textBlinkEnabled) {
    376377            for (i = 0 ; i < ICCF_prefs.textBlinkCount ; i++) {
    377378                NSRange emptyRange = {range.location, 0};
     
    500501}
    501502
     503static NSEvent *ICCF_MouseDownEventWithModifierFlags(NSEvent *e, BOOL inheritModifierFlags) {
     504    return [NSEvent mouseEventWithType: NSLeftMouseDown
     505                              location: [e locationInWindow]
     506                         modifierFlags: (inheritModifierFlags ? [e modifierFlags] : 0)
     507                             timestamp: [e timestamp]
     508                          windowNumber: [e windowNumber]
     509                               context: [e context]
     510                           eventNumber: [e eventNumber]
     511                            clickCount: 1
     512                              pressure: 0];
     513}
     514
    502515
    503516@interface NSTextView (IC_NSSharing)
     
    526539        servicesItem = nil;
    527540    }
    528     [[NSApp servicesMenu] update]; // enable keyboard equivalents
     541    if (floor(NSAppKitVersionNumber) <= NSAppKitVersionNumber10_3) {
     542        [[NSApp servicesMenu] update]; // enable keyboard equivalents in Mac OS X 10.3
     543    }
    529544}
    530545
     
    547562    ICLog(@"ICeCoffEE down: %@", e);
    548563#endif
     564    if (ICCF_sharedTrigger != nil) {
     565        ICLog(@"%@ cancelling", ICCF_sharedTrigger);
     566        [ICCF_sharedTrigger cancel];
     567    }
    549568    if (ICCF_enabled && ICCF_prefs.commandClickEnabled && ICCF_EventIsCommandMouseDown(e)) {
     569        BOOL inheritModifierFlags;
    550570        if ([self respondsToSelector: @selector(selectedRanges)]) {
    551             // discontiguous selection support, Mac OS X 10.4 or later
    552             NSArray *ranges = [self selectedRanges];
    553             ICLog(@"ICeCoffEE selected ranges: %@", ranges);
    554             if ([ranges count] > 1 || [[ranges objectAtIndex: 0] rangeValue].length != 0)
    555                 goto bypass;
     571            // Command-multiple-click or -drag for discontiguous selection, Mac OS X 10.4 or later
     572            inheritModifierFlags = YES;
    556573        } else {
    557574            // don't want to trigger selection extension or anything else; pass through as a plain click
    558             // (on Panther and earlier, command does not modify behavior)
     575            // (on Mac OS X 10.3, command does not modify behavior)
     576            inheritModifierFlags = NO;
    559577        }
    560         [super mouseDown: [NSEvent mouseEventWithType: NSLeftMouseDown location: [e locationInWindow] modifierFlags: 0 timestamp: [e timestamp] windowNumber: [e windowNumber] context: [e context] eventNumber: [e eventNumber] clickCount: 1 pressure: 0]];
     578        [super mouseDown: ICCF_MouseDownEventWithModifierFlags(e, inheritModifierFlags)];
    561579        // we don't actually get a mouseUp event, just wait for mouseDown to return
    562580        NSEvent *upEvent = [[self window] currentEvent];
     
    566584        NSAssert([upEvent type] == NSLeftMouseUp, @"NSTextView mouseDown: did not return with current event as mouse up!");
    567585        if (abs(downPt.x - upPt.x) <= kICHysteresisPixels && abs(downPt.y - upPt.y) <= kICHysteresisPixels) {
    568             ICCF_LaunchURLFromTextView(self);
     586            if (inheritModifierFlags) {
     587                // Mac OS X 10.4 and later: make sure we don't have a command-double-click
     588                [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
     589                ICLog(@"%@ set", ICCF_sharedTrigger);
     590            } else {
     591                // Mac OS X 10.3
     592                ICCF_LaunchURLFromTextView(self, e);
     593            }
    569594        }
    570595    } else {
    571 bypass:
    572596        [super mouseDown: e];
    573597    }
Note: See TracChangeset for help on using the changeset viewer.