source: trunk/ICeCoffEE/ICeCoffEE/ICeCoffEEWebKit.m@ 216

Last change on this file since 216 was 216, checked in by Nicholas Riley, 18 years ago

VERSION: Starting with 1.4.3d1.

APE.icns: Generic APE icon (not sure whether we care).

SmartCrashReportsAPI.[ho]: SCR 1.1.

ICeCoffEEWebKit.m: -elementAtPoint: isn't in current
development WebKit; switch to the version in WebHTMLView.

Info-APE Module.plist: Update version to 1.4.3d1.

ICeCoffEE.xcodeproj: Xcode 2 version of project, required fixing
script which copies the APE bundle into the installer. We're still
building for 10.3.9 and later on PowerPC only for this release.

English.lproj/APEInfo.rtfd: Small clarifications, update release notes
and version information.

English.lproj/InfoPlist.strings: Update version to 1.4.3d1.

ICeCoffEEShared.h: Use varargs macros to finally fix the stupid
warnings when ICCF_DEBUG is 0.

ICeCoffEE APE.xcode: Removed.

ICeCoffEETerminal.m: Fixes crash on clicking disabled close/minimize
widgets in Open dialog (invalid super method call) by implementing
overridden methods in the faked superclass.

ape_install: APE 1.5.1.

Info-APEManagerPrefPane.plist: Update version number.

APEMain.m: Implement SCR. Fix a comment typo. Remove some useless
uses of the comma operator so the new warning-less ICapeprintf works.

package-ICeCoffEE.sh: Use new xcodebuild syntax and build layout.
Remove a useless use of the semicolon. Nuke localizations on
development builds.

File size: 3.5 KB
Line 
1//
2// ICeCoffEEWebKit.m
3// ICeCoffEE APE
4//
5// Created by Nicholas Riley on Sun Jan 19 2003.
6// Copyright (c) 2003 Nicholas Riley. All rights reserved.
7//
8
9#import "ICeCoffEEWebKit.h"
10#import <unistd.h>
11
12// from WebCoreBridge.h
13@interface WebCoreBridge : NSObject
14
15- (NSString *)selectedString;
16- (NSRect)selectionRect;
17
18- (void)selectNSRange:(NSRange)range;
19- (void)deselectAll;
20
21@end
22
23// from WebKit, private
24@interface WebHTMLView : NSObject
25
26- (WebCoreBridge *)_bridge;
27
28- (NSRange)selectedRange;
29
30- (NSDictionary *)elementAtPoint:(NSPoint)point;
31
32@end
33
34@implementation ICeCoffEEWebKit
35
36- (NSMenu *)menuForEvent:(NSEvent *)e;
37{
38 NSMenu *myMenu = [super menuForEvent: e];
39 return ICCF_MenuForEvent(self, myMenu, e);
40}
41
42static NSEvent *downEvent = nil;
43static NSString *selectedString = nil;
44static NSRange selectedRange;
45
46- (void)mouseDown:(NSEvent *)e;
47{
48 [downEvent release]; downEvent = nil;
49 if (ICCF_enabled && ICCF_prefs.commandClickEnabled && ICCF_EventIsCommandMouseDown(e)) {
50 WebCoreBridge *bridge = [(WebHTMLView *)self _bridge];
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];
57 downEvent = [e retain];
58 }
59 [super mouseDown: e];
60}
61
62- (void)mouseUp:(NSEvent *)e;
63{
64 [super mouseUp: e];
65 if (downEvent != nil) {
66 NSPoint downPt = [downEvent locationInWindow];
67 NSPoint upPt = [e locationInWindow];
68 if (abs(downPt.x - upPt.x) > kICHysteresisPixels && abs(downPt.y - upPt.y) > kICHysteresisPixels)
69 return;
70
71 NS_DURING
72 NSPoint viewClickPt = [self convertPoint: downPt fromView: nil];
73 NSDictionary *elementDict = [(WebHTMLView *)self elementAtPoint: viewClickPt];
74 WebCoreBridge *bridge = [(WebHTMLView *)self _bridge];
75 ICLog(@"elementDict: %@", elementDict);
76 NSAssert([elementDict count] != 0, @"Internal error: Got empty element dictionary from WebHTMLView");
77 if ([elementDict objectForKey: @"WebElementLinkURL"] != nil) {
78 ICLog(@"got a link");
79 NS_VOIDRETURN; // donÕt activate on links
80 }
81 if (selectedString == nil || [selectedString length] == 0) {
82 ICLog(@"no selected string");
83 NS_VOIDRETURN;
84 }
85 ICCF_StartIC();
86 BOOL canSetSelection = [bridge respondsToSelector: @selector(selectNSRange:)];
87 if (canSetSelection) {
88 // may have become deselected in mouseDown
89 [bridge selectNSRange: selectedRange];
90 }
91 if (ICCF_LaunchURL(selectedString, ICCF_KeyboardAction(downEvent)) && ICCF_prefs.textBlinkEnabled && canSetSelection) {
92 int i;
93 NSRect selectionRect = [bridge selectionRect];
94 ICLog(@"selectedRange %@ selectionRect %@ textBlinkCount %d", NSStringFromRange(selectedRange), NSStringFromRect(selectionRect), ICCF_prefs.textBlinkCount);
95 for (i = 0 ; i < ICCF_prefs.textBlinkCount ; i++) {
96 [bridge deselectAll];
97 [self setNeedsDisplayInRect: selectionRect];
98 [self display];
99 usleep(kICBlinkDelayUsecs);
100 [bridge selectNSRange: selectedRange];
101 [self setNeedsDisplayInRect: selectionRect];
102 [self display];
103 usleep(kICBlinkDelayUsecs);
104 }
105 }
106 NS_HANDLER
107 ICCF_HandleException(localException);
108 NS_ENDHANDLER
109
110 [downEvent release]; downEvent = nil;
111 ICCF_StopIC();
112 }
113}
114
115@end
Note: See TracBrowser for help on using the repository browser.