Ignore:
Timestamp:
05/14/05 02:47:12 (19 years ago)
Author:
Nicholas Riley
Message:

English.lproj/APEInfo.rtfd: Partial documentation update for 1.4.2;
fixed many instances of outdated and incorrect information.

ICeCoffEE.m: Removed completed "to do" comments - that's what
OmniOutliner and Trac are for. Fixed delimiters to make more sense.
Redid ICCF_ParseURL() to make more sense and strip invalid characters
from beginning of URL. Added note about deprecated getCString:.
Fixed ICCF_ServicesMenuItem() to work on Tiger; moved menu population
logic (where services menu delegate used) to new
ICCF_SetServicesMenu() in ICeCoffEESetServicesMenu.[hm]. Remove key
equivalents from services in ICCF_ConsolidateServicesMenu(). First
pass at a workaround for discontiguous selection: only trigger if
there is no selection. This will be fixed to use a timer.

ICeCoffEEServicePrefController: Fixed service population to work on
Tiger, though keyboard equivalents are not provided; will need to
switch to parsing output of CFServiceControllerCopyServicesEntries()
for that one.

ICeCoffEEWebKit.m: Removed Safari 1.0-1.2 support. Fixed incorrect
comment about -selectionRect only being in Safari
1.1-1.2.

ICeCoffEESetServicesMenu.[hm]: Handle getting a usable services menu
for Panther and Tiger.

File:
1 edited

