Ignore:
Timestamp:
06/15/07 05:15:03 (17 years ago)
Author:
Nicholas Riley
Message:

ICeCoffEE.m: I was wrong in [319] about the selection extension stuff
being dumb; explain why in code, even though it's not fixed.
Implement some of the same parens support I did in Terminal. Update
for more robust service info dictionary format.

ICeCoffEEServicePrefController.m: Update for more robust service info
dictionary format.

ICeCoffEEServices.[hm]: Renamed from ICeCoffEESetServicesMenu.[hm],
since we do more now. Service info dictionary-creating code now makes
more sense and no longer has naming collision issues.

ICeCoffEEWebKit.m: Some preliminary Safari 3 compatibility stuff, not
quite working yet. An outstanding question - is it better to rely on
"public" WebCore API or private WebKit API? So far it seems the
latter is more stable.

English.lproj/APEInfo.rtfd: The Bored Zo has a name: use it. Remove
now-erroneous reference to SimpleText since TextEdit support is gone.

File:
1 edited

Legend:

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

    r319 r320  
    1212#include <unistd.h>
    1313#import "ICeCoffEESuper.h"
    14 #import "ICeCoffEESetServicesMenu.h"
     14#import "ICeCoffEEServices.h"
    1515#import "ICeCoffEETrigger.h"
    1616
     
    344344        ICCF_Delimiters(&urlLeftDelimiters, &urlRightDelimiters);
    345345
     346expandFront:
    346347        // XXX instead of 0, make this stop at the max URL length to prevent protracted searches
     348           
     349        // XXX here's how this is supposed to work:
     350        // (http://web.sabi.net/) and <http://web.sabi.net/> should work if they are the entire document, even if clicking at the end/beginning of the document, not barfing with "no URL" (correct, as now) or selecting the final >, or ) (what would happen if we remove this "add 1" accommodation).  But how about "http://web.sabi.net/(foo)"?  That should work too, as long as it's not preceded by a (.
     351        // Should probably backport to ICeCoffEETerminal, now I finally understand the method to this madness.
    347352        // add 1 to range to trap delimiters that are on the edge of the selection (i.e., <...)
    348353        delimiterRange = [s rangeOfCharacterFromSet: urlLeftDelimiters
     
    357362            range.length += range.location - delimiterRange.location - 1;
    358363            range.location = delimiterRange.location + 1;
    359         }
    360 
     364
     365            // in url/(parens)stuff, handle clicking inside or after (parens).
     366            if ([s characterAtIndex: delimiterRange.location] == '(' &&
     367                range.location > 2 /* prevent wrapping, ordinarily not necessary */) {
     368                if ([s rangeOfString: @")" options: NSLiteralSearch range: range].location != NSNotFound ||
     369                    [s rangeOfCharacterFromSet: [NSCharacterSet characterSetWithCharactersInString: @"/."]
     370                                       options: NSLiteralSearch range: range].location == NSNotFound) {
     371                    range.location -= 2;
     372                    range.length += 2;
     373                    ICLog(@"expanding past (, now |%@|", [s substringWithRange: range]);
     374                    goto expandFront;
     375                }
     376            }       
     377        }
     378       
    361379        ICCF_CheckRange(range);
    362380
     381expandBack:
    363382        // XXX instead of length of string, make this stop at the max URL length to prevent protracted searches
    364383        // add 1 to range to trap delimiters that are on the edge of the selection (i.e., ...>)
     
    374393            NSCAssert(delimiterRange.length == 1, @"Internal error: delimiter matched range is not of length 1");
    375394            range.length += delimiterRange.location - range.location - range.length;
     395           
     396            // grow URL past closing paren if we've seen an open paren
     397            if ([s characterAtIndex: delimiterRange.location] == ')' &&
     398                [s rangeOfString: @"(" options: NSLiteralSearch range: range].location != NSNotFound) {
     399                range.length += 2;
     400                ICLog(@"expanding past ), now |%@|", [s substringWithRange: range]);
     401                goto expandBack;
     402            }
    376403        }
    377404
     
    436463
    437464// returns YES if menu contains useful items, NO otherwise
    438 BOOL ICCF_ConsolidateServicesMenu(NSMenu *menu, NSDictionary *serviceOptions, NSDictionary *serviceInfo) {
     465static BOOL ICCF_ConsolidateServicesMenu(NSMenu *menu, NSDictionary *serviceOptions, NSDictionary *serviceInfo) {
    439466    [menu update]; // doesn't propagate to submenus, so we need to do this first
    440467    NSEnumerator *enumerator = [[menu itemArray] objectEnumerator];
     
    453480        } else if ( (submenu = [menuItem submenu]) != nil) {
    454481            // XXX don't rely on nil-sending working
    455             shouldKeepItem = ICCF_ConsolidateServicesMenu(submenu, [itemOptions objectForKey: (NSString *)kICServiceSubmenu], itemInfo);
     482            shouldKeepItem = ICCF_ConsolidateServicesMenu(submenu, [itemOptions objectForKey: (NSString *)kICServiceSubmenu], [itemInfo objectForKey: (NSString *)kICServiceSubmenu]);
    456483            if (shouldKeepItem && [submenu numberOfItems] == 1) { // consolidate
    457484                NSMenuItem *serviceItem = [[submenu itemAtIndex: 0] retain];
Note: See TracChangeset for help on using the changeset viewer.