PageRenderTime 55ms CodeModel.GetById 9ms RepoModel.GetById 0ms app.codeStats 0ms

/cde/lib/DtWidget/Editor.c

https://bitbucket.org/tifan/cde
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
  1. /*
  2. * CDE - Common Desktop Environment
  3. *
  4. * Copyright (c) 1993-2012, The Open Group. All rights reserved.
  5. *
  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)
  10. * any later version.
  11. *
  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
  16. * details.
  17. *
  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
  22. */
  23. /* $TOG: Editor.c /main/24 1999/10/14 16:38:25 mgreess $
  24. **********************************<+>*************************************
  25. ***************************************************************************
  26. **
  27. ** File: Editor.c
  28. **
  29. ** Project: Text Editor widget
  30. **
  31. ** Description:
  32. ** -----------
  33. ** This is the main source file for the Text Editor widget.
  34. **
  35. *******************************************************************
  36. * (c) Copyright 1996 Digital Equipment Corporation.
  37. * (c) Copyright 1993, 1994, 1996 Hewlett-Packard Company.
  38. * (c) Copyright 1993, 1994, 1996 International Business Machines Corp.
  39. * (c) Copyright 1993, 1994, 1996 Sun Microsystems, Inc.
  40. * (c) Copyright 1996 Novell, Inc.
  41. * (c) Copyright 1996 FUJITSU LIMITED.
  42. * (c) Copyright 1996 Hitachi.
  43. * (c) Copyright 1993, 1994 Unix System Labs, Inc., a subsidiary of Novell, Inc.
  44. ********************************************************************
  45. **
  46. **************************************************************************
  47. **********************************<+>*************************************/
  48. /*-------------------------------------------------------------
  49. ** Include Files
  50. */
  51. #include <ctype.h>
  52. #if defined(__hpux) || defined(__osf__) || defined(USL)
  53. # include <wchar.h>
  54. #elif defined(__uxp__)
  55. # include <widec.h>
  56. # include <wctype.h>
  57. #elif defined(sun)
  58. # if (_XOPEN_VERSION==3)
  59. # include <wctype.h>
  60. # else
  61. # include <wchar.h>
  62. # endif
  63. # include <libintl.h>
  64. #elif defined(linux)
  65. # include <wctype.h>
  66. # define NO_putwc
  67. #endif /* linux */
  68. #include <sys/wait.h>
  69. #include "signal.h"
  70. #include <string.h>
  71. #include <limits.h> /* For LINE_MAX definition */
  72. #include <sys/errno.h> /* For Error handling */
  73. #include "EditorP.h"
  74. #include <Dt/Dnd.h>
  75. #include "X11/Xutil.h"
  76. #include <X11/StringDefs.h>
  77. #include <X11/keysymdef.h>
  78. #include <Xm/Form.h>
  79. #include <Xm/MessageB.h>
  80. #include <Xm/MwmUtil.h>
  81. #include <Xm/TextF.h>
  82. /* Need the following for _DtOkString */
  83. #include <Dt/DtP.h>
  84. #include <Dt/DtMsgsP.h>
  85. #include "DtWidgetI.h"
  86. /*
  87. * Private functions borrowed from Motif.
  88. */
  89. extern XmTextLineTable _XmTextGetLineTable(Widget widget, int *total_lines);
  90. extern char * _XmStringSourceGetString(XmTextWidget tw,
  91. XmTextPosition from,
  92. XmTextPosition to,
  93. #if NeedWidePrototypes
  94. int want_wchar);
  95. #else
  96. Boolean want_wchar);
  97. #endif /* NeedWidePrototypes */
  98. /*-------------------------------------------------------------
  99. ** Public Interface
  100. **-------------------------------------------------------------
  101. */
  102. /******** Public Function Declarations ********/
  103. /******** End Public Function Declarations ********/
  104. /*-------------------------------------------------------------
  105. ** Forward Declarations
  106. **-------------------------------------------------------------
  107. */
  108. /******** Static Function Declarations ********/
  109. static void ClassInitialize(void);
  110. static void Initialize(
  111. Widget rw,
  112. Widget nw,
  113. ArgList al,
  114. Cardinal *num_args) ;
  115. static void VariableInitialize(
  116. DtEditorWidget new);
  117. static void ValidateResources(
  118. DtEditorWidget new,
  119. DtEditorWidget request);
  120. static Widget CreateText(
  121. DtEditorWidget parent);
  122. static void extractFontMetrics(
  123. DtEditorWidget w,
  124. XmFontList fontlist,
  125. int *height,
  126. int *width);
  127. static void getFontMetrics(
  128. DtEditorWidget w);
  129. static void Destroy(
  130. Widget widget);
  131. static void SetStatusLine(
  132. DtEditorWidget ew,
  133. Boolean statusLineOn);
  134. static Widget CreateStatusLine(
  135. DtEditorWidget parent);
  136. static Boolean SetValues(
  137. Widget cw,
  138. Widget rw,
  139. Widget nw);
  140. static void _DtEditorGetCenterToggleLabel(
  141. Widget wid,
  142. int resource_offset,
  143. XtArgVal *value );
  144. static void _DtEditorGetChangeAllButtonLabel(
  145. Widget wid,
  146. int resource_offset,
  147. XtArgVal *value );
  148. static void _DtEditorGetChangeButtonLabel(
  149. Widget wid,
  150. int resource_offset,
  151. XtArgVal *value );
  152. static void _DtEditorGetChangeFieldLabel(
  153. Widget wid,
  154. int resource_offset,
  155. XtArgVal *value );
  156. static void _DtEditorGetColumns(
  157. Widget wid,
  158. int resource_offset,
  159. XtArgVal *value );
  160. static void _DtEditorGetCurrentLineLabel(
  161. Widget wid,
  162. int resource_offset,
  163. XtArgVal *value );
  164. static void _DtEditorGetCursorPosition(
  165. Widget wid,
  166. int resource_offset,
  167. XtArgVal *value );
  168. static void _DtEditorGetFindButtonLabel(
  169. Widget wid,
  170. int resource_offset,
  171. XtArgVal *value );
  172. static void _DtEditorGetFindFieldLabel(
  173. Widget wid,
  174. int resource_offset,
  175. XtArgVal *value );
  176. static void _DtEditorGetFormatAllButtonLabel(
  177. Widget wid,
  178. int resource_offset,
  179. XtArgVal *value );
  180. static void _DtEditorGetFormatParagraphButtonLabel(
  181. Widget wid,
  182. int resource_offset,
  183. XtArgVal *value );
  184. static void _DtEditorGetJustifyToggleLabel(
  185. Widget wid,
  186. int resource_offset,
  187. XtArgVal *value );
  188. static void _DtEditorGetLeftAlignToggleLabel(
  189. Widget wid,
  190. int resource_offset,
  191. XtArgVal *value );
  192. static void _DtEditorGetLeftMarginFieldLabel(
  193. Widget wid,
  194. int resource_offset,
  195. XtArgVal *value );
  196. static void _DtEditorGetMaxLength(
  197. Widget wid,
  198. int resource_offset,
  199. XtArgVal *value );
  200. static void _DtEditorGetMisspelledListLabel(
  201. Widget wid,
  202. int resource_offset,
  203. XtArgVal *value );
  204. static void _DtEditorGetRightAlignToggleLabel(
  205. Widget wid,
  206. int resource_offset,
  207. XtArgVal *value );
  208. static void _DtEditorGetRightMarginFieldLabel(
  209. Widget wid,
  210. int resource_offset,
  211. XtArgVal *value );
  212. static void _DtEditorGetRows(
  213. Widget wid,
  214. int resource_offset,
  215. XtArgVal *value );
  216. static void _DtEditorGetScrollLeftSide(
  217. Widget wid,
  218. int resource_offset,
  219. XtArgVal *value );
  220. static void _DtEditorGetScrollTopSide(
  221. Widget wid,
  222. int resource_offset,
  223. XtArgVal *value );
  224. static void _DtEditorGetTextBackground(
  225. Widget wid,
  226. int resource_offset,
  227. XtArgVal *value );
  228. static void _DtEditorGetTextForeground(
  229. Widget wid,
  230. int resource_offset,
  231. XtArgVal *value );
  232. static void _DtEditorGetTopCharacter(
  233. Widget wid,
  234. int resource_offset,
  235. XtArgVal *value );
  236. static void _DtEditorGetLineCountLabel(
  237. Widget wid,
  238. int resource_offset,
  239. XtArgVal *value );
  240. static void FixWordWrap( /* XXX Word Wrap workaround */
  241. Widget w, /* XXX Word Wrap workaround */
  242. Boolean wrapOn); /* XXX Word Wrap workaround */
  243. static void BackwardChar(
  244. Widget w,
  245. XEvent *event,
  246. char **params,
  247. Cardinal *num_params);
  248. static void BackwardPara(
  249. Widget w,
  250. XEvent *event,
  251. char **params,
  252. Cardinal *num_params);
  253. static void BackwardWord(
  254. Widget w,
  255. XEvent *event,
  256. char **params,
  257. Cardinal *num_params);
  258. static void BeginningOfFile(
  259. Widget w,
  260. XEvent *event,
  261. char **params,
  262. Cardinal *num_params);
  263. static void BeginningOfLine(
  264. Widget w,
  265. XEvent *event,
  266. char **params,
  267. Cardinal *num_params);
  268. static void ClearSelection(
  269. Widget w,
  270. XEvent *event,
  271. char **params,
  272. Cardinal *num_params);
  273. static void CopyClipboard(
  274. Widget w,
  275. XEvent *event,
  276. char **params,
  277. Cardinal *num_params);
  278. static void CutClipboard(
  279. Widget w,
  280. XEvent *event,
  281. char **params,
  282. Cardinal *num_params);
  283. static void DeleteNextChar(
  284. Widget w,
  285. XEvent *event,
  286. char **params,
  287. Cardinal *num_params);
  288. static void DeleteNextWord(
  289. Widget w,
  290. XEvent *event,
  291. char **params,
  292. Cardinal *num_params);
  293. static void DeletePrevChar(
  294. Widget w,
  295. XEvent *event,
  296. char **params,
  297. Cardinal *num_params);
  298. static void DeletePrevWord(
  299. Widget w,
  300. XEvent *event,
  301. char **params,
  302. Cardinal *num_params);
  303. static void DeleteToEOL(
  304. Widget w,
  305. XEvent *event,
  306. char **params,
  307. Cardinal *num_params);
  308. static void DeleteToSOL(
  309. Widget w,
  310. XEvent *event,
  311. char **params,
  312. Cardinal *num_params);
  313. static void DeselectAll(
  314. Widget w,
  315. XEvent *event,
  316. char **params,
  317. Cardinal *num_params);
  318. static void EndOfFile(
  319. Widget w,
  320. XEvent *event,
  321. char **params,
  322. Cardinal *num_params);
  323. static void EndOfLine(
  324. Widget w,
  325. XEvent *event,
  326. char **params,
  327. Cardinal *num_params);
  328. static void ForwardChar(
  329. Widget w,
  330. XEvent *event,
  331. char **params,
  332. Cardinal *num_params);
  333. static void ForwardPara(
  334. Widget w,
  335. XEvent *event,
  336. char **params,
  337. Cardinal *num_params);
  338. static void ForwardWord(
  339. Widget w,
  340. XEvent *event,
  341. char **params,
  342. Cardinal *num_params);
  343. static void GoToLine(
  344. Widget w,
  345. XEvent *event,
  346. char **params,
  347. Cardinal *num_params);
  348. static void GoToLine_I(
  349. Widget w,
  350. XEvent *event,
  351. char **params,
  352. Cardinal *num_params);
  353. static void Help(
  354. Widget w,
  355. XEvent *event,
  356. char **params,
  357. Cardinal *num_params);
  358. static void InsertString(
  359. Widget w,
  360. XEvent *event,
  361. char **params,
  362. Cardinal *num_params);
  363. static void KeySelect(
  364. Widget w,
  365. XEvent *event,
  366. char **params,
  367. Cardinal *num_params);
  368. static void NewlineAndBackup(
  369. Widget w,
  370. XEvent *event,
  371. char **params,
  372. Cardinal *num_params);
  373. static void NewlineAndIndent(
  374. Widget w,
  375. XEvent *event,
  376. char **params,
  377. Cardinal *num_params);
  378. static void NextPage(
  379. Widget w,
  380. XEvent *event,
  381. char **params,
  382. Cardinal *num_params);
  383. static void PageLeft(
  384. Widget w,
  385. XEvent *event,
  386. char **params,
  387. Cardinal *num_params);
  388. static void PageRight(
  389. Widget w,
  390. XEvent *event,
  391. char **params,
  392. Cardinal *num_params);
  393. static void PasteClipboard(
  394. Widget w,
  395. XEvent *event,
  396. char **params,
  397. Cardinal *num_params);
  398. static void PreviousPage(
  399. Widget w,
  400. XEvent *event,
  401. char **params,
  402. Cardinal *num_params);
  403. static void ProcessCancel(
  404. Widget w,
  405. XEvent *event,
  406. char **params,
  407. Cardinal *num_params);
  408. static void ProcessDown(
  409. Widget w,
  410. XEvent *event,
  411. char **params,
  412. Cardinal *num_params);
  413. static void ProcessShiftDown(
  414. Widget w,
  415. XEvent *event,
  416. char **params,
  417. Cardinal *num_params);
  418. static void ProcessShiftUp(
  419. Widget w,
  420. XEvent *event,
  421. char **params,
  422. Cardinal *num_params);
  423. static void ProcessUp(
  424. Widget w,
  425. XEvent *event,
  426. char **params,
  427. Cardinal *num_params);
  428. static void QuoteNextChar(
  429. Widget w,
  430. XEvent *event,
  431. char **params,
  432. Cardinal *num_params);
  433. static void QuoteNextChar_I(
  434. Widget w,
  435. XEvent *event,
  436. char **params,
  437. Cardinal *num_params);
  438. static void SelectAll(
  439. Widget w,
  440. XEvent *event,
  441. char **params,
  442. Cardinal *num_params);
  443. static void ToggleInsertMode(
  444. Widget w,
  445. XEvent *event,
  446. char **params,
  447. Cardinal *num_params);
  448. static void ToggleInsertMode_I(
  449. Widget w,
  450. XEvent *event,
  451. char **params,
  452. Cardinal *num_params);
  453. static void UndoEdit(
  454. Widget w,
  455. XEvent *event,
  456. char **params,
  457. Cardinal *num_params);
  458. static void UndoEdit_I(
  459. Widget w,
  460. XEvent *event,
  461. char **params,
  462. Cardinal *num_params);
  463. static void Call_TextSelectCallback(
  464. DtEditorWidget editor);
  465. static void Call_TextDeselectCallback(
  466. DtEditorWidget editor);
  467. static void Editor_SetSelectionProc(
  468. XmTextSource source,
  469. XmTextPosition left,
  470. XmTextPosition right,
  471. Time set_time );
  472. static void CallHelpCallback(
  473. DtEditorWidget editor,
  474. int reason);
  475. static void HelpEditWindowCB(
  476. Widget w,
  477. caddr_t client_data,
  478. caddr_t call_data );
  479. static void HelpStatusCurrentLineCB(
  480. Widget w,
  481. caddr_t client_data,
  482. caddr_t call_data );
  483. static void HelpStatusTotalLinesCB(
  484. Widget w,
  485. caddr_t client_data,
  486. caddr_t call_data );
  487. static void HelpStatusMessageCB(
  488. Widget w,
  489. caddr_t client_data,
  490. caddr_t call_data );
  491. static void HelpStatusOverstrikeCB(
  492. Widget w,
  493. caddr_t client_data,
  494. caddr_t call_data );
  495. static void RegisterDropZone(
  496. DtEditorWidget w );
  497. static void UnregisterDropZone(
  498. DtEditorWidget w );
  499. static void SetInfoDialogTitle(
  500. DtEditorWidget editor );
  501. static int FormatText (
  502. AdjRecPtr pAdjRec );
  503. static void AdjustParaCB(
  504. Widget w,
  505. caddr_t client_data,
  506. caddr_t call_data );
  507. static void AdjustAllCB(
  508. Widget w,
  509. caddr_t client_data,
  510. caddr_t call_data );
  511. static DtEditorErrorCode DoAdjust(
  512. DtEditorWidget editor,
  513. int leftMargin,
  514. int rightMargin,
  515. unsigned int alignment,
  516. XmTextPosition start,
  517. XmTextPosition end);
  518. static void SetFormatDialogTitle(
  519. DtEditorWidget editor);
  520. static void ResetFormatDialog(
  521. DtEditorWidget editor);
  522. static void CreateFormatDialog(
  523. DtEditorWidget editor);
  524. static void GetAdjustSettings(
  525. DtEditorWidget pPad,
  526. DtEditorFormatSettings *formatSettings);
  527. static void UpdateOverstrikeIndicator(
  528. DtEditorWidget widget,
  529. Boolean overstrikeOn );
  530. /******** End Static Function Declarations ********/
  531. /****************************************************************
  532. *
  533. * Compatability routines
  534. *
  535. ****************************************************************/
  536. #if defined(NO_putwc)
  537. static wint_t putwc(wint_t wc, FILE *stream)
  538. {
  539. int rc = putc((int) wc, stream);
  540. return (wint_t) rc;
  541. }
  542. static wint_t getwc(FILE *stream)
  543. {
  544. int rc = getc(stream);
  545. return (wint_t) rc;
  546. }
  547. #endif /* NO_putwc */
  548. /****************************************************************
  549. *
  550. * Translations and Actions
  551. *
  552. ****************************************************************/
  553. /*
  554. * The following are the translations which DtEditor places (overrides)
  555. * on the scrolled text widget. If the DtNtextTranslations resource is
  556. * set, it will also be added (in override mode) to the text widget.
  557. */
  558. static char EditorTranslationTable[] = "\
  559. ~s ~c ~m ~a <Key>Return: newline-and-indent()\n\
  560. ~s m<Key>osfBackSpace: I-undo-edit()\n\
  561. ~s c<Key>osfBackSpace: delete-previous-word()\n\
  562. s<Key>osfBackSpace: delete-to-start-of-line()\n\
  563. ~s ~c <Key>osfInsert: I-toggle-insert-mode()\n\
  564. <Key>osfUndo: I-undo-edit()\n\
  565. c<Key>g: I-go-to-line()\n\
  566. c<Key>q: I-quote-next-character()\n\
  567. c<Key>z: I-undo-edit()";
  568. /*
  569. * The following are DtEditor's actions. A few are internal only (_I
  570. * suffix) and will be called by the default translations DtEditor places
  571. * on the text widget (see previous comment). The rest will only be called
  572. * from an application with XtCallActionProc(). The main difference is
  573. * the internal ones will be passed a text widget ID, while the public
  574. * ones will be passed a DtEditor ID.
  575. */
  576. static XtActionsRec EditorActionTable[] = {
  577. {"I-go-to-line", (XtActionProc)GoToLine_I},
  578. {"I-toggle-insert-mode", (XtActionProc)ToggleInsertMode_I},
  579. {"I-undo-edit", (XtActionProc)UndoEdit_I},
  580. {"I-quote-next-character", (XtActionProc)QuoteNextChar_I},
  581. {"backward-character", (XtActionProc)BackwardChar},
  582. {"backward-paragraph", (XtActionProc)BackwardPara},
  583. {"backward-word", (XtActionProc)BackwardWord},
  584. {"beginning-of-file", (XtActionProc)BeginningOfFile},
  585. {"beginning-of-line", (XtActionProc)BeginningOfLine},
  586. {"clear-selection", (XtActionProc)ClearSelection},
  587. {"copy-clipboard", (XtActionProc)CopyClipboard},
  588. {"cut-clipboard", (XtActionProc)CutClipboard},
  589. {"delete-next-character", (XtActionProc)DeleteNextChar},
  590. {"delete-next-word", (XtActionProc)DeleteNextWord},
  591. {"delete-previous-character", (XtActionProc)DeletePrevChar},
  592. {"delete-previous-word", (XtActionProc)DeletePrevWord},
  593. {"delete-to-end-of-line", (XtActionProc)DeleteToEOL},
  594. {"delete-to-start-of-line", (XtActionProc)DeleteToSOL},
  595. {"deselect-all", (XtActionProc)DeselectAll},
  596. {"end-of-file", (XtActionProc)EndOfFile},
  597. {"end-of-line", (XtActionProc)EndOfLine},
  598. {"forward-character", (XtActionProc)ForwardChar},
  599. {"forward-paragraph", (XtActionProc)ForwardPara},
  600. {"forward-word", (XtActionProc)ForwardWord},
  601. {"go-to-line", (XtActionProc)GoToLine},
  602. {"Help", (XtActionProc)Help},
  603. {"insert-string", (XtActionProc)InsertString},
  604. {"key-select", (XtActionProc)KeySelect},
  605. {"newline-and-backup", (XtActionProc)NewlineAndBackup},
  606. {"newline-and-indent", (XtActionProc)NewlineAndIndent},
  607. {"next-page", (XtActionProc)NextPage},
  608. {"page-left", (XtActionProc)PageLeft},
  609. {"page-right", (XtActionProc)PageRight},
  610. {"paste-clipboard", (XtActionProc)PasteClipboard},
  611. {"previous-page", (XtActionProc)PreviousPage},
  612. {"process-cancel", (XtActionProc)ProcessCancel},
  613. {"process-down", (XtActionProc)ProcessDown},
  614. {"process-shift-down", (XtActionProc)ProcessShiftDown},
  615. {"process-shift-up", (XtActionProc)ProcessShiftUp},
  616. {"process-up", (XtActionProc)ProcessUp},
  617. {"quote-next-character", (XtActionProc)QuoteNextChar},
  618. {"select-all", (XtActionProc)SelectAll},
  619. {"toggle-insert-mode", (XtActionProc)ToggleInsertMode},
  620. {"undo-edit", (XtActionProc)UndoEdit},
  621. };
  622. /****************************************************************
  623. *
  624. * Defines
  625. *
  626. ****************************************************************/
  627. #define NL_SETN 1
  628. #ifdef _AIX
  629. #define iswctype(a,b) is_wctype(a,b)
  630. #define wctype(a) get_wctype(a)
  631. #endif /* _AIX */
  632. #if !(defined(sun) && (_XOPEN_VERSION==3))
  633. # define iswblank(wc) iswctype((wc),blnkclass)
  634. # undef getwc /* Use the libc function */
  635. #if defined(__osf__) || defined(_AIX) /* __osf__ || _AIX */
  636. /* function prototype for wctype() was changed to meet spec1170 */
  637. /* digital compiler flagged warning */
  638. /* IBM defines wctype to get_wctype above - don't use const. */
  639. static char *blankString = "space";
  640. #elif defined(USL)
  641. # define wctype_t int
  642. #else /* __osf__ || _AIX */
  643. static const char *blankString = "space";
  644. #endif /* __osf__ || _AIX */
  645. static wctype_t _DtEditor_blankClass;
  646. #else
  647. # define wctype_t int
  648. # if defined(__uxp__)
  649. # if (OSMAJORVERSION < 2)
  650. typedef long wint_t ;
  651. # endif
  652. # define WEOF (-1)
  653. # endif /* uxp */
  654. # define iswblank(a) iswspace(a)
  655. # if !defined(__uxp__)
  656. # define iswctype(a,b) _iswctype(a,b)
  657. # endif
  658. # if defined(__uxp__)
  659. # define wcwidth(a) scrwidth(a)
  660. # else
  661. # define wcwidth(a) sun_wcwidth(a)
  662. # endif
  663. #endif /* not sun and not uxp */
  664. #define MAXTABSIZE 100 /* max legal tabsize */
  665. /****************************************************************
  666. *
  667. * Define misc data structures
  668. *
  669. ****************************************************************/
  670. static wctype_t ekinclass = 0; /* Prop value for "ekinsoku" class */
  671. static wctype_t bekinclass = 0; /* Prop value for "bekinsoku" class */
  672. static wctype_t blnkclass = 0; /* Prop value for "Blank" Class */
  673. /****************************************************************
  674. *
  675. * Resource List
  676. *
  677. ****************************************************************/
  678. static XmSyntheticResource syn_resources[] =
  679. {
  680. {
  681. DtNcolumns, sizeof(short),
  682. XtOffset (DtEditorWidget, editor.editStuff.columns),
  683. _DtEditorGetColumns, NULL
  684. },
  685. {
  686. DtNcenterToggleLabel, sizeof (XmString),
  687. XtOffset (DtEditorWidget, editor.formatStuff.centerToggleLabel),
  688. _DtEditorGetCenterToggleLabel, NULL
  689. },
  690. {
  691. DtNchangeAllButtonLabel, sizeof (XmString),
  692. XtOffset (DtEditorWidget,
  693. editor.searchStuff.changeAllButtonLabel),
  694. _DtEditorGetChangeAllButtonLabel, NULL
  695. },
  696. {
  697. DtNchangeButtonLabel, sizeof (XmString),
  698. XtOffset(DtEditorWidget, editor.searchStuff.changeButtonLabel),
  699. _DtEditorGetChangeButtonLabel, NULL
  700. },
  701. {
  702. DtNchangeFieldLabel, sizeof (XmString),
  703. XtOffset(DtEditorWidget, editor.searchStuff.changeFieldLabel),
  704. _DtEditorGetChangeFieldLabel, NULL
  705. },
  706. {
  707. DtNcurrentLineLabel, sizeof (XmString),
  708. XtOffset(DtEditorWidget, editor.statusStuff.currentLineLabel),
  709. _DtEditorGetCurrentLineLabel, NULL
  710. },
  711. {
  712. DtNcursorPosition, sizeof (XmTextPosition),
  713. XtOffset(DtEditorWidget, editor.editStuff.cursorPos),
  714. _DtEditorGetCursorPosition, NULL
  715. },
  716. {
  717. DtNfindButtonLabel, sizeof (XmString),
  718. XtOffset(DtEditorWidget, editor.searchStuff.findButtonLabel),
  719. _DtEditorGetFindButtonLabel, NULL
  720. },
  721. {
  722. DtNfindFieldLabel, sizeof (XmString),
  723. XtOffset(DtEditorWidget, editor.searchStuff.findFieldLabel),
  724. _DtEditorGetFindFieldLabel, NULL
  725. },
  726. {
  727. DtNformatAllButtonLabel, sizeof (XmString),
  728. XtOffset(DtEditorWidget,
  729. editor.formatStuff.formatAllButtonLabel),
  730. _DtEditorGetFormatAllButtonLabel, NULL
  731. },
  732. {
  733. DtNformatParagraphButtonLabel, sizeof (XmString),
  734. XtOffset(DtEditorWidget,
  735. editor.formatStuff.formatParaButtonLabel),
  736. _DtEditorGetFormatParagraphButtonLabel, NULL
  737. },
  738. {
  739. DtNjustifyToggleLabel, sizeof (XmString),
  740. XtOffset (DtEditorWidget,
  741. editor.formatStuff.justifyToggleLabel),
  742. _DtEditorGetJustifyToggleLabel, NULL
  743. },
  744. {
  745. DtNleftAlignToggleLabel, sizeof (XmString),
  746. XtOffset (DtEditorWidget,
  747. editor.formatStuff.leftAlignToggleLabel),
  748. _DtEditorGetLeftAlignToggleLabel, NULL
  749. },
  750. {
  751. DtNleftMarginFieldLabel, sizeof (XmString),
  752. XtOffset (DtEditorWidget,
  753. editor.formatStuff.leftMarginFieldLabel),
  754. _DtEditorGetLeftMarginFieldLabel, NULL
  755. },
  756. {
  757. DtNmaxLength, sizeof(int),
  758. XtOffset(DtEditorWidget, editor.editStuff.maxLength),
  759. _DtEditorGetMaxLength, NULL
  760. },
  761. {
  762. DtNmisspelledListLabel, sizeof (XmString),
  763. XtOffset (DtEditorWidget,
  764. editor.searchStuff.misspelledListLabel),
  765. _DtEditorGetMisspelledListLabel, NULL
  766. },
  767. {
  768. DtNrightAlignToggleLabel, sizeof (XmString),
  769. XtOffset (DtEditorWidget,
  770. editor.formatStuff.rightAlignToggleLabel),
  771. _DtEditorGetRightAlignToggleLabel, NULL
  772. },
  773. {
  774. DtNrightMarginFieldLabel, sizeof (XmString),
  775. XtOffset (DtEditorWidget,
  776. editor.formatStuff.rightMarginFieldLabel),
  777. _DtEditorGetRightMarginFieldLabel, NULL
  778. },
  779. {
  780. DtNrows, sizeof(short),
  781. XtOffset (DtEditorWidget, editor.editStuff.rows),
  782. _DtEditorGetRows, NULL
  783. },
  784. {
  785. DtNscrollLeftSide, sizeof (Boolean),
  786. XtOffset (DtEditorWidget, editor.editStuff.scrollLeft),
  787. _DtEditorGetScrollLeftSide, NULL
  788. },
  789. {
  790. DtNscrollTopSide, sizeof (Boolean),
  791. XtOffset (DtEditorWidget, editor.editStuff.scrollTop),
  792. _DtEditorGetScrollTopSide, NULL
  793. },
  794. {
  795. DtNtextBackground, sizeof(Pixel),
  796. XtOffset (DtEditorWidget, editor.editStuff.background),
  797. _DtEditorGetTextBackground, NULL
  798. },
  799. {
  800. DtNtextForeground, sizeof(Pixel),
  801. XtOffset (DtEditorWidget, editor.editStuff.foreground),
  802. _DtEditorGetTextForeground, NULL
  803. },
  804. {
  805. DtNtopCharacter, sizeof(XmTextPosition),
  806. XtOffset (DtEditorWidget, editor.editStuff.topCharacter),
  807. _DtEditorGetTopCharacter, NULL
  808. },
  809. {
  810. DtNtotalLineCountLabel, sizeof (XmString),
  811. XtOffset (DtEditorWidget, editor.statusStuff.totalLineLabel),
  812. _DtEditorGetLineCountLabel, NULL
  813. },
  814. };
  815. static XtResource resources[] =
  816. {
  817. {
  818. DtNautoShowCursorPosition,
  819. DtCAutoShowCursorPosition, XmRBoolean, sizeof (Boolean),
  820. XtOffset(DtEditorWidget,
  821. editor.editStuff.autoShowCursorPos),
  822. XmRImmediate, (XtPointer) True
  823. },
  824. {
  825. DtNbuttonFontList, DtCFontList, XmRFontList, sizeof(XmFontList),
  826. XtOffsetOf(struct _XmBulletinBoardRec,
  827. bulletin_board.button_font_list),
  828. XmRFontList, (XtPointer) NULL
  829. },
  830. {
  831. DtNblinkRate, DtCBlinkRate, XmRInt, sizeof(int),
  832. XtOffset(DtEditorWidget, editor.editStuff.blinkRate),
  833. XmRImmediate, (XtPointer) 500
  834. },
  835. {
  836. DtNcenterToggleLabel, DtCCenterToggleLabel,
  837. XmRXmString, sizeof (XmString),
  838. XtOffset (DtEditorWidget, editor.formatStuff.centerToggleLabel),
  839. XmRImmediate, (XtPointer) DtUNSPECIFIED
  840. },
  841. {
  842. DtNchangeAllButtonLabel, DtCChangeAllButtonLabel,
  843. XmRXmString, sizeof (XmString),
  844. XtOffset (DtEditorWidget,
  845. editor.searchStuff.changeAllButtonLabel),
  846. XmRImmediate, (XtPointer) DtUNSPECIFIED
  847. },
  848. {
  849. DtNchangeButtonLabel, DtCChangeButtonLabel,
  850. XmRXmString, sizeof (XmString),
  851. XtOffset(DtEditorWidget, editor.searchStuff.changeButtonLabel),
  852. XmRImmediate, (XtPointer) DtUNSPECIFIED
  853. },
  854. {
  855. DtNchangeFieldLabel, DtCChangeFieldLabel,
  856. XmRXmString, sizeof (XmString),
  857. XtOffset(DtEditorWidget, editor.searchStuff.changeFieldLabel),
  858. XmRImmediate, (XtPointer) DtUNSPECIFIED
  859. },
  860. {
  861. DtNcolumns, DtCColumns, XmRShort, sizeof(short),
  862. XtOffset (DtEditorWidget, editor.editStuff.columns),
  863. XmRImmediate, (XtPointer) DtUNSPECIFIED
  864. },
  865. {
  866. DtNcurrentLineLabel, DtCCurrentLineLabel,
  867. XmRXmString, sizeof (XmString),
  868. XtOffset(DtEditorWidget, editor.statusStuff.currentLineLabel),
  869. XmRImmediate, (XtPointer) DtUNSPECIFIED
  870. },
  871. {
  872. DtNcursorPosition, DtCCursorPosition, XmRTextPosition,
  873. sizeof (XmTextPosition),
  874. XtOffset(DtEditorWidget, editor.editStuff.cursorPos),
  875. XmRImmediate, (XtPointer) DtUNSPECIFIED
  876. },
  877. {
  878. DtNcursorPositionVisible, DtCCursorPositionVisible,
  879. XmRBoolean, sizeof (Boolean),
  880. XtOffset(DtEditorWidget,
  881. editor.editStuff.cursorPosVisible),
  882. XmRImmediate, (XtPointer) True
  883. },
  884. {
  885. DtNdialogTitle, DtCDialogTitle, XmRXmString, sizeof (XmString),
  886. XtOffsetOf(struct _XmBulletinBoardRec,
  887. bulletin_board.dialog_title),
  888. XmRString, (XtPointer) NULL
  889. },
  890. {
  891. DtNeditable, DtCEditable, XmRBoolean, sizeof (Boolean),
  892. XtOffset (DtEditorWidget, editor.editStuff.editable),
  893. XmRImmediate, (XtPointer) True
  894. },
  895. {
  896. DtNfindButtonLabel, DtCFindButtonLabel,
  897. XmRXmString, sizeof (XmString),
  898. XtOffset(DtEditorWidget, editor.searchStuff.findButtonLabel),
  899. XmRImmediate, (XtPointer) DtUNSPECIFIED
  900. },
  901. {
  902. DtNfindChangeDialogTitle, DtCFindChangeDialogTitle,
  903. XmRXmString, sizeof (XmString),
  904. XtOffset(DtEditorWidget, editor.searchStuff.fndChngTitle),
  905. XmRString, (XtPointer) NULL
  906. },
  907. {
  908. DtNfindFieldLabel, DtCFindFieldLabel,
  909. XmRXmString, sizeof (XmString),
  910. XtOffset(DtEditorWidget, editor.searchStuff.findFieldLabel),
  911. XmRImmediate, (XtPointer) DtUNSPECIFIED
  912. },
  913. {
  914. DtNformatAllButtonLabel, DtCFormatAllButtonLabel,
  915. XmRXmString, sizeof (XmString),
  916. XtOffset(DtEditorWidget,
  917. editor.formatStuff.formatAllButtonLabel),
  918. XmRImmediate, (XtPointer) DtUNSPECIFIED
  919. },
  920. {
  921. DtNformatParagraphButtonLabel, DtCFormatParagraphButtonLabel,
  922. XmRXmString, sizeof (XmString),
  923. XtOffset(DtEditorWidget,
  924. editor.formatStuff.formatParaButtonLabel),
  925. XmRImmediate, (XtPointer) DtUNSPECIFIED
  926. },
  927. {
  928. DtNformatSettingsDialogTitle, DtCFormatSettingsDialogTitle,
  929. XmRXmString, sizeof (XmString),
  930. XtOffset(DtEditorWidget, editor.formatStuff.formatDialogTitle),
  931. XmRString, (XtPointer) NULL
  932. },
  933. {
  934. DtNinformationDialogTitle, DtCInformationDialogTitle,
  935. XmRXmString, sizeof (XmString),
  936. XtOffset(DtEditorWidget, editor.warningStuff.infoDialogTitle),
  937. XmRString, (XtPointer) NULL
  938. },
  939. {
  940. DtNinsertLabel, DtCInsertLabel, XmRXmString, sizeof (XmString),
  941. XtOffset (DtEditorWidget, editor.statusStuff.ins),
  942. XmRImmediate, (XtPointer) DtUNSPECIFIED
  943. },
  944. {
  945. DtNjustifyToggleLabel, DtCJustifyToggleLabel,
  946. XmRXmString, sizeof (XmString),
  947. XtOffset(DtEditorWidget, editor.formatStuff.justifyToggleLabel),
  948. XmRImmediate, (XtPointer) DtUNSPECIFIED
  949. },
  950. {
  951. DtNlabelFontList, DtCFontList, XmRFontList, sizeof(XmFontList),
  952. XtOffsetOf(struct _XmBulletinBoardRec,
  953. bulletin_board.label_font_list),
  954. XmRFontList, (XtPointer) NULL
  955. },
  956. {
  957. DtNleftAlignToggleLabel, DtCLeftAlignToggleLabel,
  958. XmRXmString, sizeof (XmString),
  959. XtOffset(DtEditorWidget,
  960. editor.formatStuff.leftAlignToggleLabel),
  961. XmRImmediate, (XtPointer) DtUNSPECIFIED
  962. },
  963. {
  964. DtNleftMarginFieldLabel, DtCLeftMarginFieldLabel,
  965. XmRXmString, sizeof (XmString),
  966. XtOffset(DtEditorWidget,
  967. editor.formatStuff.leftMarginFieldLabel),
  968. XmRImmediate, (XtPointer) DtUNSPECIFIED
  969. },
  970. {
  971. DtNmaxLength, DtCMaxLength, XmRInt, sizeof(int),
  972. XtOffset(DtEditorWidget, editor.editStuff.maxLength),
  973. XmRImmediate, (XtPointer) DtUNSPECIFIED
  974. },
  975. {
  976. DtNmisspelledListLabel, DtCMisspelledListLabel,
  977. XmRXmString, sizeof (XmString),
  978. XtOffset (DtEditorWidget,
  979. editor.searchStuff.misspelledListLabel),
  980. XmRImmediate, (XtPointer) DtUNSPECIFIED
  981. },
  982. {
  983. DtNoverstrike, DtCOverstrike, XmRBoolean, sizeof (Boolean),
  984. XtOffset(DtEditorWidget, editor.editStuff.overstrikeMode),
  985. XmRImmediate, (XtPointer) False
  986. },
  987. {
  988. DtNoverstrikeLabel, DtCOverstrikeLabel,
  989. XmRXmString, sizeof (XmString),
  990. XtOffset (DtEditorWidget, editor.statusStuff.ovr),
  991. XmRImmediate, (XtPointer) DtUNSPECIFIED
  992. },
  993. {
  994. DtNrightAlignToggleLabel, DtCRightAlignToggleLabel,
  995. XmRXmString, sizeof (XmString),
  996. XtOffset(DtEditorWidget,
  997. editor.formatStuff.rightAlignToggleLabel),
  998. XmRImmediate, (XtPointer) DtUNSPECIFIED
  999. },
  1000. {
  1001. DtNrightMarginFieldLabel, DtCRightMarginFieldLabel,
  1002. XmRXmString, sizeof (XmString),
  1003. XtOffset(DtEditorWidget,
  1004. editor.formatStuff.rightMarginFieldLabel),
  1005. XmRImmediate, (XtPointer) DtUNSPECIFIED
  1006. },
  1007. {
  1008. DtNrows, DtCRows, XmRShort, sizeof(short),
  1009. XtOffset (DtEditorWidget, editor.editStuff.rows),
  1010. XmRImmediate, (XtPointer) DtUNSPECIFIED
  1011. },
  1012. {
  1013. DtNscrollHorizontal, DtCScroll, XmRBoolean, sizeof (Boolean),
  1014. XtOffset (DtEditorWidget, editor.editStuff.scrollHorizontal),
  1015. XmRImmediate, (XtPointer) True
  1016. },
  1017. {
  1018. DtNscrollLeftSide, DtCScrollSide, XmRBoolean, sizeof (Boolean),
  1019. XtOffset (DtEditorWidget, editor.editStuff.scrollLeft),
  1020. XmRImmediate, (XtPointer) DtUNSPECIFIED
  1021. },
  1022. {
  1023. DtNscrollTopSide, DtCScrollSide, XmRBoolean, sizeof (Boolean),
  1024. XtOffset (DtEditorWidget, editor.editStuff.scrollTop),
  1025. XmRImmediate, (XtPointer) DtUNSPECIFIED
  1026. },
  1027. {
  1028. DtNscrollVertical, DtCScroll, XmRBoolean, sizeof (Boolean),
  1029. XtOffset (DtEditorWidget, editor.editStuff.scrollVertical),
  1030. XmRImmediate, (XtPointer) True
  1031. },
  1032. {
  1033. DtNshowStatusLine,
  1034. DtCShowStatusLine, XmRBoolean, sizeof (Boolean),
  1035. XtOffset (DtEditorWidget, editor.statusStuff.showStatusLine),
  1036. XmRImmediate, (XtPointer) False
  1037. },
  1038. {
  1039. DtNspellDialogTitle, DtCSpellDialogTitle,
  1040. XmRXmString, sizeof (XmString),
  1041. XtOffset(DtEditorWidget, editor.searchStuff.spellTitle),
  1042. XmRString, (XtPointer) NULL
  1043. },
  1044. {
  1045. DtNspellFilter, DtCSpellFilter, XmRString, sizeof(XmRString),
  1046. XtOffset (DtEditorWidget, editor.searchStuff.spellFilter),
  1047. XmRString, "spell"
  1048. },
  1049. {
  1050. DtNtextBackground, DtCBackground,
  1051. XmRPixel, sizeof(Pixel),
  1052. XtOffset (DtEditorWidget, editor.editStuff.background),
  1053. XmRImmediate, (XtPointer) DtUNSPECIFIED
  1054. },
  1055. {
  1056. DtNtextDeselectCallback,
  1057. DtCCallback, XtRCallback, sizeof (XtCallbackList),
  1058. XtOffset (DtEditorWidget, editor.textDeselect),
  1059. XtRCallback, (XtPointer) NULL
  1060. },
  1061. {
  1062. DtNtextForeground, DtCForeground,
  1063. XmRPixel, sizeof(Pixel),
  1064. XtOffset (DtEditorWidget, editor.editStuff.foreground),
  1065. XmRImmediate, (XtPointer) DtUNSPECIFIED
  1066. },
  1067. {
  1068. DtNtextFontList, DtCFontList, XmRFontList, sizeof(XmFontList),
  1069. XtOffsetOf(struct _XmBulletinBoardRec,
  1070. bulletin_board.text_font_list),
  1071. XmRFontList, (XtPointer) NULL
  1072. },
  1073. {
  1074. DtNtextSelectCallback,
  1075. DtCCallback, XtRCallback, sizeof (XtCallbackList),
  1076. XtOffset (DtEditorWidget, editor.textSelect),
  1077. XtRCallback, (XtPointer) NULL
  1078. },
  1079. {
  1080. DtNtextTranslations, DtCTranslations,
  1081. XmRTranslationTable, sizeof (XtTranslations),
  1082. XtOffsetOf(struct _XmBulletinBoardRec,
  1083. bulletin_board.text_translations),
  1084. XmRImmediate, (XtPointer) NULL
  1085. },
  1086. {
  1087. DtNtopCharacter, DtCTopCharacter,
  1088. XmRTextPosition, sizeof(XmTextPosition),
  1089. XtOffset (DtEditorWidget, editor.editStuff.topCharacter),
  1090. XmRImmediate, (XtPointer) DtUNSPECIFIED
  1091. },
  1092. {
  1093. DtNtotalLineCountLabel, DtCTotalLineCountLabel,
  1094. XmRXmString, sizeof (XmString),
  1095. XtOffset (DtEditorWidget,
  1096. editor.statusStuff.totalLineLabel),
  1097. XmRImmediate, (XtPointer) DtUNSPECIFIED
  1098. },
  1099. {
  1100. DtNwordWrap,
  1101. DtCWordWrap, XmRBoolean, sizeof (Boolean),
  1102. XtOffset (DtEditorWidget, editor.editStuff.wordWrap),
  1103. XmRImmediate, (XtPointer) False
  1104. },
  1105. };
  1106. /****************************************************************
  1107. *
  1108. * Public Function Declarations
  1109. *
  1110. ****************************************************************/
  1111. /****************************************************************
  1112. *
  1113. * Class Record
  1114. *
  1115. ****************************************************************/
  1116. externaldef( dteditorclassrec ) DtEditorClassRec
  1117. dtEditorClassRec =
  1118. {
  1119. /* Core Part
  1120. */
  1121. {
  1122. (WidgetClass) &xmFormClassRec, /* superclass */
  1123. "DtEditor", /* class_name */
  1124. sizeof (DtEditorRec), /* widget_size */
  1125. ClassInitialize, /* class_initialize */
  1126. NULL, /* class_part_initialize*/
  1127. False, /* class_inited */
  1128. (XtInitProc) Initialize, /* initialize */
  1129. NULL, /* initialize_hook */
  1130. XtInheritRealize, /* realize */
  1131. (XtActionList)EditorActionTable,/* actions */
  1132. (Cardinal)XtNumber(EditorActionTable), /* num_actions */
  1133. resources, /* resources */
  1134. XtNumber (resources), /* num_resources */
  1135. NULLQUARK, /* xrm_class */
  1136. True, /* compress_motion */
  1137. XtExposeCompressMaximal, /* compress_exposure */
  1138. False, /* compress_enterleave */
  1139. False, /* visible_interest */
  1140. (XtWidgetProc) Destroy, /* destroy */
  1141. XtInheritResize, /* resize */
  1142. XtInheritExpose, /* expose */
  1143. (XtSetValuesFunc) SetValues, /* set_values */
  1144. NULL, /* set_values_hook */
  1145. XtInheritSetValuesAlmost, /* set_values_almost */
  1146. NULL, /* get_values_hook */
  1147. XtInheritAcceptFocus, /* accept_focus */
  1148. XtVersion, /* version */
  1149. NULL, /* callback private */
  1150. XtInheritTranslations, /* tm_table */
  1151. XtInheritQueryGeometry, /* query_geometry */
  1152. (XtStringProc)NULL, /* display_accelerator */
  1153. NULL, /* extension */
  1154. },
  1155. /* Composite Part
  1156. */
  1157. {
  1158. XtInheritGeometryManager, /* geometry_manager */
  1159. XtInheritChangeManaged, /* change_managed */
  1160. XtInheritInsertChild, /* insert_child */
  1161. XtInheritDeleteChild, /* delete_child */
  1162. NULL, /* extension */
  1163. },
  1164. /* Constraint Part
  1165. */
  1166. {
  1167. NULL, /* constraint_resources */
  1168. 0, /* num_constraint_resource */
  1169. sizeof(XmFormConstraintRec), /* size of constraint */
  1170. NULL, /* initialization */
  1171. NULL, /* constraint_destroy */
  1172. NULL, /* constraint_set_values */
  1173. NULL, /* extension */
  1174. },
  1175. /* XmManager Part
  1176. */
  1177. {
  1178. XmInheritTranslations, /* default_translations */
  1179. syn_resources, /* syn_resources */
  1180. XtNumber(syn_resources), /* num_syn_resources */
  1181. NULL, /* syn_cont_resources */
  1182. 0, /* num_syn_cont_resources */
  1183. XmInheritParentProcess, /* parent_process */
  1184. NULL, /* extension */
  1185. },
  1186. /* XmbulletinBoard Part
  1187. */
  1188. {
  1189. FALSE, /* always_install_accelerators */
  1190. (XmGeoCreateProc)NULL, /* geo_matrix_create */
  1191. XmInheritFocusMovedProc, /* focus_moved_proc */
  1192. NULL, /* extension */
  1193. },
  1194. /* XmForm Part
  1195. */
  1196. {
  1197. (int) NULL, /* extension */
  1198. },
  1199. /* DtEditor Part
  1200. */
  1201. {
  1202. (int) NULL, /* extension */
  1203. }
  1204. };
  1205. WidgetClass dtEditorWidgetClass = (WidgetClass) &dtEditorClassRec;
  1206. /*-------------------------------------------------------------
  1207. ** Editor Procs
  1208. **-------------------------------------------------------------
  1209. */
  1210. /****************************************************************
  1211. *
  1212. * Private Procs
  1213. *
  1214. ****************************************************************/
  1215. /*-------------------------------------------------------------
  1216. ** Function: static void ClassInitialize (void);
  1217. **
  1218. ** Parameters:
  1219. **
  1220. ** Purpose: This is the Editor class initializzation routine.
  1221. ** It is called once, before the first instance
  1222. ** is created.
  1223. */
  1224. static void
  1225. ClassInitialize(void)
  1226. {
  1227. #if !(defined(sun) && (_XOPEN_VERSION==3)) && !defined(USL) && !defined(__uxp__)
  1228. _DtEditor_blankClass = wctype(blankString);
  1229. /*
  1230. ** These calls determine if the particular value is True for
  1231. ** the current locale. A value of -1 is returned if the locale
  1232. ** does not support the charclass. If the locale supports the
  1233. ** charclass, the return value is passed as a parameter to the
  1234. ** iswctype call.
  1235. */
  1236. ekinclass = wctype("ekinsoku");
  1237. bekinclass = wctype("bkinsoku");
  1238. blnkclass = wctype("blank");
  1239. #endif /* end not Sun */
  1240. }
  1241. /*-------------------------------------------------------------
  1242. ** Function: static void Initialize (
  1243. ** Widget rw,
  1244. ** Widget nw,
  1245. ** ArgList arg_list,
  1246. ** Cardinal *num_args)
  1247. **
  1248. ** Parameters:
  1249. **
  1250. ** Purpose: This is the Editor widget initialize routine.
  1251. ** It is responsible for the following:
  1252. ** 1) Validate all resources the user passed in,
  1253. ** 2) Override any invalid resources,
  1254. ** 3) Initialize the internal data structures,
  1255. ** 4) Create the edit area widget
  1256. ** 5) Create the status area widget, if requested
  1257. ** 6) Add any callbacks and actions
  1258. */
  1259. static void
  1260. Initialize(
  1261. Widget rw,
  1262. Widget nw,
  1263. ArgList arg_list,
  1264. Cardinal *num_args)
  1265. {
  1266. DtEditorWidget request = (DtEditorWidget) rw,
  1267. new = (DtEditorWidget) nw;
  1268. /* Initialize non-resource portion of the instance structure */
  1269. VariableInitialize (new);
  1270. /* Validate the incoming arguments to make sure they are OK */
  1271. ValidateResources (new, request);
  1272. /*
  1273. * Create & customize the scrolled text widget
  1274. */
  1275. M_text(new) = CreateText (new);
  1276. XtManageChild( M_text(new)) ;
  1277. /*
  1278. * If the widget is not "read only" then register it as a drop zone
  1279. */
  1280. if ( M_editable(new) == True )
  1281. RegisterDropZone( new );
  1282. /*
  1283. * Compute the width & height of the scrolled text's font. These values
  1284. * will be used when formatting and in calculating the window manager
  1285. * hints.
  1286. */
  1287. getFontMetrics(new);
  1288. /*
  1289. * Create the status line
  1290. */
  1291. SetStatusLine( new, M_status_showStatusLine(request) );
  1292. } /* end Initialize */
  1293. /*-------------------------------------------------------------
  1294. ** Function: static void VariableInitialize (
  1295. ** DtEditorWidget new )
  1296. **
  1297. ** Parameters: The Editor widget being created
  1298. **
  1299. ** Purpose: This routine:
  1300. ** 1) Initializes the widget's instance structure
  1301. */
  1302. static void
  1303. VariableInitialize(
  1304. DtEditorWidget new)
  1305. {
  1306. Widget thisParent;
  1307. /*
  1308. * Initialize the non-resource instance fields
  1309. */
  1310. M_display(new) = XtDisplayOfObject( (Widget)new->core.parent );
  1311. M_app_context(new) = XtDisplayToApplicationContext(M_display(new));
  1312. /*
  1313. * Empty 'for' walks up the widget tree to find a shell.
  1314. */
  1315. for (thisParent = new->core.parent;
  1316. thisParent != (Widget)NULL && XtIsShell(thisParent) == False;
  1317. thisParent = XtParent(thisParent));
  1318. M_topLevelShell(new) = thisParent;
  1319. /* Initialize edit area fields */
  1320. M_loadingAllNewData(new) = False;
  1321. M_unreadChanges(new) = False; /* There have not been any changes since */
  1322. /* the app requested the data */
  1323. M_deletionStart(new) = NO_DELETION_IN_PROGRESS;
  1324. M_deletedText(new) = (char *)NULL;
  1325. M_insertStart(new) = 0;
  1326. M_insertionLength(new) = 0;
  1327. M_textSelectCbCalled(new) = False;
  1328. M_fontWidth(new) = -1;
  1329. /* Initialize status line fields */
  1330. M_status_statusArea(new) = (Widget)NULL;
  1331. M_status_messageText(new) = (Widget)NULL;
  1332. M_status_currentLine(new) = -1;
  1333. M_status_lastLine(new) = -1;
  1334. /* Initialize search function data */
  1335. M_search_dialog(new) = (Widget) NULL;
  1336. M_search_dialogMode(new) = SPELL;
  1337. M_search_string(new) = (char *)NULL;
  1338. M_replace_string(new) = (char *)NULL;
  1339. M_misspelled_string(new) = (char *)NULL;
  1340. M_misspelled_found(new) = False;
  1341. /* Initialize format function data */
  1342. M_format_dialog(new) = (Widget)NULL;
  1343. /* Initialize warning dialogs data */
  1344. M_gen_warning(new) = (Widget)NULL;
  1345. } /* end VariableInitialize */
  1346. /*-------------------------------------------------------------
  1347. ** Function: static void ValidateResources (
  1348. ** DtEditorWidget new,
  1349. ** DtEditorWidget request )
  1350. **
  1351. ** Parameters: The Editor widget being created & its requested
  1352. ** resource values
  1353. **
  1354. ** Purpose: This routine:
  1355. ** 1) Validates the widget's requested resources
  1356. */
  1357. static void
  1358. ValidateResources(
  1359. DtEditorWidget new,
  1360. DtEditorWidget request)
  1361. {
  1362. /*
  1363. * Validate the requested values for the editor's resources
  1364. */
  1365. /*
  1366. * Make local copies of all resource strings assigned by the application.
  1367. */
  1368. if (M_spellFilter(request) != (char *) NULL)
  1369. M_spellFilter(new) = XtNewString( M_spellFilter(request) );
  1370. /*
  1371. * Copy the dialog titles if the application set them, otherwise,
  1372. * get their values from the message catalog.
  1373. */
  1374. if (M_spellTitle(request) != (XmString) NULL)
  1375. M_spellTitle(new) = XmStringCopy( M_spellTitle(request) );
  1376. else
  1377. M_spellTitle(new) = XmStringCreateLocalized(SPELL_TITLE);
  1378. if (M_fndChngTitle(request) != (XmString) NULL)
  1379. M_fndChngTitle(new) = XmStringCopy( M_fndChngTitle(request) );
  1380. else
  1381. M_fndChngTitle(new) = XmStringCreateLocalized(FIND_TITLE);
  1382. if (E_format_dialogTitle(request) != (XmString) NULL)
  1383. E_format_dialogTitle(new) = XmStringCopy( E_format_dialogTitle(request) );
  1384. else
  1385. E_format_dialogTitle(new) = XmStringCreateLocalized(FORMAT_SETTINGS);
  1386. if (E_infoDialogTitle(request) != (XmString) NULL)
  1387. E_infoDialogTitle(new) = XmStringCopy( E_infoDialogTitle(request) );
  1388. else
  1389. E_infoDialogTitle(new) = XmStringCreateLocalized(INFO_TITLE);
  1390. /*
  1391. * Copy the insert & overstrike label indicators if the appli-
  1392. * cation set them, otherwise, get their value from the message
  1393. * catalog.
  1394. * Check for DtUNSPECIFIED because NULL is a valid value.
  1395. */
  1396. if (M_status_insertLabel(request) != (XmString) DtUNSPECIFIED)
  1397. M_status_insertLabel(new) =
  1398. XmStringCopy( M_status_insertLabel(request) );
  1399. else
  1400. M_status_insertLabel(new) = XmStringCreateLocalized(INS);
  1401. if (M_status_overstrikeLabel(request) != (XmString) DtUNSPECIFIED)
  1402. M_status_overstrikeLabel(new) =
  1403. XmStringCopy( M_status_overstrikeLabel(request) );
  1404. else
  1405. M_status_overstrikeLabel(new) = XmStringCreateLocalized(OVR);
  1406. } /* end ValidateResources */
  1407. /*-------------------------------------------------------------
  1408. ** Function: static Widget CreateText (
  1409. ** DtEditorWidget parent)
  1410. **
  1411. ** Parameters: The parent of the text widget
  1412. **
  1413. ** Purpose: This routine creates the scrolled text widget which
  1414. ** lives inside the editor widget.
  1415. ** It is responsible for the following:
  1416. ** 1) Creating the scrolled text widget,
  1417. ** 2) Adding specific translations,
  1418. ** 3) Adding our own callbacks,
  1419. ** 4) Substituting our own set selection routine.
  1420. */
  1421. static Widget
  1422. CreateText(
  1423. DtEditorWidget parent)
  1424. {
  1425. register int ac; /* arg count */
  1426. Arg al[21]; /* arg list */
  1427. Widget text;
  1428. /*
  1429. * First, set up the hardwired scrolled text widget resource values.
  1430. * (Change these and you die! Aha! Ha! Ha! Ha! [evil laugh])
  1431. */
  1432. ac = 0;
  1433. XtSetArg (al[ac], XmNeditMode, XmMULTI_LINE_EDIT); ac++;
  1434. XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
  1435. XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
  1436. XtSetArg(al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
  1437. XtSetArg(al[ac], XmNpendingDelete, True); ac++;
  1438. /*
  1439. * Now, set up the resource values which can vary (passed in from
  1440. * application or default values).
  1441. *
  1442. * If a synthetic resource is DtUNSPECIFIED don't set it, but let
  1443. * it default to the scrolled text default value.
  1444. * If it is specified, clear the data field after setting the
  1445. * resource because the value in the field will be out of sync
  1446. * with the real value.
  1447. */
  1448. XtSetArg(al[ac], XmNautoShowCursorPosition, M_autoShowCursorPos(parent));
  1449. ac++;
  1450. XtSetArg(al[ac], XmNblinkRate, M_blinkRate(parent)); ac++;
  1451. if ( M_columns(parent) != DtUNSPECIFIED) {
  1452. XtSetArg (al[ac], XmNcolumns, M_columns(parent) ); ac++;
  1453. M_columns(parent) = (short) DtUNSPECIFIED;
  1454. }
  1455. if ( M_cursorPos(parent) != DtUNSPECIFIED) {
  1456. XtSetArg (al[ac], XmNcursorPosition, M_cursorPos(parent)); ac++;
  1457. M_cursorPos(parent) = (XmTextPosition) DtUNSPECIFIED;
  1458. }
  1459. XtSetArg(al[ac], XmNcursorPositionVisible, M_cursorPosVisible(parent));
  1460. ac++;
  1461. XtSetArg(al[ac], XmNeditable, M_editable(parent)); ac++;
  1462. if ( E_textFontList(parent) != (XmFontList) NULL) {
  1463. XtSetArg (al[ac], XmNfontList, E_textFontList(parent)); ac++;
  1464. }
  1465. if ( M_maxLength(parent) != DtUNSPECIFIED) {
  1466. XtSetArg (al[ac], XmNmaxLength, M_maxLength(parent) ); ac++;
  1467. M_maxLength(parent) = (int) DtUNSPECIFIED;
  1468. }
  1469. if ( M_rows(parent) != DtUNSPECIFIED) {
  1470. XtSetArg (al[ac], XmNrows, M_rows(parent) ); ac++;
  1471. M_rows(parent) = (short) DtUNSPECIFIED;
  1472. }
  1473. XtSetArg (al[ac], XmNscrollHorizontal, M_scrollHorizontal(parent) ); ac++;
  1474. if ( M_scrollLeftSide(parent) != (Boolean)DtUNSPECIFIED) {
  1475. XtSetArg (al[ac], XmNscrollLeftSide, M_scrollLeftSide(parent) ); ac++;
  1476. M_scrollLeftSide(parent) = (Boolean)DtUNSPECIFIED;
  1477. }
  1478. if ( M_scrollTopSide(parent) != (Boolean)DtUNSPECIFIED) {
  1479. XtSetArg (al[ac], XmNscrollTopSide, M_scrollTopSide(parent) ); ac++;
  1480. M_scrollTopSide(parent) = (Boolean)DtUNSPECIFIED;
  1481. }
  1482. XtSetArg (al[ac], XmNscrollVertical, M_scrollVertical(parent) ); ac++;