2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* $XConsortium: Editor.h /main/3 1995/10/26 09:32:07 rswiston $ */
25 * (c) Copyright 1993, 1994 Hewlett-Packard Company
26 * (c) Copyright 1993, 1994 International Business Machines Corp.
27 * (c) Copyright 1993, 1994 Sun Microsystems, Inc.
28 * (c) Copyright 1993, 1994 Novell, Inc.
45 /* Sources of Help requests */
46 /* Used with XmNhelpCallback */
48 #define DtEDITOR_HELP_EDIT_WINDOW 1
49 #define DtEDITOR_HELP_STATUS_LINE 2
50 #define DtEDITOR_HELP_STATUS_CURRENT_LINE 3
51 #define DtEDITOR_HELP_STATUS_TOTAL_LINES 4
52 #define DtEDITOR_HELP_STATUS_MESSAGE 5
53 #define DtEDITOR_HELP_STATUS_OVERSTRIKE 6
54 #define DtEDITOR_HELP_FORMAT_DIALOG 7
55 #define DtEDITOR_HELP_FORMAT_LEFT_MARGIN 8
56 #define DtEDITOR_HELP_FORMAT_RIGHT_MARGIN 9
57 #define DtEDITOR_HELP_FORMAT_ALIGNMENT 10
58 #define DtEDITOR_HELP_CHANGE_DIALOG 11
59 #define DtEDITOR_HELP_CHANGE_FIND 12
60 #define DtEDITOR_HELP_CHANGE_CHANGE 13
61 #define DtEDITOR_HELP_SPELL_DIALOG 14
62 #define DtEDITOR_HELP_SPELL_MISSPELLED_WORDS 15
63 #define DtEDITOR_HELP_SPELL_CHANGE 16
65 /* Specifies the last line in the edit area */
66 /* Used with DtEditorGoToLine */
67 #define DtEDITOR_LAST_LINE -999
69 /* Resource constants */
71 #ifndef DtNautoShowCursorPosition
72 #define DtNautoShowCursorPosition XmNautoShowCursorPosition
74 #ifndef DtCAutoShowCursorPosition
75 #define DtCAutoShowCursorPosition XmCAutoShowCursorPosition
78 #define DtNblinkRate XmNblinkRate
81 #define DtCBlinkRate XmCBlinkRate
83 #ifndef DtNbuttonFontList
84 #define DtNbuttonFontList XmNbuttonFontList
87 #define DtCFontList XmCFontList
89 #ifndef DtNcenterToggleLabel
90 #define DtNcenterToggleLabel "centerToggleLabel"
92 #ifndef DtCCenterToggleLabel
93 #define DtCCenterToggleLabel "CenterToggleLabel"
95 #ifndef DtNchangeAllButtonLabel
96 #define DtNchangeAllButtonLabel "changeAllButtonLabel"
98 #ifndef DtCChangeAllButtonLabel
99 #define DtCChangeAllButtonLabel "ChangeAllButtonLabel"
101 #ifndef DtNchangeButtonLabel
102 #define DtNchangeButtonLabel "changeButtonLabel"
104 #ifndef DtCChangeButtonLabel
105 #define DtCChangeButtonLabel "ChangeButtonLabel"
107 #ifndef DtNchangeFieldLabel
108 #define DtNchangeFieldLabel "changeFieldLabel"
110 #ifndef DtCChangeFieldLabel
111 #define DtCChangeFieldLabel "ChangeFieldLabel"
114 #define DtNcolumns XmNcolumns
117 #define DtCColumns XmCColumns
119 #ifndef DtNcurrentLineLabel
120 #define DtNcurrentLineLabel "currentLineLabel"
122 #ifndef DtCCurrentLineLabel
123 #define DtCCurrentLineLabel "CurrentLineLabel"
125 #ifndef DtNcursorPosition
126 #define DtNcursorPosition XmNcursorPosition
128 #ifndef DtCCursorPosition
129 #define DtCCursorPosition XmCCursorPosition
131 #ifndef DtNcursorPositionVisible
132 #define DtNcursorPositionVisible XmNcursorPositionVisible
134 #ifndef DtCCursorPositionVisible
135 #define DtCCursorPositionVisible XmCCursorPositionVisible
137 #ifndef DtNdialogTitle
138 #define DtNdialogTitle "dialogTitle"
140 #ifndef DtCDialogTitle
141 #define DtCDialogTitle XmCDialogTitle
144 #define DtNeditable XmNeditable
147 #define DtCEditable XmCEditable
149 #ifndef DtNfindButtonLabel
150 #define DtNfindButtonLabel "findButtonLabel"
152 #ifndef DtCFindButtonLabel
153 #define DtCFindButtonLabel "FindButtonLabel"
155 #ifndef DtNfindChangeDialogTitle
156 #define DtNfindChangeDialogTitle "findChangeDialogTitle"
158 #ifndef DtCFindChangeDialogTitle
159 #define DtCFindChangeDialogTitle "FindChangeDialogTitle"
161 #ifndef DtNfindFieldLabel
162 #define DtNfindFieldLabel "findFieldLabel"
164 #ifndef DtCFindFieldLabel
165 #define DtCFindFieldLabel "FindFieldLabel"
167 #ifndef DtNformatAllButtonLabel
168 #define DtNformatAllButtonLabel "formatAllButtonLabel"
170 #ifndef DtCFormatAllButtonLabel
171 #define DtCFormatAllButtonLabel "FormatAllButtonLabel"
173 #ifndef DtNformatParagraphButtonLabel
174 #define DtNformatParagraphButtonLabel "formatParagraphButtonLabel"
176 #ifndef DtCFormatParagraphButtonLabel
177 #define DtCFormatParagraphButtonLabel "FormatParagraphButtonLabel"
179 #ifndef DtNformatSettingsDialogTitle
180 #define DtNformatSettingsDialogTitle "formatSettingsDialogTitle"
182 #ifndef DtCFormatSettingsDialogTitle
183 #define DtCFormatSettingsDialogTitle "FormatSettingsDialogTitle"
185 #ifndef DtNinformationDialogTitle
186 #define DtNinformationDialogTitle "informationDialogTitle"
188 #ifndef DtCInformationDialogTitle
189 #define DtCInformationDialogTitle "InformationDialogTitle"
191 #ifndef DtNinsertLabel
192 #define DtNinsertLabel "insertLabel"
194 #ifndef DtCInsertLabel
195 #define DtCInsertLabel "InsertLabel"
197 #ifndef DtNjustifyToggleLabel
198 #define DtNjustifyToggleLabel "justifyToggleLabel"
200 #ifndef DtCJustifyToggleLabel
201 #define DtCJustifyToggleLabel "JustifyToggleLabel"
203 #ifndef DtNlabelFontList
204 #define DtNlabelFontList XmNlabelFontList
206 #ifndef DtNleftAlignToggleLabel
207 #define DtNleftAlignToggleLabel "leftAlignToggleLabel"
209 #ifndef DtCLeftAlignToggleLabel
210 #define DtCLeftAlignToggleLabel "LeftAlignToggleLabel"
212 #ifndef DtNleftMarginFieldLabel
213 #define DtNleftMarginFieldLabel "leftMarginFieldLabel"
215 #ifndef DtCLeftMarginFieldLabel
216 #define DtCLeftMarginFieldLabel "LeftMarginFieldLabel"
219 #define DtNmaxLength XmNmaxLength
222 #define DtCMaxLength XmCMaxLength
224 #ifndef DtNmisspelledListLabel
225 #define DtNmisspelledListLabel "misspelledListLabel"
227 #ifndef DtCMisspelledListLabel
228 #define DtCMisspelledListLabel "MisspelledListLabel"
230 #ifndef DtNoverstrike
231 #define DtNoverstrike "overstrike"
233 #ifndef DtCOverstrike
234 #define DtCOverstrike "Overstrike"
236 #ifndef DtNoverstrikeLabel
237 #define DtNoverstrikeLabel "overstrikeLabel"
239 #ifndef DtCOverstrikeLabel
240 #define DtCOverstrikeLabel "OverstrikeLabel"
242 #ifndef DtNrightAlignToggleLabel
243 #define DtNrightAlignToggleLabel "rightAlignToggleLabel"
245 #ifndef DtCRightAlignToggleLabel
246 #define DtCRightAlignToggleLabel "RightAlignToggleLabel"
248 #ifndef DtNrightMarginFieldLabel
249 #define DtNrightMarginFieldLabel "rightMarginFieldLabel"
251 #ifndef DtCRightMarginFieldLabel
252 #define DtCRightMarginFieldLabel "RightMarginFieldLabel"
255 #define DtNrows XmNrows
258 #define DtCRows XmCRows
260 #ifndef DtNscrollHorizontal
261 #define DtNscrollHorizontal XmNscrollHorizontal
264 #define DtCScroll XmCScroll
266 #ifndef DtNscrollLeftSide
267 #define DtNscrollLeftSide XmNscrollLeftSide
269 #ifndef DtCScrollSide
270 #define DtCScrollSide XmCScrollSide
272 #ifndef DtNscrollTopSide
273 #define DtNscrollTopSide XmNscrollTopSide
275 #ifndef DtNscrollVertical
276 #define DtNscrollVertical XmNscrollVertical
278 #ifndef DtNshowStatusLine
279 #define DtNshowStatusLine "showStatusLine"
281 #ifndef DtCShowStatusLine
282 #define DtCShowStatusLine "ShowStatusLine"
284 #ifndef DtNspellDialogTitle
285 #define DtNspellDialogTitle "spellDialogTitle"
287 #ifndef DtCSpellDialogTitle
288 #define DtCSpellDialogTitle "SpellDialogTitle"
290 #ifndef DtNspellFilter
291 #define DtNspellFilter "spellFilter"
293 #ifndef DtCSpellFilter
294 #define DtCSpellFilter "SpellFilter"
296 #ifndef DtNtextBackground
297 #define DtNtextBackground "textBackground"
299 #ifndef DtCBackground
300 #define DtCBackground XmCBackground
302 #ifndef DtNtextDeselectCallback
303 #define DtNtextDeselectCallback "textDeselectCallback"
305 #ifndef DtNtextFontList
306 #define DtNtextFontList XmNtextFontList
308 #ifndef DtNtextForeground
309 #define DtNtextForeground "textForeground"
311 #ifndef DtCForeground
312 #define DtCForeground XmCForeground
314 #ifndef DtNtextSelectCallback
315 #define DtNtextSelectCallback "textSelectCallback"
317 #ifndef DtNtextTranslations
318 #define DtNtextTranslations XmNtextTranslations
320 #ifndef DtCTranslations
321 #define DtCTranslations XmCTranslations
324 #define DtCCallback XmCCallback
326 #ifndef DtNtopCharacter
327 #define DtNtopCharacter XmNtopCharacter
329 #ifndef DtCTopCharacter
330 #define DtCTopCharacter XmCTopCharacter
332 #ifndef DtNtotalLineCountLabel
333 #define DtNtotalLineCountLabel "totalLineCountLabel"
335 #ifndef DtCTotalLineCountLabel
336 #define DtCTotalLineCountLabel "TotalLineCountLabel"
339 #define DtNwordWrap XmNwordWrap
342 #define DtCWordWrap XmCWordWrap
345 #ifndef DtEditorHelpCallbackStruct
346 #define DtEditorHelpCallbackStruct XmAnyCallbackStruct
348 #ifndef DtEditorSelectCallbackStruct
349 #define DtEditorSelectCallbackStruct XmAnyCallbackStruct
351 #ifndef DtEditorDeselectCallbackStruct
352 #define DtEditorDeselectCallbackStruct XmAnyCallbackStruct
356 /* Used with DtEditorChange() */
359 DtEDITOR_CURRENT_SELECTION,
360 DtEDITOR_NEXT_OCCURRENCE,
361 DtEDITOR_ALL_OCCURRENCES
364 /* Used with DtEditorFormat() */
368 DtEDITOR_FORMAT_PARAGRAPH
372 DtEDITOR_ALIGN_CENTER,
373 DtEDITOR_ALIGN_JUSTIFY,
378 /* Used with DtNtextSelectCallback */
380 DtEDITOR_TEXT_SELECT,
381 DtEDITOR_TEXT_DESELECT
388 typedef enum _DtEditorErrorCode{
390 DtEDITOR_INVALID_TYPE,
391 DtEDITOR_INVALID_RANGE,
393 DtEDITOR_ILLEGAL_SIZE,
394 DtEDITOR_SPELL_FILTER_FAILED,
395 DtEDITOR_NO_TMP_FILE,
396 DtEDITOR_INVALID_FILENAME,
397 DtEDITOR_NONEXISTENT_FILE,
398 DtEDITOR_UNREADABLE_FILE,
399 DtEDITOR_READ_ONLY_FILE,
400 DtEDITOR_NO_FILE_ACCESS,
402 DtEDITOR_CHAR_SPECIAL_FILE,
403 DtEDITOR_BLOCK_MODE_FILE,
404 DtEDITOR_UNWRITABLE_FILE,
405 DtEDITOR_WRITABLE_FILE,
406 DtEDITOR_SAVE_FAILED,
407 DtEDITOR_INSUFFICIENT_MEMORY,
408 DtEDITOR_NULLS_REMOVED
412 /* Used with DtEditorChange() to specify Find and Change To strings */
414 typedef struct _DtEditorChangeValues {
417 } DtEditorChangeValues;
419 /* Used with DtEditorFormat() to specify left margin, right margin *
420 * and justification styles. */
422 typedef struct _DtEditorFormatSettings {
425 unsigned int alignment;
426 } DtEditorFormatSettings;
428 /* Types used to tag data to/from the editor widget */
430 typedef enum _DtEditorDataFormat{
434 } DtEditorDataFormat;
437 /* Types used to pass data to/from the editor widget */
439 typedef struct _DtEditor_DataObj {
444 typedef struct _DtEditorContentRec {
445 DtEditorDataFormat type;
449 DtEditor_DataObj data;
451 } DtEditorContentRec;
454 /* Widget class and instance */
456 typedef struct _DtEditorClassRec *DtEditorClass;
457 typedef struct _DtEditorRec *DtEditorWidget;
466 externalref WidgetClass dtEditorWidgetClass;
473 extern Widget DtCreateEditor(
479 extern DtEditorErrorCode DtEditorAppend(
481 DtEditorContentRec *data);
483 extern DtEditorErrorCode DtEditorAppendFromFile(
487 extern Boolean DtEditorChange(
489 DtEditorChangeValues *findChangeStrings,
490 unsigned int instanceToChange);
492 extern Boolean DtEditorCheckForUnsavedChanges(
495 extern Boolean DtEditorClearSelection(
498 extern Boolean DtEditorCopyToClipboard(
501 extern Boolean DtEditorCutToClipboard(
504 extern Boolean DtEditorDeleteSelection(
507 extern Boolean DtEditorDeselect(
510 extern void DtEditorDisableRedisplay(
513 extern void DtEditorEnableRedisplay(
516 extern Boolean DtEditorFind(
520 extern DtEditorErrorCode DtEditorFormat(
522 DtEditorFormatSettings *formatSettings,
523 unsigned int amountToFormat);
525 extern DtEditorErrorCode DtEditorGetContents(
527 DtEditorContentRec *data,
528 Boolean hardCarriageReturns,
529 Boolean markContentsAsSaved);
531 extern XmTextPosition DtEditorGetInsertionPosition(
534 extern XmTextPosition DtEditorGetLastPosition(
537 extern Widget DtEditorGetMessageTextFieldID(
540 extern void DtEditorGetSizeHints(
544 extern void DtEditorGoToLine(
548 extern DtEditorErrorCode DtEditorInsert(
550 DtEditorContentRec *data);
552 extern DtEditorErrorCode DtEditorInsertFromFile(
556 extern void DtEditorInvokeFindChangeDialog(
559 extern void DtEditorInvokeFormatDialog(
562 extern DtEditorErrorCode DtEditorInvokeSpellDialog(
565 extern Boolean DtEditorPasteFromClipboard(
568 extern DtEditorErrorCode DtEditorReplace(
570 XmTextPosition startPos,
571 XmTextPosition endPos,
572 DtEditorContentRec *data);
574 extern DtEditorErrorCode DtEditorReplaceFromFile(
576 XmTextPosition startPos,
577 XmTextPosition endPos,
580 extern void DtEditorReset(
583 extern DtEditorErrorCode DtEditorSaveContentsToFile(
586 Boolean overwriteIfExists,
587 Boolean hardCarriageReturns,
588 Boolean markContentsAsSaved);
590 extern Boolean DtEditorSelectAll(
593 extern DtEditorErrorCode DtEditorSetContents(
595 DtEditorContentRec *data);
597 extern DtEditorErrorCode DtEditorSetContentsFromFile(
601 extern void DtEditorSetInsertionPosition(
603 XmTextPosition position);
605 extern void DtEditorTraverseToEditor(
608 extern Boolean DtEditorUndoEdit(
616 #endif /* _Dt_Editor_h */