2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
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)
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
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
23 /* $XConsortium: editCB.c /main/3 1995/11/01 10:35:26 rswiston $ */
24 /**********************************<+>*************************************
25 ***************************************************************************
29 ** Project: DT dtpad, a memo maker type editor based on the Dt Editor
35 ** This file contains the callbacks for the [Edit] menu items.
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 ********************************************************************
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 ********************************************************************
52 **************************************************************************
53 **********************************<+>*************************************/
55 #include <Dt/HourGlass.h>
58 /************************************************************************
59 * EditUndoCB - [Edit] menu, [Undo] button.
60 * Undoes the last edit.
61 ************************************************************************/
69 Editor *pPad = (Editor *)client_data;
70 DtEditorUndoEdit(pPad->editor);
74 /************************************************************************
75 * EditCutCB - [Edit] menu, [Cut] button.
76 * Cuts the current selection to the Motif clipboard.
77 ************************************************************************/
85 Editor *pPad = (Editor *)client_data;
86 DtEditorCutToClipboard(pPad->editor);
90 /************************************************************************
91 * EditCopyCB - [Edit] menu, [Copy] button.
92 * Copies the current selection to the Motif clipboard.
93 ************************************************************************/
101 Editor *pPad = (Editor *)client_data;
102 DtEditorCopyToClipboard(pPad->editor);
106 /************************************************************************
107 * EditPasteCB - [Edit] menu, [Paste] button.
108 * Pastes from the Motif clipboard.
109 ************************************************************************/
117 Editor *pPad = (Editor *)client_data;
118 DtEditorPasteFromClipboard(pPad->editor);
120 /* XXX - Do DtEditorGetInsertPosition & DtEditorSetInsertionPosition
121 * need to be executed here??
122 * XmTextPosition cursorPos;
123 * cursorPos = XmTextGetInsertionPosition(pPad->text);
124 * XmTextShowPosition(pPad->text, cursorPos);
129 /************************************************************************
130 * EditClearCB - [Edit] menu, [Replace] button
131 * Replaces the current selection with blanks.
132 ************************************************************************/
140 Editor *pPad = (Editor *)client_data;
141 DtEditorClearSelection(pPad->editor);
145 /************************************************************************
146 * EditDeleteCB - [Edit] menu, [Delete] button.
147 * Deletes the current selection.
148 ************************************************************************/
156 Editor *pPad = (Editor *)client_data;
157 DtEditorDeleteSelection(pPad->editor);
161 /************************************************************************
162 * SelectAllCB - [Edit] menu, [Select All] button.
164 ************************************************************************/
172 Editor *pPad = (Editor *)client_data;
173 DtEditorSelectAll(pPad->editor);
177 /************************************************************************
178 * FindChangeCB - [Edit] menu, [Find/Change...] button.
179 * Invokes the Dt Editor widget search dialog.
180 ************************************************************************/
188 Editor *pPad = (Editor *)client_data;
189 DtEditorInvokeFindChangeDialog(pPad->editor);
193 /************************************************************************
194 * CheckSpellingCB - [Edit] menu, [Check Spelling...] button.
195 * Invokes the Dt Editor widget spell dialog.
196 ************************************************************************/
204 Editor *pPad = (Editor *)client_data;
205 DtEditorInvokeSpellDialog(pPad->editor);
209 /************************************************************************
210 * SetSelectionMenuItems - Sets the sensitivity of [Edit] menu items
211 * that deal with the current selection in the edit window - allowing
213 ************************************************************************/
216 SetSelectionMenuItems(
220 XtSetSensitive(pPad->editStuff.widgets.cutBtn,
221 sensitivity && ! pPad->xrdb.viewOnly);
222 XtSetSensitive(pPad->editStuff.widgets.copyBtn,
223 sensitivity); /* Copy can be done in viewOnly mode */
224 XtSetSensitive(pPad->editStuff.widgets.clearBtn,
225 sensitivity && ! pPad->xrdb.viewOnly);
226 XtSetSensitive(pPad->editStuff.widgets.deleteBtn,
227 sensitivity && ! pPad->xrdb.viewOnly);
231 /************************************************************************
232 * TextSelectedCB - DtEditor widget DtNtextSelectCallback called when
233 * text in the editor window is selected.
234 * Makes [Edit] menu items related to a selection sensitive.
235 ************************************************************************/
243 Editor *pPad = (Editor *)client_data;
244 SetSelectionMenuItems(pPad, True);
248 /************************************************************************
249 * TextDeselectedCB - DtEditor widget DtNtextSelectCallback called when
250 * text in the editor window is deselected.
251 * Makes [Edit] menu items related to a selection insensitive.
252 ************************************************************************/
260 Editor *pPad = (Editor *)client_data;
261 SetSelectionMenuItems(pPad, False);