2 * Copyright (C) 2008, Apple Inc. and The Mozilla Foundation.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. Neither the names of Apple Inc. ("Apple") or The Mozilla
15 * Foundation ("Mozilla") nor the names of their contributors may be used
16 * to endorse or promote products derived from this software without
17 * specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY APPLE, MOZILLA AND THEIR CONTRIBUTORS "AS
20 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE, MOZILLA OR
23 * THEIR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
25 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 #error "npinput.h can only be included from Objective-C code."
38 #ifndef _NP_TEXTINPUT_H_
39 #define _NP_TEXTINPUT_H_
45 #include <WebKit/npapi.h>
47 #import <Cocoa/Cocoa.h>
49 typedef void (*NPP_InsertTextFunc)(NPP npp, id aString);
50 typedef void (*NPP_DoCommandBySelectorFunc)(NPP npp, SEL aSelector);
51 typedef void (*NPP_SetMarkedTextFunc)(NPP npp, id aString, NSRange selRange);
52 typedef void (*NPP_UnmarkTextFunc)(NPP npp);
53 typedef BOOL (*NPP_HasMarkedTextFunc)(NPP npp);
54 typedef NSAttributedString * (*NPP_AttributedSubstringFromRangeFunc)(NPP npp, NSRange theRange);
55 typedef NSRange (*NPP_MarkedRangeFunc)(NPP npp);
56 typedef NSRange (*NPP_SelectedRangeFunc)(NPP npp);
57 typedef NSRect (*NPP_FirstRectForCharacterRangeFunc)(NPP npp, NSRange theRange);
58 typedef unsigned long long (*NPP_CharacterIndexForPointFunc)(NPP npp, NSPoint thePoint);
59 typedef NSArray *(*NPP_ValidAttributesForMarkedTextFunc)(NPP npp);
61 typedef struct _NPPluginTextInputFuncs {
65 NPP_InsertTextFunc insertText;
66 NPP_DoCommandBySelectorFunc doCommandBySelector;
67 NPP_SetMarkedTextFunc setMarkedText;
68 NPP_UnmarkTextFunc unmarkText;
69 NPP_HasMarkedTextFunc hasMarkedText;
70 NPP_AttributedSubstringFromRangeFunc attributedSubstringFromRange;
71 NPP_MarkedRangeFunc markedRange;
72 NPP_SelectedRangeFunc selectedRange;
73 NPP_FirstRectForCharacterRangeFunc firstRectForCharacterRange;
74 NPP_CharacterIndexForPointFunc characterIndexForPoint;
75 NPP_ValidAttributesForMarkedTextFunc validAttributesForMarkedText;
76 } NPPluginTextInputFuncs;
78 void NPP_InsertText(NPP npp, id aString);
79 void NPP_DoCommandBySelector(NPP npp, SEL aSelector);
80 void NPP_SetMarkedText(NPP npp, id aString, NSRange selRange);
81 void NPP_UnmarkText(NPP npp);
82 BOOL NPP_HasMarkedText(NPP npp);
83 NSAttributedString *NPP_AttributedSubstringFromRange(NPP npp, NSRange theRange);
84 NSRange NPP_MarkedRange(NPP npp);
85 NSRange NPP_SelectedRange(NPP npp);
86 NSRect NPP_FirstRectForCharacterRange(NPP npp, NSRange theRange);
87 unsigned long long NPP_CharacterIndexForPoint(NPP npp, NSPoint thePoint);
88 NSArray NPP_ValidAttributesForMarkedText(NPP npp);
90 typedef void (*NPN_MarkedTextAbandonedFunc)(NPP npp);
91 typedef void (*NPN_MarkedTextSelectionChangedFunc)(NPP npp, NSRange newSel);
93 typedef struct _NPBrowserTextInputFuncs {
97 NPN_MarkedTextAbandonedFunc markedTextAbandoned;
98 NPN_MarkedTextSelectionChangedFunc markedTextSelectionChanged;
99 } NPBrowserTextInputFuncs;
101 void NPN_MarkedTextAbandoned(NPP npp);
102 void NPN_MarkedTextSelectionChanged(NPP npp, NSRange newSel);