editCB.c 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  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 libraries 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: editCB.c /main/3 1995/11/01 10:35:26 rswiston $ */
  24. /**********************************<+>*************************************
  25. ***************************************************************************
  26. **
  27. ** File: editCB.c
  28. **
  29. ** Project: DT dtpad, a memo maker type editor based on the Dt Editor
  30. ** widget.
  31. **
  32. ** Description:
  33. ** -----------
  34. **
  35. ** This file contains the callbacks for the [Edit] menu items.
  36. **
  37. *******************************************************************
  38. ** (c) Copyright Hewlett-Packard Company, 1991, 1992. All rights are
  39. ** reserved. Copying or other reproduction of this program
  40. ** except for archival purposes is prohibited without prior
  41. ** written consent of Hewlett-Packard Company.
  42. ********************************************************************
  43. **
  44. ********************************************************************
  45. ** (c) Copyright 1993, 1994 Hewlett-Packard Company
  46. ** (c) Copyright 1993, 1994 International Business Machines Corp.
  47. ** (c) Copyright 1993, 1994 Sun Microsystems, Inc.
  48. ** (c) Copyright 1993, 1994 Novell, Inc.
  49. ********************************************************************
  50. **
  51. **
  52. **************************************************************************
  53. **********************************<+>*************************************/
  54. #include "dtpad.h"
  55. #include <Dt/HourGlass.h>
  56. /************************************************************************
  57. * EditUndoCB - [Edit] menu, [Undo] button.
  58. * Undoes the last edit.
  59. ************************************************************************/
  60. /* ARGSUSED */
  61. void
  62. EditUndoCB(
  63. Widget w,
  64. caddr_t client_data,
  65. caddr_t call_data )
  66. {
  67. Editor *pPad = (Editor *)client_data;
  68. DtEditorUndoEdit(pPad->editor);
  69. }
  70. /************************************************************************
  71. * EditCutCB - [Edit] menu, [Cut] button.
  72. * Cuts the current selection to the Motif clipboard.
  73. ************************************************************************/
  74. /* ARGSUSED */
  75. void
  76. EditCutCB(
  77. Widget w,
  78. caddr_t client_data,
  79. caddr_t call_data )
  80. {
  81. Editor *pPad = (Editor *)client_data;
  82. DtEditorCutToClipboard(pPad->editor);
  83. }
  84. /************************************************************************
  85. * EditCopyCB - [Edit] menu, [Copy] button.
  86. * Copies the current selection to the Motif clipboard.
  87. ************************************************************************/
  88. /* ARGSUSED */
  89. void
  90. EditCopyCB(
  91. Widget w,
  92. caddr_t client_data,
  93. caddr_t call_data )
  94. {
  95. Editor *pPad = (Editor *)client_data;
  96. DtEditorCopyToClipboard(pPad->editor);
  97. }
  98. /************************************************************************
  99. * EditPasteCB - [Edit] menu, [Paste] button.
  100. * Pastes from the Motif clipboard.
  101. ************************************************************************/
  102. /* ARGSUSED */
  103. void
  104. EditPasteCB(
  105. Widget w,
  106. caddr_t client_data,
  107. caddr_t call_data )
  108. {
  109. Editor *pPad = (Editor *)client_data;
  110. DtEditorPasteFromClipboard(pPad->editor);
  111. /* XXX - Do DtEditorGetInsertPosition & DtEditorSetInsertionPosition
  112. * need to be executed here??
  113. * XmTextPosition cursorPos;
  114. * cursorPos = XmTextGetInsertionPosition(pPad->text);
  115. * XmTextShowPosition(pPad->text, cursorPos);
  116. */
  117. }
  118. /************************************************************************
  119. * EditClearCB - [Edit] menu, [Replace] button
  120. * Replaces the current selection with blanks.
  121. ************************************************************************/
  122. /* ARGSUSED */
  123. void
  124. EditClearCB(
  125. Widget w,
  126. caddr_t client_data,
  127. caddr_t call_data )
  128. {
  129. Editor *pPad = (Editor *)client_data;
  130. DtEditorClearSelection(pPad->editor);
  131. }
  132. /************************************************************************
  133. * EditDeleteCB - [Edit] menu, [Delete] button.
  134. * Deletes the current selection.
  135. ************************************************************************/
  136. /* ARGSUSED */
  137. void
  138. EditDeleteCB(
  139. Widget w,
  140. caddr_t client_data,
  141. caddr_t call_data )
  142. {
  143. Editor *pPad = (Editor *)client_data;
  144. DtEditorDeleteSelection(pPad->editor);
  145. }
  146. /************************************************************************
  147. * SelectAllCB - [Edit] menu, [Select All] button.
  148. * Selects all text.
  149. ************************************************************************/
  150. /* ARGSUSED */
  151. void
  152. SelectAllCB(
  153. Widget w,
  154. caddr_t client_data,
  155. caddr_t call_data )
  156. {
  157. Editor *pPad = (Editor *)client_data;
  158. DtEditorSelectAll(pPad->editor);
  159. }
  160. /************************************************************************
  161. * FindChangeCB - [Edit] menu, [Find/Change...] button.
  162. * Invokes the Dt Editor widget search dialog.
  163. ************************************************************************/
  164. /* ARGSUSED */
  165. void
  166. FindChangeCB(
  167. Widget w,
  168. caddr_t client_data,
  169. caddr_t call_data )
  170. {
  171. Editor *pPad = (Editor *)client_data;
  172. DtEditorInvokeFindChangeDialog(pPad->editor);
  173. }
  174. /************************************************************************
  175. * CheckSpellingCB - [Edit] menu, [Check Spelling...] button.
  176. * Invokes the Dt Editor widget spell dialog.
  177. ************************************************************************/
  178. /* ARGSUSED */
  179. void
  180. CheckSpellingCB(
  181. Widget w,
  182. caddr_t client_data,
  183. caddr_t call_data )
  184. {
  185. Editor *pPad = (Editor *)client_data;
  186. DtEditorInvokeSpellDialog(pPad->editor);
  187. }
  188. /************************************************************************
  189. * SetSelectionMenuItems - Sets the sensitivity of [Edit] menu items
  190. * that deal with the current selection in the edit window - allowing
  191. * for viewOnly mode.
  192. ************************************************************************/
  193. /* ARGSUSED */
  194. void
  195. SetSelectionMenuItems(
  196. Editor *pPad,
  197. Boolean sensitivity)
  198. {
  199. XtSetSensitive(pPad->editStuff.widgets.cutBtn,
  200. sensitivity && ! pPad->xrdb.viewOnly);
  201. XtSetSensitive(pPad->editStuff.widgets.copyBtn,
  202. sensitivity); /* Copy can be done in viewOnly mode */
  203. XtSetSensitive(pPad->editStuff.widgets.clearBtn,
  204. sensitivity && ! pPad->xrdb.viewOnly);
  205. XtSetSensitive(pPad->editStuff.widgets.deleteBtn,
  206. sensitivity && ! pPad->xrdb.viewOnly);
  207. }
  208. /************************************************************************
  209. * TextSelectedCB - DtEditor widget DtNtextSelectCallback called when
  210. * text in the editor window is selected.
  211. * Makes [Edit] menu items related to a selection sensitive.
  212. ************************************************************************/
  213. /* ARGSUSED */
  214. void
  215. TextSelectedCB(
  216. Widget w,
  217. caddr_t client_data,
  218. caddr_t call_data)
  219. {
  220. Editor *pPad = (Editor *)client_data;
  221. SetSelectionMenuItems(pPad, True);
  222. }
  223. /************************************************************************
  224. * TextDeselectedCB - DtEditor widget DtNtextSelectCallback called when
  225. * text in the editor window is deselected.
  226. * Makes [Edit] menu items related to a selection insensitive.
  227. ************************************************************************/
  228. /* ARGSUSED */
  229. void
  230. TextDeselectedCB(
  231. Widget w,
  232. caddr_t client_data,
  233. caddr_t call_data)
  234. {
  235. Editor *pPad = (Editor *)client_data;
  236. SetSelectionMenuItems(pPad, False);
  237. }