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 libraries 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: EditorP.h /main/4 1996/06/19 11:28:20 cde-dec $ */
24 /**********************************<+>*************************************
25 ***************************************************************************
29 ** Project: DtEditor widget
33 ** Private include file for the DtEditor widget, text editor class.
35 *******************************************************************
37 * (c) Copyright 1993, 1994 Hewlett-Packard Company
38 * (c) Copyright 1993, 1994 International Business Machines Corp.
39 * (c) Copyright 1993, 1994 Sun Microsystems, Inc.
40 * (c) Copyright 1993, 1994 Unix System Labs, Inc., a subsidiary of Novell, Inc.
42 ********************************************************************
45 **************************************************************************
46 **********************************<+>*************************************/
50 #include <Dt/Editor.h>
55 #include <sys/types.h>
58 #include <X11/StringDefs.h>
59 #include <X11/Intrinsic.h>
60 #include <X11/Xatom.h>
62 #include <Xm/Protocols.h>
75 /****************************************************************
79 ****************************************************************/
82 #define WRITE_ACCESS 2
88 #define UNKNOWN_ACTION -1
89 #define EXTEND_SELECTION 0
90 #define ICON_FOCUSED 1
92 #define NO_DELETION_IN_PROGRESS -999
95 #define DtUNSPECIFIED (~0)
99 #define CLOSE_BUTTON DTWIDGET_GETMESSAGE( \
100 MS_Common, MSG_CLOSE, _DtMsgCommon_0000)
102 #define HELP_BUTTON DTWIDGET_GETMESSAGE( \
103 MS_Common, MSG_HELP, _DtMsgCommon_0001)
105 #define FORMAT_SETTINGS DTWIDGET_GETMESSAGE( \
106 MS_Editor, EDITOR_FORMAT_SETTINGS, _DtMsgEditor_0000)
108 #define RIGHT_MARGIN DTWIDGET_GETMESSAGE( \
109 MS_Editor, EDITOR_RIGHT_MARGIN, _DtMsgEditor_0001)
111 #define LEFT_MARGIN DTWIDGET_GETMESSAGE( \
112 MS_Editor, EDITOR_LEFT_MARGIN, _DtMsgEditor_0002)
114 #define LEFT_ALIGN DTWIDGET_GETMESSAGE( \
115 MS_Editor, EDITOR_LEFT_ALIGN, _DtMsgEditor_0003)
117 #define RIGHT_ALIGN DTWIDGET_GETMESSAGE( \
118 MS_Editor, EDITOR_RIGHT_ALIGN, _DtMsgEditor_0004)
120 #define JUSTIFY DTWIDGET_GETMESSAGE( \
121 MS_Editor, EDITOR_JUSTIFY, _DtMsgEditor_0005)
123 #define CENTER DTWIDGET_GETMESSAGE( \
124 MS_Editor, EDITOR_CENTER, _DtMsgEditor_0006)
126 #define PARAGRAPH DTWIDGET_GETMESSAGE( \
127 MS_Editor, EDITOR_PARAGRAPH, _DtMsgEditor_0007)
129 #define ALL DTWIDGET_GETMESSAGE( \
130 MS_Editor, EDITOR_ALL, _DtMsgEditor_0008)
132 #define SPELL_TITLE DTWIDGET_GETMESSAGE( \
133 MS_Editor, EDITOR_SPELL_TITLE, _DtMsgEditor_0009)
135 #define FIND_TITLE DTWIDGET_GETMESSAGE( \
136 MS_Editor, EDITOR_FIND_TITLE, _DtMsgEditor_0010)
138 #define MISSPELLED DTWIDGET_GETMESSAGE( \
139 MS_Editor, EDITOR_MISSPELLED, _DtMsgEditor_0011)
141 #define FIND_LABEL DTWIDGET_GETMESSAGE( \
142 MS_Editor, EDITOR_FIND_LABEL, _DtMsgEditor_0012)
144 #define CHANGE_LABEL DTWIDGET_GETMESSAGE( \
145 MS_Editor, EDITOR_CHANGE_LABEL, _DtMsgEditor_0013)
147 #define FIND_BUTTON DTWIDGET_GETMESSAGE( \
148 MS_Editor, EDITOR_FIND_BUTTON, _DtMsgEditor_0014)
150 #define CHANGE_BUTTON DTWIDGET_GETMESSAGE( \
151 MS_Editor, EDITOR_CHANGE_BUTTON, _DtMsgEditor_0015)
153 #define CHNG_ALL_BUTTON DTWIDGET_GETMESSAGE( \
154 MS_Editor, EDITOR_CHNG_ALL_BUTTON, _DtMsgEditor_0016)
156 #define NO_FIND DTWIDGET_GETMESSAGE( \
157 MS_Editor, EDITOR_NO_FIND, _DtMsgEditor_0017)
159 #define INFO_TITLE DTWIDGET_GETMESSAGE( \
160 MS_Editor, EDITOR_INFO_TITLE, _DtMsgEditor_0018)
162 #define LINE DTWIDGET_GETMESSAGE( \
163 MS_Editor, EDITOR_LINE, _DtMsgEditor_0019)
165 #define TOTAL DTWIDGET_GETMESSAGE( \
166 MS_Editor, EDITOR_TOTAL, _DtMsgEditor_0020)
168 #define OVR DTWIDGET_GETMESSAGE( \
169 MS_Editor, EDITOR_OVR, _DtMsgEditor_0021)
171 #define INS DTWIDGET_GETMESSAGE( \
172 MS_Editor, EDITOR_INS, _DtMsgEditor_0022)
174 #define BAD_FILTER DTWIDGET_GETMESSAGE( \
175 MS_Editor, EDITOR_FILTER_ERROR, _DtMsgEditor_0023)
177 #define BAD_FILTER2 DTWIDGET_GETMESSAGE( \
178 MS_Editor, EDITOR_FILTER_ERROR2, _DtMsgEditor_0024)
180 #define ERROR_TITLE DTWIDGET_GETMESSAGE( \
181 MS_Editor, EDITOR_ERROR_TITLE, _DtMsgEditor_0025)
184 /****************************************************************
188 ****************************************************************/
190 typedef struct _AdjRec {
191 int bflag; /* -b (blanks) option */
192 int cflag; /* -c (center) option */
193 int jflag; /* -j (justify) option */
194 int rflag; /* -r (right justify) */
195 int tabsize; /* tab size in use */
197 FILE *infp; /* file pointer for unformatted data */
198 FILE *outfp; /* file pointer for formatted data */
199 } AdjRec, *AdjRecPtr;
202 /****************************************************************
204 * Deleted text structure definition
206 ****************************************************************/
207 typedef struct _DtEditorUndoRec {
209 XmTextPosition deletionStart;
210 XmTextPosition insertStart;
214 /****************************************************************
216 * Data structures for miscellaneous edit information
218 ****************************************************************/
219 typedef struct _DtEditorEditStuff
224 XmTextPosition cursorPos,
226 Boolean autoShowCursorPos,
237 int fontWidth, /* widest font, used for formatting */
238 fontHeight; /* font height; used for WM size hints */
240 DtEditorUndoRec undo; /* holds deleted text for undo */
242 Boolean loadingAllNewData,
243 unreadChanges; /* Data changed since read by app? */
245 SetSelectionProc setSelection;
248 /****************************************************************
250 * Data structures for Search
252 ****************************************************************/
253 typedef struct _DtEditorSearchWidgets {
267 } DtEditorSearchWidgets;
269 typedef struct _DtEditorSearchStuff {
270 DtEditorSearchWidgets widgets;
271 int search_dialog_mode;
272 char *search_string, /* last string searched for */
273 *replace_string, /* last replacement string */
274 *misspelled_string, /* last misspelled word selected */
276 Boolean misspelled_found;
277 Dimension buttonHeight;
280 changeAllButtonLabel,
286 } DtEditorSearchStuff;
288 /****************************************************************
290 * Data structures for Format
292 ****************************************************************/
293 typedef struct _DtEditorFormatWidgets {
294 Widget format_dialog,
297 rightMargField, /* format right margin text field */
298 leftMargField, /* format left margin text field */
300 left_just, /* format type toggle button */
301 right_just, /* format type toggle button */
302 both_just, /* format type toggle button */
303 center, /* format type toggle button */
309 } DtEditorFormatWidgets;
311 typedef struct _DtEditorFormatStuff {
312 DtEditorFormatWidgets widgets;
313 XmString centerToggleLabel,
314 formatAllButtonLabel,
315 formatParaButtonLabel,
318 leftAlignToggleLabel,
319 leftMarginFieldLabel,
320 rightAlignToggleLabel,
321 rightMarginFieldLabel;
322 } DtEditorFormatStuff;
325 /****************************************************************
327 * Data structures for the Status Line
329 ****************************************************************/
331 typedef struct _status {
332 Boolean showStatusLine;
346 } DtEditorStatusStuff;
348 /****************************************************************
350 * Data structures for holding warning dialogs
352 ****************************************************************/
354 typedef struct _textlibwarning {
355 Widget warningDialog;
356 XmString infoDialogTitle;
357 } DtEditorWarningStuff;
360 /****************************************************************
362 * Class Part structure definition
364 ****************************************************************/
365 typedef struct _DtEditorClassPart
371 /****************************************************************
373 * Full Class Record declaration
375 ****************************************************************/
376 typedef struct _DtEditorClassRec
378 CoreClassPart core_class;
379 CompositeClassPart composite_class;
380 ConstraintClassPart constraint_class;
381 XmManagerClassPart manager_class;
382 XmBulletinBoardClassPart bulletin_board_class;
383 XmFormClassPart form_class;
384 DtEditorClassPart editor_class;
387 externalref DtEditorClassRec dtEditorClassRec;
390 /****************************************************************
392 * Resources added by the Editor widget
394 ****************************************************************/
395 typedef struct _DtEditorPart
398 Widget topLevelShell,
400 * scrolled text widget
403 Dimension width; /* the text widget width */
405 /* All data for Edit functions */
406 DtEditorEditStuff editStuff;
407 /* All data for Search functions */
408 DtEditorSearchStuff searchStuff;
409 /* All data for Format functions */
410 DtEditorFormatStuff formatStuff;
411 /* All data for warning dialogs functions */
412 DtEditorWarningStuff warningStuff;
413 /* All data for the status line */
414 DtEditorStatusStuff statusStuff;
416 XtAppContext app_context;
419 * The editor widget's callbacks
422 Boolean textSelectCbCalled;
423 XtCallbackList textSelect;
424 XtCallbackList textDeselect;
429 /****************************************************************
431 * Full Instance Record declaration
433 ****************************************************************/
434 typedef struct _DtEditorRec
437 CompositePart composite;
438 ConstraintPart constraint;
439 XmManagerPart manager;
440 XmBulletinBoardPart bulletin_board;
446 /****************************************************************
450 ****************************************************************/
453 * Class and Instance Macros
457 * Note: DtEditor utilizes the bulletin board's dialog_title and
458 * text_translations fields to hold its dialogTitle and textTranslations
461 #define E_dialogTitle(m) (m -> bulletin_board.dialog_title)
462 #define E_textTranslations(m) (m -> bulletin_board.text_translations)
463 #define E_buttonFontList(m) (m -> bulletin_board.button_font_list)
464 #define E_labelFontList(m) (m -> bulletin_board.label_font_list)
465 #define E_textFontList(m) (m -> bulletin_board.text_font_list)
467 #define M_app_context(m) (m -> editor.app_context)
468 #define M_display(m) (m -> editor.display)
469 #define M_topLevelShell(m) (m -> editor.topLevelShell)
470 #define M_text(m) (m -> editor.text)
471 #define M_textWidth(m) (m -> editor.width)
474 #define M_textSelect(m) (m -> editor.textSelect)
475 #define M_textDeselect(m) (m -> editor.textDeselect)
476 #define M_textSelectCbCalled(m) (m -> editor.textSelectCbCalled)
478 /* editStuff - scrolled text resources */
479 #define M_autoShowCursorPos(m) (m->editor.editStuff.autoShowCursorPos)
480 #define M_blinkRate(m) (m -> editor.editStuff.blinkRate)
481 #define M_columns(m) (m -> editor.editStuff.columns)
482 #define M_cursorPos(m) (m -> editor.editStuff.cursorPos)
483 #define M_cursorPosVisible(m) (m -> editor.editStuff.cursorPosVisible)
484 #define M_editable(m) (m -> editor.editStuff.editable)
485 #define M_fontWidth(m) (m -> editor.editStuff.fontWidth)
486 #define M_fontHeight(m) (m -> editor.editStuff.fontHeight)
487 #define M_maxLength(m) (m -> editor.editStuff.maxLength)
488 #define M_overstrikeMode(m) (m -> editor.editStuff.overstrikeMode)
489 #define M_rows(m) (m -> editor.editStuff.rows)
490 #define M_scrollHorizontal(m) (m -> editor.editStuff.scrollHorizontal)
491 #define M_scrollLeftSide(m) (m -> editor.editStuff.scrollLeft)
492 #define M_scrollTopSide(m) (m -> editor.editStuff.scrollTop)
493 #define M_scrollVertical(m) (m -> editor.editStuff.scrollVertical)
494 #define M_topCharacter(m) (m -> editor.editStuff.topCharacter)
495 #define M_wordWrap(m) (m -> editor.editStuff.wordWrap)
496 #define M_textBackground(m) (m -> editor.editStuff.background)
497 #define M_textForeground(m) (m -> editor.editStuff.foreground)
499 /* editStuff - scrolled text related data */
500 #define M_deletionStart(m) (m -> editor.editStuff.undo.deletionStart)
501 #define M_deletedText(m) (m -> editor.editStuff.undo.deletedText)
502 #define M_insertStart(m) (m -> editor.editStuff.undo.insertStart)
503 #define M_insertionLength(m) (m -> editor.editStuff.undo.insertionLength)
504 #define M_loadingAllNewData(m) (m -> editor.editStuff.loadingAllNewData)
505 #define M_unreadChanges(m) (m -> editor.editStuff.unreadChanges)
506 #define M_setSelection(m) (m -> editor.editStuff.setSelection)
509 #define M_search_dialogMode(m) (m ->editor.searchStuff.search_dialog_mode)
510 #define M_spellTitle(m) (m -> editor.searchStuff.spellTitle)
511 #define M_fndChngTitle(m) (m -> editor.searchStuff.fndChngTitle)
512 #define E_changeAllButtonLabel(m) (m->editor.searchStuff.changeAllButtonLabel)
513 #define E_changeButtonLabel(m) (m->editor.searchStuff.changeButtonLabel)
514 #define E_changeFieldLabel(m) (m->editor.searchStuff.changeFieldLabel)
515 #define E_findButtonLabel(m) (m->editor.searchStuff.findButtonLabel)
516 #define E_findFieldLabel(m) (m->editor.searchStuff.findFieldLabel)
517 #define E_misspelledListLabel(m) (m->editor.searchStuff.misspelledListLabel)
518 #define M_search_string(m) (m -> editor.searchStuff.search_string)
519 #define M_replace_string(m) (m -> editor.searchStuff.replace_string)
520 #define M_misspelled_string(m) (m -> editor.searchStuff.misspelled_string)
521 #define M_misspelled_found(m) (m -> editor.searchStuff.misspelled_found)
522 #define M_spellFilter(m) (m -> editor.searchStuff.spellFilter)
523 #define M_replaceText(m) (m -> editor.searchStuff.widgets.replaceText)
524 #define M_findText(m) (m -> editor.searchStuff.widgets.findText)
525 #define M_search_replaceLbl(m) (m -> editor.searchStuff.widgets.replaceLbl)
526 #define M_search_buttonHeight(m) (m -> editor.searchStuff.buttonHeight)
527 #define M_search_dialog(m) (m -> editor.searchStuff.widgets.formDlg)
528 #define M_search_closeBtn(m) (m -> editor.searchStuff.widgets.closeBtn)
529 #define M_search_helpBtn(m) (m -> editor.searchStuff.widgets.helpBtn)
530 #define M_search_findBtn(m) (m -> editor.searchStuff.widgets.findBtn)
531 #define M_search_replaceBtn(m) (m -> editor.searchStuff.widgets.replaceBtn)
532 #define M_search_replaceAllBtn(m)\
533 (m -> editor.searchStuff.widgets.replaceAllBtn)
534 #define M_search_spellList(m) (m -> editor.searchStuff.widgets.spellList)
535 #define M_search_listLbl(m) (m -> editor.searchStuff.widgets.listLbl)
536 #define M_search_findLbl(m) (m -> editor.searchStuff.widgets.findLbl)
537 #define M_search_separator(m) (m -> editor.searchStuff.widgets.separator)
540 #define E_format_centerToggleLabel(m) (m->editor.formatStuff.centerToggleLabel)
541 #define E_format_formatAllButtonLabel(m)\
542 (m->editor.formatStuff.formatAllButtonLabel)
543 #define E_format_formatParagraphButtonLabel(m)\
544 (m->editor.formatStuff.formatParaButtonLabel)
545 #define E_format_dialogTitle(m) (m->editor.formatStuff.formatDialogTitle)
546 #define E_format_justifyToggleLabel(m)\
547 (m->editor.formatStuff.justifyToggleLabel)
548 #define E_format_leftAlignToggleLabel(m)\
549 (m->editor.formatStuff.leftAlignToggleLabel)
550 #define E_format_leftMarginFieldLabel(m)\
551 (m->editor.formatStuff.leftMarginFieldLabel)
552 #define E_format_rightAlignToggleLabel(m)\
553 (m->editor.formatStuff.rightAlignToggleLabel)
554 #define E_format_rightMarginFieldLabel(m)\
555 (m->editor.formatStuff.rightMarginFieldLabel)
556 #define M_format_all(m) (m -> editor.formatStuff.widgets.all)
557 #define M_format_bothJust(m) (m -> editor.formatStuff.widgets.both_just)
558 #define M_format_center(m) (m -> editor.formatStuff.widgets.center)
559 #define M_format_close(m) (m -> editor.formatStuff.widgets.close)
560 #define M_format_dialog(m) (m -> editor.formatStuff.widgets.format_dialog)
561 #define M_format_help(m) (m -> editor.formatStuff.widgets.help)
562 #define M_format_leftJust(m) (m -> editor.formatStuff.widgets.left_just)
563 #define M_format_leftLabel(m) (m -> editor.formatStuff.widgets.left_label)
564 #define M_format_leftMarginField(m) (m -> editor.formatStuff.widgets.leftMargField)
565 #define M_format_paragraph(m) (m -> editor.formatStuff.widgets.paragraph)
566 #define M_format_radioBox(m) (m -> editor.formatStuff.widgets.radio_box)
567 #define M_format_rightJust(m) (m -> editor.formatStuff.widgets.right_just)
568 #define M_format_rightLabel(m) (m -> editor.formatStuff.widgets.right_label)
569 #define M_format_rightMarginField(m) (m -> editor.formatStuff.widgets.rightMargField)
570 #define M_format_separator(m) (m -> editor.formatStuff.widgets.separator)
573 #define M_status_showStatusLine(m) (m -> editor.statusStuff.showStatusLine)
574 #define M_status_currentLine(m) (m -> editor.statusStuff.currentLine)
575 #define M_status_lastLine(m) (m -> editor.statusStuff.lastLine)
576 #define M_status_overstrikeLabel(m) (m -> editor.statusStuff.ovr)
577 #define M_status_insertLabel(m) (m -> editor.statusStuff.ins)
578 #define E_status_currentLineLabel(m) (m -> editor.statusStuff.currentLineLabel)
579 #define E_status_totalLineCountLabel(m) (m->editor.statusStuff.totalLineLabel)
580 #define M_status_statusArea(m) (m -> editor.statusStuff.statusArea)
581 #define M_status_lineLabel(m) (m -> editor.statusStuff.lineLabel)
582 #define M_status_lineText(m) (m -> editor.statusStuff.lineText)
583 #define M_status_totalLabel(m) (m -> editor.statusStuff.totalLabel)
584 #define M_status_totalText(m) (m -> editor.statusStuff.totalText)
585 #define M_status_overstrikeWidget(m) (m->editor.statusStuff.overstrikeLabel)
586 #define M_status_messageText(m) (m -> editor.statusStuff.messageText)
589 #define M_gen_warning(m) (m ->editor.warningStuff.warningDialog)
590 #define E_infoDialogTitle(m) (m ->editor.warningStuff.infoDialogTitle)
595 #define M_editor(m) ((DtEditorWidget) m ->core.parent -> core.parent)
598 /****************************************************************
600 * Private library functions
602 ****************************************************************/
604 /*** library-private functions in Editor.c ***/
605 extern void _DtEditorResetUndo(
606 DtEditorWidget editor);
607 extern void _DtEditorUpdateLineDisplay(
608 DtEditorWidget editor,
610 Boolean forceUpdate );
611 extern int _DtEditorGetLineIndex(
614 extern void _DtEditorWarning(
615 DtEditorWidget pPriv,
617 unsigned char dialogType);
618 extern DtEditorErrorCode _DtEditorValidateFileAccess(
621 extern void _DtEditorHelpSearchCB (
623 caddr_t client_data ,
625 extern void _DtEditorHelpSearchSpellCB (
627 caddr_t client_data ,
629 extern void _DtEditorHelpSearchFindCB (
631 caddr_t client_data ,
633 extern void _DtEditorHelpSearchChangeCB (
635 caddr_t client_data ,
638 /*** library-private functions in EditAreaData.c ***/
640 extern char *_DtEditorGetPointer(
644 /*** library-private functions in EditorCalls.c ***/
646 extern void _DtEditorModifyVerifyCB(
651 /*** library-private functions in SearchCalls.c ***/
653 extern void _DtEditorSearchMapCB(
657 extern int _DtEditor_CountCharacters(
659 int num_count_bytes);
660 extern void _DtEditorDialogSearchCB(
664 extern void _DtEditorDialogReplaceCB(
668 extern void _DtEditorDialogReplaceAllCB(
672 extern void _DtEditorDialogFindCancelCB(
676 extern void _DtEditorMisspelledSelectCB(
680 extern void _DtEditorMisspelledDblClickCB(
684 extern void _DtEditorFindTextChangedCB(
688 extern void _DtEditorReplaceTextChangedCB(
692 extern void _DtEditorSetFindSensitivity(
693 DtEditorWidget pPriv,
694 Boolean sensitivity);
695 extern void _DtEditorSetReplaceSensitivity(
696 DtEditorWidget pPriv,
697 Boolean sensitivity);
698 extern void _DtEditorSetReplaceAllSensitivity(
699 DtEditorWidget pPriv,
700 Boolean sensitivity);
703 /*** library-private functions in SearchDlg.c ***/
704 extern void _DtEditorSearch(
705 DtEditorWidget pPriv,
707 Boolean createonly );
709 #endif /* _DtEditorP_h */