Legend:

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

    r169 r182  
    1515- (NSDictionary *)elementAtPoint:(NSPoint)point;
    1616- (NSString *)selectedString;
    17 - (void)deselectAll;
    18 
    19 // only in Safari 1.0-1.2
    20 - (void)setSelectionFrom:(id /* WebDOMNode */)start startOffset:(int)startOffset to:(id /* WebDOMNode */)end endOffset:(int) endOffset;
    21 
    22 - (id /* WebDOMNode */)selectionStart;
    23 - (int)selectionStartOffset;
    24 - (id /* WebDOMNode */)selectionEnd;
    25 - (int)selectionEndOffset;
    26 
    27 // only in Safari 1.1-1.2
    2817- (NSRect)selectionRect;
    2918
    30 // only in Safari 1.3
    3119- (void)selectNSRange:(NSRange)range;
     20- (void)deselectAll;
    3221
    3322@end
     
    3827- (WebCoreBridge *)_bridge;
    3928
    40 // only in Safari 1.3
    4129- (NSRange)selectedRange;
    4230
     
    5240
    5341static NSEvent *downEvent = nil;
    54 
    55 // used in Safari < 1.3 because there's no sane way to set the selection
    56 typedef struct {
    57     int startOffset;
    58     int endOffset;
    59     id fromNode;
    60     id toNode;
    61 } ICCF_WebCoreSelection;
    62 
    63 static ICCF_WebCoreSelection selection = {nil, nil, 0, 0};
    64 
    65 void ICCF_GetWebCoreBridgeSelection(WebCoreBridge *bridge, ICCF_WebCoreSelection *ioSel) {
    66     [ioSel->fromNode release]; ioSel->fromNode = nil;
    67     [ioSel->toNode release]; ioSel->toNode = nil;
    68     ioSel->startOffset = [bridge selectionStartOffset];
    69     ioSel->endOffset = [bridge selectionEndOffset];
    70     ioSel->fromNode = [[bridge selectionStart] retain];
    71     ioSel->toNode = [[bridge selectionEnd] retain];
    72 }
    73 
    74 void ICCF_SetWebCoreBridgeSelection(WebCoreBridge *bridge, ICCF_WebCoreSelection *inSel) {
    75     if (inSel->fromNode == nil || inSel->toNode == nil)
    76         [bridge deselectAll];
    77     [bridge setSelectionFrom: inSel->fromNode
    78                  startOffset: inSel->startOffset
    79                           to: inSel->toNode
    80                    endOffset: inSel->endOffset];
    81 }
    82 // end Safari < 1.3 section
    83 
    8442static NSString *selectedString = nil;
    8543static NSRange selectedRange;
     
    8745- (void)mouseDown:(NSEvent *)e;
    8846{
    89         [downEvent release]; downEvent = nil;
    90     // don't want command-option-click, command-shift-click, etc. to trigger
     47    [downEvent release]; downEvent = nil;
     48    // don't want command-control-click, command-shift-click, etc. to trigger
    9149    if (ICCF_enabled && ICCF_prefs.commandClickEnabled && ICCF_EventIsCommandMouseDown(e)) {
    9250        WebCoreBridge *bridge = [(WebHTMLView *)self _bridge];
    93                 if ([self respondsToSelector: @selector(selectedRange)]) {
    94                         // Safari 1.3 save selection: it may be deselected on super mouseDown
    95                         selectedRange = [(WebHTMLView *)self selectedRange];
    96                 } else if ([bridge respondsToSelector: @selector(selectionStartOffset)]) {
    97                         // Safari < 1.3 save selection: it will be deselected on super mouseDown
    98                         ICCF_GetWebCoreBridgeSelection(bridge, &selection);
    99                         ICLog(@"selection start %d@%@ end %d@%@ string %@", [bridge selectionStartOffset], [bridge selectionStart], [bridge selectionEndOffset], [bridge selectionEnd], [bridge selectedString]);
    100                 }
    101                 [selectedString release]; selectedString = nil;
    102                 selectedString = [[bridge selectedString] retain];
     51        if ([self respondsToSelector: @selector(selectedRange)]) {
     52            // save selection: it may be deselected on super mouseDown
     53            selectedRange = [(WebHTMLView *)self selectedRange];
     54        }
     55        [selectedString release]; selectedString = nil;
     56        selectedString = [[bridge selectedString] retain];
    10357        downEvent = [e retain];
    10458    }
     
    12680                NS_VOIDRETURN; // donÕt activate on links
    12781            }
    128                         if (selectedString == nil || [selectedString length] == 0) {
    129                                 ICLog(@"no selected string");
    130                                 NS_VOIDRETURN;
    131                         }
    132                         ICCF_StartIC();
    133                         ICCF_LaunchURL(selectedString, ICCF_KeyboardAction());
    134                         if (ICCF_prefs.textBlinkEnabled &&
    135                                 [bridge respondsToSelector: @selector(selectNSRange:)]) {
    136                                 // blink text in Safari 1.3
    137                                 [bridge selectNSRange: selectedRange];
    138                                 int i;
    139                                 NSRect selectionRect = [bridge selectionRect];
    140                                 ICLog(@"selectedRange %@ selectionRect %@ textBlinkCount %d", NSStringFromRange(selectedRange), NSStringFromRect(selectionRect), ICCF_prefs.textBlinkCount);
    141                                 for (i = 0 ; i < ICCF_prefs.textBlinkCount ; i++) {
    142                                         [bridge deselectAll];
    143                                         [self setNeedsDisplayInRect: selectionRect];
    144                                         [self display];
    145                                         usleep(kICBlinkDelayUsecs);
    146                                         [bridge selectNSRange: selectedRange];
    147                                         [self setNeedsDisplayInRect: selectionRect];
    148                                         [self display];
    149                                         usleep(kICBlinkDelayUsecs);
    150                                 }
    151                         } else {
    152                                 // select text in Safari 1.0-1.2
    153                                 ICCF_SetWebCoreBridgeSelection(bridge, &selection);
    154                                 if (ICCF_prefs.textBlinkEnabled &&
    155                                         [bridge respondsToSelector: @selector(selectionRect)]) {
    156                                         // blink text in Safari 1.1/1.2
    157                                         int i;
    158                                         NSRect selectionRect = [bridge selectionRect];
    159                                         for (i = 0 ; i < ICCF_prefs.textBlinkCount ; i++) {
    160                                                 [bridge deselectAll];
    161                                                 [self setNeedsDisplayInRect: selectionRect];
    162                                                 [self display];
    163                                                 usleep(kICBlinkDelayUsecs);
    164                                                 ICCF_SetWebCoreBridgeSelection(bridge, &selection);
    165                                                 [self setNeedsDisplayInRect: selectionRect];
    166                                                 [self display];
    167                                                 usleep(kICBlinkDelayUsecs);
    168                                         }
    169                                 }
    170                         }
     82            if (selectedString == nil || [selectedString length] == 0) {
     83                ICLog(@"no selected string");
     84                NS_VOIDRETURN;
     85            }
     86            ICCF_StartIC();
     87            ICCF_LaunchURL(selectedString, ICCF_KeyboardAction());
     88            if (ICCF_prefs.textBlinkEnabled && [bridge respondsToSelector: @selector(selectNSRange:)]) {
     89                [bridge selectNSRange: selectedRange];
     90                int i;
     91                NSRect selectionRect = [bridge selectionRect];
     92                ICLog(@"selectedRange %@ selectionRect %@ textBlinkCount %d", NSStringFromRange(selectedRange), NSStringFromRect(selectionRect), ICCF_prefs.textBlinkCount);
     93                for (i = 0 ; i < ICCF_prefs.textBlinkCount ; i++) {
     94                    [bridge deselectAll];
     95                    [self setNeedsDisplayInRect: selectionRect];
     96                    [self display];
     97                    usleep(kICBlinkDelayUsecs);
     98                    [bridge selectNSRange: selectedRange];
     99                    [self setNeedsDisplayInRect: selectionRect];
     100                    [self display];
     101                    usleep(kICBlinkDelayUsecs);
     102                }
     103            }
    171104        NS_HANDLER
    172105            ICCF_HandleException(localException);
Note: See TracChangeset for help on using the changeset viewer.