1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 *
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
9 *
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
14 *
15 * The Original Code is mozilla.org code.
16 *
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998
20 * the Initial Developer. All Rights Reserved.
21 *
22 * Contributor(s):
23 *
24 * Alternatively, the contents of this file may be used under the terms of
25 * either of the GNU General Public License Version 2 or later (the "GPL"),
26 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
35 *
36 * ***** END LICENSE BLOCK ***** */
37
38 #include "nsISupports.idl"
39
40 interface nsIDOMKeyEvent;
41
42 [scriptable, uuid(1480e196-0d5c-40cf-8563-ed8a33eabcf2)]
43 interface nsIPlaintextEditor : nsISupports
44 {
45
46 // XXX Why aren't these in nsIEditor?
47 const long eEditorPlaintextMask = 0x0001; /* only plain text entry is allowed via events */
48 const long eEditorSingleLineMask = 0x0002; /* enter key and CR-LF handled specially */
49 const long eEditorPasswordMask = 0x0004; /* text is not entered into content, only a representative character */
50 const long eEditorReadonlyMask = 0x0008; /* editing events are disabled. Editor may still accept focus. */
51 const long eEditorDisabledMask = 0x0010; /* all events are disabled (like scrolling). Editor will not accept focus. */
52 const long eEditorFilterInputMask = 0x0020; /* text input is limited to certain character types, use mFilter */
53 const long eEditorMailMask = 0x0040; /* use mail-compose editing rules */
54 const long eEditorUseAsyncUpdatesMask = 0x0080; /* prevent immediate reflows and view refreshes */
55 const long eEditorEnableWrapHackMask = 0x0100; /* allow the editor to set font: monospace on the root node */
56 const long eEditorWidgetMask = 0x0200; /* bit for widgets */
57 const long eEditorNoCSSMask = 0x0400; /* this HTML editor should not create css styles */
58 const long eEditorAllowInteraction = 0x0800; /* */
59
60 /*
61 * The valid values for newlines handling.
62 * Can't change the values unless we remove
63 * use of the pref.
64 */
65 const long eNewlinesPasteIntact = 0;
66 const long eNewlinesPasteToFirst = 1;
67 const long eNewlinesReplaceWithSpaces = 2;
68 const long eNewlinesStrip = 3;
69 const long eNewlinesReplaceWithCommas = 4;
70 const long eNewlinesStripSurroundingWhitespace = 5;
71
72 /**
73 * The length of the contents in characters.
74 * XXX change this type to 'unsigned long'
75 */
76 readonly attribute long textLength;
77
78 /**
79 * The maximum number of characters allowed.
80 * default: -1 (unlimited).
81 */
82 attribute long maxTextLength;
83
84 /** Get and set the body wrap width.
85 *
86 * Special values:
87 * 0 = wrap to window width
88 * -1 = no wrap at all
89 */
90 attribute long wrapWidth;
91
92 /**
93 * Similar to the setter for wrapWidth, but just sets the editor
94 * internal state without actually changing the content being edited
95 * to wrap at that column. This should only be used by callers who
96 * are sure that their content is already set up correctly.
97 */
98 void setWrapColumn(in long aWrapColumn);
99
100 /** Get and set newline handling.
101 *
102 * Values are the constants defined above.
103 */
104 attribute long newlineHandling;
105
106 /**
107 * EditorKeyPress consumes a keyevent.
108 * @param aKeyEvent key event to consume
109 */
110 void handleKeyPress(in nsIDOMKeyEvent aKeyEvent);
111
112 /**
113 * Inserts a string at the current location,
114 * given by the selection.
115 * If the selection is not collapsed, the selection is deleted
116 * and the insertion takes place at the resulting collapsed selection.
117 *
118 * @param aString the string to be inserted
119 */
120 void insertText(in DOMString aStringToInsert);
121
122 /**
123 * Insert a line break into the content model.
124 * The interpretation of a break is up to the implementation:
125 * it may enter a character, split a node in the tree, etc.
126 * This may be more efficient than calling InsertText with a newline.
127 */
128 void insertLineBreak();
129 };