1 /* $XConsortium: editCB.c /main/3 1995/11/01 10:35:26 rswiston $ */
2 /**********************************<+>*************************************
3 ***************************************************************************
7 ** Project: DT dtpad, a memo maker type editor based on the Dt Editor
13 ** This file contains the callbacks for the [Edit] menu items.
15 *******************************************************************
16 ** (c) Copyright Hewlett-Packard Company, 1991, 1992. All rights are
17 ** reserved. Copying or other reproduction of this program
18 ** except for archival purposes is prohibited without prior
19 ** written consent of Hewlett-Packard Company.
20 ********************************************************************
22 ********************************************************************
23 ** (c) Copyright 1993, 1994 Hewlett-Packard Company
24 ** (c) Copyright 1993, 1994 International Business Machines Corp.
25 ** (c) Copyright 1993, 1994 Sun Microsystems, Inc.
26 ** (c) Copyright 1993, 1994 Novell, Inc.
27 ********************************************************************
30 **************************************************************************
31 **********************************<+>*************************************/
33 #include <Dt/HourGlass.h>
36 /************************************************************************
37 * EditUndoCB - [Edit] menu, [Undo] button.
38 * Undoes the last edit.
39 ************************************************************************/
47 Editor *pPad = (Editor *)client_data;
48 DtEditorUndoEdit(pPad->editor);
52 /************************************************************************
53 * EditCutCB - [Edit] menu, [Cut] button.
54 * Cuts the current selection to the Motif clipboard.
55 ************************************************************************/
63 Editor *pPad = (Editor *)client_data;
64 DtEditorCutToClipboard(pPad->editor);
68 /************************************************************************
69 * EditCopyCB - [Edit] menu, [Copy] button.
70 * Copies the current selection to the Motif clipboard.
71 ************************************************************************/
79 Editor *pPad = (Editor *)client_data;
80 DtEditorCopyToClipboard(pPad->editor);
84 /************************************************************************
85 * EditPasteCB - [Edit] menu, [Paste] button.
86 * Pastes from the Motif clipboard.
87 ************************************************************************/
95 Editor *pPad = (Editor *)client_data;
96 DtEditorPasteFromClipboard(pPad->editor);
98 /* XXX - Do DtEditorGetInsertPosition & DtEditorSetInsertionPosition
99 * need to be executed here??
100 * XmTextPosition cursorPos;
101 * cursorPos = XmTextGetInsertionPosition(pPad->text);
102 * XmTextShowPosition(pPad->text, cursorPos);
107 /************************************************************************
108 * EditClearCB - [Edit] menu, [Replace] button
109 * Replaces the current selection with blanks.
110 ************************************************************************/
118 Editor *pPad = (Editor *)client_data;
119 DtEditorClearSelection(pPad->editor);
123 /************************************************************************
124 * EditDeleteCB - [Edit] menu, [Delete] button.
125 * Deletes the current selection.
126 ************************************************************************/
134 Editor *pPad = (Editor *)client_data;
135 DtEditorDeleteSelection(pPad->editor);
139 /************************************************************************
140 * SelectAllCB - [Edit] menu, [Select All] button.
142 ************************************************************************/
150 Editor *pPad = (Editor *)client_data;
151 DtEditorSelectAll(pPad->editor);
155 /************************************************************************
156 * FindChangeCB - [Edit] menu, [Find/Change...] button.
157 * Invokes the Dt Editor widget search dialog.
158 ************************************************************************/
166 Editor *pPad = (Editor *)client_data;
167 DtEditorInvokeFindChangeDialog(pPad->editor);
171 /************************************************************************
172 * CheckSpellingCB - [Edit] menu, [Check Spelling...] button.
173 * Invokes the Dt Editor widget spell dialog.
174 ************************************************************************/
182 Editor *pPad = (Editor *)client_data;
183 DtEditorInvokeSpellDialog(pPad->editor);
187 /************************************************************************
188 * SetSelectionMenuItems - Sets the sensitivity of [Edit] menu items
189 * that deal with the current selection in the edit window - allowing
191 ************************************************************************/
194 SetSelectionMenuItems(
198 XtSetSensitive(pPad->editStuff.widgets.cutBtn,
199 sensitivity && ! pPad->xrdb.viewOnly);
200 XtSetSensitive(pPad->editStuff.widgets.copyBtn,
201 sensitivity); /* Copy can be done in viewOnly mode */
202 XtSetSensitive(pPad->editStuff.widgets.clearBtn,
203 sensitivity && ! pPad->xrdb.viewOnly);
204 XtSetSensitive(pPad->editStuff.widgets.deleteBtn,
205 sensitivity && ! pPad->xrdb.viewOnly);
209 /************************************************************************
210 * TextSelectedCB - DtEditor widget DtNtextSelectCallback called when
211 * text in the editor window is selected.
212 * Makes [Edit] menu items related to a selection sensitive.
213 ************************************************************************/
221 Editor *pPad = (Editor *)client_data;
222 SetSelectionMenuItems(pPad, True);
226 /************************************************************************
227 * TextDeselectedCB - DtEditor widget DtNtextSelectCallback called when
228 * text in the editor window is deselected.
229 * Makes [Edit] menu items related to a selection insensitive.
230 ************************************************************************/
238 Editor *pPad = (Editor *)client_data;
239 SetSelectionMenuItems(pPad, False);