Editor.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616
  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. /* $XConsortium: Editor.h /main/3 1995/10/26 09:32:07 rswiston $ */
  24. /*
  25. * (c) Copyright 1993, 1994 Hewlett-Packard Company
  26. * (c) Copyright 1993, 1994 International Business Machines Corp.
  27. * (c) Copyright 1993, 1994 Sun Microsystems, Inc.
  28. * (c) Copyright 1993, 1994 Novell, Inc.
  29. */
  30. #ifndef _Dt_Editor_h
  31. #define _Dt_Editor_h
  32. #include <Xm/Xm.h>
  33. #ifdef __cplusplus
  34. extern "C" {
  35. #endif
  36. /*
  37. * Constants
  38. */
  39. /* Sources of Help requests */
  40. /* Used with XmNhelpCallback */
  41. #define DtEDITOR_HELP_EDIT_WINDOW 1
  42. #define DtEDITOR_HELP_STATUS_LINE 2
  43. #define DtEDITOR_HELP_STATUS_CURRENT_LINE 3
  44. #define DtEDITOR_HELP_STATUS_TOTAL_LINES 4
  45. #define DtEDITOR_HELP_STATUS_MESSAGE 5
  46. #define DtEDITOR_HELP_STATUS_OVERSTRIKE 6
  47. #define DtEDITOR_HELP_FORMAT_DIALOG 7
  48. #define DtEDITOR_HELP_FORMAT_LEFT_MARGIN 8
  49. #define DtEDITOR_HELP_FORMAT_RIGHT_MARGIN 9
  50. #define DtEDITOR_HELP_FORMAT_ALIGNMENT 10
  51. #define DtEDITOR_HELP_CHANGE_DIALOG 11
  52. #define DtEDITOR_HELP_CHANGE_FIND 12
  53. #define DtEDITOR_HELP_CHANGE_CHANGE 13
  54. #define DtEDITOR_HELP_SPELL_DIALOG 14
  55. #define DtEDITOR_HELP_SPELL_MISSPELLED_WORDS 15
  56. #define DtEDITOR_HELP_SPELL_CHANGE 16
  57. /* Specifies the last line in the edit area */
  58. /* Used with DtEditorGoToLine */
  59. #define DtEDITOR_LAST_LINE -999
  60. /* Resource constants */
  61. #ifndef DtNautoShowCursorPosition
  62. #define DtNautoShowCursorPosition XmNautoShowCursorPosition
  63. #endif
  64. #ifndef DtCAutoShowCursorPosition
  65. #define DtCAutoShowCursorPosition XmCAutoShowCursorPosition
  66. #endif
  67. #ifndef DtNblinkRate
  68. #define DtNblinkRate XmNblinkRate
  69. #endif
  70. #ifndef DtCBlinkRate
  71. #define DtCBlinkRate XmCBlinkRate
  72. #endif
  73. #ifndef DtNbuttonFontList
  74. #define DtNbuttonFontList XmNbuttonFontList
  75. #endif
  76. #ifndef DtCFontList
  77. #define DtCFontList XmCFontList
  78. #endif
  79. #ifndef DtNcenterToggleLabel
  80. #define DtNcenterToggleLabel "centerToggleLabel"
  81. #endif
  82. #ifndef DtCCenterToggleLabel
  83. #define DtCCenterToggleLabel "CenterToggleLabel"
  84. #endif
  85. #ifndef DtNchangeAllButtonLabel
  86. #define DtNchangeAllButtonLabel "changeAllButtonLabel"
  87. #endif
  88. #ifndef DtCChangeAllButtonLabel
  89. #define DtCChangeAllButtonLabel "ChangeAllButtonLabel"
  90. #endif
  91. #ifndef DtNchangeButtonLabel
  92. #define DtNchangeButtonLabel "changeButtonLabel"
  93. #endif
  94. #ifndef DtCChangeButtonLabel
  95. #define DtCChangeButtonLabel "ChangeButtonLabel"
  96. #endif
  97. #ifndef DtNchangeFieldLabel
  98. #define DtNchangeFieldLabel "changeFieldLabel"
  99. #endif
  100. #ifndef DtCChangeFieldLabel
  101. #define DtCChangeFieldLabel "ChangeFieldLabel"
  102. #endif
  103. #ifndef DtNcolumns
  104. #define DtNcolumns XmNcolumns
  105. #endif
  106. #ifndef DtCColumns
  107. #define DtCColumns XmCColumns
  108. #endif
  109. #ifndef DtNcurrentLineLabel
  110. #define DtNcurrentLineLabel "currentLineLabel"
  111. #endif
  112. #ifndef DtCCurrentLineLabel
  113. #define DtCCurrentLineLabel "CurrentLineLabel"
  114. #endif
  115. #ifndef DtNcursorPosition
  116. #define DtNcursorPosition XmNcursorPosition
  117. #endif
  118. #ifndef DtCCursorPosition
  119. #define DtCCursorPosition XmCCursorPosition
  120. #endif
  121. #ifndef DtNcursorPositionVisible
  122. #define DtNcursorPositionVisible XmNcursorPositionVisible
  123. #endif
  124. #ifndef DtCCursorPositionVisible
  125. #define DtCCursorPositionVisible XmCCursorPositionVisible
  126. #endif
  127. #ifndef DtNdialogTitle
  128. #define DtNdialogTitle "dialogTitle"
  129. #endif
  130. #ifndef DtCDialogTitle
  131. #define DtCDialogTitle XmCDialogTitle
  132. #endif
  133. #ifndef DtNeditable
  134. #define DtNeditable XmNeditable
  135. #endif
  136. #ifndef DtCEditable
  137. #define DtCEditable XmCEditable
  138. #endif
  139. #ifndef DtNfindButtonLabel
  140. #define DtNfindButtonLabel "findButtonLabel"
  141. #endif
  142. #ifndef DtCFindButtonLabel
  143. #define DtCFindButtonLabel "FindButtonLabel"
  144. #endif
  145. #ifndef DtNfindChangeDialogTitle
  146. #define DtNfindChangeDialogTitle "findChangeDialogTitle"
  147. #endif
  148. #ifndef DtCFindChangeDialogTitle
  149. #define DtCFindChangeDialogTitle "FindChangeDialogTitle"
  150. #endif
  151. #ifndef DtNfindFieldLabel
  152. #define DtNfindFieldLabel "findFieldLabel"
  153. #endif
  154. #ifndef DtCFindFieldLabel
  155. #define DtCFindFieldLabel "FindFieldLabel"
  156. #endif
  157. #ifndef DtNformatAllButtonLabel
  158. #define DtNformatAllButtonLabel "formatAllButtonLabel"
  159. #endif
  160. #ifndef DtCFormatAllButtonLabel
  161. #define DtCFormatAllButtonLabel "FormatAllButtonLabel"
  162. #endif
  163. #ifndef DtNformatParagraphButtonLabel
  164. #define DtNformatParagraphButtonLabel "formatParagraphButtonLabel"
  165. #endif
  166. #ifndef DtCFormatParagraphButtonLabel
  167. #define DtCFormatParagraphButtonLabel "FormatParagraphButtonLabel"
  168. #endif
  169. #ifndef DtNformatSettingsDialogTitle
  170. #define DtNformatSettingsDialogTitle "formatSettingsDialogTitle"
  171. #endif
  172. #ifndef DtCFormatSettingsDialogTitle
  173. #define DtCFormatSettingsDialogTitle "FormatSettingsDialogTitle"
  174. #endif
  175. #ifndef DtNinformationDialogTitle
  176. #define DtNinformationDialogTitle "informationDialogTitle"
  177. #endif
  178. #ifndef DtCInformationDialogTitle
  179. #define DtCInformationDialogTitle "InformationDialogTitle"
  180. #endif
  181. #ifndef DtNinsertLabel
  182. #define DtNinsertLabel "insertLabel"
  183. #endif
  184. #ifndef DtCInsertLabel
  185. #define DtCInsertLabel "InsertLabel"
  186. #endif
  187. #ifndef DtNjustifyToggleLabel
  188. #define DtNjustifyToggleLabel "justifyToggleLabel"
  189. #endif
  190. #ifndef DtCJustifyToggleLabel
  191. #define DtCJustifyToggleLabel "JustifyToggleLabel"
  192. #endif
  193. #ifndef DtNlabelFontList
  194. #define DtNlabelFontList XmNlabelFontList
  195. #endif
  196. #ifndef DtNleftAlignToggleLabel
  197. #define DtNleftAlignToggleLabel "leftAlignToggleLabel"
  198. #endif
  199. #ifndef DtCLeftAlignToggleLabel
  200. #define DtCLeftAlignToggleLabel "LeftAlignToggleLabel"
  201. #endif
  202. #ifndef DtNleftMarginFieldLabel
  203. #define DtNleftMarginFieldLabel "leftMarginFieldLabel"
  204. #endif
  205. #ifndef DtCLeftMarginFieldLabel
  206. #define DtCLeftMarginFieldLabel "LeftMarginFieldLabel"
  207. #endif
  208. #ifndef DtNmaxLength
  209. #define DtNmaxLength XmNmaxLength
  210. #endif
  211. #ifndef DtCMaxLength
  212. #define DtCMaxLength XmCMaxLength
  213. #endif
  214. #ifndef DtNmisspelledListLabel
  215. #define DtNmisspelledListLabel "misspelledListLabel"
  216. #endif
  217. #ifndef DtCMisspelledListLabel
  218. #define DtCMisspelledListLabel "MisspelledListLabel"
  219. #endif
  220. #ifndef DtNoverstrike
  221. #define DtNoverstrike "overstrike"
  222. #endif
  223. #ifndef DtCOverstrike
  224. #define DtCOverstrike "Overstrike"
  225. #endif
  226. #ifndef DtNoverstrikeLabel
  227. #define DtNoverstrikeLabel "overstrikeLabel"
  228. #endif
  229. #ifndef DtCOverstrikeLabel
  230. #define DtCOverstrikeLabel "OverstrikeLabel"
  231. #endif
  232. #ifndef DtNrightAlignToggleLabel
  233. #define DtNrightAlignToggleLabel "rightAlignToggleLabel"
  234. #endif
  235. #ifndef DtCRightAlignToggleLabel
  236. #define DtCRightAlignToggleLabel "RightAlignToggleLabel"
  237. #endif
  238. #ifndef DtNrightMarginFieldLabel
  239. #define DtNrightMarginFieldLabel "rightMarginFieldLabel"
  240. #endif
  241. #ifndef DtCRightMarginFieldLabel
  242. #define DtCRightMarginFieldLabel "RightMarginFieldLabel"
  243. #endif
  244. #ifndef DtNrows
  245. #define DtNrows XmNrows
  246. #endif
  247. #ifndef DtCRows
  248. #define DtCRows XmCRows
  249. #endif
  250. #ifndef DtNscrollHorizontal
  251. #define DtNscrollHorizontal XmNscrollHorizontal
  252. #endif
  253. #ifndef DtCScroll
  254. #define DtCScroll XmCScroll
  255. #endif
  256. #ifndef DtNscrollLeftSide
  257. #define DtNscrollLeftSide XmNscrollLeftSide
  258. #endif
  259. #ifndef DtCScrollSide
  260. #define DtCScrollSide XmCScrollSide
  261. #endif
  262. #ifndef DtNscrollTopSide
  263. #define DtNscrollTopSide XmNscrollTopSide
  264. #endif
  265. #ifndef DtNscrollVertical
  266. #define DtNscrollVertical XmNscrollVertical
  267. #endif
  268. #ifndef DtNshowStatusLine
  269. #define DtNshowStatusLine "showStatusLine"
  270. #endif
  271. #ifndef DtCShowStatusLine
  272. #define DtCShowStatusLine "ShowStatusLine"
  273. #endif
  274. #ifndef DtNspellDialogTitle
  275. #define DtNspellDialogTitle "spellDialogTitle"
  276. #endif
  277. #ifndef DtCSpellDialogTitle
  278. #define DtCSpellDialogTitle "SpellDialogTitle"
  279. #endif
  280. #ifndef DtNspellFilter
  281. #define DtNspellFilter "spellFilter"
  282. #endif
  283. #ifndef DtCSpellFilter
  284. #define DtCSpellFilter "SpellFilter"
  285. #endif
  286. #ifndef DtNtextBackground
  287. #define DtNtextBackground "textBackground"
  288. #endif
  289. #ifndef DtCBackground
  290. #define DtCBackground XmCBackground
  291. #endif
  292. #ifndef DtNtextDeselectCallback
  293. #define DtNtextDeselectCallback "textDeselectCallback"
  294. #endif
  295. #ifndef DtNtextFontList
  296. #define DtNtextFontList XmNtextFontList
  297. #endif
  298. #ifndef DtNtextForeground
  299. #define DtNtextForeground "textForeground"
  300. #endif
  301. #ifndef DtCForeground
  302. #define DtCForeground XmCForeground
  303. #endif
  304. #ifndef DtNtextSelectCallback
  305. #define DtNtextSelectCallback "textSelectCallback"
  306. #endif
  307. #ifndef DtNtextTranslations
  308. #define DtNtextTranslations XmNtextTranslations
  309. #endif
  310. #ifndef DtCTranslations
  311. #define DtCTranslations XmCTranslations
  312. #endif
  313. #ifndef DtCCallback
  314. #define DtCCallback XmCCallback
  315. #endif
  316. #ifndef DtNtopCharacter
  317. #define DtNtopCharacter XmNtopCharacter
  318. #endif
  319. #ifndef DtCTopCharacter
  320. #define DtCTopCharacter XmCTopCharacter
  321. #endif
  322. #ifndef DtNtotalLineCountLabel
  323. #define DtNtotalLineCountLabel "totalLineCountLabel"
  324. #endif
  325. #ifndef DtCTotalLineCountLabel
  326. #define DtCTotalLineCountLabel "TotalLineCountLabel"
  327. #endif
  328. #ifndef DtNwordWrap
  329. #define DtNwordWrap XmNwordWrap
  330. #endif
  331. #ifndef DtCWordWrap
  332. #define DtCWordWrap XmCWordWrap
  333. #endif
  334. #ifndef DtEditorHelpCallbackStruct
  335. #define DtEditorHelpCallbackStruct XmAnyCallbackStruct
  336. #endif
  337. #ifndef DtEditorSelectCallbackStruct
  338. #define DtEditorSelectCallbackStruct XmAnyCallbackStruct
  339. #endif
  340. #ifndef DtEditorDeselectCallbackStruct
  341. #define DtEditorDeselectCallbackStruct XmAnyCallbackStruct
  342. #endif
  343. /* Used with DtEditorChange() */
  344. enum {
  345. DtEDITOR_CURRENT_SELECTION,
  346. DtEDITOR_NEXT_OCCURRENCE,
  347. DtEDITOR_ALL_OCCURRENCES
  348. };
  349. /* Used with DtEditorFormat() */
  350. enum {
  351. DtEDITOR_FORMAT_ALL,
  352. DtEDITOR_FORMAT_PARAGRAPH
  353. };
  354. enum {
  355. DtEDITOR_ALIGN_CENTER,
  356. DtEDITOR_ALIGN_JUSTIFY,
  357. DtEDITOR_ALIGN_LEFT,
  358. DtEDITOR_ALIGN_RIGHT
  359. };
  360. /* Used with DtNtextSelectCallback */
  361. enum {
  362. DtEDITOR_TEXT_SELECT,
  363. DtEDITOR_TEXT_DESELECT
  364. };
  365. /*
  366. * Types
  367. */
  368. typedef enum _DtEditorErrorCode{
  369. DtEDITOR_NO_ERRORS,
  370. DtEDITOR_INVALID_TYPE,
  371. DtEDITOR_INVALID_RANGE,
  372. DtEDITOR_NULL_ITEM,
  373. DtEDITOR_ILLEGAL_SIZE,
  374. DtEDITOR_SPELL_FILTER_FAILED,
  375. DtEDITOR_NO_TMP_FILE,
  376. DtEDITOR_INVALID_FILENAME,
  377. DtEDITOR_NONEXISTENT_FILE,
  378. DtEDITOR_UNREADABLE_FILE,
  379. DtEDITOR_READ_ONLY_FILE,
  380. DtEDITOR_NO_FILE_ACCESS,
  381. DtEDITOR_DIRECTORY,
  382. DtEDITOR_CHAR_SPECIAL_FILE,
  383. DtEDITOR_BLOCK_MODE_FILE,
  384. DtEDITOR_UNWRITABLE_FILE,
  385. DtEDITOR_WRITABLE_FILE,
  386. DtEDITOR_SAVE_FAILED,
  387. DtEDITOR_INSUFFICIENT_MEMORY,
  388. DtEDITOR_NULLS_REMOVED
  389. } DtEditorErrorCode;
  390. /* Used with DtEditorChange() to specify Find and Change To strings */
  391. typedef struct _DtEditorChangeValues {
  392. char *find;
  393. char *changeTo;
  394. } DtEditorChangeValues;
  395. /* Used with DtEditorFormat() to specify left margin, right margin *
  396. * and justification styles. */
  397. typedef struct _DtEditorFormatSettings {
  398. int leftMargin;
  399. int rightMargin;
  400. unsigned int alignment;
  401. } DtEditorFormatSettings;
  402. /* Types used to tag data to/from the editor widget */
  403. typedef enum _DtEditorDataFormat{
  404. DtEDITOR_TEXT,
  405. DtEDITOR_WCHAR,
  406. DtEDITOR_DATA
  407. } DtEditorDataFormat;
  408. /* Types used to pass data to/from the editor widget */
  409. typedef struct _DtEditor_DataObj {
  410. unsigned int length;
  411. void *buf;
  412. } DtEditor_DataObj;
  413. typedef struct _DtEditorContentRec {
  414. DtEditorDataFormat type;
  415. union {
  416. char *string;
  417. wchar_t *wchar;
  418. DtEditor_DataObj data;
  419. } value;
  420. } DtEditorContentRec;
  421. /* Widget class and instance */
  422. typedef struct _DtEditorClassRec *DtEditorClass;
  423. typedef struct _DtEditorRec *DtEditorWidget;
  424. /*
  425. * Data
  426. */
  427. /* Widget class */
  428. externalref WidgetClass dtEditorWidgetClass;
  429. /*
  430. * Functions
  431. */
  432. extern Widget DtCreateEditor(
  433. Widget parent,
  434. char *name,
  435. ArgList arglist,
  436. Cardinal argcount);
  437. extern DtEditorErrorCode DtEditorAppend(
  438. Widget widget,
  439. DtEditorContentRec *data);
  440. extern DtEditorErrorCode DtEditorAppendFromFile(
  441. Widget widget,
  442. char *fileName);
  443. extern Boolean DtEditorChange(
  444. Widget widget,
  445. DtEditorChangeValues *findChangeStrings,
  446. unsigned int instanceToChange);
  447. extern Boolean DtEditorCheckForUnsavedChanges(
  448. Widget widget);
  449. extern Boolean DtEditorClearSelection(
  450. Widget widget);
  451. extern Boolean DtEditorCopyToClipboard(
  452. Widget widget);
  453. extern Boolean DtEditorCutToClipboard(
  454. Widget widget);
  455. extern Boolean DtEditorDeleteSelection(
  456. Widget widget);
  457. extern Boolean DtEditorDeselect(
  458. Widget widget);
  459. extern void DtEditorDisableRedisplay(
  460. Widget widget);
  461. extern void DtEditorEnableRedisplay(
  462. Widget widget);
  463. extern Boolean DtEditorFind(
  464. Widget widget,
  465. char * find);
  466. extern DtEditorErrorCode DtEditorFormat(
  467. Widget widget,
  468. DtEditorFormatSettings *formatSettings,
  469. unsigned int amountToFormat);
  470. extern DtEditorErrorCode DtEditorGetContents(
  471. Widget widget,
  472. DtEditorContentRec *data,
  473. Boolean hardCarriageReturns,
  474. Boolean markContentsAsSaved);
  475. extern XmTextPosition DtEditorGetInsertionPosition(
  476. Widget widget);
  477. extern XmTextPosition DtEditorGetLastPosition(
  478. Widget widget);
  479. extern Widget DtEditorGetMessageTextFieldID(
  480. Widget widget);
  481. extern void DtEditorGetSizeHints(
  482. Widget widget,
  483. XSizeHints *pHints);
  484. extern void DtEditorGoToLine(
  485. Widget widget,
  486. int lineNumber);
  487. extern DtEditorErrorCode DtEditorInsert(
  488. Widget widget,
  489. DtEditorContentRec *data);
  490. extern DtEditorErrorCode DtEditorInsertFromFile(
  491. Widget widget,
  492. char *fileName);
  493. extern void DtEditorInvokeFindChangeDialog(
  494. Widget widget);
  495. extern void DtEditorInvokeFormatDialog(
  496. Widget widget);
  497. extern DtEditorErrorCode DtEditorInvokeSpellDialog(
  498. Widget widget);
  499. extern Boolean DtEditorPasteFromClipboard(
  500. Widget widget);
  501. extern DtEditorErrorCode DtEditorReplace(
  502. Widget widget,
  503. XmTextPosition startPos,
  504. XmTextPosition endPos,
  505. DtEditorContentRec *data);
  506. extern DtEditorErrorCode DtEditorReplaceFromFile(
  507. Widget widget,
  508. XmTextPosition startPos,
  509. XmTextPosition endPos,
  510. char *fileName);
  511. extern void DtEditorReset(
  512. Widget widget);
  513. extern DtEditorErrorCode DtEditorSaveContentsToFile(
  514. Widget widget,
  515. char *fileName,
  516. Boolean overwriteIfExists,
  517. Boolean hardCarriageReturns,
  518. Boolean markContentsAsSaved);
  519. extern Boolean DtEditorSelectAll(
  520. Widget widget);
  521. extern DtEditorErrorCode DtEditorSetContents(
  522. Widget widget,
  523. DtEditorContentRec *data);
  524. extern DtEditorErrorCode DtEditorSetContentsFromFile(
  525. Widget widget,
  526. char *fileName);
  527. extern void DtEditorSetInsertionPosition(
  528. Widget widget,
  529. XmTextPosition position);
  530. extern void DtEditorTraverseToEditor(
  531. Widget widget);
  532. extern Boolean DtEditorUndoEdit(
  533. Widget widget);
  534. #ifdef __cplusplus
  535. }
  536. #endif
  537. #endif /* _Dt_Editor_h */