/cde/lib/DtWidget/Editor.c
C | 1690 lines | 1219 code | 205 blank | 266 comment | 46 complexity | 5b07f868bea1cf3573a84695c1290213 MD5 | raw file
Possible License(s): LGPL-2.1, IPL-1.0, 0BSD
- /*
- * CDE - Common Desktop Environment
- *
- * Copyright (c) 1993-2012, The Open Group. All rights reserved.
- *
- * These libraries and programs are free software; you can
- * redistribute them and/or modify them under the terms of the GNU
- * Lesser General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option)
- * any later version.
- *
- * These libraries and programs are distributed in the hope that
- * they will be useful, but WITHOUT ANY WARRANTY; without even the
- * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- * PURPOSE. See the GNU Lesser General Public License for more
- * details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with these librararies and programs; if not, write
- * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
- * Floor, Boston, MA 02110-1301 USA
- */
- /* $TOG: Editor.c /main/24 1999/10/14 16:38:25 mgreess $
- **********************************<+>*************************************
- ***************************************************************************
- **
- ** File: Editor.c
- **
- ** Project: Text Editor widget
- **
- ** Description:
- ** -----------
- ** This is the main source file for the Text Editor widget.
- **
- *******************************************************************
- * (c) Copyright 1996 Digital Equipment Corporation.
- * (c) Copyright 1993, 1994, 1996 Hewlett-Packard Company.
- * (c) Copyright 1993, 1994, 1996 International Business Machines Corp.
- * (c) Copyright 1993, 1994, 1996 Sun Microsystems, Inc.
- * (c) Copyright 1996 Novell, Inc.
- * (c) Copyright 1996 FUJITSU LIMITED.
- * (c) Copyright 1996 Hitachi.
- * (c) Copyright 1993, 1994 Unix System Labs, Inc., a subsidiary of Novell, Inc.
- ********************************************************************
- **
- **************************************************************************
- **********************************<+>*************************************/
- /*-------------------------------------------------------------
- ** Include Files
- */
- #include <ctype.h>
- #if defined(__hpux) || defined(__osf__) || defined(USL)
- # include <wchar.h>
- #elif defined(__uxp__)
- # include <widec.h>
- # include <wctype.h>
- #elif defined(sun)
- # if (_XOPEN_VERSION==3)
- # include <wctype.h>
- # else
- # include <wchar.h>
- # endif
- # include <libintl.h>
- #elif defined(linux)
- # include <wctype.h>
- # define NO_putwc
- #endif /* linux */
- #include <sys/wait.h>
- #include "signal.h"
- #include <string.h>
- #include <limits.h> /* For LINE_MAX definition */
- #include <sys/errno.h> /* For Error handling */
- #include "EditorP.h"
- #include <Dt/Dnd.h>
- #include "X11/Xutil.h"
- #include <X11/StringDefs.h>
- #include <X11/keysymdef.h>
- #include <Xm/Form.h>
- #include <Xm/MessageB.h>
- #include <Xm/MwmUtil.h>
- #include <Xm/TextF.h>
- /* Need the following for _DtOkString */
- #include <Dt/DtP.h>
- #include <Dt/DtMsgsP.h>
- #include "DtWidgetI.h"
- /*
- * Private functions borrowed from Motif.
- */
- extern XmTextLineTable _XmTextGetLineTable(Widget widget, int *total_lines);
- extern char * _XmStringSourceGetString(XmTextWidget tw,
- XmTextPosition from,
- XmTextPosition to,
- #if NeedWidePrototypes
- int want_wchar);
- #else
- Boolean want_wchar);
- #endif /* NeedWidePrototypes */
- /*-------------------------------------------------------------
- ** Public Interface
- **-------------------------------------------------------------
- */
- /******** Public Function Declarations ********/
- /******** End Public Function Declarations ********/
- /*-------------------------------------------------------------
- ** Forward Declarations
- **-------------------------------------------------------------
- */
- /******** Static Function Declarations ********/
- static void ClassInitialize(void);
- static void Initialize(
- Widget rw,
- Widget nw,
- ArgList al,
- Cardinal *num_args) ;
- static void VariableInitialize(
- DtEditorWidget new);
- static void ValidateResources(
- DtEditorWidget new,
- DtEditorWidget request);
- static Widget CreateText(
- DtEditorWidget parent);
- static void extractFontMetrics(
- DtEditorWidget w,
- XmFontList fontlist,
- int *height,
- int *width);
- static void getFontMetrics(
- DtEditorWidget w);
- static void Destroy(
- Widget widget);
- static void SetStatusLine(
- DtEditorWidget ew,
- Boolean statusLineOn);
- static Widget CreateStatusLine(
- DtEditorWidget parent);
- static Boolean SetValues(
- Widget cw,
- Widget rw,
- Widget nw);
- static void _DtEditorGetCenterToggleLabel(
- Widget wid,
- int resource_offset,
- XtArgVal *value );
- static void _DtEditorGetChangeAllButtonLabel(
- Widget wid,
- int resource_offset,
- XtArgVal *value );
- static void _DtEditorGetChangeButtonLabel(
- Widget wid,
- int resource_offset,
- XtArgVal *value );
- static void _DtEditorGetChangeFieldLabel(
- Widget wid,
- int resource_offset,
- XtArgVal *value );
- static void _DtEditorGetColumns(
- Widget wid,
- int resource_offset,
- XtArgVal *value );
- static void _DtEditorGetCurrentLineLabel(
- Widget wid,
- int resource_offset,
- XtArgVal *value );
- static void _DtEditorGetCursorPosition(
- Widget wid,
- int resource_offset,
- XtArgVal *value );
- static void _DtEditorGetFindButtonLabel(
- Widget wid,
- int resource_offset,
- XtArgVal *value );
- static void _DtEditorGetFindFieldLabel(
- Widget wid,
- int resource_offset,
- XtArgVal *value );
- static void _DtEditorGetFormatAllButtonLabel(
- Widget wid,
- int resource_offset,
- XtArgVal *value );
- static void _DtEditorGetFormatParagraphButtonLabel(
- Widget wid,
- int resource_offset,
- XtArgVal *value );
- static void _DtEditorGetJustifyToggleLabel(
- Widget wid,
- int resource_offset,
- XtArgVal *value );
- static void _DtEditorGetLeftAlignToggleLabel(
- Widget wid,
- int resource_offset,
- XtArgVal *value );
- static void _DtEditorGetLeftMarginFieldLabel(
- Widget wid,
- int resource_offset,
- XtArgVal *value );
- static void _DtEditorGetMaxLength(
- Widget wid,
- int resource_offset,
- XtArgVal *value );
- static void _DtEditorGetMisspelledListLabel(
- Widget wid,
- int resource_offset,
- XtArgVal *value );
- static void _DtEditorGetRightAlignToggleLabel(
- Widget wid,
- int resource_offset,
- XtArgVal *value );
- static void _DtEditorGetRightMarginFieldLabel(
- Widget wid,
- int resource_offset,
- XtArgVal *value );
- static void _DtEditorGetRows(
- Widget wid,
- int resource_offset,
- XtArgVal *value );
- static void _DtEditorGetScrollLeftSide(
- Widget wid,
- int resource_offset,
- XtArgVal *value );
- static void _DtEditorGetScrollTopSide(
- Widget wid,
- int resource_offset,
- XtArgVal *value );
- static void _DtEditorGetTextBackground(
- Widget wid,
- int resource_offset,
- XtArgVal *value );
- static void _DtEditorGetTextForeground(
- Widget wid,
- int resource_offset,
- XtArgVal *value );
- static void _DtEditorGetTopCharacter(
- Widget wid,
- int resource_offset,
- XtArgVal *value );
- static void _DtEditorGetLineCountLabel(
- Widget wid,
- int resource_offset,
- XtArgVal *value );
- static void FixWordWrap( /* XXX Word Wrap workaround */
- Widget w, /* XXX Word Wrap workaround */
- Boolean wrapOn); /* XXX Word Wrap workaround */
- static void BackwardChar(
- Widget w,
- XEvent *event,
- char **params,
- Cardinal *num_params);
- static void BackwardPara(
- Widget w,
- XEvent *event,
- char **params,
- Cardinal *num_params);
- static void BackwardWord(
- Widget w,
- XEvent *event,
- char **params,
- Cardinal *num_params);
- static void BeginningOfFile(
- Widget w,
- XEvent *event,
- char **params,
- Cardinal *num_params);
- static void BeginningOfLine(
- Widget w,
- XEvent *event,
- char **params,
- Cardinal *num_params);
- static void ClearSelection(
- Widget w,
- XEvent *event,
- char **params,
- Cardinal *num_params);
- static void CopyClipboard(
- Widget w,
- XEvent *event,
- char **params,
- Cardinal *num_params);
- static void CutClipboard(
- Widget w,
- XEvent *event,
- char **params,
- Cardinal *num_params);
- static void DeleteNextChar(
- Widget w,
- XEvent *event,
- char **params,
- Cardinal *num_params);
- static void DeleteNextWord(
- Widget w,
- XEvent *event,
- char **params,
- Cardinal *num_params);
- static void DeletePrevChar(
- Widget w,
- XEvent *event,
- char **params,
- Cardinal *num_params);
- static void DeletePrevWord(
- Widget w,
- XEvent *event,
- char **params,
- Cardinal *num_params);
- static void DeleteToEOL(
- Widget w,
- XEvent *event,
- char **params,
- Cardinal *num_params);
- static void DeleteToSOL(
- Widget w,
- XEvent *event,
- char **params,
- Cardinal *num_params);
- static void DeselectAll(
- Widget w,
- XEvent *event,
- char **params,
- Cardinal *num_params);
- static void EndOfFile(
- Widget w,
- XEvent *event,
- char **params,
- Cardinal *num_params);
- static void EndOfLine(
- Widget w,
- XEvent *event,
- char **params,
- Cardinal *num_params);
- static void ForwardChar(
- Widget w,
- XEvent *event,
- char **params,
- Cardinal *num_params);
- static void ForwardPara(
- Widget w,
- XEvent *event,
- char **params,
- Cardinal *num_params);
- static void ForwardWord(
- Widget w,
- XEvent *event,
- char **params,
- Cardinal *num_params);
- static void GoToLine(
- Widget w,
- XEvent *event,
- char **params,
- Cardinal *num_params);
- static void GoToLine_I(
- Widget w,
- XEvent *event,
- char **params,
- Cardinal *num_params);
- static void Help(
- Widget w,
- XEvent *event,
- char **params,
- Cardinal *num_params);
- static void InsertString(
- Widget w,
- XEvent *event,
- char **params,
- Cardinal *num_params);
- static void KeySelect(
- Widget w,
- XEvent *event,
- char **params,
- Cardinal *num_params);
- static void NewlineAndBackup(
- Widget w,
- XEvent *event,
- char **params,
- Cardinal *num_params);
- static void NewlineAndIndent(
- Widget w,
- XEvent *event,
- char **params,
- Cardinal *num_params);
- static void NextPage(
- Widget w,
- XEvent *event,
- char **params,
- Cardinal *num_params);
- static void PageLeft(
- Widget w,
- XEvent *event,
- char **params,
- Cardinal *num_params);
- static void PageRight(
- Widget w,
- XEvent *event,
- char **params,
- Cardinal *num_params);
- static void PasteClipboard(
- Widget w,
- XEvent *event,
- char **params,
- Cardinal *num_params);
- static void PreviousPage(
- Widget w,
- XEvent *event,
- char **params,
- Cardinal *num_params);
- static void ProcessCancel(
- Widget w,
- XEvent *event,
- char **params,
- Cardinal *num_params);
- static void ProcessDown(
- Widget w,
- XEvent *event,
- char **params,
- Cardinal *num_params);
- static void ProcessShiftDown(
- Widget w,
- XEvent *event,
- char **params,
- Cardinal *num_params);
- static void ProcessShiftUp(
- Widget w,
- XEvent *event,
- char **params,
- Cardinal *num_params);
- static void ProcessUp(
- Widget w,
- XEvent *event,
- char **params,
- Cardinal *num_params);
- static void QuoteNextChar(
- Widget w,
- XEvent *event,
- char **params,
- Cardinal *num_params);
- static void QuoteNextChar_I(
- Widget w,
- XEvent *event,
- char **params,
- Cardinal *num_params);
- static void SelectAll(
- Widget w,
- XEvent *event,
- char **params,
- Cardinal *num_params);
- static void ToggleInsertMode(
- Widget w,
- XEvent *event,
- char **params,
- Cardinal *num_params);
- static void ToggleInsertMode_I(
- Widget w,
- XEvent *event,
- char **params,
- Cardinal *num_params);
- static void UndoEdit(
- Widget w,
- XEvent *event,
- char **params,
- Cardinal *num_params);
- static void UndoEdit_I(
- Widget w,
- XEvent *event,
- char **params,
- Cardinal *num_params);
- static void Call_TextSelectCallback(
- DtEditorWidget editor);
- static void Call_TextDeselectCallback(
- DtEditorWidget editor);
- static void Editor_SetSelectionProc(
- XmTextSource source,
- XmTextPosition left,
- XmTextPosition right,
- Time set_time );
- static void CallHelpCallback(
- DtEditorWidget editor,
- int reason);
- static void HelpEditWindowCB(
- Widget w,
- caddr_t client_data,
- caddr_t call_data );
- static void HelpStatusCurrentLineCB(
- Widget w,
- caddr_t client_data,
- caddr_t call_data );
- static void HelpStatusTotalLinesCB(
- Widget w,
- caddr_t client_data,
- caddr_t call_data );
- static void HelpStatusMessageCB(
- Widget w,
- caddr_t client_data,
- caddr_t call_data );
- static void HelpStatusOverstrikeCB(
- Widget w,
- caddr_t client_data,
- caddr_t call_data );
- static void RegisterDropZone(
- DtEditorWidget w );
- static void UnregisterDropZone(
- DtEditorWidget w );
- static void SetInfoDialogTitle(
- DtEditorWidget editor );
- static int FormatText (
- AdjRecPtr pAdjRec );
- static void AdjustParaCB(
- Widget w,
- caddr_t client_data,
- caddr_t call_data );
- static void AdjustAllCB(
- Widget w,
- caddr_t client_data,
- caddr_t call_data );
- static DtEditorErrorCode DoAdjust(
- DtEditorWidget editor,
- int leftMargin,
- int rightMargin,
- unsigned int alignment,
- XmTextPosition start,
- XmTextPosition end);
- static void SetFormatDialogTitle(
- DtEditorWidget editor);
- static void ResetFormatDialog(
- DtEditorWidget editor);
- static void CreateFormatDialog(
- DtEditorWidget editor);
- static void GetAdjustSettings(
- DtEditorWidget pPad,
- DtEditorFormatSettings *formatSettings);
- static void UpdateOverstrikeIndicator(
- DtEditorWidget widget,
- Boolean overstrikeOn );
- /******** End Static Function Declarations ********/
- /****************************************************************
- *
- * Compatability routines
- *
- ****************************************************************/
- #if defined(NO_putwc)
- static wint_t putwc(wint_t wc, FILE *stream)
- {
- int rc = putc((int) wc, stream);
- return (wint_t) rc;
- }
- static wint_t getwc(FILE *stream)
- {
- int rc = getc(stream);
- return (wint_t) rc;
- }
- #endif /* NO_putwc */
- /****************************************************************
- *
- * Translations and Actions
- *
- ****************************************************************/
- /*
- * The following are the translations which DtEditor places (overrides)
- * on the scrolled text widget. If the DtNtextTranslations resource is
- * set, it will also be added (in override mode) to the text widget.
- */
- static char EditorTranslationTable[] = "\
- ~s ~c ~m ~a <Key>Return: newline-and-indent()\n\
- ~s m<Key>osfBackSpace: I-undo-edit()\n\
- ~s c<Key>osfBackSpace: delete-previous-word()\n\
- s<Key>osfBackSpace: delete-to-start-of-line()\n\
- ~s ~c <Key>osfInsert: I-toggle-insert-mode()\n\
- <Key>osfUndo: I-undo-edit()\n\
- c<Key>g: I-go-to-line()\n\
- c<Key>q: I-quote-next-character()\n\
- c<Key>z: I-undo-edit()";
- /*
- * The following are DtEditor's actions. A few are internal only (_I
- * suffix) and will be called by the default translations DtEditor places
- * on the text widget (see previous comment). The rest will only be called
- * from an application with XtCallActionProc(). The main difference is
- * the internal ones will be passed a text widget ID, while the public
- * ones will be passed a DtEditor ID.
- */
- static XtActionsRec EditorActionTable[] = {
- {"I-go-to-line", (XtActionProc)GoToLine_I},
- {"I-toggle-insert-mode", (XtActionProc)ToggleInsertMode_I},
- {"I-undo-edit", (XtActionProc)UndoEdit_I},
- {"I-quote-next-character", (XtActionProc)QuoteNextChar_I},
- {"backward-character", (XtActionProc)BackwardChar},
- {"backward-paragraph", (XtActionProc)BackwardPara},
- {"backward-word", (XtActionProc)BackwardWord},
- {"beginning-of-file", (XtActionProc)BeginningOfFile},
- {"beginning-of-line", (XtActionProc)BeginningOfLine},
- {"clear-selection", (XtActionProc)ClearSelection},
- {"copy-clipboard", (XtActionProc)CopyClipboard},
- {"cut-clipboard", (XtActionProc)CutClipboard},
- {"delete-next-character", (XtActionProc)DeleteNextChar},
- {"delete-next-word", (XtActionProc)DeleteNextWord},
- {"delete-previous-character", (XtActionProc)DeletePrevChar},
- {"delete-previous-word", (XtActionProc)DeletePrevWord},
- {"delete-to-end-of-line", (XtActionProc)DeleteToEOL},
- {"delete-to-start-of-line", (XtActionProc)DeleteToSOL},
- {"deselect-all", (XtActionProc)DeselectAll},
- {"end-of-file", (XtActionProc)EndOfFile},
- {"end-of-line", (XtActionProc)EndOfLine},
- {"forward-character", (XtActionProc)ForwardChar},
- {"forward-paragraph", (XtActionProc)ForwardPara},
- {"forward-word", (XtActionProc)ForwardWord},
- {"go-to-line", (XtActionProc)GoToLine},
- {"Help", (XtActionProc)Help},
- {"insert-string", (XtActionProc)InsertString},
- {"key-select", (XtActionProc)KeySelect},
- {"newline-and-backup", (XtActionProc)NewlineAndBackup},
- {"newline-and-indent", (XtActionProc)NewlineAndIndent},
- {"next-page", (XtActionProc)NextPage},
- {"page-left", (XtActionProc)PageLeft},
- {"page-right", (XtActionProc)PageRight},
- {"paste-clipboard", (XtActionProc)PasteClipboard},
- {"previous-page", (XtActionProc)PreviousPage},
- {"process-cancel", (XtActionProc)ProcessCancel},
- {"process-down", (XtActionProc)ProcessDown},
- {"process-shift-down", (XtActionProc)ProcessShiftDown},
- {"process-shift-up", (XtActionProc)ProcessShiftUp},
- {"process-up", (XtActionProc)ProcessUp},
- {"quote-next-character", (XtActionProc)QuoteNextChar},
- {"select-all", (XtActionProc)SelectAll},
- {"toggle-insert-mode", (XtActionProc)ToggleInsertMode},
- {"undo-edit", (XtActionProc)UndoEdit},
- };
- /****************************************************************
- *
- * Defines
- *
- ****************************************************************/
- #define NL_SETN 1
- #ifdef _AIX
- #define iswctype(a,b) is_wctype(a,b)
- #define wctype(a) get_wctype(a)
- #endif /* _AIX */
- #if !(defined(sun) && (_XOPEN_VERSION==3))
- # define iswblank(wc) iswctype((wc),blnkclass)
- # undef getwc /* Use the libc function */
- #if defined(__osf__) || defined(_AIX) /* __osf__ || _AIX */
- /* function prototype for wctype() was changed to meet spec1170 */
- /* digital compiler flagged warning */
- /* IBM defines wctype to get_wctype above - don't use const. */
- static char *blankString = "space";
- #elif defined(USL)
- # define wctype_t int
- #else /* __osf__ || _AIX */
- static const char *blankString = "space";
- #endif /* __osf__ || _AIX */
- static wctype_t _DtEditor_blankClass;
- #else
- # define wctype_t int
- # if defined(__uxp__)
- # if (OSMAJORVERSION < 2)
- typedef long wint_t ;
- # endif
- # define WEOF (-1)
- # endif /* uxp */
- # define iswblank(a) iswspace(a)
- # if !defined(__uxp__)
- # define iswctype(a,b) _iswctype(a,b)
- # endif
- # if defined(__uxp__)
- # define wcwidth(a) scrwidth(a)
- # else
- # define wcwidth(a) sun_wcwidth(a)
- # endif
- #endif /* not sun and not uxp */
- #define MAXTABSIZE 100 /* max legal tabsize */
- /****************************************************************
- *
- * Define misc data structures
- *
- ****************************************************************/
- static wctype_t ekinclass = 0; /* Prop value for "ekinsoku" class */
- static wctype_t bekinclass = 0; /* Prop value for "bekinsoku" class */
- static wctype_t blnkclass = 0; /* Prop value for "Blank" Class */
- /****************************************************************
- *
- * Resource List
- *
- ****************************************************************/
- static XmSyntheticResource syn_resources[] =
- {
- {
- DtNcolumns, sizeof(short),
- XtOffset (DtEditorWidget, editor.editStuff.columns),
- _DtEditorGetColumns, NULL
- },
- {
- DtNcenterToggleLabel, sizeof (XmString),
- XtOffset (DtEditorWidget, editor.formatStuff.centerToggleLabel),
- _DtEditorGetCenterToggleLabel, NULL
- },
- {
- DtNchangeAllButtonLabel, sizeof (XmString),
- XtOffset (DtEditorWidget,
- editor.searchStuff.changeAllButtonLabel),
- _DtEditorGetChangeAllButtonLabel, NULL
- },
- {
- DtNchangeButtonLabel, sizeof (XmString),
- XtOffset(DtEditorWidget, editor.searchStuff.changeButtonLabel),
- _DtEditorGetChangeButtonLabel, NULL
- },
- {
- DtNchangeFieldLabel, sizeof (XmString),
- XtOffset(DtEditorWidget, editor.searchStuff.changeFieldLabel),
- _DtEditorGetChangeFieldLabel, NULL
- },
- {
- DtNcurrentLineLabel, sizeof (XmString),
- XtOffset(DtEditorWidget, editor.statusStuff.currentLineLabel),
- _DtEditorGetCurrentLineLabel, NULL
- },
- {
- DtNcursorPosition, sizeof (XmTextPosition),
- XtOffset(DtEditorWidget, editor.editStuff.cursorPos),
- _DtEditorGetCursorPosition, NULL
- },
- {
- DtNfindButtonLabel, sizeof (XmString),
- XtOffset(DtEditorWidget, editor.searchStuff.findButtonLabel),
- _DtEditorGetFindButtonLabel, NULL
- },
- {
- DtNfindFieldLabel, sizeof (XmString),
- XtOffset(DtEditorWidget, editor.searchStuff.findFieldLabel),
- _DtEditorGetFindFieldLabel, NULL
- },
- {
- DtNformatAllButtonLabel, sizeof (XmString),
- XtOffset(DtEditorWidget,
- editor.formatStuff.formatAllButtonLabel),
- _DtEditorGetFormatAllButtonLabel, NULL
- },
- {
- DtNformatParagraphButtonLabel, sizeof (XmString),
- XtOffset(DtEditorWidget,
- editor.formatStuff.formatParaButtonLabel),
- _DtEditorGetFormatParagraphButtonLabel, NULL
- },
- {
- DtNjustifyToggleLabel, sizeof (XmString),
- XtOffset (DtEditorWidget,
- editor.formatStuff.justifyToggleLabel),
- _DtEditorGetJustifyToggleLabel, NULL
- },
- {
- DtNleftAlignToggleLabel, sizeof (XmString),
- XtOffset (DtEditorWidget,
- editor.formatStuff.leftAlignToggleLabel),
- _DtEditorGetLeftAlignToggleLabel, NULL
- },
- {
- DtNleftMarginFieldLabel, sizeof (XmString),
- XtOffset (DtEditorWidget,
- editor.formatStuff.leftMarginFieldLabel),
- _DtEditorGetLeftMarginFieldLabel, NULL
- },
- {
- DtNmaxLength, sizeof(int),
- XtOffset(DtEditorWidget, editor.editStuff.maxLength),
- _DtEditorGetMaxLength, NULL
- },
- {
- DtNmisspelledListLabel, sizeof (XmString),
- XtOffset (DtEditorWidget,
- editor.searchStuff.misspelledListLabel),
- _DtEditorGetMisspelledListLabel, NULL
- },
- {
- DtNrightAlignToggleLabel, sizeof (XmString),
- XtOffset (DtEditorWidget,
- editor.formatStuff.rightAlignToggleLabel),
- _DtEditorGetRightAlignToggleLabel, NULL
- },
- {
- DtNrightMarginFieldLabel, sizeof (XmString),
- XtOffset (DtEditorWidget,
- editor.formatStuff.rightMarginFieldLabel),
- _DtEditorGetRightMarginFieldLabel, NULL
- },
- {
- DtNrows, sizeof(short),
- XtOffset (DtEditorWidget, editor.editStuff.rows),
- _DtEditorGetRows, NULL
- },
- {
- DtNscrollLeftSide, sizeof (Boolean),
- XtOffset (DtEditorWidget, editor.editStuff.scrollLeft),
- _DtEditorGetScrollLeftSide, NULL
- },
- {
- DtNscrollTopSide, sizeof (Boolean),
- XtOffset (DtEditorWidget, editor.editStuff.scrollTop),
- _DtEditorGetScrollTopSide, NULL
- },
- {
- DtNtextBackground, sizeof(Pixel),
- XtOffset (DtEditorWidget, editor.editStuff.background),
- _DtEditorGetTextBackground, NULL
- },
- {
- DtNtextForeground, sizeof(Pixel),
- XtOffset (DtEditorWidget, editor.editStuff.foreground),
- _DtEditorGetTextForeground, NULL
- },
- {
- DtNtopCharacter, sizeof(XmTextPosition),
- XtOffset (DtEditorWidget, editor.editStuff.topCharacter),
- _DtEditorGetTopCharacter, NULL
- },
- {
- DtNtotalLineCountLabel, sizeof (XmString),
- XtOffset (DtEditorWidget, editor.statusStuff.totalLineLabel),
- _DtEditorGetLineCountLabel, NULL
- },
- };
- static XtResource resources[] =
- {
- {
- DtNautoShowCursorPosition,
- DtCAutoShowCursorPosition, XmRBoolean, sizeof (Boolean),
- XtOffset(DtEditorWidget,
- editor.editStuff.autoShowCursorPos),
- XmRImmediate, (XtPointer) True
- },
- {
- DtNbuttonFontList, DtCFontList, XmRFontList, sizeof(XmFontList),
- XtOffsetOf(struct _XmBulletinBoardRec,
- bulletin_board.button_font_list),
- XmRFontList, (XtPointer) NULL
- },
- {
- DtNblinkRate, DtCBlinkRate, XmRInt, sizeof(int),
- XtOffset(DtEditorWidget, editor.editStuff.blinkRate),
- XmRImmediate, (XtPointer) 500
- },
- {
- DtNcenterToggleLabel, DtCCenterToggleLabel,
- XmRXmString, sizeof (XmString),
- XtOffset (DtEditorWidget, editor.formatStuff.centerToggleLabel),
- XmRImmediate, (XtPointer) DtUNSPECIFIED
- },
- {
- DtNchangeAllButtonLabel, DtCChangeAllButtonLabel,
- XmRXmString, sizeof (XmString),
- XtOffset (DtEditorWidget,
- editor.searchStuff.changeAllButtonLabel),
- XmRImmediate, (XtPointer) DtUNSPECIFIED
- },
- {
- DtNchangeButtonLabel, DtCChangeButtonLabel,
- XmRXmString, sizeof (XmString),
- XtOffset(DtEditorWidget, editor.searchStuff.changeButtonLabel),
- XmRImmediate, (XtPointer) DtUNSPECIFIED
- },
- {
- DtNchangeFieldLabel, DtCChangeFieldLabel,
- XmRXmString, sizeof (XmString),
- XtOffset(DtEditorWidget, editor.searchStuff.changeFieldLabel),
- XmRImmediate, (XtPointer) DtUNSPECIFIED
- },
- {
- DtNcolumns, DtCColumns, XmRShort, sizeof(short),
- XtOffset (DtEditorWidget, editor.editStuff.columns),
- XmRImmediate, (XtPointer) DtUNSPECIFIED
- },
- {
- DtNcurrentLineLabel, DtCCurrentLineLabel,
- XmRXmString, sizeof (XmString),
- XtOffset(DtEditorWidget, editor.statusStuff.currentLineLabel),
- XmRImmediate, (XtPointer) DtUNSPECIFIED
- },
- {
- DtNcursorPosition, DtCCursorPosition, XmRTextPosition,
- sizeof (XmTextPosition),
- XtOffset(DtEditorWidget, editor.editStuff.cursorPos),
- XmRImmediate, (XtPointer) DtUNSPECIFIED
- },
- {
- DtNcursorPositionVisible, DtCCursorPositionVisible,
- XmRBoolean, sizeof (Boolean),
- XtOffset(DtEditorWidget,
- editor.editStuff.cursorPosVisible),
- XmRImmediate, (XtPointer) True
- },
- {
- DtNdialogTitle, DtCDialogTitle, XmRXmString, sizeof (XmString),
- XtOffsetOf(struct _XmBulletinBoardRec,
- bulletin_board.dialog_title),
- XmRString, (XtPointer) NULL
- },
- {
- DtNeditable, DtCEditable, XmRBoolean, sizeof (Boolean),
- XtOffset (DtEditorWidget, editor.editStuff.editable),
- XmRImmediate, (XtPointer) True
- },
- {
- DtNfindButtonLabel, DtCFindButtonLabel,
- XmRXmString, sizeof (XmString),
- XtOffset(DtEditorWidget, editor.searchStuff.findButtonLabel),
- XmRImmediate, (XtPointer) DtUNSPECIFIED
- },
- {
- DtNfindChangeDialogTitle, DtCFindChangeDialogTitle,
- XmRXmString, sizeof (XmString),
- XtOffset(DtEditorWidget, editor.searchStuff.fndChngTitle),
- XmRString, (XtPointer) NULL
- },
- {
- DtNfindFieldLabel, DtCFindFieldLabel,
- XmRXmString, sizeof (XmString),
- XtOffset(DtEditorWidget, editor.searchStuff.findFieldLabel),
- XmRImmediate, (XtPointer) DtUNSPECIFIED
- },
- {
- DtNformatAllButtonLabel, DtCFormatAllButtonLabel,
- XmRXmString, sizeof (XmString),
- XtOffset(DtEditorWidget,
- editor.formatStuff.formatAllButtonLabel),
- XmRImmediate, (XtPointer) DtUNSPECIFIED
- },
- {
- DtNformatParagraphButtonLabel, DtCFormatParagraphButtonLabel,
- XmRXmString, sizeof (XmString),
- XtOffset(DtEditorWidget,
- editor.formatStuff.formatParaButtonLabel),
- XmRImmediate, (XtPointer) DtUNSPECIFIED
- },
- {
- DtNformatSettingsDialogTitle, DtCFormatSettingsDialogTitle,
- XmRXmString, sizeof (XmString),
- XtOffset(DtEditorWidget, editor.formatStuff.formatDialogTitle),
- XmRString, (XtPointer) NULL
- },
- {
- DtNinformationDialogTitle, DtCInformationDialogTitle,
- XmRXmString, sizeof (XmString),
- XtOffset(DtEditorWidget, editor.warningStuff.infoDialogTitle),
- XmRString, (XtPointer) NULL
- },
- {
- DtNinsertLabel, DtCInsertLabel, XmRXmString, sizeof (XmString),
- XtOffset (DtEditorWidget, editor.statusStuff.ins),
- XmRImmediate, (XtPointer) DtUNSPECIFIED
- },
- {
- DtNjustifyToggleLabel, DtCJustifyToggleLabel,
- XmRXmString, sizeof (XmString),
- XtOffset(DtEditorWidget, editor.formatStuff.justifyToggleLabel),
- XmRImmediate, (XtPointer) DtUNSPECIFIED
- },
- {
- DtNlabelFontList, DtCFontList, XmRFontList, sizeof(XmFontList),
- XtOffsetOf(struct _XmBulletinBoardRec,
- bulletin_board.label_font_list),
- XmRFontList, (XtPointer) NULL
- },
- {
- DtNleftAlignToggleLabel, DtCLeftAlignToggleLabel,
- XmRXmString, sizeof (XmString),
- XtOffset(DtEditorWidget,
- editor.formatStuff.leftAlignToggleLabel),
- XmRImmediate, (XtPointer) DtUNSPECIFIED
- },
- {
- DtNleftMarginFieldLabel, DtCLeftMarginFieldLabel,
- XmRXmString, sizeof (XmString),
- XtOffset(DtEditorWidget,
- editor.formatStuff.leftMarginFieldLabel),
- XmRImmediate, (XtPointer) DtUNSPECIFIED
- },
- {
- DtNmaxLength, DtCMaxLength, XmRInt, sizeof(int),
- XtOffset(DtEditorWidget, editor.editStuff.maxLength),
- XmRImmediate, (XtPointer) DtUNSPECIFIED
- },
- {
- DtNmisspelledListLabel, DtCMisspelledListLabel,
- XmRXmString, sizeof (XmString),
- XtOffset (DtEditorWidget,
- editor.searchStuff.misspelledListLabel),
- XmRImmediate, (XtPointer) DtUNSPECIFIED
- },
- {
- DtNoverstrike, DtCOverstrike, XmRBoolean, sizeof (Boolean),
- XtOffset(DtEditorWidget, editor.editStuff.overstrikeMode),
- XmRImmediate, (XtPointer) False
- },
- {
- DtNoverstrikeLabel, DtCOverstrikeLabel,
- XmRXmString, sizeof (XmString),
- XtOffset (DtEditorWidget, editor.statusStuff.ovr),
- XmRImmediate, (XtPointer) DtUNSPECIFIED
- },
- {
- DtNrightAlignToggleLabel, DtCRightAlignToggleLabel,
- XmRXmString, sizeof (XmString),
- XtOffset(DtEditorWidget,
- editor.formatStuff.rightAlignToggleLabel),
- XmRImmediate, (XtPointer) DtUNSPECIFIED
- },
- {
- DtNrightMarginFieldLabel, DtCRightMarginFieldLabel,
- XmRXmString, sizeof (XmString),
- XtOffset(DtEditorWidget,
- editor.formatStuff.rightMarginFieldLabel),
- XmRImmediate, (XtPointer) DtUNSPECIFIED
- },
- {
- DtNrows, DtCRows, XmRShort, sizeof(short),
- XtOffset (DtEditorWidget, editor.editStuff.rows),
- XmRImmediate, (XtPointer) DtUNSPECIFIED
- },
- {
- DtNscrollHorizontal, DtCScroll, XmRBoolean, sizeof (Boolean),
- XtOffset (DtEditorWidget, editor.editStuff.scrollHorizontal),
- XmRImmediate, (XtPointer) True
- },
- {
- DtNscrollLeftSide, DtCScrollSide, XmRBoolean, sizeof (Boolean),
- XtOffset (DtEditorWidget, editor.editStuff.scrollLeft),
- XmRImmediate, (XtPointer) DtUNSPECIFIED
- },
- {
- DtNscrollTopSide, DtCScrollSide, XmRBoolean, sizeof (Boolean),
- XtOffset (DtEditorWidget, editor.editStuff.scrollTop),
- XmRImmediate, (XtPointer) DtUNSPECIFIED
- },
- {
- DtNscrollVertical, DtCScroll, XmRBoolean, sizeof (Boolean),
- XtOffset (DtEditorWidget, editor.editStuff.scrollVertical),
- XmRImmediate, (XtPointer) True
- },
- {
- DtNshowStatusLine,
- DtCShowStatusLine, XmRBoolean, sizeof (Boolean),
- XtOffset (DtEditorWidget, editor.statusStuff.showStatusLine),
- XmRImmediate, (XtPointer) False
- },
- {
- DtNspellDialogTitle, DtCSpellDialogTitle,
- XmRXmString, sizeof (XmString),
- XtOffset(DtEditorWidget, editor.searchStuff.spellTitle),
- XmRString, (XtPointer) NULL
- },
- {
- DtNspellFilter, DtCSpellFilter, XmRString, sizeof(XmRString),
- XtOffset (DtEditorWidget, editor.searchStuff.spellFilter),
- XmRString, "spell"
- },
- {
- DtNtextBackground, DtCBackground,
- XmRPixel, sizeof(Pixel),
- XtOffset (DtEditorWidget, editor.editStuff.background),
- XmRImmediate, (XtPointer) DtUNSPECIFIED
- },
- {
- DtNtextDeselectCallback,
- DtCCallback, XtRCallback, sizeof (XtCallbackList),
- XtOffset (DtEditorWidget, editor.textDeselect),
- XtRCallback, (XtPointer) NULL
- },
- {
- DtNtextForeground, DtCForeground,
- XmRPixel, sizeof(Pixel),
- XtOffset (DtEditorWidget, editor.editStuff.foreground),
- XmRImmediate, (XtPointer) DtUNSPECIFIED
- },
- {
- DtNtextFontList, DtCFontList, XmRFontList, sizeof(XmFontList),
- XtOffsetOf(struct _XmBulletinBoardRec,
- bulletin_board.text_font_list),
- XmRFontList, (XtPointer) NULL
- },
- {
- DtNtextSelectCallback,
- DtCCallback, XtRCallback, sizeof (XtCallbackList),
- XtOffset (DtEditorWidget, editor.textSelect),
- XtRCallback, (XtPointer) NULL
- },
- {
- DtNtextTranslations, DtCTranslations,
- XmRTranslationTable, sizeof (XtTranslations),
- XtOffsetOf(struct _XmBulletinBoardRec,
- bulletin_board.text_translations),
- XmRImmediate, (XtPointer) NULL
- },
- {
- DtNtopCharacter, DtCTopCharacter,
- XmRTextPosition, sizeof(XmTextPosition),
- XtOffset (DtEditorWidget, editor.editStuff.topCharacter),
- XmRImmediate, (XtPointer) DtUNSPECIFIED
- },
- {
- DtNtotalLineCountLabel, DtCTotalLineCountLabel,
- XmRXmString, sizeof (XmString),
- XtOffset (DtEditorWidget,
- editor.statusStuff.totalLineLabel),
- XmRImmediate, (XtPointer) DtUNSPECIFIED
- },
- {
- DtNwordWrap,
- DtCWordWrap, XmRBoolean, sizeof (Boolean),
- XtOffset (DtEditorWidget, editor.editStuff.wordWrap),
- XmRImmediate, (XtPointer) False
- },
- };
- /****************************************************************
- *
- * Public Function Declarations
- *
- ****************************************************************/
- /****************************************************************
- *
- * Class Record
- *
- ****************************************************************/
- externaldef( dteditorclassrec ) DtEditorClassRec
- dtEditorClassRec =
- {
- /* Core Part
- */
- {
- (WidgetClass) &xmFormClassRec, /* superclass */
- "DtEditor", /* class_name */
- sizeof (DtEditorRec), /* widget_size */
- ClassInitialize, /* class_initialize */
- NULL, /* class_part_initialize*/
- False, /* class_inited */
- (XtInitProc) Initialize, /* initialize */
- NULL, /* initialize_hook */
- XtInheritRealize, /* realize */
- (XtActionList)EditorActionTable,/* actions */
- (Cardinal)XtNumber(EditorActionTable), /* num_actions */
- resources, /* resources */
- XtNumber (resources), /* num_resources */
- NULLQUARK, /* xrm_class */
- True, /* compress_motion */
- XtExposeCompressMaximal, /* compress_exposure */
- False, /* compress_enterleave */
- False, /* visible_interest */
- (XtWidgetProc) Destroy, /* destroy */
- XtInheritResize, /* resize */
- XtInheritExpose, /* expose */
- (XtSetValuesFunc) SetValues, /* set_values */
- NULL, /* set_values_hook */
- XtInheritSetValuesAlmost, /* set_values_almost */
- NULL, /* get_values_hook */
- XtInheritAcceptFocus, /* accept_focus */
- XtVersion, /* version */
- NULL, /* callback private */
- XtInheritTranslations, /* tm_table */
- XtInheritQueryGeometry, /* query_geometry */
- (XtStringProc)NULL, /* display_accelerator */
- NULL, /* extension */
- },
- /* Composite Part
- */
- {
- XtInheritGeometryManager, /* geometry_manager */
- XtInheritChangeManaged, /* change_managed */
- XtInheritInsertChild, /* insert_child */
- XtInheritDeleteChild, /* delete_child */
- NULL, /* extension */
- },
- /* Constraint Part
- */
- {
- NULL, /* constraint_resources */
- 0, /* num_constraint_resource */
- sizeof(XmFormConstraintRec), /* size of constraint */
- NULL, /* initialization */
- NULL, /* constraint_destroy */
- NULL, /* constraint_set_values */
- NULL, /* extension */
- },
- /* XmManager Part
- */
- {
- XmInheritTranslations, /* default_translations */
- syn_resources, /* syn_resources */
- XtNumber(syn_resources), /* num_syn_resources */
- NULL, /* syn_cont_resources */
- 0, /* num_syn_cont_resources */
- XmInheritParentProcess, /* parent_process */
- NULL, /* extension */
- },
- /* XmbulletinBoard Part
- */
- {
- FALSE, /* always_install_accelerators */
- (XmGeoCreateProc)NULL, /* geo_matrix_create */
- XmInheritFocusMovedProc, /* focus_moved_proc */
- NULL, /* extension */
- },
- /* XmForm Part
- */
- {
- (int) NULL, /* extension */
- },
- /* DtEditor Part
- */
- {
- (int) NULL, /* extension */
- }
- };
- WidgetClass dtEditorWidgetClass = (WidgetClass) &dtEditorClassRec;
- /*-------------------------------------------------------------
- ** Editor Procs
- **-------------------------------------------------------------
- */
- /****************************************************************
- *
- * Private Procs
- *
- ****************************************************************/
- /*-------------------------------------------------------------
- ** Function: static void ClassInitialize (void);
- **
- ** Parameters:
- **
- ** Purpose: This is the Editor class initializzation routine.
- ** It is called once, before the first instance
- ** is created.
- */
- static void
- ClassInitialize(void)
- {
- #if !(defined(sun) && (_XOPEN_VERSION==3)) && !defined(USL) && !defined(__uxp__)
- _DtEditor_blankClass = wctype(blankString);
- /*
- ** These calls determine if the particular value is True for
- ** the current locale. A value of -1 is returned if the locale
- ** does not support the charclass. If the locale supports the
- ** charclass, the return value is passed as a parameter to the
- ** iswctype call.
- */
- ekinclass = wctype("ekinsoku");
- bekinclass = wctype("bkinsoku");
- blnkclass = wctype("blank");
- #endif /* end not Sun */
- }
- /*-------------------------------------------------------------
- ** Function: static void Initialize (
- ** Widget rw,
- ** Widget nw,
- ** ArgList arg_list,
- ** Cardinal *num_args)
- **
- ** Parameters:
- **
- ** Purpose: This is the Editor widget initialize routine.
- ** It is responsible for the following:
- ** 1) Validate all resources the user passed in,
- ** 2) Override any invalid resources,
- ** 3) Initialize the internal data structures,
- ** 4) Create the edit area widget
- ** 5) Create the status area widget, if requested
- ** 6) Add any callbacks and actions
- */
- static void
- Initialize(
- Widget rw,
- Widget nw,
- ArgList arg_list,
- Cardinal *num_args)
- {
- DtEditorWidget request = (DtEditorWidget) rw,
- new = (DtEditorWidget) nw;
- /* Initialize non-resource portion of the instance structure */
- VariableInitialize (new);
- /* Validate the incoming arguments to make sure they are OK */
- ValidateResources (new, request);
- /*
- * Create & customize the scrolled text widget
- */
- M_text(new) = CreateText (new);
- XtManageChild( M_text(new)) ;
- /*
- * If the widget is not "read only" then register it as a drop zone
- */
- if ( M_editable(new) == True )
- RegisterDropZone( new );
- /*
- * Compute the width & height of the scrolled text's font. These values
- * will be used when formatting and in calculating the window manager
- * hints.
- */
- getFontMetrics(new);
- /*
- * Create the status line
- */
- SetStatusLine( new, M_status_showStatusLine(request) );
- } /* end Initialize */
- /*-------------------------------------------------------------
- ** Function: static void VariableInitialize (
- ** DtEditorWidget new )
- **
- ** Parameters: The Editor widget being created
- **
- ** Purpose: This routine:
- ** 1) Initializes the widget's instance structure
- */
- static void
- VariableInitialize(
- DtEditorWidget new)
- {
- Widget thisParent;
- /*
- * Initialize the non-resource instance fields
- */
- M_display(new) = XtDisplayOfObject( (Widget)new->core.parent );
- M_app_context(new) = XtDisplayToApplicationContext(M_display(new));
- /*
- * Empty 'for' walks up the widget tree to find a shell.
- */
- for (thisParent = new->core.parent;
- thisParent != (Widget)NULL && XtIsShell(thisParent) == False;
- thisParent = XtParent(thisParent));
- M_topLevelShell(new) = thisParent;
- /* Initialize edit area fields */
- M_loadingAllNewData(new) = False;
- M_unreadChanges(new) = False; /* There have not been any changes since */
- /* the app requested the data */
- M_deletionStart(new) = NO_DELETION_IN_PROGRESS;
- M_deletedText(new) = (char *)NULL;
- M_insertStart(new) = 0;
- M_insertionLength(new) = 0;
- M_textSelectCbCalled(new) = False;
- M_fontWidth(new) = -1;
- /* Initialize status line fields */
- M_status_statusArea(new) = (Widget)NULL;
- M_status_messageText(new) = (Widget)NULL;
- M_status_currentLine(new) = -1;
- M_status_lastLine(new) = -1;
- /* Initialize search function data */
- M_search_dialog(new) = (Widget) NULL;
- M_search_dialogMode(new) = SPELL;
- M_search_string(new) = (char *)NULL;
- M_replace_string(new) = (char *)NULL;
- M_misspelled_string(new) = (char *)NULL;
- M_misspelled_found(new) = False;
- /* Initialize format function data */
- M_format_dialog(new) = (Widget)NULL;
- /* Initialize warning dialogs data */
- M_gen_warning(new) = (Widget)NULL;
- } /* end VariableInitialize */
- /*-------------------------------------------------------------
- ** Function: static void ValidateResources (
- ** DtEditorWidget new,
- ** DtEditorWidget request )
- **
- ** Parameters: The Editor widget being created & its requested
- ** resource values
- **
- ** Purpose: This routine:
- ** 1) Validates the widget's requested resources
- */
- static void
- ValidateResources(
- DtEditorWidget new,
- DtEditorWidget request)
- {
- /*
- * Validate the requested values for the editor's resources
- */
- /*
- * Make local copies of all resource strings assigned by the application.
- */
- if (M_spellFilter(request) != (char *) NULL)
- M_spellFilter(new) = XtNewString( M_spellFilter(request) );
- /*
- * Copy the dialog titles if the application set them, otherwise,
- * get their values from the message catalog.
- */
- if (M_spellTitle(request) != (XmString) NULL)
- M_spellTitle(new) = XmStringCopy( M_spellTitle(request) );
- else
- M_spellTitle(new) = XmStringCreateLocalized(SPELL_TITLE);
- if (M_fndChngTitle(request) != (XmString) NULL)
- M_fndChngTitle(new) = XmStringCopy( M_fndChngTitle(request) );
- else
- M_fndChngTitle(new) = XmStringCreateLocalized(FIND_TITLE);
- if (E_format_dialogTitle(request) != (XmString) NULL)
- E_format_dialogTitle(new) = XmStringCopy( E_format_dialogTitle(request) );
- else
- E_format_dialogTitle(new) = XmStringCreateLocalized(FORMAT_SETTINGS);
- if (E_infoDialogTitle(request) != (XmString) NULL)
- E_infoDialogTitle(new) = XmStringCopy( E_infoDialogTitle(request) );
- else
- E_infoDialogTitle(new) = XmStringCreateLocalized(INFO_TITLE);
- /*
- * Copy the insert & overstrike label indicators if the appli-
- * cation set them, otherwise, get their value from the message
- * catalog.
- * Check for DtUNSPECIFIED because NULL is a valid value.
- */
- if (M_status_insertLabel(request) != (XmString) DtUNSPECIFIED)
- M_status_insertLabel(new) =
- XmStringCopy( M_status_insertLabel(request) );
- else
- M_status_insertLabel(new) = XmStringCreateLocalized(INS);
- if (M_status_overstrikeLabel(request) != (XmString) DtUNSPECIFIED)
- M_status_overstrikeLabel(new) =
- XmStringCopy( M_status_overstrikeLabel(request) );
- else
- M_status_overstrikeLabel(new) = XmStringCreateLocalized(OVR);
- } /* end ValidateResources */
- /*-------------------------------------------------------------
- ** Function: static Widget CreateText (
- ** DtEditorWidget parent)
- **
- ** Parameters: The parent of the text widget
- **
- ** Purpose: This routine creates the scrolled text widget which
- ** lives inside the editor widget.
- ** It is responsible for the following:
- ** 1) Creating the scrolled text widget,
- ** 2) Adding specific translations,
- ** 3) Adding our own callbacks,
- ** 4) Substituting our own set selection routine.
- */
- static Widget
- CreateText(
- DtEditorWidget parent)
- {
- register int ac; /* arg count */
- Arg al[21]; /* arg list */
- Widget text;
- /*
- * First, set up the hardwired scrolled text widget resource values.
- * (Change these and you die! Aha! Ha! Ha! Ha! [evil laugh])
- */
- ac = 0;
- XtSetArg (al[ac], XmNeditMode, XmMULTI_LINE_EDIT); ac++;
- XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
- XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
- XtSetArg(al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
- XtSetArg(al[ac], XmNpendingDelete, True); ac++;
- /*
- * Now, set up the resource values which can vary (passed in from
- * application or default values).
- *
- * If a synthetic resource is DtUNSPECIFIED don't set it, but let
- * it default to the scrolled text default value.
- * If it is specified, clear the data field after setting the
- * resource because the value in the field will be out of sync
- * with the real value.
- */
- XtSetArg(al[ac], XmNautoShowCursorPosition, M_autoShowCursorPos(parent));
- ac++;
- XtSetArg(al[ac], XmNblinkRate, M_blinkRate(parent)); ac++;
- if ( M_columns(parent) != DtUNSPECIFIED) {
- XtSetArg (al[ac], XmNcolumns, M_columns(parent) ); ac++;
- M_columns(parent) = (short) DtUNSPECIFIED;
- }
- if ( M_cursorPos(parent) != DtUNSPECIFIED) {
- XtSetArg (al[ac], XmNcursorPosition, M_cursorPos(parent)); ac++;
- M_cursorPos(parent) = (XmTextPosition) DtUNSPECIFIED;
- }
- XtSetArg(al[ac], XmNcursorPositionVisible, M_cursorPosVisible(parent));
- ac++;
- XtSetArg(al[ac], XmNeditable, M_editable(parent)); ac++;
-
- if ( E_textFontList(parent) != (XmFontList) NULL) {
- XtSetArg (al[ac], XmNfontList, E_textFontList(parent)); ac++;
- }
- if ( M_maxLength(parent) != DtUNSPECIFIED) {
- XtSetArg (al[ac], XmNmaxLength, M_maxLength(parent) ); ac++;
- M_maxLength(parent) = (int) DtUNSPECIFIED;
- }
- if ( M_rows(parent) != DtUNSPECIFIED) {
- XtSetArg (al[ac], XmNrows, M_rows(parent) ); ac++;
- M_rows(parent) = (short) DtUNSPECIFIED;
- }
- XtSetArg (al[ac], XmNscrollHorizontal, M_scrollHorizontal(parent) ); ac++;
- if ( M_scrollLeftSide(parent) != (Boolean)DtUNSPECIFIED) {
- XtSetArg (al[ac], XmNscrollLeftSide, M_scrollLeftSide(parent) ); ac++;
- M_scrollLeftSide(parent) = (Boolean)DtUNSPECIFIED;
- }
- if ( M_scrollTopSide(parent) != (Boolean)DtUNSPECIFIED) {
- XtSetArg (al[ac], XmNscrollTopSide, M_scrollTopSide(parent) ); ac++;
- M_scrollTopSide(parent) = (Boolean)DtUNSPECIFIED;
- }
- XtSetArg (al[ac], XmNscrollVertical, M_scrollVertical(parent) ); ac++;