Initial import of the CDE 2.1.30 sources from the Open Group.
This commit is contained in:
119
cde/programs/dtpad/Dtpad
Normal file
119
cde/programs/dtpad/Dtpad
Normal file
@@ -0,0 +1,119 @@
|
||||
! $TOG: Dtpad /main/15 1997/07/08 11:34:52 mgreess $
|
||||
#include "Dt"
|
||||
|
||||
!######################################################################
|
||||
!#
|
||||
!# Dtpad
|
||||
!#
|
||||
!# Common Desktop Environment (CDE)
|
||||
!#
|
||||
!# Application Defaults for the Text Editor
|
||||
!#
|
||||
!# (c) Copyright 1993, 1994, 1995 Hewlett-Packard Company
|
||||
!# (c) Copyright 1993, 1994, 1995 International Business Machines Corp.
|
||||
!# (c) Copyright 1993, 1994, 1995 Sun Microsystems, Inc.
|
||||
!# (c) Copyright 1993, 1994, 1995 Novell, Inc.
|
||||
!#
|
||||
!######################################################################
|
||||
|
||||
|
||||
!######################################################################
|
||||
!#
|
||||
!# Formatting for the printing output.
|
||||
!#
|
||||
!######################################################################
|
||||
!#
|
||||
!# Formatting when printing to printer.
|
||||
!#
|
||||
|
||||
!# Sizes the PrintShell.
|
||||
Dtpad*Print.width: 8.5in
|
||||
Dtpad*Print.height: 11.0in
|
||||
Dtpad*Print.Page*foreground: black
|
||||
Dtpad*Print.Page*background: white
|
||||
|
||||
!# Places a border around the text portion of the output.
|
||||
Dtpad*Print.Page*shadowThickness: 2
|
||||
Dtpad*Print.Page*topShadowColor: black
|
||||
Dtpad*Print.Page*bottomShadowColor: black
|
||||
|
||||
!# Controls margins and background of the header and footer labels.
|
||||
Dtpad*Print.Page*XmLabel*marginTop: 0
|
||||
Dtpad*Print.Page*XmLabel*marginBottom: 0
|
||||
!Dtpad*Print.Page*XmLabel*background: grey
|
||||
|
||||
!# Fonts for headers, footers, and text.
|
||||
Dtpad*Print.Page*XmLabel.renderTable: %|nls-36-#HeaderLeft#|
|
||||
Dtpad*Print.Page*Editor.renderTable: %|nls-37-#Editor#|
|
||||
|
||||
|
||||
!#
|
||||
!# Formatting when "printing" to video.
|
||||
!# Debugging only
|
||||
!#
|
||||
Dtpad*PrintVideo.width: 8.5in
|
||||
Dtpad*PrintVideo.height: 9.5in
|
||||
Dtpad*PrintVideo.Page.width: 8.5in
|
||||
Dtpad*PrintVideo.Page.height: 9.5in
|
||||
Dtpad*PrintVideo.Page*foreground: black
|
||||
Dtpad*PrintVideo.Page*background: white
|
||||
|
||||
Dtpad*PrintVideo.Page*shadowThickness: 2
|
||||
Dtpad*PrintVideo.Page*topShadowColor: black
|
||||
Dtpad*PrintVideo.Page*bottomShadowColor: black
|
||||
|
||||
Dtpad*PrintVideo.Page*XmLabel*marginTop: 0
|
||||
Dtpad*PrintVideo.Page*XmLabel*marginBottom: 0
|
||||
!Dtpad*PrintVideo.Page*XmLabel*background: grey
|
||||
|
||||
|
||||
!######################################################################
|
||||
!#
|
||||
!# Formatting for the Print Setup dialog.
|
||||
!#
|
||||
!######################################################################
|
||||
Dtpad*DtPrintSetup*DocumentName.leftOffset: 10
|
||||
Dtpad*DtPrintSetup*WrapToFit.leftOffset: 35
|
||||
Dtpad*DtPrintSetup*MarginFrame.leftOffset: 35
|
||||
Dtpad*DtPrintSetup*HdrFtrFrame.leftOffset: 35
|
||||
|
||||
!######################################################################
|
||||
!#
|
||||
!# Miscellaneous
|
||||
!#
|
||||
!######################################################################
|
||||
!# Text Editor secondary color.
|
||||
!#Dtpad*SecondaryColorSetId: 8
|
||||
|
||||
!# Text Editor default geometry. Multi byte locales should set it to
|
||||
!# smaller size.
|
||||
Dtpad.geometry: %|nls-17-#80x24#|
|
||||
|
||||
!######################################################################
|
||||
!#
|
||||
!# CDE compliant menu accelerators and accelerator text.
|
||||
!#
|
||||
!######################################################################
|
||||
|
||||
Dtpad*fileMenu.print.acceleratorText: %|nls-18-#Ctrl+P#|
|
||||
Dtpad*fileMenu.print.accelerator: %|nls-19-#Ctrl<Key>p#|
|
||||
Dtpad*fileMenu.close.acceleratorText: %|nls-20-#Alt+F4#|
|
||||
Dtpad*fileMenu.close.accelerator: %|nls-21-#Alt<Key>F4#|
|
||||
|
||||
Dtpad*editMenu.undo.acceleratorText: %|nls-22-#Ctrl+Z#|
|
||||
Dtpad*editMenu.undo.accelerator: %|nls-23-#Ctrl<Key>z#|
|
||||
Dtpad*editMenu.cut.acceleratorText: %|nls-24-#Ctrl+X#|
|
||||
Dtpad*editMenu.cut.accelerator: %|nls-25-#Ctrl<Key>x#|
|
||||
Dtpad*editMenu.copy.acceleratorText: %|nls-26-#Ctrl+C#|
|
||||
Dtpad*editMenu.copy.accelerator: %|nls-27-#Ctrl<Key>c#|
|
||||
Dtpad*editMenu.paste.acceleratorText: %|nls-28-#Ctrl+V#|
|
||||
Dtpad*editMenu.paste.accelerator: %|nls-29-#Ctrl<Key>v#|
|
||||
Dtpad*editMenu.selectAll.acceleratorText: %|nls-30-#Ctrl+/#|
|
||||
Dtpad*editMenu.selectAll.accelerator: %|nls-31-#Ctrl<Key>/#|
|
||||
Dtpad*editMenu.findChange.acceleratorText: %|nls-32-#Ctrl+F#|
|
||||
Dtpad*editMenu.findChange.accelerator: %|nls-33-#Ctrl<Key>f#|
|
||||
|
||||
Dtpad*optionsMenu.overstrike.acceleratorText: %|nls-34-#Insert#|
|
||||
Dtpad*optionsMenu.overstrike.accelerator: %|nls-35-#<Key>osfInsert#|
|
||||
|
||||
!########################### eof ###########################
|
||||
32
cde/programs/dtpad/Imakefile
Normal file
32
cde/programs/dtpad/Imakefile
Normal file
@@ -0,0 +1,32 @@
|
||||
XCOMM $XConsortium: Imakefile /main/11 1996/09/14 15:16:29 drk $
|
||||
|
||||
DEFINES = -DDT_LITE -DWORDWRAP -UNLS16
|
||||
|
||||
DEPLIBS = DepDtClientLibs
|
||||
LOCAL_LIBRARIES = DtClientLibs
|
||||
SYS_LIBRARIES = DtClientSysLibs DtClientExtraLibs
|
||||
|
||||
#if defined (SunArchitecture)
|
||||
EXTRA_CCOPTIONS = -xF
|
||||
# LOCAL_LDFLAGS = -M mapfile.reorder
|
||||
#endif
|
||||
|
||||
SRCS = \
|
||||
dtpad.c editCB.c fileCB.c \
|
||||
fileDlg.c fileIo.c formatCB.c \
|
||||
helpCB.c helpDlg.c main.c \
|
||||
optionsCB.c printJob.c printOutput.c \
|
||||
printSetup.c session.c ttMsgSupport.c \
|
||||
ttSaveSupport.c version.c
|
||||
|
||||
OBJS = \
|
||||
dtpad.o editCB.o fileCB.o \
|
||||
fileDlg.o fileIo.o formatCB.o \
|
||||
helpCB.o helpDlg.o main.o \
|
||||
optionsCB.o printJob.o printOutput.o \
|
||||
printSetup.o session.o ttMsgSupport.o \
|
||||
ttSaveSupport.o version.o
|
||||
|
||||
ComplexProgramTarget(dtpad)
|
||||
|
||||
AllTarget(Dtpad)
|
||||
1240
cde/programs/dtpad/dtpad.c
Normal file
1240
cde/programs/dtpad/dtpad.c
Normal file
File diff suppressed because it is too large
Load Diff
1086
cde/programs/dtpad/dtpad.h
Normal file
1086
cde/programs/dtpad/dtpad.h
Normal file
File diff suppressed because it is too large
Load Diff
768
cde/programs/dtpad/dtpad.msg
Normal file
768
cde/programs/dtpad/dtpad.msg
Normal file
@@ -0,0 +1,768 @@
|
||||
$ $TOG: dtpad.msg /main/16 1999/09/15 14:23:53 mgreess $
|
||||
$ *************************************<+>*************************************
|
||||
$ *****************************************************************************
|
||||
$ **
|
||||
$ ** File: dtpad.msg
|
||||
$ **
|
||||
$ ** Project: DT Text Editor client (sometimes called dtpad)
|
||||
$ **
|
||||
$ ** Description:
|
||||
$ ** -----------
|
||||
$ ** This file is the source for the message catalog for dtpad
|
||||
$ **
|
||||
$ **
|
||||
$ *****************************************************************************
|
||||
$ **
|
||||
$ ** (c) Copyright 1992, 1993 Hewlett-Packard Company
|
||||
$ ** All Rights reserved
|
||||
$ **
|
||||
$ **
|
||||
$ *****************************************************************************
|
||||
$ **
|
||||
$ *****************************************************************************
|
||||
$ ** (c) Copyright 1993, 1994 Hewlett-Packard Company
|
||||
$ ** (c) Copyright 1993, 1994 International Business Machines Corp.
|
||||
$ ** (c) Copyright 1993, 1994 Sun Microsystems, Inc.
|
||||
$ ** (c) Copyright 1993, 1994 Novell, Inc.
|
||||
$ *****************************************************************************
|
||||
$ **
|
||||
$quote "
|
||||
$set 2
|
||||
$ **********************************************
|
||||
$ ** General messages used in multiple files **
|
||||
$ **********************************************
|
||||
|
||||
$ Label used for all "Help" buttons in all DIALOGS.
|
||||
$ It is not used for the Help menu.
|
||||
$quote
|
||||
1 Help
|
||||
$ Unrecognized arguments
|
||||
2 dtpad: illegal option: %s
|
||||
$ Extra arguments
|
||||
3 dtpad: extra argument: %s
|
||||
|
||||
|
||||
$set 4
|
||||
$ *****************************************************************
|
||||
$ ** fileCB.c **
|
||||
$ ** These are the strings which change between the Open dialog **
|
||||
$ ** and the Include dialog. These two operations use the same **
|
||||
$ ** Motif dialog, and simply change these two labels. **
|
||||
$ *****************************************************************
|
||||
|
||||
$ Title of the Open dialog
|
||||
1 Open a File
|
||||
|
||||
$ label for the File text field in the file selection box
|
||||
$ ***UNUSED*** This label is no longer used and need not be localized.
|
||||
2 File to Open:
|
||||
|
||||
$ Title of the Include dialog
|
||||
3 Include a File
|
||||
|
||||
$ Label for the File text field in the file selection box
|
||||
$ ***UNUSED*** This label is no longer used and need not be localized.
|
||||
4 File to Include:
|
||||
|
||||
$ Error when printing a file and a temporary copy can not be saved.
|
||||
5 Unable to create a temporary file.
|
||||
|
||||
|
||||
$set 5
|
||||
$ ***************************************************************************
|
||||
$ ** dtpad.c **
|
||||
$ ** fileDlg.c **
|
||||
$ ** **
|
||||
$ ** Messages and strings used in dialogs for all operations involving the **
|
||||
$ ** "File" menu items. **
|
||||
$ ***************************************************************************
|
||||
$ These compose the dialog which appears if the user attempts to exit, open
|
||||
$ a different file, drop a file, or start a "New" session with unsaved
|
||||
$ changes to the current file.
|
||||
|
||||
$ This is used to build: "Save changes to FILENAME?"
|
||||
1 Save changes to %s?
|
||||
|
||||
$ This is used as-is, whenever the current file is unnamed.
|
||||
2 The current file has no name.\nDo you want to save it?
|
||||
|
||||
$ This is used to build a message like "Do you want to save the current
|
||||
$ copy of FILENAME before you Edit NEWFILENAME?" when a new file is droped
|
||||
$ on the edit window.
|
||||
$ ***UNUSED*** Currently, dropped files are INSERTED in the text rather than
|
||||
$ opened for editing so this message is no longer used and need
|
||||
$ not be localized.
|
||||
3 Do you want to save the current\ncopy of %s\nbefore you Edit %s?
|
||||
|
||||
$ Used when about to write over an existing file.
|
||||
$ The "%s" is replaced by the file name.
|
||||
5 The file %s already exists.\nDo you want to over write that file\nwith the contents within this edit session?
|
||||
|
||||
$ Title of "file already exists" dialog. Also used for other "Warning" type
|
||||
$ dialogs.
|
||||
6 Warning
|
||||
|
||||
$ Title of "Save As" dialog.
|
||||
7 Save As
|
||||
|
||||
$ Labels for add/don't-add newlines radio buttons in the Save As dialog
|
||||
$ ***UNUSED*** These labels are no longer used and need not be localized.
|
||||
$ They've been replaced by messages 44 and 45
|
||||
8 Add newline characters to the end of word-wrapped lines.
|
||||
9 Do not add newlines. Only line breaks created by [Return]\nwill be preserved.
|
||||
|
||||
$ Labels for the Save Warning dialog. Also used in the confirmation, or
|
||||
$ Editor Return dialog.
|
||||
14 No
|
||||
15 Yes
|
||||
$ Title of the dialog - used when user selects "New", "Open", or "Exit" with
|
||||
$ unsaved changes in the text.
|
||||
16 Save?
|
||||
|
||||
$ Title of general error dialog
|
||||
17 Error
|
||||
|
||||
$ Title of the resource-specified "confirmation" dialog
|
||||
$ This dialog is generally specified by programs such as mailers, which
|
||||
$ want to know if the user wants to send the message.
|
||||
$ There is no default message for the dialog, since it is _only_ posted if
|
||||
$ the message string is specified via a resource (dtpad*confirmationString:)
|
||||
$ This message is only used if the "dtpad*mainTitle:" resource is not set.
|
||||
$ If this resource _is_ set, the the mainTitle is also used as the title
|
||||
$ for the exit confirmation dialog.
|
||||
$ DO NOT LOCALIZE - the user should never see this message
|
||||
18 Exit Confirmation
|
||||
|
||||
$ Title for general information dialog. e.g. Find dialog can't find word in
|
||||
$ file.
|
||||
20 Information
|
||||
|
||||
$ Default file name in Save As dialog box.
|
||||
21 UNTITLED
|
||||
|
||||
$ Error message when a file can not be saved. The "%1$s" gets replaced by
|
||||
$ the file name and the "%2$s" gets replaced by the reason why the file could
|
||||
$ not be saved (messages 31-39).
|
||||
30 Unable to save %1$s.\n%2$s
|
||||
|
||||
$ Messages 31-39 are reasons why a file could not be saved.
|
||||
$ Messages 34-39 are substitued in message 30 for "%2$s".
|
||||
31 Unable to save file.\nFile name was not specified.
|
||||
|
||||
34 File does not allow writing by anyone.
|
||||
|
||||
35 File is a directory.
|
||||
|
||||
36 File is a character special device.
|
||||
|
||||
37 File is a block mode device.
|
||||
|
||||
$ ***UNUSED*** This message should never appear since currently there is
|
||||
$ only one supported file format - text. And this type is
|
||||
$ hard coded into dtpad.
|
||||
38 Invalid file format.
|
||||
|
||||
$ This is a "catch all" when the file can not be saved and none of the above
|
||||
$ errors apply.
|
||||
39 Unknown reason - possibly not enough disk space.
|
||||
|
||||
$ This is displayed when a ToolTalk edit request on a buffer is received,
|
||||
$ a Save operation is done and there are unsaved changes.
|
||||
40 Save changes?
|
||||
|
||||
$ This is displayed when a ToolTalk edit request on a file or buffer is
|
||||
$ received with a document name specified in the request, a Save operation
|
||||
$ is done and there are unsaved changes. The "%s" in the message is
|
||||
$ replaced by the document name (instead of the filename).
|
||||
41 Save changes to \"%s\"?
|
||||
|
||||
$ Title of "Copy As" dialog which is substitued for the "Save As" dialog
|
||||
$ when file name changes are disallowd. This should match the menu button
|
||||
$ label specified in message 108 of set 11.
|
||||
$ ***UNUSED*** This title is no longer used and need not be localized.
|
||||
42 Copy As
|
||||
|
||||
$ Title of "Copy To File" dialog which is substitued for the "Save As" dialog
|
||||
$ when file name changes are disallowd. This should match the menu button
|
||||
$ label specified in message 110 of set 11.
|
||||
43 Copy To File
|
||||
|
||||
$ Labels for add/don't-add newlines radio buttons in the SaveAs and Save dialogs
|
||||
44 Add newline characters to the end of wrap-to-fit lines.
|
||||
45 Do not add newlines. Only line breaks created by [Return]\nwill be preserved.
|
||||
$
|
||||
$ New message as of 5/31/95 (i.e. new since Sample Implementation). This
|
||||
$ new message is in response to bug DTS CISlx19530.
|
||||
$
|
||||
46 Either file is unwritable or path to\nfile does not exist.
|
||||
|
||||
$
|
||||
$ "-NEW"
|
||||
$
|
||||
47 "Operation failed due to insufficient memory.\nTry increasing swap space."
|
||||
|
||||
$
|
||||
$ "-NEW"
|
||||
$
|
||||
48 "Format operation failed."
|
||||
|
||||
$set 6
|
||||
$ ************************************************************************
|
||||
$ ** fileIo.c **
|
||||
$ ** **
|
||||
$ ** Error messages generated when there are problems reading a file. **
|
||||
$ ************************************************************************
|
||||
|
||||
1 This file has been opened for reading only.
|
||||
2 This file does not exist.
|
||||
3 Unable to edit a Directory.
|
||||
4 Unable to edit a character special device file.
|
||||
5 Unable to edit a block mode device file.
|
||||
6 Embedded Nulls stripped from file.
|
||||
7 Unable to load file (insufficient memory).
|
||||
8 Unable to access file (can't determine it's status).
|
||||
9 Unable to read from file (probably no read permission).
|
||||
|
||||
$ Message placed in the status line message area based on the -viewOnly
|
||||
$ resource and whether or not the file being edited is read only
|
||||
10 View Only
|
||||
11 Read Only
|
||||
12 Unable to read from the file (unknown reason).
|
||||
|
||||
|
||||
$set 7
|
||||
$ ************************************
|
||||
$ ** main.c **
|
||||
$ ** dtpad.c **
|
||||
$ ** Prefix string for all dialogs. **
|
||||
$ ************************************
|
||||
$ bogus?? blank string gotten but otherwise unused in main()
|
||||
$ DO NOT LOCALIZE string 1
|
||||
1
|
||||
|
||||
$ The name used in the title bar of every window.
|
||||
$ Be sure to end this message with a space character.
|
||||
2 Text Editor -
|
||||
|
||||
$ Default file name used in the main window title.
|
||||
$ ***UNUSED*** This mesage has been replaced by message 6 of this set and
|
||||
$ need not be localized.
|
||||
3 (unnamed)
|
||||
|
||||
$ Terminal error message displayed to stdout when the desk top services
|
||||
$ can not be initialized (via DtInitialize())
|
||||
4 Unable to initialize Desktop services ... exiting Text Editor.
|
||||
|
||||
$ Terminal error message displayed to stdout when a connection to the
|
||||
$ display can not be opend (via XtDisplay())
|
||||
5 Can not open display ... exiting Text Editor.
|
||||
|
||||
$ Default file name used in the main window title.
|
||||
$ This should correspond to the default file name used in the "Save As"
|
||||
$ dialog box - specified in message 21 of set 5.
|
||||
6 (UNTITLED)
|
||||
|
||||
$
|
||||
$ New messages (7,8) since CDE/SI - error gets displayed when user tries to run
|
||||
$ dtpad -server when and dtpad server process is already running on the
|
||||
$ $DISPLAY.
|
||||
7 ERROR: A dtpad server on %s\n\
|
||||
is already serving this display.
|
||||
8 ERROR: A dtpad server is already\n\
|
||||
serving this display.
|
||||
$
|
||||
$ Message 9 is also new since CDE/SI - new as of 5/22/95. It is a usage message
|
||||
$ for dtpad. Don't translate the '-OPTION' just the text explaining the
|
||||
$ option.
|
||||
$
|
||||
9 '%s' is a bad option.\n\
|
||||
Usage: %s...\n\
|
||||
-saveOnClose\n\
|
||||
\tDtpad automatically and silently saves the current text when there\n\
|
||||
\tare unsaved changes and the Text Editor is closed.\n\n\
|
||||
-missingFileWarning\n\
|
||||
\tPosts a warning dialog whenever a file name is specified and\n\
|
||||
\tthe file dones not exist or cannot be accessed.\n\n\
|
||||
-noReadOnlyWarning\n\
|
||||
\tDisables the warning dialog posted whenever a file is\n\
|
||||
\tspecified for which the user does not have write permission.\n\n\
|
||||
-noNameChange\n\
|
||||
\tIndicates that the default file name associated with the\n\
|
||||
\tcurrent text is not to change when the text is saved under a\n\
|
||||
\tname different than what it was read in under.\n\n\
|
||||
-viewOnly\n\
|
||||
\tDisallows editing of text in the edit window, essentially\n\
|
||||
\tturning the Text Editor into a Text Viewer.\n\n\
|
||||
-statusLine\n\
|
||||
\tDisplays a status line at the bottom of the edit window. The\n\
|
||||
\tstatus line shows the line number of the line where the text\n\
|
||||
\tcursor is currently positioned.\n\n\
|
||||
-wrapToFit\n\
|
||||
\tInitially turns on wrap-to-fit mode.\n\n\
|
||||
-workspaceList WorkspaceList\n\
|
||||
\tDisplays the edit window for the current invocation of the\n\
|
||||
\tText Editor in the specified workspace or workspaces.\n\n\
|
||||
-session SessionFile\n
|
||||
|
||||
10 \tRestores the Text Editor to all text editing windows and\n\
|
||||
\tsettings that were in effect at a previous CDE shutdown. All\n\
|
||||
\tother command-line options are ignored when this option is\n\
|
||||
\tspecified.\n\n\
|
||||
-standAlone\n\
|
||||
\tForces the current invocation of the Text Editor to do its\n\
|
||||
\town text processing in its own window, independent of the\n\
|
||||
\tText Editor server.\n\n\
|
||||
-noBlocking\n\
|
||||
\tTerminates the Text Editor requestor process as soon as the\n\
|
||||
\tText Editor server determines that it can handle the\n\
|
||||
\trequestor's edit request.\n\n\
|
||||
-server\n\
|
||||
\tForces a Text Editor server to be started up (if one is not\n\
|
||||
\talready running) to process all subsequent edit requests for\n\
|
||||
\tthe display.\n\n\
|
||||
-exitOnLastClose\n\
|
||||
\tSpecifies that the Text Editor server process is to terminate\n\
|
||||
\twhen the last edit window for the display is closed. It\n\
|
||||
\tshould only be used with the -server option since it only\n\
|
||||
\tapplies to the server process.\n\n\
|
||||
See the dtpad man page for more details on any of these options.\n\n
|
||||
|
||||
$ "NEW-"
|
||||
11 "Exiting text editor ..."
|
||||
$ "NEW-"
|
||||
12 "Running in standalone mode ..."
|
||||
$ "NEW-"
|
||||
13 "Could not connect to ToolTalk service:\n%s\n%s\n"
|
||||
|
||||
|
||||
$
|
||||
$set 10
|
||||
$ ************************************************************************
|
||||
$ ** session.c **
|
||||
$ ** THESE MESSAGES ARE _ONLY_ WRITTEN TO THE ERRORLOG FILE.
|
||||
$ **
|
||||
$ ************************************************************************
|
||||
$ Strings used to build error messages issued when the session save
|
||||
$ file cannot be read or written.
|
||||
1 Check the file permissions.
|
||||
2 %s is the file that would have been used to save your session.
|
||||
|
||||
|
||||
$set 11
|
||||
$ ***********************************************************
|
||||
$ ** dtpad.c **
|
||||
$ ** **
|
||||
$ ** These are all of the menu button labels and mnemonics **
|
||||
$ ***********************************************************
|
||||
|
||||
$ ***UNUSED*** Messages 1-14 are no longer used and need not be localized.
|
||||
$ All of the mnemonics and labels relating to the "Help" menu
|
||||
$ have been replaced by messages 81-96.
|
||||
|
||||
$ *
|
||||
$ * Mnemonics and labels for the "Help" pulldown menu and items.
|
||||
$ *
|
||||
$ Mnemonic and label for the "Help" pulldown menu
|
||||
1 H
|
||||
2 Help
|
||||
|
||||
$ mnemonic and label for the "Overview" item
|
||||
3 V
|
||||
4 Overview...
|
||||
|
||||
$ mnemonic and label for the "Tasks" item
|
||||
5 T
|
||||
6 Tasks...
|
||||
|
||||
$ nmemonic and label for the "Table of Contents" item are message nos. 71 & 72
|
||||
|
||||
$ mnemonic and label for the "Reference" item
|
||||
7 R
|
||||
8 Reference...
|
||||
|
||||
$ mnemonic and label for the "On Item" item
|
||||
9 O
|
||||
10 On Item
|
||||
|
||||
$ mnemonic and label for "Using Help" item
|
||||
11 U
|
||||
12 Using Help...
|
||||
|
||||
$ mnemonic and label for "About Text Editor" item
|
||||
13 A
|
||||
14 About Text Editor...
|
||||
|
||||
$ *
|
||||
$ * Mnemonics and labels for the "File" pulldown menu and items.
|
||||
$ *
|
||||
$ mnemonic and label for the "File" pulldown menu
|
||||
15 F
|
||||
16 File
|
||||
|
||||
$ mnemonic and label for the "New" item
|
||||
17 N
|
||||
18 New
|
||||
|
||||
$ mnemonic and label for the "Open" item
|
||||
19 O
|
||||
20 Open...
|
||||
|
||||
$ mnemonic and label for the "Include" item
|
||||
21 I
|
||||
22 Include...
|
||||
|
||||
$ mnemonic and label for the "Save" item
|
||||
$ NOTE: The "Save" label can be either Message 24 or message 73
|
||||
23 S
|
||||
24 Save
|
||||
|
||||
$ mnemonic and label for the "Save As" item
|
||||
25 A
|
||||
26 Save As...
|
||||
|
||||
$ mnemonic and label for the "Print..." item
|
||||
27 P
|
||||
28 Print...
|
||||
|
||||
$ mnemonic and label for the "Close" item
|
||||
29 C
|
||||
30 Close
|
||||
|
||||
$ *
|
||||
$ * Mnemonics and labels for the "Edit" pulldown menu and items.
|
||||
$ *
|
||||
$ mnemonic and label for the "Edit" pulldown menu
|
||||
31 E
|
||||
32 Edit
|
||||
|
||||
$ mnemonic and label for the "Undo" menu item
|
||||
33 U
|
||||
34 Undo
|
||||
|
||||
$ mnemonic and label for the "Cut" menu item
|
||||
35 t
|
||||
36 Cut
|
||||
|
||||
$ mnemonic and label for the "Copy" menu item
|
||||
37 C
|
||||
38 Copy
|
||||
|
||||
$ mnemonic and label for the "Paste" menu item
|
||||
39 P
|
||||
40 Paste
|
||||
|
||||
$ mnemonic and label for the "Clear" menu item
|
||||
41 e
|
||||
42 Clear
|
||||
|
||||
$ mnemonic and label for the "Delete" menu item
|
||||
43 D
|
||||
44 Delete
|
||||
|
||||
$ ***UNUSED*** Messages 45-50 are no longer used and need not be localized.
|
||||
$ They have been replaced by messages 101-106 of this set.
|
||||
$ mnemonic and label for the "Select All" menu item
|
||||
$ 45 A
|
||||
$ 46 Select All
|
||||
|
||||
$ mnemonic and label for the "Find/Change" menu item
|
||||
$ 47 F
|
||||
$ 48 Find/Change...
|
||||
|
||||
$ mnemonic and label for the Check Spelling menu item
|
||||
$ 49 S
|
||||
$ 50 Check Spelling...
|
||||
|
||||
$ *
|
||||
$ * Mnemonics and labels for the "Format" pulldown menu and items.
|
||||
$ *
|
||||
$ mnemonic and label for the "Format" pulldown menu
|
||||
51 r
|
||||
52 Format
|
||||
|
||||
$ mnemonic and label for the "Settings..." menu item
|
||||
53 S
|
||||
54 Settings...
|
||||
|
||||
$ mnemonic and label for the "Paragraph" menu item
|
||||
55 P
|
||||
56 Paragraph
|
||||
|
||||
$ mnemonic and label for the "All" menu item
|
||||
57 l
|
||||
58 All
|
||||
|
||||
$ *
|
||||
$ * Mnemonics and labels for the "Options" pulldown menu and items.
|
||||
$ *
|
||||
$ mnemonic and label for the "Format" pulldown menu
|
||||
59 O
|
||||
60 Options
|
||||
|
||||
$ mnemonic and label for the "Overstrike" toggle button
|
||||
61 O
|
||||
62 Overstrike
|
||||
|
||||
$ mnemonic and label for the "Word Wrap" toggle button
|
||||
$ ***UNUSED*** This label and mnemonic are no longer used and need not be
|
||||
$ localized. They've been replaced by messages 111 and 112.
|
||||
63 W
|
||||
64 Word Wrap
|
||||
|
||||
$ mnemonic and label for the "Status Line" toggle button
|
||||
65 S
|
||||
66 Status Line
|
||||
|
||||
$ *
|
||||
$ * Late additions.
|
||||
$ *
|
||||
|
||||
$ nmemonic and label for the "Table of Contents" item of the "Help" menu
|
||||
$ ***UNUSED*** This nmemonic and label are no longer used and need not be
|
||||
$ localized. They've been replaced by messages 87 and 88.
|
||||
71 C
|
||||
72 Table of Contents...
|
||||
|
||||
$ label for the "Save" item in the "File" pulldown menu
|
||||
$ NOTE: This label is used in place of message 24 when text has been
|
||||
$ changed but has not been saved
|
||||
73 Save (needed)
|
||||
|
||||
|
||||
$ *
|
||||
$ * Mnemonics and labels for the "Help" pulldown menu and items.
|
||||
$ *
|
||||
$ Mnemonic and label for the "Help" pulldown menu
|
||||
81 H
|
||||
82 Help
|
||||
|
||||
$ mnemonic and label for the "Overview" item
|
||||
83 v
|
||||
84 Overview
|
||||
|
||||
$ mnemonic and label for the "Tasks" item
|
||||
85 T
|
||||
86 Tasks
|
||||
|
||||
$ nmemonic and label for the "Table of Contents" item
|
||||
87 C
|
||||
88 Table of Contents
|
||||
|
||||
$ mnemonic and label for the "Reference" item
|
||||
89 R
|
||||
90 Reference
|
||||
|
||||
$ mnemonic and label for the "On Item" item
|
||||
91 O
|
||||
92 On Item
|
||||
|
||||
$ mnemonic and label for "Using Help" item
|
||||
93 U
|
||||
94 Using Help
|
||||
|
||||
$ mnemonic and label for "About Text Editor" item
|
||||
95 A
|
||||
96 About Text Editor
|
||||
|
||||
|
||||
$ *
|
||||
$ * Changes for "Edit" pulldown menu messages 45-50.
|
||||
$ *
|
||||
|
||||
$ mnemonic and label for the "Select All" menu item
|
||||
101 S
|
||||
102 Select All
|
||||
|
||||
$ mnemonic and label for the "Find/Change" menu item
|
||||
103 F
|
||||
104 Find/Change...
|
||||
|
||||
$ mnemonic and label for the Check Spelling menu item
|
||||
105 k
|
||||
106 Check Spelling...
|
||||
|
||||
$ mnemonic and label for the "Copy As" File menu item
|
||||
$ (should match the dialog title specified in message 42 of set 5)
|
||||
$ ***UNUSED*** This label is no longer used and need not be localized.
|
||||
107 A
|
||||
108 Copy As...
|
||||
|
||||
$ mnemonic and label for the "Copy To File" File menu item
|
||||
$ (should match the dialog title specified in message 42 of set 5)
|
||||
109 F
|
||||
110 Copy To File...
|
||||
|
||||
$ mnemonic and label for the "Wrap To Fit" toggle button
|
||||
111 W
|
||||
112 Wrap To Fit
|
||||
|
||||
$ label for the "Print" item
|
||||
113 Print
|
||||
|
||||
$ ***********************************************************
|
||||
$ ** helpCB.c **
|
||||
$ ** **
|
||||
$ ** Messages and strings associated with online help. **
|
||||
$ ** **
|
||||
$ ***********************************************************
|
||||
$set 12
|
||||
$ Message used for "Help - On Item" if the user clicks outside application
|
||||
1 You must select an item within the Text Editor.
|
||||
|
||||
|
||||
$ ***********************************************************
|
||||
$ ** ttMsgSupport.c **
|
||||
$ ** **
|
||||
$ ** Messages and strings associated with ToolTalk. **
|
||||
$ ** **
|
||||
$ ***********************************************************
|
||||
$set 13
|
||||
1 Checkpoint save failed.
|
||||
2 Checkpoint reply failed.
|
||||
|
||||
$ NEW message after the SAMPLE IMPLEMENTATION.... more errors/warnings can
|
||||
$ be detected while reading in a file via ToolTalk.
|
||||
3 Unable to set contents of Text Editor (unknown reason).
|
||||
|
||||
|
||||
$ ****************************************************************************
|
||||
$ ****************************************************************************
|
||||
$ **
|
||||
$ ** SETS 14 - 15 WERE ADDED TO SUPPORT CDEnext PRINTING
|
||||
$ **
|
||||
$ ** The following set was added to support CDEnext printing based on
|
||||
$ ** the Xp Print Server.
|
||||
$ **
|
||||
$ ****************************************************************************
|
||||
$ ****************************************************************************
|
||||
|
||||
$ ****************************************************************************
|
||||
$ ****************************************************************************
|
||||
$ **
|
||||
$ ** SET 14
|
||||
$ **
|
||||
$ ****************************************************************************
|
||||
$ ****************************************************************************
|
||||
$set 14
|
||||
$
|
||||
$ Messages 1 - 17 are used in printJob.
|
||||
$
|
||||
$ This is warning message is displayed when the user has provided
|
||||
$ a margin specifier in the PrintSetup dialog which cannot be parsed.
|
||||
$
|
||||
$quote "
|
||||
1 "One of the following margin specifiers \n has incorrect syntax: \n %s \n %s \n %s \n %s \nUse default margins instead?"
|
||||
$
|
||||
$ Messages 2 - 7 are messages for errors which can occur in the
|
||||
$ process of loading a dtpad document file for printing.
|
||||
$
|
||||
2 "File does not exist."
|
||||
3 "Specified file is a directory."
|
||||
4 "File type error."
|
||||
5 "File contains NULL characters."
|
||||
6 "Unable to load file (insufficient memory)."
|
||||
7 "File does not have read permissions"
|
||||
|
||||
$ Messages 8 - 11 are format strings used to construct the header
|
||||
$ and footer strings which appear in the printing output.
|
||||
$
|
||||
$ Message 8 is the format string used to make a Date header/footer.
|
||||
$ Message 9 is the format string used to make a DocName header/footer.
|
||||
$ Message 10 is the format string used to make a Page# header/footer.
|
||||
$ Message 11 is the format string used to make a UserName header/footer.
|
||||
8 "Date: %s"
|
||||
9 "Document: %s"
|
||||
10 "Page %d of %d"
|
||||
11 "Document For: %s"
|
||||
|
||||
$
|
||||
$ Messages 12 - 13 are used in printSetup to construct the
|
||||
$ app-specific printing options for DtMail which will be included
|
||||
$ in the DtPrintSetupBox.
|
||||
$
|
||||
$ Message 12 is the string labeling the field in the GUI which
|
||||
$ contains the name of the document.
|
||||
$ Message 13 is the label used on the Toggle Button to indicate that
|
||||
$ lines which would extend beyond the edge of the printed page be
|
||||
$ "wrapped" to the next line.
|
||||
12 "Document Name: "
|
||||
13 "Wrap To Fit"
|
||||
|
||||
|
||||
$ Messages 14 - 15 are status messages for the PrintToFile function.
|
||||
$
|
||||
$ Message 14 indicates that the PrintToFile function was unsuccessful.
|
||||
$ Message 15 indicates that the PrintToFile function was successful.
|
||||
$ NOTE: 'Print to File' should be translated as in
|
||||
$ DtPrint.msg:Set1, Msg3.
|
||||
14 "'Print to File' was unsuccessful."
|
||||
15 "'Print to File' completed successfully."
|
||||
|
||||
$ Messages 16 - 19 are obsolete, and have been replaced by 25
|
||||
$
|
||||
$ Messages 16 - 19 are status messages for the popup PDM function.
|
||||
$
|
||||
$ Message 16 indicates that there was no pdm deamon running.
|
||||
$ Message 17 indicates that the pdm deamon was unable to start a pdm.
|
||||
$ Message 18 indicates that the pdm couldnt connect to the video display.
|
||||
$ Message 19 indicates that the pdm couldnt connect to the print display.
|
||||
16 "No PDM found in the environment."
|
||||
17 "Cannot start the PDM."
|
||||
18 "PDM is not authorized to connect to Video display."
|
||||
19 "PDM is not authorized to connect to Print display."
|
||||
|
||||
$ Messages 20 - 22 are status messages displayed while printing
|
||||
$
|
||||
$ Message 20 indicates that the user has asked to close the editor
|
||||
$ window. Dtpad is prevented from doing so until the
|
||||
$ active print jobs have completed.
|
||||
$ Message 21 status message displayed when the print job is started.
|
||||
$ Message 22 status message displayed as the print job progresses.
|
||||
20 "Close pending: waiting for task to terminate ..."
|
||||
21 "Printing %s ..."
|
||||
22 "Printing %s: page %d of %d ..."
|
||||
|
||||
$ Message 23 is used in the construction of a title string for the
|
||||
$ Print Setup dialog.
|
||||
23 "Print Setup - "
|
||||
|
||||
$ Message 24 is used to alert the user to the fact that the X Print
|
||||
$ Server cannot complete the print request due to a lack
|
||||
$ of resources.
|
||||
$ "NEW-"
|
||||
24 "The X Print Server is temporarily out of resources"
|
||||
|
||||
$ Messages 25 is used to handle errors from the PDM
|
||||
25 "Print Dialog Manager (PDM) error - setup failed."
|
||||
|
||||
$ ****************************************************************************
|
||||
$ ****************************************************************************
|
||||
$ **
|
||||
$ ** SET 15
|
||||
$ **
|
||||
$ ****************************************************************************
|
||||
$ ****************************************************************************
|
||||
$
|
||||
$set 15
|
||||
$
|
||||
$ Messages 1-5 are used in printSetup.c in the pulldown menu for the
|
||||
$ header/footer options in the print setup dialog.
|
||||
$
|
||||
$ Message 1 specifies that the page header/footer field be empty.
|
||||
$ Message 2 put the Date in the page header/footer field.
|
||||
$ Message 3 put the Document Name in the page header/footer field.
|
||||
$ Message 4 put the Page Nmbr msg header in the page header/footer field.
|
||||
$ Message 5 put the User Name msg header in the page header/footer field.
|
||||
1 "Empty"
|
||||
2 "Date"
|
||||
3 "Document Name"
|
||||
4 "Page Number"
|
||||
5 "User Name"
|
||||
|
||||
$ Messages 6-9 are used to construct error messages informing users
|
||||
$ that they have input an invalid print page margin specification for
|
||||
$
|
||||
6 "Top Margin specifier is invalid: "
|
||||
7 "Right Margin specifier is invalid: "
|
||||
8 "Bottom Margin specifier is invalid: "
|
||||
9 "Left Margin specifier is invalid: "
|
||||
240
cde/programs/dtpad/editCB.c
Normal file
240
cde/programs/dtpad/editCB.c
Normal file
@@ -0,0 +1,240 @@
|
||||
/* $XConsortium: editCB.c /main/3 1995/11/01 10:35:26 rswiston $ */
|
||||
/**********************************<+>*************************************
|
||||
***************************************************************************
|
||||
**
|
||||
** File: editCB.c
|
||||
**
|
||||
** Project: DT dtpad, a memo maker type editor based on the Dt Editor
|
||||
** widget.
|
||||
**
|
||||
** Description:
|
||||
** -----------
|
||||
**
|
||||
** This file contains the callbacks for the [Edit] menu items.
|
||||
**
|
||||
*******************************************************************
|
||||
** (c) Copyright Hewlett-Packard Company, 1991, 1992. All rights are
|
||||
** reserved. Copying or other reproduction of this program
|
||||
** except for archival purposes is prohibited without prior
|
||||
** written consent of Hewlett-Packard Company.
|
||||
********************************************************************
|
||||
**
|
||||
********************************************************************
|
||||
** (c) Copyright 1993, 1994 Hewlett-Packard Company
|
||||
** (c) Copyright 1993, 1994 International Business Machines Corp.
|
||||
** (c) Copyright 1993, 1994 Sun Microsystems, Inc.
|
||||
** (c) Copyright 1993, 1994 Novell, Inc.
|
||||
********************************************************************
|
||||
**
|
||||
**
|
||||
**************************************************************************
|
||||
**********************************<+>*************************************/
|
||||
#include "dtpad.h"
|
||||
#include <Dt/HourGlass.h>
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* EditUndoCB - [Edit] menu, [Undo] button.
|
||||
* Undoes the last edit.
|
||||
************************************************************************/
|
||||
/* ARGSUSED */
|
||||
void
|
||||
EditUndoCB(
|
||||
Widget w,
|
||||
caddr_t client_data,
|
||||
caddr_t call_data )
|
||||
{
|
||||
Editor *pPad = (Editor *)client_data;
|
||||
DtEditorUndoEdit(pPad->editor);
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* EditCutCB - [Edit] menu, [Cut] button.
|
||||
* Cuts the current selection to the Motif clipboard.
|
||||
************************************************************************/
|
||||
/* ARGSUSED */
|
||||
void
|
||||
EditCutCB(
|
||||
Widget w,
|
||||
caddr_t client_data,
|
||||
caddr_t call_data )
|
||||
{
|
||||
Editor *pPad = (Editor *)client_data;
|
||||
DtEditorCutToClipboard(pPad->editor);
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* EditCopyCB - [Edit] menu, [Copy] button.
|
||||
* Copies the current selection to the Motif clipboard.
|
||||
************************************************************************/
|
||||
/* ARGSUSED */
|
||||
void
|
||||
EditCopyCB(
|
||||
Widget w,
|
||||
caddr_t client_data,
|
||||
caddr_t call_data )
|
||||
{
|
||||
Editor *pPad = (Editor *)client_data;
|
||||
DtEditorCopyToClipboard(pPad->editor);
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* EditPasteCB - [Edit] menu, [Paste] button.
|
||||
* Pastes from the Motif clipboard.
|
||||
************************************************************************/
|
||||
/* ARGSUSED */
|
||||
void
|
||||
EditPasteCB(
|
||||
Widget w,
|
||||
caddr_t client_data,
|
||||
caddr_t call_data )
|
||||
{
|
||||
Editor *pPad = (Editor *)client_data;
|
||||
DtEditorPasteFromClipboard(pPad->editor);
|
||||
|
||||
/* XXX - Do DtEditorGetInsertPosition & DtEditorSetInsertionPosition
|
||||
* need to be executed here??
|
||||
* XmTextPosition cursorPos;
|
||||
* cursorPos = XmTextGetInsertionPosition(pPad->text);
|
||||
* XmTextShowPosition(pPad->text, cursorPos);
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* EditClearCB - [Edit] menu, [Replace] button
|
||||
* Replaces the current selection with blanks.
|
||||
************************************************************************/
|
||||
/* ARGSUSED */
|
||||
void
|
||||
EditClearCB(
|
||||
Widget w,
|
||||
caddr_t client_data,
|
||||
caddr_t call_data )
|
||||
{
|
||||
Editor *pPad = (Editor *)client_data;
|
||||
DtEditorClearSelection(pPad->editor);
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* EditDeleteCB - [Edit] menu, [Delete] button.
|
||||
* Deletes the current selection.
|
||||
************************************************************************/
|
||||
/* ARGSUSED */
|
||||
void
|
||||
EditDeleteCB(
|
||||
Widget w,
|
||||
caddr_t client_data,
|
||||
caddr_t call_data )
|
||||
{
|
||||
Editor *pPad = (Editor *)client_data;
|
||||
DtEditorDeleteSelection(pPad->editor);
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* SelectAllCB - [Edit] menu, [Select All] button.
|
||||
* Selects all text.
|
||||
************************************************************************/
|
||||
/* ARGSUSED */
|
||||
void
|
||||
SelectAllCB(
|
||||
Widget w,
|
||||
caddr_t client_data,
|
||||
caddr_t call_data )
|
||||
{
|
||||
Editor *pPad = (Editor *)client_data;
|
||||
DtEditorSelectAll(pPad->editor);
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* FindChangeCB - [Edit] menu, [Find/Change...] button.
|
||||
* Invokes the Dt Editor widget search dialog.
|
||||
************************************************************************/
|
||||
/* ARGSUSED */
|
||||
void
|
||||
FindChangeCB(
|
||||
Widget w,
|
||||
caddr_t client_data,
|
||||
caddr_t call_data )
|
||||
{
|
||||
Editor *pPad = (Editor *)client_data;
|
||||
DtEditorInvokeFindChangeDialog(pPad->editor);
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* CheckSpellingCB - [Edit] menu, [Check Spelling...] button.
|
||||
* Invokes the Dt Editor widget spell dialog.
|
||||
************************************************************************/
|
||||
/* ARGSUSED */
|
||||
void
|
||||
CheckSpellingCB(
|
||||
Widget w,
|
||||
caddr_t client_data,
|
||||
caddr_t call_data )
|
||||
{
|
||||
Editor *pPad = (Editor *)client_data;
|
||||
DtEditorInvokeSpellDialog(pPad->editor);
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* SetSelectionMenuItems - Sets the sensitivity of [Edit] menu items
|
||||
* that deal with the current selection in the edit window - allowing
|
||||
* for viewOnly mode.
|
||||
************************************************************************/
|
||||
/* ARGSUSED */
|
||||
void
|
||||
SetSelectionMenuItems(
|
||||
Editor *pPad,
|
||||
Boolean sensitivity)
|
||||
{
|
||||
XtSetSensitive(pPad->editStuff.widgets.cutBtn,
|
||||
sensitivity && ! pPad->xrdb.viewOnly);
|
||||
XtSetSensitive(pPad->editStuff.widgets.copyBtn,
|
||||
sensitivity); /* Copy can be done in viewOnly mode */
|
||||
XtSetSensitive(pPad->editStuff.widgets.clearBtn,
|
||||
sensitivity && ! pPad->xrdb.viewOnly);
|
||||
XtSetSensitive(pPad->editStuff.widgets.deleteBtn,
|
||||
sensitivity && ! pPad->xrdb.viewOnly);
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* TextSelectedCB - DtEditor widget DtNtextSelectCallback called when
|
||||
* text in the editor window is selected.
|
||||
* Makes [Edit] menu items related to a selection sensitive.
|
||||
************************************************************************/
|
||||
/* ARGSUSED */
|
||||
void
|
||||
TextSelectedCB(
|
||||
Widget w,
|
||||
caddr_t client_data,
|
||||
caddr_t call_data)
|
||||
{
|
||||
Editor *pPad = (Editor *)client_data;
|
||||
SetSelectionMenuItems(pPad, True);
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* TextDeselectedCB - DtEditor widget DtNtextSelectCallback called when
|
||||
* text in the editor window is deselected.
|
||||
* Makes [Edit] menu items related to a selection insensitive.
|
||||
************************************************************************/
|
||||
/* ARGSUSED */
|
||||
void
|
||||
TextDeselectedCB(
|
||||
Widget w,
|
||||
caddr_t client_data,
|
||||
caddr_t call_data)
|
||||
{
|
||||
Editor *pPad = (Editor *)client_data;
|
||||
SetSelectionMenuItems(pPad, False);
|
||||
}
|
||||
1384
cde/programs/dtpad/fileCB.c
Normal file
1384
cde/programs/dtpad/fileCB.c
Normal file
File diff suppressed because it is too large
Load Diff
958
cde/programs/dtpad/fileDlg.c
Normal file
958
cde/programs/dtpad/fileDlg.c
Normal file
@@ -0,0 +1,958 @@
|
||||
/* $TOG: fileDlg.c /main/8 1999/09/15 15:15:56 mgreess $ */
|
||||
/**********************************<+>*************************************
|
||||
***************************************************************************
|
||||
**
|
||||
** File: fileDlg.c
|
||||
**
|
||||
** Project: DT dtpad, a memo maker type editor based on the Dt Editor
|
||||
** widget.
|
||||
**
|
||||
** Description: Routines which manipulate the dialogs associated with
|
||||
** operations in the File menu.
|
||||
** -----------
|
||||
**
|
||||
*******************************************************************
|
||||
** (c) Copyright Hewlett-Packard Company, 1990, 1991, 1992. All rights are
|
||||
** reserved. Copying or other reproduction of this program
|
||||
** except for archival purposes is prohibited without prior
|
||||
** written consent of Hewlett-Packard Company.
|
||||
********************************************************************
|
||||
**
|
||||
*******************************************************************
|
||||
** (c) Copyright 1993, 1994 Hewlett-Packard Company
|
||||
** (c) Copyright 1993, 1994 International Business Machines Corp.
|
||||
** (c) Copyright 1993, 1994 Sun Microsystems, Inc.
|
||||
** (c) Copyright 1993, 1994 Novell, Inc.
|
||||
********************************************************************
|
||||
**
|
||||
**
|
||||
**************************************************************************
|
||||
**********************************<+>*************************************/
|
||||
#include "dtpad.h"
|
||||
#include <Xm/DialogS.h>
|
||||
#include <Xm/Form.h>
|
||||
#include <Xm/FileSB.h>
|
||||
#include <Xm/Separator.h>
|
||||
#include <Xm/MwmUtil.h>
|
||||
#include <Dt/HourGlass.h>
|
||||
|
||||
#define MAX_DIR_PATH_LEN 1024
|
||||
|
||||
#define SAVE_CH ((char *)GETMESSAGE(5, 1, "Save changes to %s?"))
|
||||
#define SAVE_CH_NONAME ((char *)GETMESSAGE(5, 2, "The current file has no name.\nDo you want to save it?"))
|
||||
#define SAVE_CH_BUF ((char *)GETMESSAGE(5, 40, "Save changes?"))
|
||||
#define SAVE_CH_DOC ((char *)GETMESSAGE(5, 41, "Save changes to \"%s?\""))
|
||||
#define SAVE_DROP ((char *)GETMESSAGE(5, 3, "Do you want to save the current copy of %s\nbefore you Edit %s?"))
|
||||
#define MSG1 ((char *)GETMESSAGE(5, 5, "The file %s already exists.\nDo you want to over write that file\nwith the contents within this edit session? "))
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* Forward Declarations
|
||||
************************************************************************/
|
||||
static void CreateFileSelectionDialog(
|
||||
Editor *pPad );
|
||||
static void CreateSaveWarning(
|
||||
Editor *pPad );
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* PostAlreadyExistsDlg - Setup and post dialog to determine whether
|
||||
* the user wishes to clobber existing file or try saving it under a
|
||||
* new name.
|
||||
*
|
||||
* Inputs: pPad->fileStuff.savingName - name of file to save
|
||||
************************************************************************/
|
||||
void
|
||||
PostAlreadyExistsDlg(
|
||||
Editor *pPad)
|
||||
{
|
||||
Arg args[10];
|
||||
int n;
|
||||
char *tmpMess;
|
||||
XmString tmpMessStr;
|
||||
SaveAs *pSaveAs = &pPad->fileStuff.fileWidgets.saveAs;
|
||||
|
||||
/* create the dialog if it is the first time */
|
||||
if (!pSaveAs->alrdy_exist)
|
||||
{
|
||||
Pixel foreground; /* dialog foreground */
|
||||
Pixel background; /* dialog background */
|
||||
Pixmap pixmap; /* dialog pixmap */
|
||||
XmString tempStr, tempStr2;
|
||||
char buf[256];
|
||||
|
||||
n = 0;
|
||||
strcpy(buf, DialogTitle(pPad));
|
||||
strcat(buf, (char *)GETMESSAGE(5, 6, "Warning"));
|
||||
tempStr = XmStringCreateLocalized(buf);
|
||||
XtSetArg(args[n], XmNdialogTitle, tempStr); n++;
|
||||
XtSetArg (args[n], XmNokLabelString,
|
||||
XmStringCreateLocalized((String) _DtOkString)); n++;
|
||||
tempStr2 = XmStringCreateLocalized((char *)GETMESSAGE(2, 1, "Help"));
|
||||
XtSetArg (args[n], XmNhelpLabelString, tempStr2); n++;
|
||||
XtSetArg (args[n], XmNcancelLabelString,
|
||||
XmStringCreateLocalized((String) _DtCancelString)); n++;
|
||||
pSaveAs->alrdy_exist = XmCreateMessageDialog (pPad->app_shell, "Warn",
|
||||
args, n);
|
||||
XmStringFree(tempStr);
|
||||
XmStringFree(tempStr2);
|
||||
n=0;
|
||||
XtSetArg(args[n], XmNmwmInputMode,
|
||||
MWM_INPUT_PRIMARY_APPLICATION_MODAL);n++;
|
||||
XtSetValues(XtParent(pSaveAs->alrdy_exist), args, n);
|
||||
|
||||
|
||||
n = 0;
|
||||
XtSetArg(args[n], XmNforeground, &foreground); n++;
|
||||
XtSetArg(args[n], XmNbackground, &background); n++;
|
||||
XtGetValues(pSaveAs->alrdy_exist, args, n);
|
||||
|
||||
n = 0;
|
||||
pixmap = XmGetPixmap(XtScreen(pSaveAs->alrdy_exist), "warn_image",
|
||||
foreground, background);
|
||||
XtSetArg(args[n], XmNsymbolPixmap, pixmap); n++;
|
||||
XtSetValues(pSaveAs->alrdy_exist, args, n);
|
||||
|
||||
XtAddCallback (pSaveAs->alrdy_exist, XmNokCallback,
|
||||
(XtCallbackProc) AlrdyExistsOkCB,
|
||||
(XtPointer) pPad);
|
||||
XtAddCallback (pSaveAs->alrdy_exist, XmNcancelCallback,
|
||||
(XtCallbackProc) AlrdyExistsCancelCB,
|
||||
(XtPointer) pPad);
|
||||
XtAddCallback (pSaveAs->alrdy_exist, XmNhelpCallback,
|
||||
(XtCallbackProc) HelpFileAlreadyExistsCB,
|
||||
(XtPointer) pPad);
|
||||
|
||||
XtRealizeWidget (pSaveAs->alrdy_exist);
|
||||
}
|
||||
|
||||
tmpMess =
|
||||
(char *)XtMalloc(strlen(MSG1) + strlen(pPad->fileStuff.savingName) + 1);
|
||||
sprintf(tmpMess, MSG1, pPad->fileStuff.savingName);
|
||||
tmpMessStr = XmStringCreateLocalized(tmpMess);
|
||||
n = 0;
|
||||
XtSetArg(args[n], XmNmessageString, tmpMessStr); n++;
|
||||
XtSetValues(pSaveAs->alrdy_exist, args, n);
|
||||
XtFree(tmpMess);
|
||||
XmStringFree(tmpMessStr);
|
||||
|
||||
XtManageChild (pSaveAs->alrdy_exist);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* SetSaveAsDirAndFile - Seeds the directory and file name fields of
|
||||
* the SaveAs File Selection Box.
|
||||
*
|
||||
* The possibilities for an initial directory are:
|
||||
*
|
||||
* 1. The user's previously entered path.
|
||||
* 2. We're editing a file, so use its path.
|
||||
* 3. Use the CWD of our process.
|
||||
*
|
||||
************************************************************************/
|
||||
void
|
||||
SetSaveAsDirAndFile(Editor *pPad)
|
||||
{
|
||||
char dirbuf[MAX_DIR_PATH_LEN], *currentVal, *directoryVal,
|
||||
*lastSlash, *pColon;
|
||||
int firstSelect = -1, lastSelect = -1;
|
||||
Widget textField;
|
||||
Arg args[5];
|
||||
register int n;
|
||||
XmString dirString;
|
||||
dirbuf[0] = (char) '\0';
|
||||
|
||||
/* -----> Get the file name field from the previous SaveAs FSB.
|
||||
* XXX - Should use GetValues to get XmNdirSpec. */
|
||||
textField = XmFileSelectionBoxGetChild(
|
||||
pPad->fileStuff.fileWidgets.saveAs.saveAs_form,
|
||||
XmDIALOG_TEXT);
|
||||
currentVal = XmTextFieldGetString(textField);
|
||||
|
||||
/* -----> If the user previously entered a file name via the SaveAs FSB,
|
||||
* use its values. */
|
||||
if (currentVal != (char *)NULL && *currentVal != (char)'\0') {
|
||||
/* -----> If the file name begins with '/', it has a pathname and we
|
||||
* can use it for the initial directory */
|
||||
if ( currentVal[0] == '/' ) {
|
||||
strcpy(dirbuf, currentVal);
|
||||
/* Trim off everything behind the last slash */
|
||||
if ((lastSlash = MbStrrchr(dirbuf, '/')) != (char *)NULL) {
|
||||
*(lastSlash + 1) = (char)'\0';
|
||||
}
|
||||
} else {
|
||||
/* -----> The filename does not have a directory, so use the value
|
||||
* from the directory field. */
|
||||
n=0;
|
||||
XtSetArg( args[n], XmNdirectory, &dirString ); n++;
|
||||
XtGetValues(pPad->fileStuff.fileWidgets.saveAs.saveAs_form, args, n);
|
||||
directoryVal = (char *) XtMalloc( sizeof(char) *
|
||||
(MAX_DIR_PATH_LEN + 1) );
|
||||
XmStringGetLtoR( dirString, XmFONTLIST_DEFAULT_TAG, &directoryVal );
|
||||
strcpy(dirbuf, directoryVal);
|
||||
XmStringFree(dirString);
|
||||
XtFree( directoryVal );
|
||||
}
|
||||
XtFree (currentVal);
|
||||
/* -----> No file name was not previously entered via a SaveAs FSB so use
|
||||
* other defaults. */
|
||||
} else {
|
||||
if (pPad->fileStuff.pathDir[0] != (char)'\0')
|
||||
strcpy(dirbuf, pPad->fileStuff.pathDir);
|
||||
/* -----> make sure dir ends in '/' */
|
||||
if (dirbuf[0] != (char )'\0') {
|
||||
if (dirbuf[strlen(dirbuf) - 1] != (char)'/')
|
||||
strcat(dirbuf, "/");
|
||||
} else {
|
||||
getcwd(dirbuf, MAX_DIR_PATH_LEN - 16);
|
||||
strcat(dirbuf, "/");
|
||||
}
|
||||
}
|
||||
|
||||
/* -----> set the SaveAs FSB directory mask */
|
||||
firstSelect = strlen(dirbuf);
|
||||
strcat(dirbuf, "[^.]*");
|
||||
dirString = XmStringCreateLocalized(dirbuf);
|
||||
n = 0;
|
||||
XtSetArg(args[n], XmNdirMask, dirString); n++;
|
||||
XtSetValues(pPad->fileStuff.fileWidgets.saveAs.saveAs_form, args, n);
|
||||
XmStringFree(dirString);
|
||||
dirbuf[firstSelect] = (char)'\0';
|
||||
|
||||
/* -----> set the default file name and select it */
|
||||
strcpy(dirbuf, GETMESSAGE(5, 21, "UNTITLED"));
|
||||
lastSelect = strlen(dirbuf);
|
||||
XmTextFieldSetString(textField, dirbuf);
|
||||
XmTextFieldSetSelection(textField, 0, lastSelect, CurrentTime);
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* CreateNewLineToggles - used by CreateSaveAsDialog and CreateSaveWarning
|
||||
* to create a radio box within 'parent' with two toggle buttons
|
||||
* for adding or not adding new lines if word wrap mode is on.
|
||||
************************************************************************/
|
||||
static void
|
||||
CreateNewLineToggles(
|
||||
Editor *pPad,
|
||||
Widget parent,
|
||||
ToggleWidgets *pToggleWidgets)
|
||||
{
|
||||
Arg args[20];
|
||||
register int n;
|
||||
XmString label_string;
|
||||
|
||||
/* -----> Create Radio Box */
|
||||
n = 0;
|
||||
XtSetArg(args[n], XmNshadowThickness, 0); n++;
|
||||
XtSetArg(args[n], XmNtraversalOn, True); n++;
|
||||
XtSetArg(args[n], XmNorientation, XmVERTICAL ); n++;
|
||||
pToggleWidgets->newl_radio = XmCreateRadioBox(parent, "radioBox",
|
||||
args, n);
|
||||
|
||||
/* -----> Create the toggle button for adding newlines. */
|
||||
label_string = XmStringCreateLocalized(((char *)GETMESSAGE(5, 44,
|
||||
"Add newline characters to the end of wrap-to-fit lines.")));
|
||||
n = 0;
|
||||
XtSetArg(args[n], XmNshadowThickness, 0); n++;
|
||||
XtSetArg(args[n], XmNlabelString, label_string); n++;
|
||||
pToggleWidgets->with_newl = XmCreateToggleButtonGadget(
|
||||
pToggleWidgets->newl_radio,
|
||||
"with_nl", args, n);
|
||||
XmStringFree(label_string);
|
||||
XtAddCallback(pToggleWidgets->with_newl, XmNvalueChangedCallback,
|
||||
SaveNewLinesCB, (XtPointer) pPad);
|
||||
XtManageChild(pToggleWidgets->with_newl);
|
||||
|
||||
/* -----> Create the toggle button for not adding newlines. */
|
||||
label_string = XmStringCreateLocalized(((char *)GETMESSAGE(5, 45,
|
||||
"Do not add newlines. Only line breaks created by [Return]\nwill be preserved.")));
|
||||
n = 0;
|
||||
XtSetArg(args[n], XmNshadowThickness, 0); n++;
|
||||
XtSetArg(args[n], XmNlabelString, label_string); n++;
|
||||
pToggleWidgets->without_newl = XmCreateToggleButtonGadget(
|
||||
pToggleWidgets->newl_radio,
|
||||
"without_nl", args, n);
|
||||
XmStringFree(label_string);
|
||||
XtAddCallback(pToggleWidgets->without_newl, XmNvalueChangedCallback,
|
||||
SaveNewLinesCB, (XtPointer) pPad);
|
||||
XtManageChild(pToggleWidgets->without_newl);
|
||||
|
||||
/* -----> Set the default to add newlines (if wordwrap is on) */
|
||||
pPad->fileStuff.saveWithNewlines = True;
|
||||
XmToggleButtonGadgetSetState(pToggleWidgets->with_newl, True, False);
|
||||
|
||||
/* -----> Display the radio box containing the two toggle buttons only
|
||||
* if wordwrap is on */
|
||||
if (pPad->xrdb.wordWrap == True)
|
||||
XtManageChild(pToggleWidgets->newl_radio);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* CreateSaveAsDialog
|
||||
************************************************************************/
|
||||
void
|
||||
CreateSaveAsDialog(Editor *pPad)
|
||||
{
|
||||
Arg args[20];
|
||||
register int n;
|
||||
XmString label_string;
|
||||
char buf[256];
|
||||
SaveAs *pSaveAs = &pPad->fileStuff.fileWidgets.saveAs;
|
||||
|
||||
_DtTurnOnHourGlass(pPad->app_shell);
|
||||
|
||||
/* -----> Create the FileSelectionDialog */
|
||||
strcpy(buf, DialogTitle(pPad));
|
||||
if (pPad->xrdb.nameChange) {
|
||||
strcat(buf, (char *)GETMESSAGE(5, 7, "Save As"));
|
||||
} else {
|
||||
strcat(buf, (char *)GETMESSAGE(5, 43, "Copy To File"));
|
||||
}
|
||||
label_string = XmStringCreateLocalized(buf);
|
||||
n = 0;
|
||||
XtSetArg(args[n], XmNdialogTitle, label_string); n++;
|
||||
XtSetArg(args[n], XmNmwmFunctions, MWM_FUNC_MOVE | MWM_FUNC_CLOSE); n++;
|
||||
XtSetArg(args[n], XmNmwmDecorations, MWM_DECOR_BORDER | MWM_DECOR_TITLE);
|
||||
n++;
|
||||
XtSetArg (args[n], XmNallowShellResize, False); n++;
|
||||
pSaveAs->saveAs_form = XmCreateFileSelectionDialog(pPad->app_shell,
|
||||
"save_dialog", args, n);
|
||||
XmStringFree(label_string);
|
||||
|
||||
/* -----> Add the FSB cancel, ok, and help callbacks */
|
||||
XtAddCallback(pSaveAs->saveAs_form,
|
||||
XmNcancelCallback,
|
||||
(XtCallbackProc) SaveAsCancelCB,
|
||||
(XtPointer) pPad);
|
||||
XtAddCallback(pSaveAs->saveAs_form,
|
||||
XmNokCallback,
|
||||
(XtCallbackProc) SaveAsOkCB,
|
||||
(XtPointer) pPad);
|
||||
XtAddCallback(pSaveAs->saveAs_form,
|
||||
XmNhelpCallback,
|
||||
(XtCallbackProc)HelpSaveAsDialogCB,
|
||||
(XtPointer) pPad);
|
||||
|
||||
/* -----> Don't show the filter stuff when saving
|
||||
*XtUnmanageChild(XmFileSelectionBoxGetChild(pSaveAs->saveAs_form,
|
||||
* XmDIALOG_FILTER_TEXT));
|
||||
*XtUnmanageChild(XmFileSelectionBoxGetChild(pSaveAs->saveAs_form,
|
||||
* XmDIALOG_FILTER_LABEL));
|
||||
*/
|
||||
|
||||
/* -----> Set the useAsyncGeo on the shell */
|
||||
n = 0;
|
||||
XtSetArg(args[n], XmNuseAsyncGeometry, True); n++;
|
||||
XtSetValues (pPad->app_shell, args, n);
|
||||
|
||||
/* -----> Set the ok button to the default for the bulletin board.
|
||||
* This causes the return key from the text widget to be properly
|
||||
* processed. */
|
||||
XtSetArg(args[0], XmNdefaultButton,
|
||||
XmFileSelectionBoxGetChild(pSaveAs->saveAs_form,
|
||||
XmDIALOG_OK_BUTTON));
|
||||
XtSetValues (pSaveAs->saveAs_form, args, 1);
|
||||
|
||||
/* -----> Create a radio box with two toggle buttons for either adding
|
||||
* or not adding new lines if word wrap mode is on. */
|
||||
CreateNewLineToggles(pPad,
|
||||
pSaveAs->saveAs_form, /* parent widget */
|
||||
&pSaveAs->toggleWidgets); /* new widgets */
|
||||
|
||||
_DtTurnOffHourGlass(pPad->app_shell);
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* ExtractAndStoreDir - extracts the directory from the specified
|
||||
* /dir/filename and stores it in pPad->fileStuff.pathDir.
|
||||
************************************************************************/
|
||||
void
|
||||
ExtractAndStoreDir(
|
||||
Editor *pPad,
|
||||
char *fileName,
|
||||
short type)
|
||||
{
|
||||
char *pFirstSlash, *pLastSlash;
|
||||
|
||||
pFirstSlash = MbStrchr(fileName, '/');
|
||||
if(type == OPEN) {
|
||||
if (pFirstSlash != (char *)NULL) {
|
||||
pLastSlash = MbStrrchr(fileName, '/');
|
||||
strncpy(pPad->fileStuff.pathDir, pFirstSlash,
|
||||
pLastSlash - pFirstSlash + 1);
|
||||
pPad->fileStuff.pathDir[pLastSlash - pFirstSlash + 1] = '\0';
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (pFirstSlash != (char *)NULL) {
|
||||
pLastSlash = MbStrrchr(fileName, '/');
|
||||
strncpy(pPad->fileStuff.includePathDir, pFirstSlash,
|
||||
pLastSlash - pFirstSlash + 1);
|
||||
pPad->fileStuff.includePathDir[pLastSlash - pFirstSlash + 1] = '\0';
|
||||
if(pPad->fileStuff.lastIncludeName != NULL)
|
||||
XtFree(pPad->fileStuff.lastIncludeName);
|
||||
pLastSlash++;
|
||||
pPad->fileStuff.lastIncludeName = XtNewString(pLastSlash);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* GetFileName - Ask for a file name via an Xm File Selection Box
|
||||
************************************************************************/
|
||||
void
|
||||
GetFileName(
|
||||
Editor *pPad,
|
||||
XmString title,
|
||||
short type)
|
||||
{
|
||||
char dirbuf[MAX_DIR_PATH_LEN];
|
||||
Arg al[5];
|
||||
int ac;
|
||||
int firstSelect = -1;
|
||||
XmString dirString, tmpStr;
|
||||
Select *pSelect = &pPad->fileStuff.fileWidgets.select;
|
||||
FileStuff *pStuff = &pPad->fileStuff;
|
||||
|
||||
dirbuf[0] = (char) '\0';
|
||||
|
||||
_DtTurnOnHourGlass(pPad->app_shell);
|
||||
|
||||
/* -----> create the FSB if it doesn't exits */
|
||||
if (pSelect->file_dialog == NULL) {
|
||||
CreateFileSelectionDialog(pPad);
|
||||
}
|
||||
|
||||
/* Just in case, it was unmanaged */
|
||||
XtManageChild(pSelect->file_dialog);
|
||||
|
||||
/* -----> set the FSB "ok" and "help" button callbacks */
|
||||
XtRemoveAllCallbacks(pSelect->file_dialog, XmNokCallback);
|
||||
XtAddCallback(pSelect->file_dialog, XmNokCallback,
|
||||
(XtCallbackProc) pStuff->pendingFileFunc,
|
||||
(XtPointer)pPad);
|
||||
pStuff->pendingFileFunc = (void(*)())NULL;
|
||||
XtRemoveAllCallbacks(pSelect->file_dialog, XmNhelpCallback);
|
||||
XtAddCallback(pSelect->file_dialog, XmNhelpCallback,
|
||||
(XtCallbackProc) pStuff->pendingFileHelpFunc,
|
||||
(XtPointer)pPad);
|
||||
pStuff->pendingFileHelpFunc = (void (*)())NULL;
|
||||
|
||||
/* -----> seed FSB directory from either fileName */
|
||||
if(type == OPEN) {
|
||||
if (pStuff->pathDir[0] == (char)'\0') {
|
||||
if (pStuff->fileName != NULL) {
|
||||
/* set pStuff->pathDir*/
|
||||
ExtractAndStoreDir(pPad, pStuff->fileName, OPEN);
|
||||
}
|
||||
else {
|
||||
if (pStuff->pathDir[0] != (char)'\0')
|
||||
strcpy(dirbuf, pStuff->pathDir);
|
||||
/* -----> make sure dir ends in '/' */
|
||||
if (dirbuf[0] != (char )'\0') {
|
||||
if (dirbuf[strlen(dirbuf) - 1] != (char)'/')
|
||||
strcat(dirbuf, "/");
|
||||
} else {
|
||||
getcwd(dirbuf, MAX_DIR_PATH_LEN - 16);
|
||||
strcat(dirbuf, "/");
|
||||
}
|
||||
|
||||
firstSelect = strlen(dirbuf);
|
||||
strcat(dirbuf, "[^.]*");
|
||||
dirString = XmStringCreateLocalized(dirbuf);
|
||||
ac = 0;
|
||||
XtSetArg(al[ac], XmNdirMask, dirString); ac++;
|
||||
XtSetValues(pStuff->fileWidgets.select.file_dialog, al, ac);
|
||||
XmStringFree(dirString);
|
||||
}
|
||||
}
|
||||
|
||||
if (pStuff->pathDir[0] != (char)'\0') {
|
||||
tmpStr = XmStringCreateLocalized(pStuff->pathDir);
|
||||
XtSetArg(al[0], XmNdirectory, tmpStr);
|
||||
XtSetValues(pSelect->file_dialog, al, 1);
|
||||
XmStringFree(tmpStr);
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* -----> seed FSB directory with include dir */
|
||||
if (pStuff->includePathDir[0] == (char)'\0') {
|
||||
if (pStuff->fileName != (char *)NULL) {
|
||||
/* set pStuff->pathDir*/
|
||||
ExtractAndStoreDir(pPad, pStuff->fileName, INCLUDE);
|
||||
}
|
||||
}
|
||||
if (pStuff->includePathDir[0] != (char)'\0') {
|
||||
tmpStr = XmStringCreateLocalized(pStuff->includePathDir);
|
||||
XtSetArg(al[0], XmNdirectory, tmpStr);
|
||||
XtSetValues(pSelect->file_dialog, al, 1);
|
||||
XmStringFree(tmpStr);
|
||||
}
|
||||
}
|
||||
|
||||
/* -----> find the seeded directory */
|
||||
/*XmFileSelectionDoSearch(pSelect->file_dialog, NULL);*/
|
||||
|
||||
/* -----> set the FSB title (as passed in) */
|
||||
XtSetArg(al[0], XmNdialogTitle, title);
|
||||
XtSetValues(pSelect->file_dialog, al, 1);
|
||||
|
||||
/* -----> delete the first entry from the list of dirs
|
||||
* if(!pPad->nodo) {
|
||||
* XmListDeletePos(pSelect->dir_list, 1);
|
||||
* }
|
||||
*/
|
||||
pPad->nodo = False;
|
||||
|
||||
if(type == INCLUDE) {
|
||||
if(pStuff->lastIncludeName != NULL) {
|
||||
tmpStr = XmStringCreateLocalized(pStuff->lastIncludeName);
|
||||
XmListSelectItem(XmFileSelectionBoxGetChild(pSelect->file_dialog,
|
||||
XmDIALOG_LIST), tmpStr, False);
|
||||
XtSetArg(al[0], XmNtextString, tmpStr);
|
||||
XtSetValues(pSelect->file_dialog, al, 1);
|
||||
XmStringFree(tmpStr);
|
||||
}
|
||||
}
|
||||
|
||||
/* -----> manage the FSB */
|
||||
XtManageChild (pSelect->file_dialog);
|
||||
XmProcessTraversal(XmFileSelectionBoxGetChild(pSelect->file_dialog,
|
||||
XmDIALOG_TEXT), XmTRAVERSE_CURRENT);
|
||||
XSync(pPad->display, 0);
|
||||
|
||||
_DtTurnOffHourGlass(pPad->app_shell);
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* CreateFileSelectionDialog -
|
||||
************************************************************************/
|
||||
static void
|
||||
CreateFileSelectionDialog(
|
||||
Editor *pPad )
|
||||
{
|
||||
Arg al[10]; /* arg list */
|
||||
register int ac; /* arg count */
|
||||
XmString tmpStr;
|
||||
Select *pSelect = &pPad->fileStuff.fileWidgets.select;
|
||||
|
||||
ac = 0;
|
||||
tmpStr = XmStringCreateLocalized((char *)GETMESSAGE(2, 1, "Help"));
|
||||
XtSetArg (al[ac], XmNhelpLabelString, tmpStr); ac++;
|
||||
|
||||
pSelect->file_dialog = XmCreateFileSelectionDialog(pPad->app_shell,
|
||||
"file_sel_dlg", al, ac);
|
||||
XmStringFree(tmpStr);
|
||||
|
||||
XtAddCallback(pSelect->file_dialog, XmNcancelCallback,
|
||||
(XtCallbackProc) CancelFileSelectCB, (XtPointer)pPad );
|
||||
|
||||
XtRealizeWidget (pSelect->file_dialog);
|
||||
XSync(pPad->display, 0);
|
||||
|
||||
/* XXX
|
||||
* pSelect->dir_list = FS_DirList(pSelect->file_dialog);
|
||||
*/
|
||||
|
||||
pSelect->filter_text = XmFileSelectionBoxGetChild(pSelect->file_dialog,
|
||||
XmDIALOG_FILTER_TEXT);
|
||||
pSelect->select_text = XmFileSelectionBoxGetChild(pSelect->file_dialog,
|
||||
XmDIALOG_TEXT);
|
||||
pSelect->file_list = XmFileSelectionBoxGetChild(pSelect->file_dialog,
|
||||
XmDIALOG_LIST);
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* CreateSaveWarning - Builds a PromptDialog to ask if the current contents
|
||||
* are to be saved prior to some operation. Also used to ask if new
|
||||
* lines characters are to be inserted when word wrap is on.
|
||||
*
|
||||
* PromptDialog
|
||||
* (message) (unmanaged)
|
||||
* (text input region) (unmanaged)
|
||||
* Form work area
|
||||
* RowColumn horz orientation
|
||||
* LabelGadget exclamation symbol
|
||||
* LabelGadget prompt text
|
||||
* Separator
|
||||
* RadioBox contains two new line toggles
|
||||
* (buttons) OK, Apply, Cancel, Help
|
||||
*
|
||||
* The RadioBox is managed only if wordwrap is on.
|
||||
*
|
||||
************************************************************************/
|
||||
static void
|
||||
CreateSaveWarning(
|
||||
Editor *pPad )
|
||||
{
|
||||
Arg al[10]; /* arg list */
|
||||
register int ac; /* arg count */
|
||||
char buf[256];
|
||||
Widget w, kid[5];
|
||||
Pixel foreground, background;
|
||||
Pixmap pixmap; /* dialog pixmap */
|
||||
XmString tmpStr1, tmpStr2, tmpStr3, tmpStr4, tmpStr5;
|
||||
Select *pSelect = &pPad->fileStuff.fileWidgets.select;
|
||||
|
||||
/* -----> Create a SelectionBox PromptDialog with appropriate title and
|
||||
* button labels */
|
||||
tmpStr1 = XmStringCreateLocalized(((char *)GETMESSAGE(5, 14, "No")));
|
||||
tmpStr2 = XmStringCreateLocalized(((char *)GETMESSAGE(5, 15, "Yes")));
|
||||
strcpy(buf, DialogTitle(pPad));
|
||||
strcat(buf, (char *)GETMESSAGE(5, 16, "Save?"));
|
||||
tmpStr3 = XmStringCreateLocalized(buf);
|
||||
tmpStr4 = XmStringCreateLocalized(((char *)GETMESSAGE(2, 1, "Help")));
|
||||
tmpStr5 = XmStringCreateLocalized((String) _DtCancelString);
|
||||
ac = 0;
|
||||
XtSetArg(al[ac], XmNapplyLabelString, tmpStr1); ac++;
|
||||
XtSetArg(al[ac], XmNokLabelString, tmpStr2); ac++;
|
||||
XtSetArg(al[ac], XmNdialogTitle, tmpStr3); ac++;
|
||||
XtSetArg(al[ac], XmNhelpLabelString, tmpStr4); ac++;
|
||||
XtSetArg(al[ac], XmNcancelLabelString, tmpStr5); ac++;
|
||||
XtSetArg(al[ac], XmNmwmFunctions, MWM_FUNC_MOVE | MWM_FUNC_CLOSE); ac++;
|
||||
XtSetArg(al[ac], XmNmwmDecorations, MWM_DECOR_BORDER | MWM_DECOR_TITLE);
|
||||
ac++;
|
||||
XtSetArg (al[ac], XmNallowShellResize, False); ac++;
|
||||
pSelect->save_warning = XmCreatePromptDialog(pPad->app_shell, "save_warn",
|
||||
al, ac);
|
||||
XmStringFree(tmpStr1);
|
||||
XmStringFree(tmpStr2);
|
||||
XmStringFree(tmpStr3);
|
||||
XmStringFree(tmpStr4);
|
||||
XmStringFree(tmpStr5);
|
||||
|
||||
/* -----> Set the dialog input mode */
|
||||
ac=0;
|
||||
XtSetArg(al[ac], XmNmwmInputMode, MWM_INPUT_PRIMARY_APPLICATION_MODAL);ac++;
|
||||
XtSetValues(XtParent(pSelect->save_warning), al, ac);
|
||||
|
||||
/* -----> Create Form to contain the prompt symbol and text (in a RowColumn)
|
||||
* and the "insert new lines?" toggles (in a RadioBox) */
|
||||
ac = 0;
|
||||
XtSetArg(al[ac], XmNshadowThickness, 0); ac++;
|
||||
pSelect->work_area = XmCreateForm(pSelect->save_warning, "wkarea", al, ac);
|
||||
XtManageChild(pSelect->work_area);
|
||||
|
||||
/* -----> Create a horizontal RowColumn container for the warning symbol
|
||||
* and text prompt */
|
||||
ac = 0;
|
||||
XtSetArg(al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
|
||||
XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
|
||||
XtSetArg(al[ac], XmNorientation, XmHORIZONTAL); ac++;
|
||||
pSelect->row_col = XmCreateRowColumn(pSelect->work_area, "rowCol", al, ac);
|
||||
XtManageChild(pSelect->row_col);
|
||||
|
||||
/* -----> Place the warning symbol in RowColumn container */
|
||||
ac = 0;
|
||||
XtSetArg(al[ac], XmNforeground, &foreground); ac++;
|
||||
XtSetArg(al[ac], XmNbackground, &background); ac++;
|
||||
XtGetValues(pSelect->save_warning, al, ac);
|
||||
ac = 0;
|
||||
XtSetArg(al[ac], XmNlabelType, XmPIXMAP); ac++;
|
||||
pixmap = XmGetPixmap(XtScreen(pSelect->save_warning), "warn_image",
|
||||
foreground, background);
|
||||
XtSetArg(al[ac], XmNlabelPixmap, pixmap); ac++;
|
||||
w = XmCreateLabelGadget(pSelect->row_col, "pixmap_label", al, ac);
|
||||
XtManageChild(w);
|
||||
|
||||
/* -----> Place the prompt string in the RowColumn container
|
||||
* (the prompt string is set in AskIfSave() based on whether
|
||||
* or not a file name has been specified among other things) */
|
||||
ac = 0;
|
||||
pSelect->wkArea_textLabel = XmCreateLabelGadget(pSelect->row_col,
|
||||
"txt_lab", al, ac);
|
||||
XtManageChild(pSelect->wkArea_textLabel);
|
||||
|
||||
|
||||
/* -----> Create a separator between message and new line toggles */
|
||||
ac = 0;
|
||||
XtSetArg(al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
|
||||
XtSetArg(al[ac], XmNtopWidget, pSelect->row_col); ac++;
|
||||
XtSetArg(al[ac], XmNtopOffset, 5); ac++;
|
||||
XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
|
||||
XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
|
||||
pSelect->separator = XmCreateSeparator(pSelect->work_area, "sep", al, ac);
|
||||
if (pPad->xrdb.wordWrap == True)
|
||||
XtManageChild(pSelect->separator);
|
||||
|
||||
/* -----> Create a radio box with two toggle buttons for either adding
|
||||
* or not adding new lines if word wrap mode is on. */
|
||||
CreateNewLineToggles(pPad,
|
||||
pSelect->work_area, /* parent widget */
|
||||
&pSelect->toggleWidgets); /* new widgets */
|
||||
|
||||
/* -----> Place toggle buttons below separator */
|
||||
ac = 0;
|
||||
XtSetArg(al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
|
||||
XtSetArg(al[ac], XmNtopWidget, pSelect->separator); ac++;
|
||||
XtSetArg(al[ac], XmNtopOffset, 5); ac++;
|
||||
XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
|
||||
XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
|
||||
XtSetValues(pSelect->toggleWidgets.newl_radio, al, ac);
|
||||
|
||||
/* -----> manage the apply button of the SelectionBox PromptDialog */
|
||||
w = XmSelectionBoxGetChild (pSelect->save_warning, XmDIALOG_APPLY_BUTTON);
|
||||
XtManageChild(w);
|
||||
|
||||
/* -----> don't need the SelectionBox PromptDialog text input field and
|
||||
* label */
|
||||
ac = 0;
|
||||
kid[ac++] = XmSelectionBoxGetChild (pSelect->save_warning, XmDIALOG_TEXT);
|
||||
kid[ac++] = XmSelectionBoxGetChild (pSelect->save_warning,
|
||||
XmDIALOG_SELECTION_LABEL);
|
||||
XtUnmanageChildren (kid, ac);
|
||||
|
||||
/* -----> set the SelectionBox PromptDialog [No] [Cancel] [Help] callbacks
|
||||
* (the [Yes] XmNokCallback is set in AskIfSave() based on whether
|
||||
* or not a file name has been specified among other things) */
|
||||
XtAddCallback(pSelect->save_warning, XmNapplyCallback,
|
||||
(XtCallbackProc) NoSaveCB, (XtPointer) pPad);
|
||||
XtAddCallback(pSelect->save_warning, XmNcancelCallback,
|
||||
(XtCallbackProc) AskIfSaveCancelCB, (XtPointer) pPad);
|
||||
XtAddCallback(pSelect->save_warning, XmNhelpCallback,
|
||||
(XtCallbackProc) HelpAskIfSaveDialogCB, (XtPointer) pPad);
|
||||
|
||||
/* -----> save the widget id of the Cancel button so that it can be
|
||||
* unmanaged (in AskIfSave) if a "forced" TTDT_QUIT is being
|
||||
* processed */
|
||||
pSelect->cancelBtn = XmSelectionBoxGetChild(
|
||||
pSelect->save_warning, XmDIALOG_APPLY_BUTTON);
|
||||
|
||||
XtRealizeWidget(pSelect->save_warning);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* Warning - posts a information/warning/error message dialog
|
||||
************************************************************************/
|
||||
void
|
||||
Warning(
|
||||
Editor *pPad,
|
||||
char *mess ,
|
||||
unsigned char dialogType)
|
||||
{
|
||||
Arg al[10];
|
||||
int ac;
|
||||
char *tmpMess, buf[256];
|
||||
FileWidgets *pFileWidgets = &pPad->fileStuff.fileWidgets;
|
||||
XmString tempStr;
|
||||
|
||||
tmpMess = strdup(mess);
|
||||
|
||||
/* create the dialog if it is the first time */
|
||||
if (!pFileWidgets->gen_warning)
|
||||
{
|
||||
ac = 0;
|
||||
XtSetArg(al[ac], XmNokLabelString,
|
||||
XmStringCreateLocalized((String) _DtOkString)); ac++;
|
||||
pFileWidgets->gen_warning = XmCreateMessageDialog (pPad->app_shell,
|
||||
"Warn", al, ac);
|
||||
/* Unmanage unneeded children. */
|
||||
XtUnmanageChild(XmMessageBoxGetChild(pFileWidgets->gen_warning,
|
||||
XmDIALOG_CANCEL_BUTTON) );
|
||||
XtUnmanageChild(XmMessageBoxGetChild(pFileWidgets->gen_warning,
|
||||
XmDIALOG_HELP_BUTTON) );
|
||||
|
||||
XtRealizeWidget(pFileWidgets->gen_warning);
|
||||
ac=0;
|
||||
XtSetArg(al[ac], XmNmwmInputMode,
|
||||
MWM_INPUT_PRIMARY_APPLICATION_MODAL);ac++;
|
||||
XtSetValues(XtParent(pFileWidgets->gen_warning), al, ac);
|
||||
}
|
||||
|
||||
strcpy(buf, DialogTitle(pPad));
|
||||
switch(dialogType)
|
||||
{
|
||||
case XmDIALOG_ERROR:
|
||||
strcat(buf, (char *)GETMESSAGE(5, 17, "Error"));
|
||||
break;
|
||||
case XmDIALOG_INFORMATION:
|
||||
strcat(buf, (char *)GETMESSAGE(5, 20, "Information"));
|
||||
break;
|
||||
case XmDIALOG_WARNING:
|
||||
default:
|
||||
strcat(buf, (char *)GETMESSAGE(5, 6, "Warning"));
|
||||
break;
|
||||
}
|
||||
|
||||
ac = 0;
|
||||
tempStr = XmStringCreateLocalized(buf);
|
||||
XtSetArg(al[ac], XmNdialogTitle, tempStr); ac++;
|
||||
XtSetArg(al[ac], XmNdialogType, dialogType); ac++;
|
||||
XtSetArg(al[ac], XmNmessageString,
|
||||
XmStringCreateLocalized(tmpMess)); ac++;
|
||||
XtSetValues(pFileWidgets->gen_warning, al, ac);
|
||||
XmStringFree(tempStr);
|
||||
|
||||
XtManageChild (pFileWidgets->gen_warning);
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* PostSaveError - posts a dialog displaying the status returned by
|
||||
* DtEditorSaveContentsToFile() (when called by the "File" menu
|
||||
* callbacks).
|
||||
************************************************************************/
|
||||
void
|
||||
PostSaveError(
|
||||
Editor *pPad,
|
||||
char *saveName,
|
||||
DtEditorErrorCode errorCode)
|
||||
{
|
||||
char errorMsg[256], *errorReason;
|
||||
|
||||
/* -----> determine the reason why save failed */
|
||||
switch(errorCode) {
|
||||
case DtEDITOR_NO_ERRORS:
|
||||
return;
|
||||
case DtEDITOR_INVALID_FILENAME:
|
||||
Warning(pPad, ((char *)
|
||||
GETMESSAGE(5, 31, "Unable to save file.\nFile name was not specified.")),
|
||||
XmDIALOG_ERROR);
|
||||
return;
|
||||
case DtEDITOR_UNWRITABLE_FILE:
|
||||
errorReason = strdup( (char *)
|
||||
GETMESSAGE(5, 46, "Either file is unwritable or path to\nfile does not exist."));
|
||||
break;
|
||||
case DtEDITOR_DIRECTORY:
|
||||
errorReason = strdup((char *)
|
||||
GETMESSAGE(5, 35, "File is a directory."));
|
||||
break;
|
||||
case DtEDITOR_CHAR_SPECIAL_FILE:
|
||||
errorReason = strdup((char *)
|
||||
GETMESSAGE(5, 36, "File is a character special device."));
|
||||
break;
|
||||
case DtEDITOR_BLOCK_MODE_FILE:
|
||||
errorReason = strdup((char *)
|
||||
GETMESSAGE(5, 37, "File is a block mode device."));
|
||||
break;
|
||||
case DtEDITOR_INSUFFICIENT_MEMORY:
|
||||
errorReason = strdup((char *)
|
||||
GETMESSAGE(5, 47, "Operation failed due to insufficient memory.\nTry increasing swap space."));
|
||||
break;
|
||||
case DtEDITOR_INVALID_TYPE: /* this should never occur */
|
||||
errorReason = strdup((char *)
|
||||
GETMESSAGE(5, 38, "Invalid file format."));
|
||||
break;
|
||||
case DtEDITOR_SAVE_FAILED: /* this should catch everything else */
|
||||
default: /* - but just in case */
|
||||
errorReason = strdup((char *)
|
||||
GETMESSAGE(5, 39, "Unknown reason - possibly not enough disk space."));
|
||||
break;
|
||||
}
|
||||
|
||||
/* -----> format and display error messages containing the
|
||||
* file name and reason why the save failed */
|
||||
sprintf(errorMsg,
|
||||
(char *) GETMESSAGE(5, 30, "Unable to save %1$s.\n%2$s"),
|
||||
saveName,
|
||||
errorReason);
|
||||
Warning(pPad, errorMsg, XmDIALOG_ERROR);
|
||||
free(errorReason);
|
||||
|
||||
if (pPad->fileStuff.pendingFileFunc == FileExitCB) {
|
||||
TTfailPendingQuit(pPad);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* AskIfSave - creates a dialog and corresponding "o.k." button callback
|
||||
* to save the current text to a file. The dialog message and
|
||||
* o.k. callback depend on whether or not a name is associated
|
||||
* with the text.
|
||||
************************************************************************/
|
||||
void
|
||||
AskIfSave(
|
||||
Editor *pPad)
|
||||
{
|
||||
Arg al[10]; /* arg list */
|
||||
register int ac; /* arg count */
|
||||
char *tmp = NULL;
|
||||
XmString tmpStr;
|
||||
Select *pSelect = &pPad->fileStuff.fileWidgets.select;
|
||||
|
||||
if (pSelect->save_warning == (Widget) NULL)
|
||||
CreateSaveWarning(pPad);
|
||||
|
||||
if (pPad->ttQuitReq.contract && pPad->ttQuitReq.force) {
|
||||
XtUnmanageChild(pSelect->cancelBtn);
|
||||
} else {
|
||||
XtManageChild(pSelect->cancelBtn);
|
||||
}
|
||||
|
||||
XtRemoveAllCallbacks(pSelect->save_warning, XmNokCallback);
|
||||
|
||||
if (pPad->ttEditReq.contract &&
|
||||
pPad->ttEditReq.docName && *pPad->ttEditReq.docName) {
|
||||
/* -----> TT docName supplied in media request, so ask:
|
||||
* "Save changes to "<docName>"?" */
|
||||
tmp = (char *)XtMalloc(strlen(SAVE_CH_DOC) +
|
||||
strlen(pPad->ttEditReq.docName) + 4);
|
||||
sprintf(tmp,SAVE_CH_DOC, pPad->ttEditReq.docName);
|
||||
XtAddCallback(pSelect->save_warning, XmNokCallback,
|
||||
(XtCallbackProc) FileSaveCB, (XtPointer) pPad);
|
||||
} else if (pPad->fileStuff.fileName && *pPad->fileStuff.fileName) {
|
||||
/* -----> TT or non-TT filename given, so ask:
|
||||
* "Save changes to <file>?" */
|
||||
tmp = (char *)XtMalloc(strlen(SAVE_CH) +
|
||||
strlen(pPad->fileStuff.fileName) + 4);
|
||||
sprintf(tmp,SAVE_CH, pPad->fileStuff.fileName);
|
||||
XtAddCallback(pSelect->save_warning, XmNokCallback,
|
||||
(XtCallbackProc) FileSaveCB, (XtPointer) pPad);
|
||||
} else if (pPad->ttEditReq.contract && pPad->ttEditReq.contents) {
|
||||
/* -----> TT buffer being edited w/o a docName, so simply ask:
|
||||
* "Save Changes?" */
|
||||
tmp = (char *)XtMalloc(strlen(SAVE_CH_BUF) + 4);
|
||||
sprintf(tmp,"%s",SAVE_CH_BUF);
|
||||
XtAddCallback(pSelect->save_warning, XmNokCallback,
|
||||
(XtCallbackProc) FileSaveCB, (XtPointer) pPad);
|
||||
} else {
|
||||
/* -----> no file/doc name (and not a TT buffer), so ask:
|
||||
* "File has no name. Do you wash to save it?" */
|
||||
tmp = (char *)XtMalloc(strlen(SAVE_CH_NONAME) + 4);
|
||||
sprintf(tmp,"%s",SAVE_CH_NONAME);
|
||||
XtAddCallback(pSelect->save_warning, XmNokCallback,
|
||||
(XtCallbackProc) FileSaveAsCB, (XtPointer) pPad);
|
||||
}
|
||||
|
||||
tmpStr = XmStringCreateLocalized(tmp);
|
||||
ac = 0;
|
||||
XtSetArg(al[ac], XmNlabelString, tmpStr); ac++;
|
||||
XtSetValues(pSelect->wkArea_textLabel, al, ac);
|
||||
XmStringFree(tmpStr);
|
||||
XtFree(tmp);
|
||||
|
||||
/*
|
||||
* Make sure that the AskIfSave will be visible in case the
|
||||
* main window is iconified and the user is closing the window
|
||||
* from a window manager menu.
|
||||
*/
|
||||
XtPopup(pPad->app_shell, XtGrabNone);
|
||||
XtMapWidget(pPad->app_shell);
|
||||
|
||||
XtManageChild (pSelect->save_warning);
|
||||
XmProcessTraversal(XmSelectionBoxGetChild(pSelect->save_warning,
|
||||
XmDIALOG_OK_BUTTON), XmTRAVERSE_CURRENT);
|
||||
}
|
||||
|
||||
char*
|
||||
DialogTitle(Editor *pPad)
|
||||
{
|
||||
if (pPad->dialogTitle == NULL)
|
||||
pPad->dialogTitle = strdup((char *)GETMESSAGE(7, 2, "Text Editor - "));
|
||||
|
||||
return pPad->dialogTitle;
|
||||
}
|
||||
369
cde/programs/dtpad/fileIo.c
Normal file
369
cde/programs/dtpad/fileIo.c
Normal file
@@ -0,0 +1,369 @@
|
||||
/* $XConsortium: fileIo.c /main/4 1996/10/04 17:24:28 drk $ */
|
||||
/**********************************<+>*************************************
|
||||
***************************************************************************
|
||||
**
|
||||
** File: fileIo.c
|
||||
**
|
||||
** Project: DT dtpad, a memo maker type editor based on the Dt Editor
|
||||
** widget.
|
||||
**
|
||||
** Description:
|
||||
** -----------
|
||||
**
|
||||
*******************************************************************
|
||||
** (c) Copyright Hewlett-Packard Company, 1991, 1992. All rights are
|
||||
** reserved. Copying or other reproduction of this program
|
||||
** except for archival purposes is prohibited without prior
|
||||
** written consent of Hewlett-Packard Company.
|
||||
********************************************************************
|
||||
**
|
||||
********************************************************************
|
||||
** (c) Copyright 1993, 1994 Hewlett-Packard Company
|
||||
** (c) Copyright 1993, 1994 International Business Machines Corp.
|
||||
** (c) Copyright 1993, 1994 Sun Microsystems, Inc.
|
||||
** (c) Copyright 1993, 1994 Novell, Inc.
|
||||
********************************************************************
|
||||
**
|
||||
** ToDo: roll in fixes for 10.0 ivepad
|
||||
**
|
||||
**
|
||||
**************************************************************************
|
||||
**********************************<+>*************************************/
|
||||
#include "dtpad.h"
|
||||
#include <Xm/TextP.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
#include <Xm/TextF.h>
|
||||
#include <Xm/LabelG.h>
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* LoadFile - Opens the specified file and loads its contents to the
|
||||
* DtEditor widget.
|
||||
*
|
||||
* The filename is specified either by pPad->fileStuff.fileName or
|
||||
* the 'include' argument. If the filename is specified via include,
|
||||
* the file is inserted at the current cursor location. In both
|
||||
* instances, the filename is assumed to be relative to the local host
|
||||
* where dtpad is running.
|
||||
*
|
||||
************************************************************************/
|
||||
/* [SuG 5/18/95] Done
|
||||
The NOT_SAMPLE warnings/errors need to be added to the message
|
||||
catalog. Removed ifdefs.*/
|
||||
|
||||
void
|
||||
LoadFile(
|
||||
Editor *pPad,
|
||||
char *include)
|
||||
{
|
||||
char * localName;
|
||||
DtEditorErrorCode errorCode;
|
||||
DtEditorContentRec contentRec;
|
||||
Boolean fileLoaded = False;
|
||||
Boolean fileLoadError = False;
|
||||
|
||||
|
||||
if (include != (char *)NULL) {
|
||||
localName = include;
|
||||
} else {
|
||||
localName = pPad->fileStuff.fileName;
|
||||
pPad->fileStuff.readOnly = False;
|
||||
}
|
||||
|
||||
if (localName && *localName) {
|
||||
/* try to load the file to the Dt Editor widget */
|
||||
_DtTurnOnHourGlass(pPad->app_shell);
|
||||
XSync(XtDisplay(pPad->editor), False);
|
||||
if (include != (char *) NULL) {
|
||||
errorCode = DtEditorInsertFromFile(
|
||||
pPad->editor,
|
||||
localName);
|
||||
} else {
|
||||
pPad->fileStuff.fileExists = True;
|
||||
errorCode = DtEditorSetContentsFromFile(
|
||||
pPad->editor,
|
||||
localName);
|
||||
}
|
||||
_DtTurnOffHourGlass(pPad->app_shell);
|
||||
switch (errorCode) {
|
||||
case DtEDITOR_NO_ERRORS: /* file is read/writeable */
|
||||
fileLoaded = True;
|
||||
break;
|
||||
case DtEDITOR_READ_ONLY_FILE:
|
||||
fileLoaded = True;
|
||||
if (include == (char *) NULL) {
|
||||
pPad->fileStuff.readOnly = True;
|
||||
if (pPad->xrdb.readOnlyWarning &&
|
||||
! pPad->xrdb.statusLine &&
|
||||
! pPad->xrdb.viewOnly) {
|
||||
Warning(pPad, (char *) GETMESSAGE(6, 1,
|
||||
"This file has been opened for reading only."),
|
||||
XmDIALOG_WARNING);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case DtEDITOR_NONEXISTENT_FILE:
|
||||
if (include != (char *) NULL ) {
|
||||
Warning(pPad, (char *) GETMESSAGE(6, 2,
|
||||
"This file does not exist."),
|
||||
XmDIALOG_ERROR);
|
||||
fileLoadError = True;
|
||||
} else if (pPad->xrdb.viewOnly) {
|
||||
Warning(pPad, (char *) GETMESSAGE(6, 2,
|
||||
"This file does not exist."),
|
||||
XmDIALOG_ERROR);
|
||||
} else if (pPad->xrdb.missingFileWarning) {
|
||||
Warning(pPad, (char *) GETMESSAGE(6, 2,
|
||||
"This file does not exist."),
|
||||
XmDIALOG_WARNING);
|
||||
}
|
||||
break;
|
||||
case DtEDITOR_DIRECTORY:
|
||||
Warning(pPad, (char *) GETMESSAGE(6, 3,
|
||||
"Unable to edit a Directory."),
|
||||
XmDIALOG_ERROR);
|
||||
fileLoadError = True;
|
||||
break;
|
||||
case DtEDITOR_CHAR_SPECIAL_FILE:
|
||||
Warning(pPad, (char *) GETMESSAGE(6, 4,
|
||||
"Unable to edit a character special device file."),
|
||||
XmDIALOG_ERROR);
|
||||
fileLoadError = True;
|
||||
break;
|
||||
case DtEDITOR_BLOCK_MODE_FILE:
|
||||
Warning(pPad, (char *) GETMESSAGE(6, 5,
|
||||
"Unable to edit a block mode device file."),
|
||||
XmDIALOG_ERROR);
|
||||
fileLoadError = True;
|
||||
break;
|
||||
case DtEDITOR_NULLS_REMOVED:
|
||||
Warning(pPad, (char *) GETMESSAGE(6, 6,
|
||||
"Embedded Nulls stripped from file."),
|
||||
XmDIALOG_WARNING);
|
||||
fileLoaded = True;
|
||||
break;
|
||||
case DtEDITOR_INSUFFICIENT_MEMORY:
|
||||
Warning(pPad, (char*) GETMESSAGE(6, 7,
|
||||
"Unable to load file (insufficient memory)."),
|
||||
XmDIALOG_ERROR);
|
||||
fileLoadError = True;
|
||||
break;
|
||||
case DtEDITOR_NO_FILE_ACCESS:
|
||||
Warning(pPad, (char *) GETMESSAGE(6, 8,
|
||||
"Unable to access file (can't determine its status)."),
|
||||
XmDIALOG_ERROR);
|
||||
fileLoadError = True;
|
||||
break;
|
||||
case DtEDITOR_UNREADABLE_FILE:
|
||||
Warning(pPad, (char *) GETMESSAGE(6, 9,
|
||||
"Unable to read from the file (probably no read permission)."),
|
||||
XmDIALOG_ERROR);
|
||||
fileLoadError = True;
|
||||
break;
|
||||
default:
|
||||
Warning(pPad, (char *) GETMESSAGE(6, 12,
|
||||
"Unable to read from the file (unknown reason)."),
|
||||
XmDIALOG_ERROR);
|
||||
fileLoadError = True;
|
||||
break;
|
||||
} /* switch (errorCode) */
|
||||
} /* file name specified */
|
||||
|
||||
if (include != (char *)NULL)
|
||||
return;
|
||||
|
||||
/*
|
||||
* We only get this far if the current file was to be changed
|
||||
* (i.e. the file was not included)
|
||||
*/
|
||||
SetStatusLineMsg(pPad); /* set readOnly/viewOnly in status line msg */
|
||||
|
||||
if (fileLoaded) {
|
||||
pPad->fileStuff.fileExists = True;
|
||||
} else {
|
||||
pPad->fileStuff.fileExists = False;
|
||||
|
||||
/* null out Editor widget */
|
||||
contentRec.type = DtEDITOR_TEXT;
|
||||
contentRec.value.string = "";
|
||||
errorCode = DtEditorSetContents(pPad->editor, &contentRec);
|
||||
if (errorCode != DtEDITOR_NO_ERRORS)
|
||||
Warning(pPad,"Internal Error: Unable to NULL Editor Widget.",XmDIALOG_ERROR);
|
||||
|
||||
/* clear stale file stuff */
|
||||
if (fileLoadError) {
|
||||
if (pPad->fileStuff.fileName && *pPad->fileStuff.fileName)
|
||||
XtFree(pPad->fileStuff.fileName);
|
||||
pPad->fileStuff.fileName = NULL;
|
||||
ChangeMainWindowTitle(pPad);
|
||||
return;
|
||||
}
|
||||
|
||||
/* set the pathDir and fileName */
|
||||
if (pPad->fileStuff.fileName && *pPad->fileStuff.fileName) {
|
||||
char *lastSlash;
|
||||
|
||||
strcpy(pPad->fileStuff.pathDir, pPad->fileStuff.fileName);
|
||||
if ((lastSlash = MbStrrchr(pPad->fileStuff.pathDir, '/')) !=
|
||||
(char *)NULL) {
|
||||
*(lastSlash + 1) = (char)'\0';
|
||||
}
|
||||
|
||||
lastSlash = MbStrrchr(pPad->fileStuff.fileName, '/');
|
||||
if (lastSlash != (char *)NULL) {
|
||||
lastSlash++;
|
||||
} else {
|
||||
lastSlash = pPad->fileStuff.fileName;
|
||||
}
|
||||
if (*lastSlash == (char)'-' || *lastSlash == (char)'*') {
|
||||
XtFree(pPad->fileStuff.fileName);
|
||||
pPad->fileStuff.fileName = (char *)NULL;
|
||||
}
|
||||
}
|
||||
} /* ! fileLoaded */
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* GetTempFile - generates a file name for a temporary file that can be
|
||||
* used for writing.
|
||||
************************************************************************/
|
||||
char *
|
||||
GetTempFile(void)
|
||||
{
|
||||
char *tempname = (char *)XtMalloc(L_tmpnam); /* Temporary file name. */
|
||||
FILE *tfp;
|
||||
|
||||
(void)tmpnam(tempname);
|
||||
if ((tfp = fopen(tempname, "w")) == NULL)
|
||||
{
|
||||
pid_t pid;
|
||||
/*
|
||||
* If tmpnam fails, then try to create our own temp name.
|
||||
* Try a couple of different names if necessary.
|
||||
*/
|
||||
XtFree(tempname);
|
||||
tempname = XtMalloc(256);
|
||||
pid = getpid();
|
||||
sprintf(tempname, "/usr/tmp/editor%ld", (long)pid);
|
||||
if ((tfp = fopen(tempname, "w")) == NULL)
|
||||
{
|
||||
sprintf(tempname, "/tmp/editor%ld", (long)pid);
|
||||
if ((tfp = fopen(tempname, "w")) == NULL)
|
||||
{
|
||||
XtFree(tempname);
|
||||
return (char *)NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
fclose(tfp);
|
||||
return tempname;
|
||||
}
|
||||
|
||||
|
||||
extern Editor *pPadList; /* declared/set in main.c */
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* AddPound - add a "#" character to the beginning of the base name of
|
||||
* the file name passed in the nameBuf parameter. A pointer to the
|
||||
* new name is returned. The name is constructed in a static buffer.
|
||||
* If nameBuf is empty, it returns the file name "#UNTITLED#".
|
||||
************************************************************************/
|
||||
static char *
|
||||
AddPound(
|
||||
char *nameBuf)
|
||||
{
|
||||
char tempBuf[512];
|
||||
static char returnBuf[512];
|
||||
|
||||
if (nameBuf != (char *)NULL && nameBuf[0] != (char) '\0') {
|
||||
char *baseName;
|
||||
strcpy(tempBuf, nameBuf);
|
||||
baseName = MbStrrchr(tempBuf, '/');
|
||||
if (baseName != (char *)NULL) {
|
||||
strncpy(returnBuf, tempBuf, (baseName - tempBuf) + 1);
|
||||
returnBuf[(baseName - tempBuf) + 1] = (char)'\0';
|
||||
baseName++;
|
||||
strcat(returnBuf, "#");
|
||||
strcat(returnBuf, baseName);
|
||||
if (returnBuf[strlen(returnBuf) - 1] != (char)'#')
|
||||
strcat(returnBuf, "#");
|
||||
} else {
|
||||
sprintf(returnBuf, "#%s", tempBuf);
|
||||
if(returnBuf[strlen(returnBuf) - 1] != (char)'#')
|
||||
strcat(returnBuf, "#");
|
||||
}
|
||||
} else {
|
||||
sprintf(returnBuf, "#%s#", GETMESSAGE(5, 21, "UNTITLED"));
|
||||
}
|
||||
return returnBuf;
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* PanicSave - immediately saves the text for each edit session handled
|
||||
* by the text editor to #[#]<filename>.
|
||||
************************************************************************/
|
||||
void
|
||||
PanicSave(void)
|
||||
{
|
||||
Editor *pPad;
|
||||
struct stat statbuf; /* Information on a file. */
|
||||
Boolean addNewLines;
|
||||
DtEditorErrorCode errorCode;
|
||||
|
||||
for (pPad = pPadList; pPad != (Editor *)NULL; pPad = pPad->pNextPad) {
|
||||
char *fileName = pPad->fileStuff.fileName;
|
||||
if (pPad->inUse != True || pPad->editor == NULL ||
|
||||
(! DtEditorCheckForUnsavedChanges(pPad->editor)))
|
||||
continue;
|
||||
/* -----> Try to cook up a name for a file that doesn't already exist */
|
||||
fileName = AddPound(pPad->fileStuff.fileName);
|
||||
if (stat(fileName, &statbuf) == 0) {
|
||||
fileName = AddPound(fileName);
|
||||
if (stat(fileName, &statbuf) == 0) {
|
||||
fileName = AddPound(fileName);
|
||||
if (stat(fileName, &statbuf) == 0) {
|
||||
/* Give up. We've tried enough names. The user loses. */
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
addNewLines = pPad->xrdb.wordWrap == True &&
|
||||
pPad->fileStuff.saveWithNewlines == True;
|
||||
errorCode = DtEditorSaveContentsToFile(
|
||||
pPad->editor,
|
||||
fileName,
|
||||
False, /* don't overwrite existing file */
|
||||
addNewLines, /* replace soft line feeds? */
|
||||
False); /* don't mark contents as saved */
|
||||
|
||||
/* don't really care about errorCode since we're in a hurry and
|
||||
* can't do anything about it anyway */
|
||||
}
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* SetStatusLineMsg - sets the message (XmTextField) portion of the
|
||||
* DtEditor widget's status line based on whether the pad is in
|
||||
* viewOnly mode or the file being edited/displayed is readOnly.
|
||||
************************************************************************/
|
||||
/* ARGSUSED */
|
||||
void
|
||||
SetStatusLineMsg(
|
||||
Editor *pPad)
|
||||
{
|
||||
char *message="";
|
||||
|
||||
if (pPad->xrdb.viewOnly) {
|
||||
message = (char *) GETMESSAGE(6, 10, "View Only");
|
||||
} else if (pPad->fileStuff.readOnly) {
|
||||
message = (char *) GETMESSAGE(6, 11, "Read Only");
|
||||
}
|
||||
|
||||
XmTextFieldSetString(pPad->statusLineMsg, message);
|
||||
}
|
||||
117
cde/programs/dtpad/formatCB.c
Normal file
117
cde/programs/dtpad/formatCB.c
Normal file
@@ -0,0 +1,117 @@
|
||||
/* $TOG: formatCB.c /main/5 1999/09/15 14:29:27 mgreess $ */
|
||||
/**********************************<+>*************************************
|
||||
***************************************************************************
|
||||
**
|
||||
** File: formatCB.c
|
||||
**
|
||||
** Project: DT dtpad, a memo maker type editor based on the Dt Editor
|
||||
** widget.
|
||||
**
|
||||
** Description:
|
||||
** -----------
|
||||
**
|
||||
** This file contains the callbacks for the [Format] menu items.
|
||||
**
|
||||
*******************************************************************
|
||||
** (c) Copyright Hewlett-Packard Company, 1991, 1992. All rights are
|
||||
** reserved. Copying or other reproduction of this program
|
||||
** except for archival purposes is prohibited without prior
|
||||
** written consent of Hewlett-Packard Company.
|
||||
********************************************************************
|
||||
**
|
||||
********************************************************************
|
||||
** (c) Copyright 1993, 1994 Hewlett-Packard Company
|
||||
** (c) Copyright 1993, 1994 International Business Machines Corp.
|
||||
** (c) Copyright 1993, 1994 Sun Microsystems, Inc.
|
||||
** (c) Copyright 1993, 1994 Novell, Inc.
|
||||
********************************************************************
|
||||
**
|
||||
**
|
||||
**************************************************************************
|
||||
**********************************<+>*************************************/
|
||||
#include "dtpad.h"
|
||||
/* #include <Dt/HourGlass.h> */
|
||||
|
||||
/************************************************************************
|
||||
* FormatCB - [Format] menu, [Settings...] button
|
||||
************************************************************************/
|
||||
/* ARGSUSED */
|
||||
void
|
||||
FormatCB(
|
||||
Widget w,
|
||||
caddr_t client_data,
|
||||
caddr_t call_data)
|
||||
{
|
||||
Editor *pPad = (Editor *) client_data;
|
||||
DtEditorInvokeFormatDialog(pPad->editor);
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* FormatParaCB - [Format] menu, [Paragraph] button
|
||||
************************************************************************/
|
||||
/* ARGSUSED */
|
||||
void
|
||||
FormatParaCB(
|
||||
Widget w,
|
||||
caddr_t client_data,
|
||||
caddr_t call_data)
|
||||
{
|
||||
Editor *pPad = (Editor *) client_data;
|
||||
DtEditorErrorCode error = DtEDITOR_NO_ERRORS;
|
||||
|
||||
error = DtEditorFormat(pPad->editor, NULL, DtEDITOR_FORMAT_PARAGRAPH);
|
||||
if (DtEDITOR_NO_ERRORS != error)
|
||||
{
|
||||
switch(error)
|
||||
{
|
||||
case DtEDITOR_INSUFFICIENT_MEMORY:
|
||||
Warning(
|
||||
pPad,
|
||||
(char *) GETMESSAGE(5, 47, "Operation failed due to insufficient memory.\nTry increasing swap space."),
|
||||
XmDIALOG_ERROR);
|
||||
return;
|
||||
default:
|
||||
Warning(
|
||||
pPad,
|
||||
(char *) GETMESSAGE(5, 48, "Format operation failed."),
|
||||
XmDIALOG_ERROR);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* FormatAllCB - [Format] menu, [All] button
|
||||
************************************************************************/
|
||||
/* ARGSUSED */
|
||||
void
|
||||
FormatAllCB(
|
||||
Widget w,
|
||||
caddr_t client_data,
|
||||
caddr_t call_data)
|
||||
{
|
||||
Editor *pPad = (Editor *)client_data;
|
||||
DtEditorErrorCode error = DtEDITOR_NO_ERRORS;
|
||||
|
||||
error = DtEditorFormat(pPad->editor, NULL, DtEDITOR_FORMAT_ALL);
|
||||
if (DtEDITOR_NO_ERRORS != error)
|
||||
{
|
||||
switch(error)
|
||||
{
|
||||
case DtEDITOR_INSUFFICIENT_MEMORY:
|
||||
Warning(
|
||||
pPad,
|
||||
(char *) GETMESSAGE(5, 47, "Operation failed due to insufficient memory.\nTry increasing swap space."),
|
||||
XmDIALOG_ERROR);
|
||||
return;
|
||||
default:
|
||||
Warning(
|
||||
pPad,
|
||||
(char *) GETMESSAGE(5, 48, "Format operation failed."),
|
||||
XmDIALOG_ERROR);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
155
cde/programs/dtpad/help.h
Normal file
155
cde/programs/dtpad/help.h
Normal file
@@ -0,0 +1,155 @@
|
||||
/* $XConsortium: help.h /main/4 1996/04/16 16:42:05 mgreess $ */
|
||||
/**********************************<+>*************************************
|
||||
***************************************************************************
|
||||
**
|
||||
** File: help.h
|
||||
**
|
||||
** Project: DT dtpad, a memo maker type editor based on the Dt Editor
|
||||
** widget.
|
||||
**
|
||||
** Description:
|
||||
** -----------
|
||||
** This is the header file for the help related portions of dtpad.
|
||||
** It provides the help volume name and location ids for the various
|
||||
** help volume entry points accessed via the help callbacks in helpCB.c.
|
||||
**
|
||||
** For example, in the line
|
||||
**
|
||||
** #define FILE_MENU_HELP "fileMenu"
|
||||
**
|
||||
** FILE_MENU_HELP is used in helpCB.c to display help for the [File] pulldown
|
||||
** menu which is found in the dtpad help volume immediately following the
|
||||
** "tag":
|
||||
**
|
||||
** <location id=fileMenu>∅<\location>
|
||||
**
|
||||
**
|
||||
*******************************************************************
|
||||
** (c) Copyright Hewlett-Packard Company, 1992. All rights are
|
||||
** reserved. Copying or other reproduction of this program
|
||||
** except for archival purposes is prohibited without prior
|
||||
** written consent of Hewlett-Packard Company.
|
||||
********************************************************************
|
||||
**
|
||||
********************************************************************
|
||||
** (c) Copyright 1993, 1994 Hewlett-Packard Company
|
||||
** (c) Copyright 1993, 1994 International Business Machines Corp.
|
||||
** (c) Copyright 1993, 1994 Sun Microsystems, Inc.
|
||||
** (c) Copyright 1993, 1994 Novell, Inc.
|
||||
********************************************************************
|
||||
**
|
||||
**
|
||||
**************************************************************************
|
||||
**********************************<+>*************************************/
|
||||
|
||||
/************************************************************************
|
||||
* Default Text Editor help volume name
|
||||
************************************************************************/
|
||||
#define TEXTEDITOR_HELP_VOLUME "Textedit"
|
||||
#define HELP_ON_HELP_VOLUME "Help4Help"
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* Help location ids for the menubar
|
||||
************************************************************************/
|
||||
#define MENUBAR_HELP "menubar"
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* Help location ids for pulldown menus within the menubar
|
||||
************************************************************************/
|
||||
|
||||
#define FILE_MENU_HELP "TextEditorFileMenu"
|
||||
#define EDIT_MENU_HELP "TextEditorEditMenu"
|
||||
#define OPTIONS_MENU_HELP "TextEditorOptionsMenu"
|
||||
#define HELP_MENU_HELP "TextEditorHelpMenu"
|
||||
#define FORMAT_MENU_HELP "formatMenu"
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* Help location ids for individual items within the [Help] pulldown menu
|
||||
************************************************************************/
|
||||
#define HELP_MENU_OVERVIEW_HELP "_hometopic"
|
||||
#define HELP_MENU_TASKS_HELP "Tasks"
|
||||
#define HELP_MENU_TOC_HELP "TableOfContents"
|
||||
#define HELP_MENU_REFERENCE_HELP "Reference"
|
||||
/* 'XmNActivateCallback' for [On Item] does not set a specific location id */
|
||||
/* the HELP_MENU_USING_HELP_HELP location id is for the HELP_ON_HELP_VOLUME */
|
||||
#define HELP_MENU_USING_HELP_HELP "_hometopic"
|
||||
#define HELP_MENU_ABOUT_HELP "_copyright"
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* Help location ids for dialogs posted directly or indirectly by [File]
|
||||
* menu items
|
||||
************************************************************************/
|
||||
#define FILE_OPEN_DIALOG_HELP "openDialog"
|
||||
#define FILE_INCLUDE_DIALOG_HELP "includeDialog"
|
||||
#define FILE_SAVEAS_DIALOG_HELP "saveAsDialog"
|
||||
#define FILE_COPYTOFILE_DIALOG_HELP "copytofileDialog"
|
||||
/* [Print...] causes a separate process to be invoked with its own help */
|
||||
|
||||
/* -----> dialogs conditionally posted as the result of a [File] menu action */
|
||||
#define FILE_ASKIFSAVE_DIALOG_HELP "askIfSaveDialog"
|
||||
#define FILE_EXISTS_DIALOG_HELP "fileExistsDialog"
|
||||
#define FILE_CONFIRM_DIALOG_HELP "fileConfirmDialog"
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* Help location ids for the dialog posted by [File] menu [Print...]
|
||||
* (this dialog is controlled by the DtPrintSetupBox widget)
|
||||
************************************************************************/
|
||||
#define PRINT_SETUP_DIALOG_HELP "printSetupDialog"
|
||||
|
||||
/* -----> fields/buttons within the Print Setup dialog */
|
||||
#define PRINT_APP_SPECIFIC_OPTIONS "print-appSpecific"
|
||||
#define PRINT_GENERIC_OPTIONS "print-generic"
|
||||
#define PRINT_PAGE_HEADERS_FOOTERS "print-pageHeadersFooters"
|
||||
#define PRINT_PAGE_MARGINS "print-pageMargins"
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* Help location ids for edit area and status line of the DtEditor widget
|
||||
************************************************************************/
|
||||
#define EDIT_AREA_HELP "TextEditorWindow"
|
||||
|
||||
/* -----> fields/buttons within the status line */
|
||||
#define STATUS_LINE_HELP "statusLine"
|
||||
#define STATUS_CURRENT_LINE_HELP "status-currentLine"
|
||||
#define STATUS_TOTAL_LINES_HELP "status-totalLines"
|
||||
#define STATUS_MESSAGE_HELP "status-message"
|
||||
#define STATUS_OVERSTRIKE_HELP "status-overstrike"
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* Help location ids for the dialog posted by [Format] menu [Settings...]
|
||||
* (this dialog is controlled by the DtEditor widget)
|
||||
************************************************************************/
|
||||
#define FORMAT_SETTINGS_HELP "formatDialog"
|
||||
|
||||
/* -----> fields/buttons within the Format Settings dialog */
|
||||
#define FORMAT_LEFT_MARGIN_HELP "format-leftmargin"
|
||||
#define FORMAT_RIGHT_MARGIN_HELP "format-rightmargin"
|
||||
#define FORMAT_ALIGNMENT_HELP "format-alignment"
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* Help location ids for the dialog posted by [Edit] menu [Find/Change...]
|
||||
* (this dialog is controlled by the DtEditor widget)
|
||||
************************************************************************/
|
||||
#define FINDCHANGE_HELP "findchangeDialog"
|
||||
|
||||
/* -----> fields/buttons within the Find/Change dialog */
|
||||
#define FINDCHANGE_FIND_HELP "fc-find"
|
||||
#define FINDCHANGE_CHANGETO_HELP "fc-changeto"
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* Help location ids for the dialog posted by [Edit] menu [Find/Change...]
|
||||
* (this dialog is controlled by the DtEditor widget)
|
||||
************************************************************************/
|
||||
#define SPELL_HELP "spellDialog"
|
||||
|
||||
/* -----> fields/buttons within the Check Spelling dialog */
|
||||
#define SPELL_MISSPELLED_WORDS_HELP "sp-spelllist"
|
||||
#define SPELL_CHANGETO_HELP "sp-changeto"
|
||||
536
cde/programs/dtpad/helpCB.c
Normal file
536
cde/programs/dtpad/helpCB.c
Normal file
@@ -0,0 +1,536 @@
|
||||
/* $XConsortium: helpCB.c /main/4 1996/04/16 16:42:13 mgreess $ */
|
||||
/**********************************<+>*************************************
|
||||
***************************************************************************
|
||||
**
|
||||
** File: helpCB.c
|
||||
**
|
||||
** Project: DT dtpad, a memo maker type editor based on the Dt Editor
|
||||
** widget.
|
||||
**
|
||||
** Description:
|
||||
** -----------
|
||||
**
|
||||
** This file contains the all the Text Editor help related callbacks:
|
||||
**
|
||||
** o 'XmNhelpCallback' callbacks for:
|
||||
** - the menu bar and the individual menus within the bar
|
||||
** - file selection boxes, dialogs and dialog components relating to
|
||||
** the [File] menu
|
||||
** - the DtEditor widget
|
||||
** o 'XmNActivateCallback' callbacks for each item in the [Help]
|
||||
** pulldown menu
|
||||
** o 'DtNhyperLinkCallback' and 'DtNcloseCallback' callbacks passed to
|
||||
** DtCreateHelpDialog() (via helpDlg.c:CreateHelpDialog()).
|
||||
**
|
||||
** All 'XmNhelpCallback' and 'XmNActivateCallback' callbacks, except for
|
||||
** [Help] menu [On Item...], simply set the help location id to correspond
|
||||
** to help text on the widget for which the callback was set. The On Item
|
||||
** 'XmNActivateCallback' callback determines the widget on which it was
|
||||
** invoked and then calls the 'XmNhelpCallback' callback directly. If no
|
||||
** 'XmNhelpCallback' is installed, it searches up the widget's parentage
|
||||
* until it finds one and then calls it.
|
||||
**
|
||||
** NOTE: All dialogs relating to the [Edit] and [Format] menus are
|
||||
** controlled directly by the DtEditor widget. Consequently,
|
||||
** all of the help location ids for the "Find/Change", "Check
|
||||
** Spelling" and "Format Settings" dialogs are set in the
|
||||
** in the DtEditor widget's 'XmNhelpCallback' callback
|
||||
** (i.e. in, HelpEditorWidgetCB).
|
||||
**
|
||||
*******************************************************************
|
||||
** (c) Copyright Hewlett-Packard Company, 1991, 1992, 1993. All rights are
|
||||
** reserved. Copying or other reproduction of this program
|
||||
** except for archival purposes is prohibited without prior
|
||||
** written consent of Hewlett-Packard Company.
|
||||
********************************************************************
|
||||
**
|
||||
********************************************************************
|
||||
** (c) Copyright 1993, 1994 Hewlett-Packard Company
|
||||
** (c) Copyright 1993, 1994 International Business Machines Corp.
|
||||
** (c) Copyright 1993, 1994 Sun Microsystems, Inc.
|
||||
** (c) Copyright 1993, 1994 Novell, Inc.
|
||||
********************************************************************
|
||||
**
|
||||
**
|
||||
**************************************************************************
|
||||
**********************************<+>*************************************/
|
||||
#include "dtpad.h"
|
||||
#include "help.h"
|
||||
#include <Dt/HelpDialog.h>
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* The following callbacks are set as the 'XmNhelpCallback' for the menu
|
||||
* menu bar and for the individual pulldown menus within the menu bar.
|
||||
************************************************************************/
|
||||
|
||||
void
|
||||
HelpMenubarCB(
|
||||
Widget w,
|
||||
caddr_t client_data,
|
||||
caddr_t call_data )
|
||||
{
|
||||
SetHelpVolAndDisplayHelp((Editor *)client_data, MENUBAR_HELP,
|
||||
(char *) NULL);
|
||||
}
|
||||
|
||||
void
|
||||
HelpFileCB(
|
||||
Widget w,
|
||||
caddr_t client_data,
|
||||
caddr_t call_data )
|
||||
{
|
||||
SetHelpVolAndDisplayHelp((Editor *)client_data, FILE_MENU_HELP,
|
||||
(char *) NULL);
|
||||
}
|
||||
|
||||
void
|
||||
HelpEditCB(
|
||||
Widget w,
|
||||
caddr_t client_data,
|
||||
caddr_t call_data )
|
||||
{
|
||||
SetHelpVolAndDisplayHelp((Editor *)client_data, EDIT_MENU_HELP,
|
||||
(char *) NULL);
|
||||
}
|
||||
|
||||
void
|
||||
HelpFormatCB(
|
||||
Widget w,
|
||||
caddr_t client_data,
|
||||
caddr_t call_data )
|
||||
{
|
||||
SetHelpVolAndDisplayHelp((Editor *)client_data, FORMAT_MENU_HELP,
|
||||
(char *) NULL);
|
||||
}
|
||||
|
||||
void
|
||||
HelpOptionsCB(
|
||||
Widget w,
|
||||
caddr_t client_data,
|
||||
caddr_t call_data)
|
||||
{
|
||||
SetHelpVolAndDisplayHelp((Editor *)client_data, OPTIONS_MENU_HELP,
|
||||
(char *) NULL);
|
||||
}
|
||||
|
||||
void
|
||||
HelpHelpCB(
|
||||
Widget w,
|
||||
caddr_t client_data,
|
||||
caddr_t call_data )
|
||||
{
|
||||
SetHelpVolAndDisplayHelp((Editor *)client_data, HELP_MENU_HELP,
|
||||
(char *) NULL);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* The following callbacks are set as the 'XmNhelpCallback' on file
|
||||
* selection boxes and prompt dialogs relating to the [File] menu.
|
||||
************************************************************************/
|
||||
|
||||
void
|
||||
HelpOpenDialogCB(
|
||||
Widget w,
|
||||
caddr_t client_data,
|
||||
caddr_t call_data )
|
||||
{
|
||||
SetHelpVolAndDisplayHelp((Editor *)client_data, FILE_OPEN_DIALOG_HELP,
|
||||
(char *) NULL);
|
||||
}
|
||||
|
||||
void
|
||||
HelpIncludeDialogCB(
|
||||
Widget w,
|
||||
caddr_t client_data,
|
||||
caddr_t call_data )
|
||||
{
|
||||
SetHelpVolAndDisplayHelp((Editor *)client_data, FILE_INCLUDE_DIALOG_HELP,
|
||||
(char *) NULL);
|
||||
}
|
||||
|
||||
void
|
||||
HelpSaveAsDialogCB(
|
||||
Widget w,
|
||||
caddr_t client_data,
|
||||
caddr_t call_data )
|
||||
{
|
||||
Editor *pPad = (Editor *) client_data;
|
||||
|
||||
if (pPad->xrdb.nameChange) {
|
||||
SetHelpVolAndDisplayHelp(pPad, FILE_SAVEAS_DIALOG_HELP,
|
||||
(char *) NULL);
|
||||
} else {
|
||||
SetHelpVolAndDisplayHelp(pPad, FILE_COPYTOFILE_DIALOG_HELP,
|
||||
(char *) NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
HelpAskIfSaveDialogCB(
|
||||
Widget w,
|
||||
caddr_t client_data,
|
||||
caddr_t call_data )
|
||||
{
|
||||
SetHelpVolAndDisplayHelp((Editor *)client_data, FILE_ASKIFSAVE_DIALOG_HELP,
|
||||
(char *) NULL);
|
||||
}
|
||||
|
||||
void
|
||||
HelpFileAlreadyExistsCB(
|
||||
Widget w,
|
||||
caddr_t client_data,
|
||||
caddr_t call_data )
|
||||
{
|
||||
SetHelpVolAndDisplayHelp((Editor *)client_data, FILE_EXISTS_DIALOG_HELP,
|
||||
(char *) NULL);
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* The following callback is set as the 'XmNhelpCallback' on the DtEditor
|
||||
* widget. It controls help for the "Find/Change", "Check Spelling" and
|
||||
* "Format Settings" dialogs and dialog components.
|
||||
************************************************************************/
|
||||
|
||||
void
|
||||
HelpEditorWidgetCB(
|
||||
Widget w,
|
||||
caddr_t client_data,
|
||||
caddr_t call_data )
|
||||
{
|
||||
|
||||
DtEditorHelpCallbackStruct *editorHelp =
|
||||
(DtEditorHelpCallbackStruct *) call_data;
|
||||
|
||||
switch (editorHelp->reason) {
|
||||
|
||||
/* -----> edit area */
|
||||
case DtEDITOR_HELP_EDIT_WINDOW:
|
||||
SetHelpVolAndDisplayHelp((Editor *)client_data,
|
||||
EDIT_AREA_HELP,
|
||||
(char *) NULL);
|
||||
break;
|
||||
|
||||
/* -----> status line area and fields */
|
||||
case DtEDITOR_HELP_STATUS_LINE:
|
||||
SetHelpVolAndDisplayHelp((Editor *)client_data,
|
||||
STATUS_LINE_HELP,
|
||||
(char *) NULL);
|
||||
break;
|
||||
case DtEDITOR_HELP_STATUS_CURRENT_LINE:
|
||||
SetHelpVolAndDisplayHelp((Editor *)client_data,
|
||||
STATUS_CURRENT_LINE_HELP,
|
||||
(char *) NULL);
|
||||
break;
|
||||
case DtEDITOR_HELP_STATUS_TOTAL_LINES:
|
||||
SetHelpVolAndDisplayHelp((Editor *)client_data,
|
||||
STATUS_TOTAL_LINES_HELP,
|
||||
(char *) NULL);
|
||||
break;
|
||||
case DtEDITOR_HELP_STATUS_MESSAGE:
|
||||
SetHelpVolAndDisplayHelp((Editor *)client_data,
|
||||
STATUS_MESSAGE_HELP,
|
||||
(char *) NULL);
|
||||
break;
|
||||
case DtEDITOR_HELP_STATUS_OVERSTRIKE:
|
||||
SetHelpVolAndDisplayHelp((Editor *)client_data,
|
||||
STATUS_OVERSTRIKE_HELP,
|
||||
(char *) NULL);
|
||||
break;
|
||||
|
||||
/* -----> Format Settings dialog and dialog fields */
|
||||
case DtEDITOR_HELP_FORMAT_DIALOG:
|
||||
SetHelpVolAndDisplayHelp((Editor *)client_data,
|
||||
FORMAT_SETTINGS_HELP,
|
||||
(char *) NULL);
|
||||
break;
|
||||
case DtEDITOR_HELP_FORMAT_LEFT_MARGIN:
|
||||
SetHelpVolAndDisplayHelp((Editor *)client_data,
|
||||
FORMAT_LEFT_MARGIN_HELP,
|
||||
(char *) NULL);
|
||||
break;
|
||||
case DtEDITOR_HELP_FORMAT_RIGHT_MARGIN:
|
||||
SetHelpVolAndDisplayHelp((Editor *)client_data,
|
||||
FORMAT_RIGHT_MARGIN_HELP,
|
||||
(char *) NULL);
|
||||
break;
|
||||
case DtEDITOR_HELP_FORMAT_ALIGNMENT:
|
||||
SetHelpVolAndDisplayHelp((Editor *)client_data,
|
||||
FORMAT_ALIGNMENT_HELP,
|
||||
(char *) NULL);
|
||||
break;
|
||||
|
||||
/* -----> Find/Change dialog and dialog fields */
|
||||
case DtEDITOR_HELP_CHANGE_DIALOG:
|
||||
SetHelpVolAndDisplayHelp((Editor *)client_data,
|
||||
FINDCHANGE_HELP,
|
||||
(char *) NULL);
|
||||
break;
|
||||
case DtEDITOR_HELP_CHANGE_FIND:
|
||||
SetHelpVolAndDisplayHelp((Editor *)client_data,
|
||||
FINDCHANGE_FIND_HELP,
|
||||
(char *) NULL);
|
||||
break;
|
||||
case DtEDITOR_HELP_CHANGE_CHANGE:
|
||||
SetHelpVolAndDisplayHelp((Editor *)client_data,
|
||||
FINDCHANGE_CHANGETO_HELP,
|
||||
(char *) NULL);
|
||||
break;
|
||||
|
||||
/* -----> Check Spelling dialog and dialog fields */
|
||||
case DtEDITOR_HELP_SPELL_DIALOG:
|
||||
SetHelpVolAndDisplayHelp((Editor *)client_data,
|
||||
SPELL_HELP,
|
||||
(char *) NULL);
|
||||
break;
|
||||
case DtEDITOR_HELP_SPELL_MISSPELLED_WORDS:
|
||||
SetHelpVolAndDisplayHelp((Editor *)client_data,
|
||||
SPELL_MISSPELLED_WORDS_HELP,
|
||||
(char *) NULL);
|
||||
break;
|
||||
case DtEDITOR_HELP_SPELL_CHANGE:
|
||||
SetHelpVolAndDisplayHelp((Editor *)client_data,
|
||||
SPELL_CHANGETO_HELP,
|
||||
(char *) NULL);
|
||||
break;
|
||||
|
||||
default:
|
||||
;
|
||||
|
||||
} /* switch (editorHelp->reason) */
|
||||
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* The following callbacks are set as the 'XmNhelpCallback' on the print
|
||||
* setup dialogs accessible from the [File] [Print...] menu button.
|
||||
************************************************************************/
|
||||
|
||||
void
|
||||
HelpPrintSetupDialogCB(
|
||||
Widget w,
|
||||
XtPointer client_data,
|
||||
XtPointer call_data )
|
||||
{
|
||||
SetHelpVolAndDisplayHelp((Editor *)client_data, PRINT_SETUP_DIALOG_HELP,
|
||||
(char *) NULL);
|
||||
}
|
||||
|
||||
void
|
||||
HelpPrintSetupAppSpecificCB(
|
||||
Widget w,
|
||||
XtPointer client_data,
|
||||
XtPointer call_data )
|
||||
{
|
||||
SetHelpVolAndDisplayHelp((Editor *)client_data, PRINT_APP_SPECIFIC_OPTIONS,
|
||||
(char *) NULL);
|
||||
}
|
||||
|
||||
void
|
||||
HelpPrintSetupGenericCB(
|
||||
Widget w,
|
||||
XtPointer client_data,
|
||||
XtPointer call_data )
|
||||
{
|
||||
SetHelpVolAndDisplayHelp((Editor *)client_data, PRINT_GENERIC_OPTIONS,
|
||||
(char *) NULL);
|
||||
}
|
||||
|
||||
void
|
||||
HelpPrintSetupPageHeadersFootersCB(
|
||||
Widget w,
|
||||
XtPointer client_data,
|
||||
XtPointer call_data )
|
||||
{
|
||||
SetHelpVolAndDisplayHelp((Editor *)client_data, PRINT_PAGE_HEADERS_FOOTERS,
|
||||
(char *) NULL);
|
||||
}
|
||||
|
||||
void
|
||||
HelpPrintSetupPageMargins(
|
||||
Widget w,
|
||||
XtPointer client_data,
|
||||
XtPointer call_data )
|
||||
{
|
||||
SetHelpVolAndDisplayHelp((Editor *)client_data, PRINT_PAGE_MARGINS,
|
||||
(char *) NULL);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* The following callbacks are set (in dtpad.c:CreateHelpMenu) as the
|
||||
* 'XmNactivateCallback' for each of the items in the Help menu:
|
||||
*
|
||||
* Overview...
|
||||
* ----------
|
||||
* Table of Contents...
|
||||
* Tasks...
|
||||
* Reference...
|
||||
* On Item
|
||||
* ----------
|
||||
* Using Help...
|
||||
* ----------
|
||||
* About Text Editor...
|
||||
*
|
||||
************************************************************************/
|
||||
|
||||
void
|
||||
HelpOverviewCB(
|
||||
Widget w,
|
||||
caddr_t client_data,
|
||||
caddr_t call_data )
|
||||
{
|
||||
SetHelpVolAndDisplayHelp((Editor *)client_data, HELP_MENU_OVERVIEW_HELP,
|
||||
(char *) NULL);
|
||||
}
|
||||
|
||||
void
|
||||
HelpTasksCB(
|
||||
Widget w,
|
||||
caddr_t client_data,
|
||||
caddr_t call_data )
|
||||
{
|
||||
SetHelpVolAndDisplayHelp((Editor *)client_data, HELP_MENU_TASKS_HELP,
|
||||
(char *) NULL);
|
||||
}
|
||||
|
||||
void
|
||||
HelpTOCCB(
|
||||
Widget w,
|
||||
caddr_t client_data,
|
||||
caddr_t call_data )
|
||||
{
|
||||
SetHelpVolAndDisplayHelp((Editor *)client_data, HELP_MENU_TOC_HELP,
|
||||
(char *) NULL);
|
||||
}
|
||||
|
||||
void
|
||||
HelpReferenceCB(
|
||||
Widget w,
|
||||
caddr_t client_data,
|
||||
caddr_t call_data )
|
||||
{
|
||||
SetHelpVolAndDisplayHelp((Editor *)client_data, HELP_MENU_REFERENCE_HELP,
|
||||
(char *) NULL);
|
||||
}
|
||||
|
||||
void
|
||||
HelpOnItemCB(
|
||||
Widget w,
|
||||
caddr_t client_data,
|
||||
caddr_t call_data )
|
||||
{
|
||||
Editor *pPad = (Editor *)client_data;
|
||||
Widget widget;
|
||||
|
||||
switch(DtHelpReturnSelectedWidgetId(pPad->app_shell, (Cursor)NULL, &widget))
|
||||
{
|
||||
/*
|
||||
* There are additional cases (e.g. user aborts request) but I
|
||||
* don't feel they warrant an error dialog.
|
||||
*/
|
||||
case DtHELP_SELECT_VALID:
|
||||
while (!XtIsShell(widget)) {
|
||||
if (XtHasCallbacks(widget, XmNhelpCallback) == XtCallbackHasSome) {
|
||||
XtCallCallbacks(widget, XmNhelpCallback, (XtPointer)pPad);
|
||||
return;
|
||||
}
|
||||
widget = XtParent(widget);
|
||||
}
|
||||
break;
|
||||
case DtHELP_SELECT_INVALID:
|
||||
Warning(pPad,
|
||||
GETMESSAGE(12, 1, "You must select an item within the Text Editor."),
|
||||
XmDIALOG_INFORMATION);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
HelpUsingHelpCB(
|
||||
Widget w,
|
||||
caddr_t client_data,
|
||||
caddr_t call_data )
|
||||
{
|
||||
SetHelpVolAndDisplayHelp((Editor *)client_data, HELP_MENU_USING_HELP_HELP,
|
||||
HELP_ON_HELP_VOLUME);
|
||||
}
|
||||
|
||||
void
|
||||
HelpAboutCB(
|
||||
Widget w,
|
||||
caddr_t client_data,
|
||||
caddr_t call_data )
|
||||
{
|
||||
SetHelpVolAndDisplayHelp((Editor *) client_data, HELP_MENU_ABOUT_HELP,
|
||||
(char *) NULL);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* HelpHyperlinkCB - is the 'DtNhyperLinkCallback' passed to
|
||||
* DtCreateHelpDialog (in CreateHelpDialog).
|
||||
************************************************************************/
|
||||
void
|
||||
HelpHyperlinkCB(
|
||||
Widget w,
|
||||
caddr_t client_data,
|
||||
caddr_t call_data )
|
||||
{
|
||||
DtHelpDialogCallbackStruct *pHyper =
|
||||
(DtHelpDialogCallbackStruct *) call_data;
|
||||
|
||||
switch(pHyper->hyperType)
|
||||
{
|
||||
case DtHELP_LINK_JUMP_NEW:
|
||||
DisplayNewHelpWindow((Editor *)client_data, pHyper->helpVolume,
|
||||
pHyper->locationId);
|
||||
break;
|
||||
default:
|
||||
;
|
||||
/* application defined link code goes here */
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* HelpCloseCB - is the 'DtNcloseCallback' passed to DtCreateHelpDialog
|
||||
* (in CreateHelpDialog) to close/unmap all help dialogs, both cached
|
||||
* and uncached. It checks to see if the referenced dialog is in the
|
||||
* uncached help for the current pad.
|
||||
************************************************************************/
|
||||
void
|
||||
HelpCloseCB(
|
||||
Widget w,
|
||||
caddr_t client_data,
|
||||
caddr_t call_data )
|
||||
{
|
||||
Editor *pPad = (Editor *)client_data;
|
||||
HelpStruct *pHelp;
|
||||
|
||||
if(w != pPad->MainHelp)
|
||||
{
|
||||
/*
|
||||
* empty for loop just marches pHelp to the right place
|
||||
*/
|
||||
for(pHelp = pPad->pHelpCache;
|
||||
pHelp != (HelpStruct *)NULL && pHelp->dialog != w;
|
||||
pHelp = pHelp->pNext)
|
||||
;
|
||||
|
||||
if(pHelp != (HelpStruct *)NULL)
|
||||
{
|
||||
/* this should always happen */
|
||||
pHelp->inUse = False;
|
||||
}
|
||||
}
|
||||
|
||||
XtUnmanageChild(w);
|
||||
}
|
||||
189
cde/programs/dtpad/helpDlg.c
Normal file
189
cde/programs/dtpad/helpDlg.c
Normal file
@@ -0,0 +1,189 @@
|
||||
/* $TOG: helpDlg.c /main/4 1999/09/15 15:16:22 mgreess $ */
|
||||
/**********************************<+>*************************************
|
||||
***************************************************************************
|
||||
**
|
||||
** File: helpDlg.c
|
||||
**
|
||||
** Project: HP DT dtpad, a memo maker type editor based on the
|
||||
** Dt Editor widget.
|
||||
**
|
||||
** Description: Routines which manipulate the dialogs associated with
|
||||
** operations in the Help menu.
|
||||
** -----------
|
||||
**
|
||||
*******************************************************************
|
||||
** (c) Copyright Hewlett-Packard Company, 1990, 1991, 1992. All rights are
|
||||
** reserved. Copying or other reproduction of this program
|
||||
** except for archival purposes is prohibited without prior
|
||||
** written consent of Hewlett-Packard Company.
|
||||
********************************************************************
|
||||
**
|
||||
*******************************************************************
|
||||
** (c) Copyright 1993, 1994 Hewlett-Packard Company
|
||||
** (c) Copyright 1993, 1994 International Business Machines Corp.
|
||||
** (c) Copyright 1993, 1994 Sun Microsystems, Inc.
|
||||
** (c) Copyright 1993, 1994 Novell, Inc.
|
||||
********************************************************************
|
||||
**
|
||||
**
|
||||
**************************************************************************
|
||||
**********************************<+>*************************************/
|
||||
#include <stdio.h>
|
||||
|
||||
#include "dtpad.h"
|
||||
#include "help.h"
|
||||
|
||||
#include <Xm/DialogS.h>
|
||||
#include <Xm/Form.h>
|
||||
#include <Xm/MwmUtil.h>
|
||||
#include <Dt/HelpDialog.h>
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* GetHelpDialog - obtains an "unused" help dialog from the cached list
|
||||
* for the pad or, if one doesn't exist, creates a new help dialog
|
||||
* and puts it in the cache.
|
||||
************************************************************************/
|
||||
static Widget
|
||||
GetHelpDialog(
|
||||
Editor *pPad)
|
||||
{
|
||||
HelpStruct *pHelp;
|
||||
|
||||
if (pPad->pHelpCache == (HelpStruct *)NULL) {
|
||||
pHelp = pPad->pHelpCache = (HelpStruct *)XtMalloc(sizeof(HelpStruct));
|
||||
pHelp->pNext = (HelpStruct *)NULL;
|
||||
pHelp->pPrev = (HelpStruct *)NULL;
|
||||
pHelp->inUse = True;
|
||||
pHelp->dialog = CreateHelpDialog(pPad);
|
||||
return pHelp->dialog;
|
||||
} else {
|
||||
for (pHelp = pPad->pHelpCache; pHelp != (HelpStruct *)NULL;
|
||||
pHelp = pHelp->pNext) {
|
||||
if (pHelp->inUse == False) {
|
||||
pHelp->inUse = True;
|
||||
return pHelp->dialog;
|
||||
}
|
||||
}
|
||||
pHelp = (HelpStruct *) XtMalloc(sizeof(HelpStruct));
|
||||
pPad->pHelpCache->pPrev = pHelp;
|
||||
pHelp->pNext = pPad->pHelpCache;
|
||||
pPad->pHelpCache = pHelp;
|
||||
pHelp->pPrev = (HelpStruct *)NULL;
|
||||
pHelp->inUse = True;
|
||||
pHelp->dialog = CreateHelpDialog(pPad);
|
||||
return pHelp->dialog;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* SetHelpVolAndDisplayHelp - sets the help volume and displays the help
|
||||
* text beginning at the specified location id within the volume
|
||||
************************************************************************/
|
||||
void
|
||||
SetHelpVolAndDisplayHelp(
|
||||
Editor *pPad,
|
||||
char *locationId,
|
||||
char *helpVolume)
|
||||
{
|
||||
|
||||
if (helpVolume == (char *) NULL)
|
||||
helpVolume = TEXTEDITOR_HELP_VOLUME;
|
||||
|
||||
DisplayHelp(pPad, helpVolume, locationId);
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* DisplayHelp - is called to display all the "normal" help windows. It
|
||||
* uses the one "MainHelp" dialog associated with the relevant pad.
|
||||
************************************************************************/
|
||||
void
|
||||
DisplayHelp(
|
||||
Editor *pPad,
|
||||
char *helpVolume,
|
||||
char *locationId)
|
||||
{
|
||||
if (pPad->MainHelp == NULL) {
|
||||
pPad->MainHelp = CreateHelpDialog(pPad);
|
||||
}
|
||||
|
||||
DisplayHelpDialog(pPad, pPad->MainHelp, helpVolume, locationId);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* CreateHelpDialog - creates the "MainHelp" help for the pad and sets
|
||||
* up the hyperLink and Close callbacks for it.
|
||||
************************************************************************/
|
||||
Widget
|
||||
CreateHelpDialog(
|
||||
Editor *pPad)
|
||||
{
|
||||
Arg args[10];
|
||||
int n = 0;
|
||||
Widget dialog;
|
||||
|
||||
dialog = DtCreateHelpDialog(pPad->app_shell, "helpDlg", args, n);
|
||||
XtAddCallback(dialog, DtNhyperLinkCallback,
|
||||
(XtCallbackProc)HelpHyperlinkCB, pPad);
|
||||
XtAddCallback(dialog, DtNcloseCallback,
|
||||
(XtCallbackProc)HelpCloseCB, pPad);
|
||||
return dialog;
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* DisplayNewHelpWindow - is called by the hyperLink callback,
|
||||
* helpCB.c:HelpHyperlinkCB to open a new, cached, help dialog for
|
||||
* this pad.
|
||||
************************************************************************/
|
||||
void
|
||||
DisplayNewHelpWindow(
|
||||
Editor *pPad,
|
||||
char *helpVolume,
|
||||
char *locationId)
|
||||
{
|
||||
DisplayHelpDialog(pPad, GetHelpDialog(pPad), helpVolume, locationId);
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* DisplayHelpDialog - sets the help type topic, volume, location id and
|
||||
* title for the specified help dialog.
|
||||
************************************************************************/
|
||||
void
|
||||
DisplayHelpDialog(
|
||||
Editor *pPad,
|
||||
Widget helpDialog,
|
||||
char *helpVolume,
|
||||
char *locationId)
|
||||
{
|
||||
Arg args[10];
|
||||
int n = 0;
|
||||
char *titleStr, *helpStr;
|
||||
|
||||
n = 0;
|
||||
XtSetArg(args[n], DtNhelpType, DtHELP_TYPE_TOPIC);n++;
|
||||
XtSetArg(args[n], DtNhelpVolume, helpVolume); n++;
|
||||
XtSetArg(args[n], DtNlocationId, locationId); n++;
|
||||
XtSetValues(helpDialog, args, n);
|
||||
|
||||
/*
|
||||
* It's a bit bogus to set the dialog title each time we display the
|
||||
* dialog, but it's an easy way to make sure the title is right if the
|
||||
* pad is reused and the previous user had a mainTitle specified.
|
||||
*/
|
||||
helpStr = (char*)GETMESSAGE(2, 1, "Help");
|
||||
titleStr = (char*)XtMalloc(strlen(helpStr)+strlen(DialogTitle(pPad))+1);
|
||||
sprintf(titleStr, "%s%s", DialogTitle(pPad), helpStr);
|
||||
n = 0;
|
||||
XtSetArg (args[n], XmNtitle, titleStr); n++;
|
||||
XtSetValues(XtParent(helpDialog), args, n);
|
||||
|
||||
XtManageChild(helpDialog);
|
||||
|
||||
XtFree(titleStr);
|
||||
}
|
||||
1858
cde/programs/dtpad/main.c
Normal file
1858
cde/programs/dtpad/main.c
Normal file
File diff suppressed because it is too large
Load Diff
63
cde/programs/dtpad/mapfile.reorder
Normal file
63
cde/programs/dtpad/mapfile.reorder
Normal file
@@ -0,0 +1,63 @@
|
||||
# $XConsortium: mapfile.reorder /main/3 1996/11/19 14:59:43 drk $
|
||||
text = LOAD ?RXO;
|
||||
text : .text%SetSelectionMenuItems : editCB.o;
|
||||
text : .text%PanicSave : fileIo.o;
|
||||
text : .text%TextDeselectedCB : editCB.o;
|
||||
text : .text%main : main.o;
|
||||
text : .text%CreateFirstPad : main.o;
|
||||
text : .text%CreatePad : main.o;
|
||||
text : .text%MbStrrchr : dtpad.o;
|
||||
text : .text%InitDtEditSession : main.o;
|
||||
text : .text%InitEditSessionAndFirstPad : main.o;
|
||||
text : .text%CreateDefaultImage : dtpad.o;
|
||||
text : .text%RealizeNewPad : main.o;
|
||||
text : .text%CreateMenuBar : dtpad.o;
|
||||
text : .text%CreateFileMenu : dtpad.o;
|
||||
text : .text%CreateEditMenu : dtpad.o;
|
||||
text : .text%CreateFormatMenu : dtpad.o;
|
||||
text : .text%CreateOptionsMenu : dtpad.o;
|
||||
text : .text%CreateHelpMenu : dtpad.o;
|
||||
text : .text%CreateEditorWidget : dtpad.o;
|
||||
text : .text%ChangeMainWindowTitle : dtpad.o;
|
||||
text : .text%SetStateFromResources : main.o;
|
||||
text : .text%SetWorkSpaceHints : dtpad.o;
|
||||
text : .text%OverstrikeCB : optionsCB.o;
|
||||
text : .text%WordWrapCB : optionsCB.o;
|
||||
text : .text%StatusLineCB : optionsCB.o;
|
||||
text : .text%SetInitialMenuSensitivity : main.o;
|
||||
text : .text%SetSaveAsLabelAndDialog : dtpad.o;
|
||||
text : .text%LoadFile : fileIo.o;
|
||||
text : .text%SetStatusLineMsg : fileIo.o;
|
||||
text : .text%setPanicConditions : main.o;
|
||||
text : .text%TTstartDesktopMediaExchange : ttMsgSupport.o;
|
||||
text : .text%TTmedia_ptype_declareCB : ttMsgSupport.o;
|
||||
text : .text%FindOrCreatePad : dtpad.o;
|
||||
text : .text%ManageOldPad : main.o;
|
||||
text : .text%MbBasename : dtpad.o;
|
||||
text : .text%FindChangeCB : editCB.o;
|
||||
text : .text%FileCascadingCB : fileCB.o;
|
||||
text : .text%FileSaveAsCB : fileCB.o;
|
||||
text : .text%CreateSaveAsDialog : fileDlg.o;
|
||||
text : .text%SetSaveAsDirAndFile : fileDlg.o;
|
||||
text : .text%SaveAsOkCB : fileCB.o;
|
||||
text : .text%ExtractAndStoreDir : fileDlg.o;
|
||||
text : .text%MbStrchr : dtpad.o;
|
||||
text : .text%_DtpadGetMessage : main.o;
|
||||
text : .text%SetWindowSize : main.o;
|
||||
text : .text%SetPadGeometry : main.o;
|
||||
text : .text%GetAdjustedResizeHints : main.o;
|
||||
text : .text%SetAppShellResizeHints : main.o;
|
||||
text : .text%CreateNewLineToggles : fileDlg.o;
|
||||
text : .text%TTmediaReply : ttMsgSupport.o;
|
||||
text : .text%RestoreInitialServerResources : main.o;
|
||||
text : .text%TextSelectedCB : editCB.o;
|
||||
text : .text%EditCopyCB : editCB.o;
|
||||
text : .text%EditPasteCB : editCB.o;
|
||||
text : .text%closeCB : session.o;
|
||||
text : .text%FileExitCB : fileCB.o;
|
||||
text : .text%SaveUnsaved : fileCB.o;
|
||||
text : .text%AskIfSave : fileDlg.o;
|
||||
text : .text%CreateSaveWarning : fileDlg.o;
|
||||
text : .text%NoSaveCB : fileCB.o;
|
||||
text : .text%UnmanageAllDialogs : main.o;
|
||||
text : .text%TTresetQuitArgs : ttMsgSupport.o;
|
||||
67
cde/programs/dtpad/messageParam.h
Normal file
67
cde/programs/dtpad/messageParam.h
Normal file
@@ -0,0 +1,67 @@
|
||||
/* $XConsortium: messageParam.h /main/3 1995/11/01 10:38:54 rswiston $ */
|
||||
/**********************************<+>*************************************
|
||||
***************************************************************************
|
||||
**
|
||||
** File: messageParam.h
|
||||
**
|
||||
** Project: DT dtpad, a memo maker type editor based on the motif
|
||||
** 1.1 widget.
|
||||
**
|
||||
** Description: Contains the codes used in communication between the
|
||||
** "client" and "server" dtpad. These are used in place
|
||||
** of strings to reduce the computational overhead of
|
||||
** parsing the parameters on the receiving (server) end.
|
||||
**
|
||||
*******************************************************************
|
||||
** (c) Copyright Hewlett-Packard Company, 1992. All rights are
|
||||
** reserved. Copying or other reproduction of this program
|
||||
** except for archival purposes is prohibited without prior
|
||||
** written consent of Hewlett-Packard Company.
|
||||
********************************************************************
|
||||
**
|
||||
********************************************************************
|
||||
** (c) Copyright 1993, 1994 Hewlett-Packard Company
|
||||
** (c) Copyright 1993, 1994 International Business Machines Corp.
|
||||
** (c) Copyright 1993, 1994 Sun Microsystems, Inc.
|
||||
** (c) Copyright 1993, 1994 Novell, Inc.
|
||||
********************************************************************
|
||||
**
|
||||
**
|
||||
**************************************************************************
|
||||
**********************************<+>*************************************/
|
||||
#include <Tt/tt_c.h>
|
||||
|
||||
/*
|
||||
* The codes are consecutive byte values to give the compiler the best
|
||||
* shot at optimizing the resulting "switch" statement.
|
||||
*/
|
||||
|
||||
#define NETFILE (char)'?'
|
||||
|
||||
/* non Text Editor specific options */
|
||||
#define GEOMETRY (char)'A'
|
||||
|
||||
/* basic options */
|
||||
#define STATUSLINE (char)'B'
|
||||
#define WINDOWWORDWRAP (char)'C'
|
||||
#define OVERSTRIKE (char)'D'
|
||||
#define SAVEONCLOSE (char)'E'
|
||||
#define MISSINGFILEWARNING (char)'F'
|
||||
#define NOREADONLYWARNING (char)'G'
|
||||
#define NONAMECHANGE (char)'H'
|
||||
#define VIEWONLY (char)'I'
|
||||
#define WORKSPACELIST (char)'J'
|
||||
#define SESSION (char)'K'
|
||||
|
||||
/* client/server control options */
|
||||
#define BLOCKING (char)'L'
|
||||
|
||||
/* field nos. for DTPAD_OPEN_FILE_MSG and DTPAD_RUN_SESSION_MSG fields
|
||||
* (DT_MSG_DATA_? are defined in lib1/DtSvc/DtUtil2/Message.h) */
|
||||
#define FILENAME_MSG_FIELD DT_MSG_DATA_1
|
||||
#define NETFILE_ID_MSG_FIELD DT_MSG_DATA_3
|
||||
#define PROCESS_ID_MSG_FIELD DT_MSG_DATA_5
|
||||
|
||||
/* field nos. for DTPAD_DONE message fields */
|
||||
#define CHANNEL_MSG_FIELD DT_MSG_DATA_1
|
||||
#define RETURN_STATUS_MSG_FIELD DT_MSG_DATA_2
|
||||
138
cde/programs/dtpad/optionsCB.c
Normal file
138
cde/programs/dtpad/optionsCB.c
Normal file
@@ -0,0 +1,138 @@
|
||||
/* $XConsortium: optionsCB.c /main/3 1995/11/01 10:39:09 rswiston $ */
|
||||
/**********************************<+>*************************************
|
||||
***************************************************************************
|
||||
**
|
||||
** File: optionsCB.c
|
||||
**
|
||||
** Project: DT dtpad, a memo maker type editor based on the Dt Editor
|
||||
** widget.
|
||||
**
|
||||
** Description:
|
||||
** -----------
|
||||
**
|
||||
** This file contains the callbacks for the [Options] menu items.
|
||||
**
|
||||
*******************************************************************
|
||||
** (c) Copyright Hewlett-Packard Company, 1991, 1992. All rights are
|
||||
** reserved. Copying or other reproduction of this program
|
||||
** except for archival purposes is prohibited without prior
|
||||
** written consent of Hewlett-Packard Company.
|
||||
********************************************************************
|
||||
**
|
||||
********************************************************************
|
||||
** (c) Copyright 1993, 1994 Hewlett-Packard Company
|
||||
** (c) Copyright 1993, 1994 International Business Machines Corp.
|
||||
** (c) Copyright 1993, 1994 Sun Microsystems, Inc.
|
||||
** (c) Copyright 1993, 1994 Novell, Inc.
|
||||
********************************************************************
|
||||
**
|
||||
**
|
||||
**************************************************************************
|
||||
**********************************<+>*************************************/
|
||||
#include "dtpad.h"
|
||||
#include <Dt/HourGlass.h>
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* OverstrikeCB - set Editor widget overstike and "Options" menu
|
||||
* "Overstrike" radio button state based on value passed in
|
||||
* call_data->set.
|
||||
*
|
||||
* NOTE: The default overstrike state for the entire (pPad) edit
|
||||
* session is also reset.
|
||||
************************************************************************/
|
||||
/* ARGSUSED */
|
||||
void
|
||||
OverstrikeCB(
|
||||
Widget w,
|
||||
caddr_t client_data,
|
||||
caddr_t call_data)
|
||||
{
|
||||
Arg al[1];
|
||||
Editor *pPad = (Editor *)client_data;
|
||||
XmToggleButtonCallbackStruct *cb = (XmToggleButtonCallbackStruct *)
|
||||
call_data;
|
||||
|
||||
XtSetArg(al[0], DtNoverstrike, (Boolean) cb->set);
|
||||
XtSetValues(pPad->editor, al, 1);
|
||||
pPad->xrdb.overstrike = (Boolean) cb->set; /* reset edit session default */
|
||||
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* WordWrapCB - set Editor widget word wrap state and the default state
|
||||
* for the new line radio button in the "Save As" File menu dialog
|
||||
* based on value passed in call_data->set.
|
||||
*
|
||||
* NOTE: The default word wrap state for the entire (pPad) edit
|
||||
* session is also reset.
|
||||
************************************************************************/
|
||||
/* ARGSUSED */
|
||||
void
|
||||
WordWrapCB(
|
||||
Widget w,
|
||||
caddr_t client_data,
|
||||
caddr_t call_data)
|
||||
{
|
||||
Arg al[1];
|
||||
Editor *pPad = (Editor *)client_data;
|
||||
XmToggleButtonCallbackStruct *cb = (XmToggleButtonCallbackStruct *)
|
||||
call_data;
|
||||
SaveAs *pSaveAs = &pPad->fileStuff.fileWidgets.saveAs;
|
||||
Select *pSelect = &pPad->fileStuff.fileWidgets.select;
|
||||
|
||||
XtSetArg(al[0], DtNwordWrap, (Boolean) cb->set);
|
||||
XtSetValues(pPad->editor, al, 1);
|
||||
|
||||
pPad->xrdb.wordWrap = (Boolean) cb->set; /* reset edit session default */
|
||||
|
||||
/* -----> set the default state for the "add new lines?" radio boxes in the
|
||||
* "Save As" file selection box and the "Save" prompt dialog
|
||||
* (these radio boxes are included only if word wrap is on) */
|
||||
if (pSaveAs->toggleWidgets.newl_radio != (Widget) 0) {
|
||||
if (pPad->xrdb.wordWrap == True) {
|
||||
XtManageChild(pSaveAs->toggleWidgets.newl_radio);
|
||||
} else {
|
||||
XtUnmanageChild(pSaveAs->toggleWidgets.newl_radio);
|
||||
}
|
||||
}
|
||||
if (pSelect->toggleWidgets.newl_radio != (Widget) 0) {
|
||||
if (pPad->xrdb.wordWrap == True) {
|
||||
XtManageChild(pSelect->separator);
|
||||
XtManageChild(pSelect->toggleWidgets.newl_radio);
|
||||
} else {
|
||||
XtUnmanageChild(pSelect->separator);
|
||||
XtUnmanageChild(pSelect->toggleWidgets.newl_radio);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* StatusLineCB - set Editor widget statusLine based on value passed in
|
||||
* call_data->set.
|
||||
*
|
||||
* NOTE: The default statusLine state for the entire (pPad) edit
|
||||
* session is also reset.
|
||||
************************************************************************/
|
||||
/* ARGSUSED */
|
||||
void
|
||||
StatusLineCB(
|
||||
Widget w,
|
||||
caddr_t client_data,
|
||||
caddr_t call_data)
|
||||
{
|
||||
Arg al[1];
|
||||
Editor *pPad = (Editor *)client_data;
|
||||
XmToggleButtonCallbackStruct *cb = (XmToggleButtonCallbackStruct *)
|
||||
call_data;
|
||||
|
||||
XtSetArg(al[0], DtNshowStatusLine, (Boolean) cb->set);
|
||||
XtSetValues(pPad->editor, al, 1);
|
||||
pPad->xrdb.statusLine = (Boolean) cb->set; /* reset edit session default */
|
||||
|
||||
/* Reset the resize increment and minimum window size properties. */
|
||||
SetAppShellResizeHints(pPad);
|
||||
}
|
||||
1027
cde/programs/dtpad/printJob.c
Normal file
1027
cde/programs/dtpad/printJob.c
Normal file
File diff suppressed because it is too large
Load Diff
865
cde/programs/dtpad/printOutput.c
Normal file
865
cde/programs/dtpad/printOutput.c
Normal file
@@ -0,0 +1,865 @@
|
||||
/* $TOG: printOutput.c /main/6 1997/07/07 15:06:25 mgreess $ */
|
||||
/**********************************<+>*************************************
|
||||
***************************************************************************
|
||||
**
|
||||
** File: printOption.c
|
||||
**
|
||||
** Project: HP DT dtpad, a memo maker type editor based on the
|
||||
** Dt Editor widget.
|
||||
**
|
||||
** Description: Routines which manipulate the print setup dialog
|
||||
**
|
||||
**************************************************************************
|
||||
**********************************<+>*************************************/
|
||||
/*
|
||||
* Common Desktop Environment
|
||||
*
|
||||
* (c) Copyright 1993, 1994, 1995 Hewlett-Packard Company
|
||||
* (c) Copyright 1993, 1994, 1995 International Business Machines Corp.
|
||||
* (c) Copyright 1993, 1994, 1995 Sun Microsystems, Inc.
|
||||
* (c) Copyright 1993, 1994, 1995 Novell, Inc.
|
||||
* (c) Copyright 1995 Digital Equipment Corp.
|
||||
* (c) Copyright 1995 Fujitsu Limited
|
||||
* (c) Copyright 1995 Hitachi, Ltd.
|
||||
*
|
||||
*
|
||||
* RESTRICTED RIGHTS LEGEND
|
||||
*
|
||||
*Use, duplication, or disclosure by the U.S. Government is subject to
|
||||
*restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in
|
||||
*Technical Data and Computer Software clause in DFARS 252.227-7013. Rights
|
||||
*for non-DOD U.S. Government Departments and Agencies are as set forth in
|
||||
*FAR 52.227-19(c)(1,2).
|
||||
|
||||
*Hewlett-Packard Company, 3000 Hanover Street, Palo Alto, CA 94304 U.S.A.
|
||||
*International Business Machines Corp., Route 100, Somers, NY 10589 U.S.A.
|
||||
*Sun Microsystems, Inc., 2550 Garcia Avenue, Mountain View, CA 94043 U.S.A.
|
||||
*Novell, Inc., 190 River Road, Summit, NJ 07901 U.S.A.
|
||||
*Digital Equipment Corp., 111 Powdermill Road, Maynard, MA 01754, U.S.A.
|
||||
*Fujitsu Limited, 1015, Kamikodanaka Nakahara-Ku, Kawasaki 211, Japan
|
||||
*Hitachi, Ltd., 6, Kanda Surugadai 4-Chome, Chiyoda-ku, Tokyo 101, Japan
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <X11/Intrinsic.h>
|
||||
#include <Xm/Xm.h>
|
||||
#include <Xm/DialogS.h>
|
||||
#include <Xm/Form.h>
|
||||
#include <Xm/Label.h>
|
||||
#include <Xm/Print.h>
|
||||
#include <Xm/Text.h>
|
||||
#include <Dt/Editor.h>
|
||||
|
||||
#include "dtpad.h"
|
||||
|
||||
#define READ_ACCESS 1
|
||||
#define WRITE_ACCESS 2
|
||||
|
||||
static void _poSetInnerPageDimensions(
|
||||
PrintOutput*,
|
||||
Dimension,
|
||||
Dimension,
|
||||
Dimension,
|
||||
Dimension
|
||||
);
|
||||
static int _poDoGetLinesPerPage(PrintOutput*);
|
||||
static int _poGetTopPosition(PrintOutput *pOutput);
|
||||
static DtEditorErrorCode
|
||||
_poGetFileContents(char **contents, char *file);
|
||||
static DtEditorErrorCode
|
||||
_poStripEmbeddedNulls(char *strbuf, int *len);
|
||||
extern DtEditorErrorCode
|
||||
_poEditorValidateFileAccess(char *file, int accessType);
|
||||
|
||||
/*
|
||||
* Used to initialize the top, right, bottom, and left margins
|
||||
* between the outside edge of the page (_form) and the inner
|
||||
* page that is written on.
|
||||
*/
|
||||
const char *const _poDefaultMargin = ".5in";
|
||||
|
||||
/************************************************************************
|
||||
* PrintOutputCreate
|
||||
* Creates and initialiazes a new PrintOutput output including the
|
||||
* widget hierarchy.
|
||||
************************************************************************/
|
||||
PrintOutput*
|
||||
PrintOutputCreate(Widget shell)
|
||||
{
|
||||
Widget w;
|
||||
Boolean parseError;
|
||||
PrintOutput *pOutput;
|
||||
|
||||
pOutput = (PrintOutput *) XtMalloc(sizeof(PrintOutput));
|
||||
pOutput->pShell = shell;
|
||||
|
||||
pOutput->currentLine = 0;
|
||||
pOutput->linesPerPage = 0;
|
||||
|
||||
w = XtVaCreateWidget("Page",
|
||||
xmFormWidgetClass,
|
||||
pOutput->pShell,
|
||||
XmNresizePolicy, XmRESIZE_NONE,
|
||||
NULL);
|
||||
pOutput->page = w;
|
||||
|
||||
w = XtVaCreateWidget("InnerPage",
|
||||
xmFormWidgetClass,
|
||||
pOutput->page,
|
||||
XmNresizePolicy, XmRESIZE_NONE,
|
||||
NULL);
|
||||
pOutput->innerPage = w;
|
||||
|
||||
w = XtVaCreateManagedWidget("HeaderLeft",
|
||||
xmLabelWidgetClass,
|
||||
pOutput->innerPage,
|
||||
XmNalignment, XmALIGNMENT_BEGINNING,
|
||||
XmNleftAttachment, XmATTACH_FORM,
|
||||
XmNtopAttachment, XmATTACH_FORM,
|
||||
NULL);
|
||||
pOutput->headerLeft = w;
|
||||
|
||||
w = XtVaCreateManagedWidget("HeaderRight",
|
||||
xmLabelWidgetClass,
|
||||
pOutput->innerPage,
|
||||
XmNalignment, XmALIGNMENT_END,
|
||||
XmNrightAttachment, XmATTACH_FORM,
|
||||
XmNleftAttachment, XmATTACH_WIDGET,
|
||||
XmNleftWidget, pOutput->headerLeft,
|
||||
XmNtopAttachment, XmATTACH_FORM,
|
||||
NULL);
|
||||
pOutput->headerRight = w;
|
||||
|
||||
w = XtVaCreateManagedWidget("Editor",
|
||||
#ifdef USE_DTEDITOR
|
||||
dtEditorWidgetClass,
|
||||
#else
|
||||
xmTextWidgetClass,
|
||||
#endif
|
||||
pOutput->innerPage,
|
||||
DtNscrollVertical, FALSE,
|
||||
DtNscrollHorizontal, FALSE,
|
||||
DtNshowStatusLine, FALSE,
|
||||
DtNwordWrap, TRUE,
|
||||
XmNeditMode, XmMULTI_LINE_EDIT,
|
||||
XmNleftAttachment, XmATTACH_FORM,
|
||||
XmNrightAttachment, XmATTACH_FORM,
|
||||
XmNtopAttachment, XmATTACH_WIDGET,
|
||||
XmNtopWidget, pOutput->headerLeft,
|
||||
NULL);
|
||||
pOutput->editor = w;
|
||||
|
||||
w = XtVaCreateManagedWidget("FooterLeft",
|
||||
xmLabelWidgetClass,
|
||||
pOutput->innerPage,
|
||||
XmNalignment, XmALIGNMENT_BEGINNING,
|
||||
XmNleftAttachment, XmATTACH_FORM,
|
||||
XmNbottomAttachment, XmATTACH_FORM,
|
||||
NULL);
|
||||
pOutput->footerLeft = w;
|
||||
|
||||
w = XtVaCreateManagedWidget("FooterRight",
|
||||
xmLabelWidgetClass,
|
||||
pOutput->innerPage,
|
||||
XmNalignment, XmALIGNMENT_END,
|
||||
XmNleftAttachment, XmATTACH_WIDGET,
|
||||
XmNleftWidget, pOutput->footerLeft,
|
||||
XmNrightAttachment, XmATTACH_FORM,
|
||||
XmNbottomAttachment, XmATTACH_FORM,
|
||||
NULL);
|
||||
pOutput->footerRight = w;
|
||||
|
||||
XtVaSetValues(
|
||||
pOutput->editor,
|
||||
XmNbottomAttachment, XmATTACH_WIDGET,
|
||||
XmNbottomWidget, pOutput->footerLeft,
|
||||
NULL);
|
||||
|
||||
XtManageChild(pOutput->innerPage);
|
||||
XtManageChild(pOutput->page);
|
||||
|
||||
PrintOutputSetPageMargins(
|
||||
pOutput,
|
||||
_poDefaultMargin,
|
||||
_poDefaultMargin,
|
||||
_poDefaultMargin,
|
||||
_poDefaultMargin,
|
||||
&parseError );
|
||||
assert(parseError == NULL);
|
||||
|
||||
return pOutput;
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
* PrintOutputCreate
|
||||
* Class destructor.
|
||||
************************************************************************/
|
||||
void
|
||||
PrintOutputDestroy(PrintOutput *pOutput)
|
||||
{
|
||||
if (pOutput == NULL) return;
|
||||
XtDestroyWidget(pOutput->page);
|
||||
XtFree((char*) pOutput);
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
* PrintOutputHideFooter
|
||||
* PrintOutputShowFooter
|
||||
* PrintOutputHideHeader
|
||||
* PrintOutputShowHeader
|
||||
* Unmanages/Manages the footer/header widgets
|
||||
************************************************************************/
|
||||
void
|
||||
PrintOutputHideFooters(PrintOutput *pOutput)
|
||||
{
|
||||
XtUnmanageChild(pOutput->footerLeft);
|
||||
XtUnmanageChild(pOutput->footerRight);
|
||||
XtVaSetValues(pOutput->editor, XmNbottomAttachment, XmATTACH_FORM, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
PrintOutputShowFooters(PrintOutput *pOutput)
|
||||
{
|
||||
XtManageChild(pOutput->footerLeft);
|
||||
XtManageChild(pOutput->footerRight);
|
||||
XtVaSetValues(
|
||||
pOutput->editor,
|
||||
XmNbottomAttachment, XmATTACH_WIDGET,
|
||||
XmNbottomWidget, pOutput->footerLeft,
|
||||
NULL);
|
||||
}
|
||||
|
||||
void
|
||||
PrintOutputHideHeaders(PrintOutput *pOutput)
|
||||
{
|
||||
XtUnmanageChild(pOutput->headerLeft);
|
||||
XtUnmanageChild(pOutput->headerRight);
|
||||
XtVaSetValues(pOutput->editor, XmNtopAttachment, XmATTACH_FORM, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
PrintOutputShowHeaders(PrintOutput *pOutput)
|
||||
{
|
||||
XtManageChild(pOutput->headerLeft);
|
||||
XtManageChild(pOutput->headerRight);
|
||||
XtVaSetValues(
|
||||
pOutput->editor,
|
||||
XmNtopAttachment, XmATTACH_WIDGET,
|
||||
XmNtopWidget, pOutput->headerLeft,
|
||||
NULL);
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
* PrintOutputSetHdrFtrString
|
||||
* Set the contents of the specifies header/footer
|
||||
************************************************************************/
|
||||
void
|
||||
PrintOutputSetHdrFtrString(
|
||||
PrintOutput *pOutput,
|
||||
_DtPrintHdrFtrEnum which,
|
||||
char *contents
|
||||
)
|
||||
{
|
||||
Widget w;
|
||||
XmString xms;
|
||||
|
||||
if (contents == (char *) NULL)
|
||||
return;
|
||||
|
||||
switch (which)
|
||||
{
|
||||
case DTPRINT_OPTION_HEADER_LEFT:
|
||||
w = pOutput->headerLeft;
|
||||
break;
|
||||
case DTPRINT_OPTION_HEADER_RIGHT:
|
||||
w = pOutput->headerRight;
|
||||
break;
|
||||
case DTPRINT_OPTION_FOOTER_LEFT:
|
||||
w = pOutput->footerLeft;
|
||||
break;
|
||||
case DTPRINT_OPTION_FOOTER_RIGHT:
|
||||
w = pOutput->footerRight;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
xms = XmStringCreateLocalized(contents);
|
||||
XtVaSetValues(w, XmNlabelString, xms, NULL);
|
||||
XmStringFree(xms);
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
* PrintOutputSetHdrFtrStrings
|
||||
* Set the contents of all the header/footers
|
||||
************************************************************************/
|
||||
void
|
||||
PrintOutputSetHdrFtrStrings(
|
||||
PrintOutput *pOutput,
|
||||
char *hdrLeft,
|
||||
char *hdrRight,
|
||||
char *ftrLeft,
|
||||
char *ftrRight
|
||||
)
|
||||
{
|
||||
XmString xms;
|
||||
|
||||
if (hdrLeft)
|
||||
{
|
||||
xms = XmStringCreateLocalized(hdrLeft);
|
||||
XtVaSetValues(pOutput->headerLeft, XmNlabelString, xms, NULL);
|
||||
XmStringFree(xms);
|
||||
}
|
||||
|
||||
if (hdrRight)
|
||||
{
|
||||
xms = XmStringCreateLocalized(hdrRight);
|
||||
XtVaSetValues(pOutput->headerRight, XmNlabelString, xms, NULL);
|
||||
XmStringFree(xms);
|
||||
}
|
||||
|
||||
if (ftrLeft)
|
||||
{
|
||||
xms = XmStringCreateLocalized(ftrLeft);
|
||||
XtVaSetValues(pOutput->footerLeft, XmNlabelString, xms, NULL);
|
||||
XmStringFree(xms);
|
||||
}
|
||||
|
||||
if (ftrRight)
|
||||
{
|
||||
xms = XmStringCreateLocalized(ftrRight);
|
||||
XtVaSetValues(pOutput->footerRight, XmNlabelString, xms, NULL);
|
||||
XmStringFree(xms);
|
||||
}
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
* PrintOutputSetPageMargin
|
||||
* Set the contents of the specified page margin
|
||||
************************************************************************/
|
||||
void
|
||||
PrintOutputSetPageMargin(
|
||||
PrintOutput *pOutput,
|
||||
_DtPrintMarginEnum which,
|
||||
const char *margin,
|
||||
Boolean *parseError
|
||||
)
|
||||
{
|
||||
int pixels = 0;
|
||||
XtEnum xtParseError = FALSE;
|
||||
char *marginString = XtNewString(margin);
|
||||
|
||||
if (parseError)
|
||||
*parseError = FALSE;
|
||||
|
||||
switch (which)
|
||||
{
|
||||
case DTPRINT_OPTION_MARGIN_TOP:
|
||||
pixels = XmConvertStringToUnits(
|
||||
XtScreenOfObject(pOutput->pShell),
|
||||
marginString,
|
||||
XmVERTICAL,
|
||||
XmPIXELS,
|
||||
&xtParseError);
|
||||
if (!xtParseError && pixels > 0)
|
||||
pOutput->marginTop = pixels;
|
||||
break;
|
||||
case DTPRINT_OPTION_MARGIN_RIGHT:
|
||||
pixels = XmConvertStringToUnits(
|
||||
XtScreenOfObject(pOutput->pShell),
|
||||
marginString,
|
||||
XmHORIZONTAL,
|
||||
XmPIXELS,
|
||||
&xtParseError);
|
||||
if (!xtParseError && pixels > 0)
|
||||
pOutput->marginRight = pixels;
|
||||
break;
|
||||
case DTPRINT_OPTION_MARGIN_BOTTOM:
|
||||
pixels = XmConvertStringToUnits(
|
||||
XtScreenOfObject(pOutput->pShell),
|
||||
marginString,
|
||||
XmVERTICAL,
|
||||
XmPIXELS,
|
||||
&xtParseError);
|
||||
if (!xtParseError && pixels > 0)
|
||||
pOutput->marginBottom = pixels;
|
||||
break;
|
||||
case DTPRINT_OPTION_MARGIN_LEFT:
|
||||
pixels = XmConvertStringToUnits(
|
||||
XtScreenOfObject(pOutput->pShell),
|
||||
marginString,
|
||||
XmHORIZONTAL,
|
||||
XmPIXELS,
|
||||
&xtParseError);
|
||||
if (!xtParseError && pixels > 0)
|
||||
pOutput->marginLeft = pixels;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
if (!xtParseError)
|
||||
_poSetInnerPageDimensions(
|
||||
pOutput,
|
||||
pOutput->marginTop,
|
||||
pOutput->marginRight,
|
||||
pOutput->marginBottom,
|
||||
pOutput->marginLeft);
|
||||
else
|
||||
*parseError = TRUE;
|
||||
|
||||
XtFree(marginString);
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
* PrintOutputSetPageMargins
|
||||
* Set the contents of all the page margins
|
||||
************************************************************************/
|
||||
void
|
||||
PrintOutputSetPageMargins(
|
||||
PrintOutput *pOutput,
|
||||
const char *top,
|
||||
const char *right,
|
||||
const char *bottom,
|
||||
const char *left,
|
||||
Boolean *parseError
|
||||
)
|
||||
{
|
||||
int pixels = 0;
|
||||
XtEnum xtParseError = FALSE;
|
||||
char *margin;
|
||||
|
||||
*parseError = FALSE;
|
||||
|
||||
margin = XtNewString(top);
|
||||
pixels = XmConvertStringToUnits(
|
||||
XtScreenOfObject(pOutput->pShell),
|
||||
margin,
|
||||
XmVERTICAL,
|
||||
XmPIXELS,
|
||||
&xtParseError);
|
||||
XtFree(margin);
|
||||
if (!xtParseError && pixels > 0)
|
||||
{
|
||||
pOutput->marginTop = pixels;
|
||||
}
|
||||
else
|
||||
{
|
||||
*parseError = TRUE;
|
||||
return;
|
||||
}
|
||||
|
||||
margin = XtNewString(right);
|
||||
pixels = XmConvertStringToUnits(
|
||||
XtScreenOfObject(pOutput->pShell),
|
||||
margin,
|
||||
XmHORIZONTAL,
|
||||
XmPIXELS,
|
||||
&xtParseError);
|
||||
XtFree(margin);
|
||||
if (!xtParseError && pixels > 0)
|
||||
{
|
||||
pOutput->marginRight = pixels;
|
||||
}
|
||||
else
|
||||
{
|
||||
*parseError = TRUE;
|
||||
return;
|
||||
}
|
||||
|
||||
margin = XtNewString(bottom);
|
||||
pixels = XmConvertStringToUnits(
|
||||
XtScreenOfObject(pOutput->pShell),
|
||||
margin,
|
||||
XmVERTICAL,
|
||||
XmPIXELS,
|
||||
&xtParseError);
|
||||
XtFree(margin);
|
||||
if (!xtParseError && pixels > 0)
|
||||
{
|
||||
pOutput->marginBottom = pixels;
|
||||
}
|
||||
else
|
||||
{
|
||||
*parseError = TRUE;
|
||||
return;
|
||||
}
|
||||
|
||||
margin = XtNewString(left);
|
||||
pixels = XmConvertStringToUnits(
|
||||
XtScreenOfObject(pOutput->pShell),
|
||||
margin,
|
||||
XmHORIZONTAL,
|
||||
XmPIXELS,
|
||||
&xtParseError);
|
||||
XtFree(margin);
|
||||
if (!xtParseError && pixels > 0)
|
||||
{
|
||||
pOutput->marginLeft = pixels;
|
||||
}
|
||||
else
|
||||
{
|
||||
*parseError = TRUE;
|
||||
return;
|
||||
}
|
||||
|
||||
_poSetInnerPageDimensions(
|
||||
pOutput,
|
||||
pOutput->marginTop,
|
||||
pOutput->marginRight,
|
||||
pOutput->marginBottom,
|
||||
pOutput->marginLeft);
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* PrintOutputSetWordWrap
|
||||
* Set the wrap to fit value in the editor
|
||||
************************************************************************/
|
||||
void
|
||||
PrintOutputSetWordWrap(PrintOutput *pOutput, Boolean onoff)
|
||||
{
|
||||
#ifdef USE_DTEDITOR
|
||||
XtVaSetValues(pOutput->editor, DtNwordWrap, onoff, NULL);
|
||||
#else
|
||||
XtVaSetValues(pOutput->editor, XmNwordWrap, onoff, NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
* PrintOutputGetLinesPerPage
|
||||
* Returns the number of lines per page.
|
||||
************************************************************************/
|
||||
int
|
||||
PrintOutputGetLinesPerPage(PrintOutput *pOutput)
|
||||
{
|
||||
return ((int) pOutput->linesPerPage);
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
* PrintOutputGetNumLines
|
||||
* Returns the number of lines of test in the editor.
|
||||
************************************************************************/
|
||||
int
|
||||
PrintOutputGetNumLines(PrintOutput *pOutput)
|
||||
{
|
||||
int total = 0;
|
||||
int saveTop;
|
||||
|
||||
#ifdef USE_DTEDITOR
|
||||
saveTop = pOutput->currentLine;
|
||||
PrintOutputFirstPage(pOutput);
|
||||
while (PrintOutputPageDown(pOutput))
|
||||
total += pOutput->linesPerPage;
|
||||
|
||||
DtEditorGoToLine(pOutput->editor, saveTop);
|
||||
pOutput->currentLine = saveTop;
|
||||
#else
|
||||
XtVaGetValues(pOutput->editor, XmNtotalLines, &total, NULL);
|
||||
#endif
|
||||
return(total);
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
* PrintOutputPageUp
|
||||
************************************************************************/
|
||||
Boolean
|
||||
PrintOutputPageUp(PrintOutput *pOutput)
|
||||
{
|
||||
XmTextPosition top_before, top_after;
|
||||
Boolean retval;
|
||||
|
||||
#ifdef USE_DTEDITOR
|
||||
DtEditorGoToLine(
|
||||
pOutput->editor,
|
||||
pOutput->currentLine - pOutput->linesPerPage
|
||||
);
|
||||
pOutput->currentLine -= pOutput->linesPerPage;
|
||||
if (pOutput->currentLine < 1)
|
||||
{
|
||||
pOutput->currentLine = 1;
|
||||
retval = FALSE;
|
||||
}
|
||||
#else
|
||||
top_before = (XmTextPosition) _poGetTopPosition(pOutput);
|
||||
XmTextScroll(pOutput->editor, -1 * pOutput->linesPerPage);
|
||||
top_after = (XmTextPosition) _poGetTopPosition(pOutput);
|
||||
retval = (top_before > top_after) ? TRUE : FALSE;
|
||||
#endif
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
* PrintOutputPageDown
|
||||
************************************************************************/
|
||||
Boolean
|
||||
PrintOutputPageDown(PrintOutput *pOutput)
|
||||
{
|
||||
XmTextPosition top_before, top_after;
|
||||
|
||||
top_before = (XmTextPosition) _poGetTopPosition(pOutput);
|
||||
|
||||
#ifdef USE_DTEDITOR
|
||||
DtEditorGoToLine(
|
||||
pOutput->editor,
|
||||
pOutput->currentLine + pOutput->linesPerPage
|
||||
);
|
||||
pOutput->currentLine += pOutput->linesPerPage;
|
||||
#else
|
||||
XmTextScroll(pOutput->editor, pOutput->linesPerPage);
|
||||
#endif
|
||||
|
||||
top_after = (XmTextPosition) _poGetTopPosition(pOutput);
|
||||
return (top_before < top_after) ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
* PrintOutputFirstPage
|
||||
************************************************************************/
|
||||
void
|
||||
PrintOutputFirstPage(PrintOutput *pOutput)
|
||||
{
|
||||
#ifdef USE_DTEDITOR
|
||||
XtVaSetValues(pOutput->editor, DtNtopCharacter, (XmTextPosition) 0, NULL);
|
||||
pOutput->currentLine = 1;
|
||||
#else
|
||||
XmTextSetTopCharacter(pOutput->editor, (XmTextPosition) 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
* PrintOutputLoadFile
|
||||
************************************************************************/
|
||||
DtEditorErrorCode
|
||||
PrintOutputLoadFile( PrintOutput *pOutput, char *file)
|
||||
{
|
||||
char *contents = NULL;
|
||||
DtEditorErrorCode errorCode;
|
||||
|
||||
#ifdef USE_DTEDITOR
|
||||
errorCode = DtEditorSetContentsFromFile(pOutput->editor, file);
|
||||
#else
|
||||
errorCode = _poGetFileContents(&contents, file);
|
||||
if (contents != NULL)
|
||||
{
|
||||
XmTextSetString(pOutput->editor, contents);
|
||||
free(contents);
|
||||
}
|
||||
#endif
|
||||
|
||||
return errorCode;
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
************************************************************************
|
||||
*
|
||||
* Private class methods
|
||||
*
|
||||
* _poDoGetLinesPerPage - Returns number of rows in the editor.
|
||||
* _poSetInnerPageDimensions- Sets the XmN x,y,width,height of InnerPage.
|
||||
* _poGetTopPosition - Returns the position of the 1st visible char.
|
||||
* _poGetFileContents - Returns the contents of the specified file.
|
||||
* _poStripEmbeddedNulls - Removes any embedded NULLs (\0) in a
|
||||
* string of length 'length'. The removal
|
||||
* occurs in place, with 'length' set to the
|
||||
* new, stripped length. The resulting string
|
||||
* is terminated with a trailing NULL.
|
||||
*
|
||||
************************************************************************
|
||||
************************************************************************/
|
||||
|
||||
static int
|
||||
_poDoGetLinesPerPage(PrintOutput *pOutput)
|
||||
{
|
||||
Dimension lpp;
|
||||
|
||||
XtVaGetValues(pOutput->editor, XmNrows, &lpp, NULL);
|
||||
return ((int) lpp);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
_poSetInnerPageDimensions(
|
||||
PrintOutput *pOutput,
|
||||
Dimension top,
|
||||
Dimension right,
|
||||
Dimension bottom,
|
||||
Dimension left
|
||||
)
|
||||
{
|
||||
Dimension inner_height, inner_width, inner_x, inner_y,
|
||||
outer_height, outer_width,
|
||||
editor_height, footer_height, header_height;
|
||||
|
||||
XtVaGetValues(pOutput->page,
|
||||
XmNheight, &outer_height,
|
||||
XmNwidth, &outer_width,
|
||||
NULL);
|
||||
|
||||
XtVaGetValues(pOutput->headerLeft,
|
||||
XmNheight, &header_height,
|
||||
NULL);
|
||||
|
||||
XtVaGetValues(pOutput->footerLeft,
|
||||
XmNheight, &footer_height,
|
||||
NULL);
|
||||
|
||||
inner_x = left;
|
||||
inner_y = top;
|
||||
inner_height = (outer_height > (Dimension) (top + bottom)) ?
|
||||
(outer_height - (top + bottom)) :
|
||||
outer_height;
|
||||
inner_width = (outer_width > (Dimension) (left + right)) ?
|
||||
(outer_width - (left + right)) :
|
||||
outer_width;
|
||||
editor_height =
|
||||
(inner_height > (Dimension) (header_height + footer_height)) ?
|
||||
(inner_height - (header_height + footer_height)) :
|
||||
inner_height;
|
||||
|
||||
XtVaSetValues(pOutput->editor, XmNheight, editor_height, NULL);
|
||||
|
||||
XtVaSetValues(pOutput->innerPage,
|
||||
XmNleftAttachment, XmATTACH_NONE,
|
||||
XmNtopAttachment, XmATTACH_NONE,
|
||||
XmNx, inner_x,
|
||||
XmNy, inner_y,
|
||||
XmNheight, inner_height,
|
||||
XmNwidth, inner_width,
|
||||
NULL);
|
||||
|
||||
pOutput->linesPerPage = _poDoGetLinesPerPage(pOutput);
|
||||
}
|
||||
|
||||
/*
|
||||
* _poGetTopPosition
|
||||
*/
|
||||
static int
|
||||
_poGetTopPosition(PrintOutput *pOutput)
|
||||
{
|
||||
XmTextPosition top = (XmTextPosition) 0;
|
||||
|
||||
#ifdef USE_DTEDITOR
|
||||
XtVaGetValues(pOutput->editor, DtNtopCharacter, &top, NULL);
|
||||
#else
|
||||
top = XmTextGetTopCharacter(pOutput->editor);
|
||||
#endif
|
||||
return (int) top;
|
||||
}
|
||||
|
||||
static DtEditorErrorCode
|
||||
_poGetFileContents(char **contents, char *file)
|
||||
{
|
||||
DtEditorErrorCode error = DtEDITOR_NO_ERRORS;
|
||||
struct stat statbuf;
|
||||
char *buf;
|
||||
int nbytes;
|
||||
FILE *fp = NULL;
|
||||
|
||||
if (file == NULL || *file == NULL) return
|
||||
|
||||
/*
|
||||
* Open the file for reading.
|
||||
*/
|
||||
error = _poEditorValidateFileAccess(file, READ_ACCESS);
|
||||
if (error != DtEDITOR_NO_ERRORS) return error;
|
||||
|
||||
if( (fp = fopen(file, "r")) == NULL )
|
||||
return DtEDITOR_UNREADABLE_FILE;
|
||||
|
||||
stat(file, &statbuf);
|
||||
nbytes = statbuf.st_size;
|
||||
|
||||
/*
|
||||
* Read the file contents (with room for null) & convert to a
|
||||
* string. We want to use a string because the
|
||||
* DtEditorSetContents/Append/Insert/... functions create another
|
||||
* copy of the data before actually putting it into the widget.
|
||||
*/
|
||||
buf = (char *) malloc(nbytes + 1);
|
||||
if (buf == NULL)
|
||||
return DtEDITOR_INSUFFICIENT_MEMORY;
|
||||
|
||||
nbytes = fread(buf, sizeof(char), nbytes, fp);
|
||||
buf[nbytes] = '\0';
|
||||
|
||||
/*
|
||||
* Strip out any embedded NULLs because the text widget will only
|
||||
* accept data up to the first NULL.
|
||||
*/
|
||||
error = _poStripEmbeddedNulls(buf, &nbytes);
|
||||
|
||||
/* Close the file */
|
||||
fclose(fp);
|
||||
|
||||
*contents = buf;
|
||||
return error;
|
||||
} /* end LoadFile */
|
||||
|
||||
static DtEditorErrorCode
|
||||
_poStripEmbeddedNulls(char *strbuf, int *len)
|
||||
{
|
||||
DtEditorErrorCode retval = DtEDITOR_NO_ERRORS;
|
||||
|
||||
if (strlen(strbuf) != *len)
|
||||
{
|
||||
int firstNull;
|
||||
|
||||
retval = DtEDITOR_NULLS_REMOVED;
|
||||
|
||||
/*
|
||||
* The file contains NULL characters, so we strip them out and
|
||||
* report that we have done so.
|
||||
*/
|
||||
while((firstNull = strlen(strbuf)) != *len)
|
||||
{
|
||||
int lastNull = firstNull;
|
||||
|
||||
while((lastNull+1) < *len && strbuf[lastNull+1] == (char)'\0')
|
||||
lastNull++;
|
||||
|
||||
memcpy(&strbuf[firstNull], &strbuf[lastNull+1], *len-lastNull);
|
||||
*len -= 1 + lastNull - firstNull;
|
||||
}
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
extern DtEditorErrorCode
|
||||
_poEditorValidateFileAccess( char *file, int accessType )
|
||||
{
|
||||
struct stat statbuf;
|
||||
unsigned short tmpMode;
|
||||
|
||||
if (file && *file ) return DtEDITOR_INVALID_FILENAME;
|
||||
|
||||
if (access(file, F_OK) != 0) return DtEDITOR_NONEXISTENT_FILE;
|
||||
|
||||
if( stat(file, &statbuf) != 0 ) return DtEDITOR_NO_FILE_ACCESS;
|
||||
|
||||
if( (statbuf.st_mode & S_IFMT) == S_IFDIR ) return DtEDITOR_DIRECTORY;
|
||||
|
||||
if( (statbuf.st_mode & S_IFMT) == S_IFCHR ) return DtEDITOR_CHAR_SPECIAL_FILE;
|
||||
|
||||
if((statbuf.st_mode & S_IFMT) == S_IFBLK) return DtEDITOR_BLOCK_MODE_FILE;
|
||||
|
||||
switch( accessType )
|
||||
{
|
||||
case READ_ACCESS:
|
||||
if (access(file, R_OK) != 0) return DtEDITOR_UNREADABLE_FILE;
|
||||
break;
|
||||
case WRITE_ACCESS:
|
||||
if (access(file, W_OK) != 0) return DtEDITOR_UNWRITABLE_FILE;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
} /* end stat suceeded */
|
||||
|
||||
return DtEDITOR_NO_ERRORS;
|
||||
}
|
||||
1183
cde/programs/dtpad/printSetup.c
Normal file
1183
cde/programs/dtpad/printSetup.c
Normal file
File diff suppressed because it is too large
Load Diff
422
cde/programs/dtpad/session.c
Normal file
422
cde/programs/dtpad/session.c
Normal file
@@ -0,0 +1,422 @@
|
||||
/* $XConsortium: session.c /main/3 1995/11/01 10:39:26 rswiston $ */
|
||||
/**********************************<+>*************************************
|
||||
***************************************************************************
|
||||
**
|
||||
** File: session.c
|
||||
**
|
||||
** Project: DT dtpad, a memo maker type editor based on the motif
|
||||
** text widget.
|
||||
**
|
||||
** Description: Provides the functionality for saving and restoring the
|
||||
** user's session.
|
||||
**
|
||||
**
|
||||
*******************************************************************
|
||||
** (c) Copyright Hewlett-Packard Company, 1990, 1991, 1992, 1993.
|
||||
** All rights are
|
||||
** reserved. Copying or other reproduction of this program
|
||||
** except for archival purposes is prohibited without prior
|
||||
** written consent of Hewlett-Packard Company.
|
||||
********************************************************************
|
||||
**
|
||||
********************************************************************
|
||||
** (c) Copyright 1993, 1994 Hewlett-Packard Company
|
||||
** (c) Copyright 1993, 1994 International Business Machines Corp.
|
||||
** (c) Copyright 1993, 1994 Sun Microsystems, Inc.
|
||||
** (c) Copyright 1993, 1994 Novell, Inc.
|
||||
********************************************************************
|
||||
**
|
||||
**
|
||||
**************************************************************************
|
||||
**********************************<+>*************************************/
|
||||
#include "dtpad.h"
|
||||
#include <Dt/Wsm.h>
|
||||
/*
|
||||
* This for the sleazy hack to get the window manager frame width/height
|
||||
*/
|
||||
#include <Xm/VendorSEP.h>
|
||||
|
||||
/* Copied from BaseClassI.h */
|
||||
extern XmWidgetExtData _XmGetWidgetExtData(
|
||||
Widget widget,
|
||||
#if NeedWidePrototypes
|
||||
unsigned int extType) ;
|
||||
#else
|
||||
unsigned char extType) ;
|
||||
#endif /* NeedWidePrototypes */
|
||||
|
||||
#define MSG1 ((char *)GETMESSAGE(10, 1, "Check the file permissions."))
|
||||
#define MSG2 ((char *)GETMESSAGE(10, 2, "%s is the file that would have been used to save your session."))
|
||||
|
||||
extern Widget topLevelWithWmCommand; /* declared in main.c */
|
||||
extern Editor *pPadList;
|
||||
extern int numActivePads;
|
||||
|
||||
/* Structure used on a save session to see if a dt is iconic */
|
||||
|
||||
static Atom wm_state_atom;
|
||||
typedef struct
|
||||
{
|
||||
int state;
|
||||
Window icon;
|
||||
} WM_STATE;
|
||||
|
||||
|
||||
/************************************************************************
|
||||
*
|
||||
* SaveMain - saves the parameters associated with a Pad's mainWindow
|
||||
* (called from SaveSessionCB() below).
|
||||
*
|
||||
***********************************************************************/
|
||||
void
|
||||
SaveMain(
|
||||
Editor *pPad,
|
||||
int padNum,
|
||||
int fd)
|
||||
{
|
||||
char bufr[1024];
|
||||
Position x,y;
|
||||
Dimension width, height;
|
||||
Atom *pWsPresence;
|
||||
unsigned long numInfo;
|
||||
Atom actual_type;
|
||||
int actual_format;
|
||||
unsigned long nitems;
|
||||
unsigned long leftover;
|
||||
WM_STATE * wm_state;
|
||||
|
||||
if(pPad->mainWindow != (Widget)NULL)
|
||||
{
|
||||
XmVendorShellExtObject vendorExt;
|
||||
XmWidgetExtData extData;
|
||||
|
||||
if(XtIsRealized(pPad->mainWindow))
|
||||
sprintf(bufr,"*mainWindow%d.ismapped: True\n", padNum);
|
||||
|
||||
/* Get and write out the geometry info for our Window */
|
||||
x = XtX(XtParent(pPad->mainWindow));
|
||||
y = XtY(XtParent(pPad->mainWindow));
|
||||
|
||||
/*
|
||||
* Modify x & y to take into account window mgr frames
|
||||
* This is pretty bogus, but I don't know a better way to do it.
|
||||
*/
|
||||
extData = _XmGetWidgetExtData(pPad->app_shell, XmSHELL_EXTENSION);
|
||||
vendorExt = (XmVendorShellExtObject)extData->widget;
|
||||
x -= vendorExt->vendor.xOffset;
|
||||
y -= vendorExt->vendor.yOffset;
|
||||
|
||||
width = XtWidth(XtParent(pPad->mainWindow));
|
||||
height = XtHeight(XtParent(pPad->mainWindow));
|
||||
|
||||
sprintf(bufr, "%s*mainWindow%d.x: %d\n", bufr, padNum, x);
|
||||
sprintf(bufr, "%s*mainWindow%d.y: %d\n", bufr, padNum, y);
|
||||
sprintf(bufr, "%s*mainWindow%d.width: %d\n", bufr, padNum, width);
|
||||
sprintf(bufr, "%s*mainWindow%d.height: %d\n", bufr, padNum, height);
|
||||
|
||||
wm_state_atom = XmInternAtom (XtDisplay(pPad->app_shell), "WM_STATE",
|
||||
False);
|
||||
/* Getting the WM_STATE property to see if iconified or not */
|
||||
XGetWindowProperty (XtDisplay(pPad->app_shell),
|
||||
XtWindow (pPad->app_shell),
|
||||
wm_state_atom, 0L, (long) BUFSIZ, False,
|
||||
wm_state_atom, &actual_type, &actual_format,
|
||||
&nitems, &leftover, (unsigned char **) &wm_state);
|
||||
|
||||
/* Write out if iconified our not */
|
||||
sprintf(bufr, "%s*mainWindow%d.iconify: ", bufr, padNum);
|
||||
|
||||
if (wm_state->state == IconicState)
|
||||
sprintf (bufr, "%sTrue\n", bufr);
|
||||
else
|
||||
sprintf (bufr, "%sFalse\n", bufr);
|
||||
|
||||
if(DtWsmGetWorkspacesOccupied(XtDisplay(pPad->app_shell),
|
||||
XtWindow(pPad->app_shell), &pWsPresence,
|
||||
&numInfo) == Success)
|
||||
{
|
||||
int i;
|
||||
sprintf(bufr, "%s*mainWindow%d.workspaceList: ", bufr, padNum);
|
||||
for(i = 0; i < numInfo; i++)
|
||||
{
|
||||
char *name = XGetAtomName(XtDisplay(pPad->app_shell),
|
||||
pWsPresence[i]);
|
||||
sprintf(bufr, "%s %s", bufr, name);
|
||||
XtFree(name);
|
||||
}
|
||||
sprintf(bufr, "%s\n", bufr);
|
||||
XtFree((char *)pWsPresence);
|
||||
}
|
||||
|
||||
write (fd, bufr, strlen(bufr));
|
||||
}
|
||||
if(pPad->fileStuff.fileName != (char *)NULL)
|
||||
{
|
||||
sprintf(bufr, "*mainWindow%d.fileName: %s\n", padNum,
|
||||
pPad->fileStuff.fileName);
|
||||
write (fd, bufr, strlen(bufr));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************
|
||||
*
|
||||
* SaveSessionCB - saves the editor state (just filename) - does not save
|
||||
* the file at this time.
|
||||
*
|
||||
* This routines is setup as the "WM_SAVE_YOURSELF" WMProtocolCallback
|
||||
* on the top level widget (created via XtInitialize).
|
||||
*
|
||||
************************************************************************/
|
||||
/* ARGSUSED */
|
||||
void
|
||||
SaveSessionCB(
|
||||
Widget w, /* widget id */
|
||||
caddr_t client_data, /* data from application */
|
||||
caddr_t call_data ) /* data from widget class */
|
||||
{
|
||||
char *longpath, *fileName;
|
||||
int fd, numPadsToSave;
|
||||
char *xa_CommandStr[10];
|
||||
char *tmpStr, bufr[1024];
|
||||
Editor *pPad;
|
||||
int i;
|
||||
|
||||
/* Xt may not pass a widget as advertised (??? is this needed? - hp) */
|
||||
if(!XtIsShell(w))
|
||||
w = XtParent(w);
|
||||
|
||||
for(pPad = pPadList, numPadsToSave = 0; pPad != (Editor *)NULL;
|
||||
pPad = pPad->pNextPad)
|
||||
{
|
||||
if(pPad->inUse == True)
|
||||
numPadsToSave++;
|
||||
}
|
||||
if(numPadsToSave < 1)
|
||||
{
|
||||
xa_CommandStr[0] = (char *)NULL;
|
||||
XSetCommand(XtDisplay(w), XtWindow(w), xa_CommandStr, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
DtSessionSavePath(w, &longpath, &fileName);
|
||||
|
||||
/* Create the session file */
|
||||
if ((fd = creat (longpath, S_IRUSR | S_IRGRP | S_IWUSR | S_IWGRP)) == -1)
|
||||
{
|
||||
tmpStr = (char *)malloc(strlen(MSG2) + strlen(longpath)+ 1);
|
||||
sprintf(tmpStr, MSG2, longpath);
|
||||
_DtSimpleErrnoError(pPad->progname, DtError, MSG1, tmpStr, NULL);
|
||||
free(tmpStr);
|
||||
XtFree ((char *)longpath);
|
||||
return;
|
||||
}
|
||||
|
||||
sprintf(bufr, "*pads.numActivePads: %d\n", numPadsToSave);
|
||||
write (fd, bufr, strlen(bufr));
|
||||
|
||||
for(pPad = pPadList, i = 0; pPad != (Editor *)NULL;
|
||||
pPad = pPad->pNextPad, i++)
|
||||
{
|
||||
if(pPad->inUse == True)
|
||||
SaveMain(pPad, i, fd);
|
||||
}
|
||||
|
||||
close(fd);
|
||||
|
||||
i = 0;
|
||||
xa_CommandStr[i] = pPadList->progname; i++;
|
||||
xa_CommandStr[i] = "-session"; i++;
|
||||
xa_CommandStr[i] = fileName; i++;
|
||||
|
||||
XSetCommand(XtDisplay(topLevelWithWmCommand),
|
||||
XtWindow(topLevelWithWmCommand), xa_CommandStr, i);
|
||||
|
||||
XtFree ((char *)fileName);
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
*
|
||||
* closeCB - set up as the "WM_DELETE_WINDOW" WMProtocolCallback on the
|
||||
* application shell for each Editor instance - and called when
|
||||
* a delete window command is received from the Window Manager.
|
||||
* Waits for CloseWindow to become false before it continues.
|
||||
*
|
||||
***********************************************************************/
|
||||
|
||||
/* ARGSUSED */
|
||||
void
|
||||
closeCB(
|
||||
Widget w,
|
||||
caddr_t client_data,
|
||||
caddr_t call_data )
|
||||
{
|
||||
Editor *pPad = (Editor *)client_data;
|
||||
|
||||
/* call the callback for Exit within the File Menu pulldown */
|
||||
XtCallCallbacks(pPad->ExitWid, XmNactivateCallback, (XtPointer)pPad);
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
*
|
||||
* restoreSession - gets the valid x and y location of where to put the
|
||||
* Text Edit on the root window. Sets the global varible
|
||||
* dtpad.saveRestore to True so the rest of the program knows that
|
||||
* a session is being restored.
|
||||
*
|
||||
***********************************************************************/
|
||||
void
|
||||
restoreSession(
|
||||
Editor *pPad)
|
||||
{
|
||||
XrmDatabase db;
|
||||
char *tmpStr;
|
||||
XrmName xrm_name[5];
|
||||
XrmRepresentation rep_type;
|
||||
XrmValue value;
|
||||
char *fileName = pPad->xrdb.session;
|
||||
char *path;
|
||||
int numPadsToRestore, i;
|
||||
Boolean foundPad;
|
||||
|
||||
if(DtSessionRestorePath(topLevelWithWmCommand, &path, fileName) == False)
|
||||
path = fileName;
|
||||
|
||||
/* Open the file as a resource database */
|
||||
if ((db = XrmGetFileDatabase (path)) == NULL)
|
||||
{
|
||||
tmpStr = (char *)XtMalloc(strlen(MSG2) + strlen(path)+ 1);
|
||||
sprintf(tmpStr, MSG2, path);
|
||||
_DtSimpleErrnoError(pPad->progname, DtError, MSG1, tmpStr, NULL);
|
||||
XtFree(tmpStr);
|
||||
return;
|
||||
}
|
||||
|
||||
xrm_name[0] = XrmStringToQuark ("pads");
|
||||
xrm_name[1] = XrmStringToQuark ("numActivePads");
|
||||
xrm_name[2] = NULL;
|
||||
XrmQGetResource (db, xrm_name, xrm_name, &rep_type, &value);
|
||||
numPadsToRestore = atoi((char *)value.addr);
|
||||
|
||||
if(numPadsToRestore == 0)
|
||||
{
|
||||
/*
|
||||
* Either it's an old (i.e. 2.01) session file,
|
||||
* or it's bogus. Either way, we'll create one
|
||||
* window, taking whatever mainWindow: resources
|
||||
* we can find.
|
||||
*/
|
||||
xrm_name[0] = XrmStringToQuark ("mainWindow");
|
||||
xrm_name[2] = NULL;
|
||||
|
||||
/* get x position */
|
||||
xrm_name[1] = XrmStringToQuark ("x");
|
||||
XrmQGetResource (db, xrm_name, xrm_name, &rep_type, &value);
|
||||
pPad->x = atoi((char *)value.addr);
|
||||
|
||||
/* get y position */
|
||||
xrm_name[1] = XrmStringToQuark ("y");
|
||||
XrmQGetResource (db, xrm_name, xrm_name, &rep_type, &value);
|
||||
pPad->y = atoi((char *)value.addr);
|
||||
|
||||
pPad->saveRestore = True;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
RestorePad(pPad, 0, db);
|
||||
|
||||
for(i = 1; i < numPadsToRestore; i++)
|
||||
{
|
||||
foundPad = FindOrCreatePad(&pPad);
|
||||
RestorePad(pPad, i, db);
|
||||
|
||||
if(foundPad == False)
|
||||
RealizeNewPad(pPad);
|
||||
else
|
||||
ManageOldPad(pPad, False);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************
|
||||
*
|
||||
* RestoreMain -
|
||||
*
|
||||
***********************************************************************/
|
||||
static void
|
||||
RestoreMain(
|
||||
Editor *pPad,
|
||||
int padNum,
|
||||
XrmDatabase db)
|
||||
{
|
||||
char * iconify = NULL;
|
||||
char buf[1024];
|
||||
XrmName xrm_name[5];
|
||||
XrmRepresentation rep_type;
|
||||
XrmValue value;
|
||||
|
||||
sprintf(buf, "mainWindow%d", padNum);
|
||||
xrm_name[0] = XrmStringToQuark(buf);
|
||||
xrm_name[2] = NULL;
|
||||
|
||||
/* get x position */
|
||||
xrm_name[1] = XrmStringToQuark ("x");
|
||||
XrmQGetResource (db, xrm_name, xrm_name, &rep_type, &value);
|
||||
pPad->x = atoi((char *)value.addr);
|
||||
|
||||
/* get y position */
|
||||
xrm_name [1] = XrmStringToQuark ("y");
|
||||
XrmQGetResource (db, xrm_name, xrm_name, &rep_type, &value);
|
||||
pPad->y = atoi((char *)value.addr);
|
||||
|
||||
/* get width */
|
||||
xrm_name [1] = XrmStringToQuark ("width");
|
||||
XrmQGetResource (db, xrm_name, xrm_name, &rep_type, &value);
|
||||
pPad->width = atoi((char *)value.addr);
|
||||
|
||||
/* get height */
|
||||
xrm_name [1] = XrmStringToQuark ("height");
|
||||
XrmQGetResource (db, xrm_name, xrm_name, &rep_type, &value);
|
||||
pPad->height = atoi((char *)value.addr);
|
||||
|
||||
/* Get and set whether the view is iconic */
|
||||
xrm_name [1] = XrmStringToQuark ("iconify");
|
||||
XrmQGetResource (db, xrm_name, xrm_name, &rep_type, &value);
|
||||
/* If there is an iconify resource and its value is True, */
|
||||
/* then mark the window as iconified. */
|
||||
if ((iconify = (char *) value.addr) != NULL &&
|
||||
strcmp (iconify, "True") == 0)
|
||||
pPad->iconic = True;
|
||||
else
|
||||
pPad->iconic = False;
|
||||
|
||||
/* get the file name */
|
||||
xrm_name [1] = XrmStringToQuark ("fileName");
|
||||
XrmQGetResource (db, xrm_name, xrm_name, &rep_type, &value);
|
||||
pPad->fileStuff.fileName = strdup((char *) value.addr);
|
||||
|
||||
/* get workspace list */
|
||||
xrm_name[1] = XrmStringToQuark("workspaceList");
|
||||
XrmQGetResource(db, xrm_name, xrm_name, &rep_type, &value);
|
||||
pPad->xrdb.workspaceList = strdup((char *) value.addr);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************
|
||||
*
|
||||
* RestorePad -
|
||||
*
|
||||
***********************************************************************/
|
||||
void
|
||||
RestorePad(
|
||||
Editor *pPad,
|
||||
int padNum,
|
||||
XrmDatabase db)
|
||||
{
|
||||
RestoreMain(pPad, padNum, db);
|
||||
pPad->saveRestore = True;
|
||||
}
|
||||
920
cde/programs/dtpad/ttMsgSupport.c
Normal file
920
cde/programs/dtpad/ttMsgSupport.c
Normal file
@@ -0,0 +1,920 @@
|
||||
/* $TOG: ttMsgSupport.c /main/7 1999/09/15 14:23:02 mgreess $ */
|
||||
/**********************************<+>*************************************
|
||||
***************************************************************************
|
||||
**
|
||||
** File: ttMsgSupport.c
|
||||
**
|
||||
** Project: DT dtpad, a memo maker type editor based on the Dt Editor
|
||||
** widget.
|
||||
**
|
||||
** Description:
|
||||
** -----------
|
||||
**
|
||||
** Provides support for the Tool Talk "Desktop" and "Document and Media
|
||||
** Exchange" message sets.
|
||||
**
|
||||
** XXX - Need to use mesage catalogs for error messages and not write to
|
||||
** stdout or stderr.
|
||||
**
|
||||
*******************************************************************
|
||||
** (c) Copyright Hewlett-Packard Company, 1990, 1991, 1992, 1993.
|
||||
** All rights are
|
||||
** reserved. Copying or other reproduction of this program
|
||||
** except for archival purposes is prohibited without prior
|
||||
** written consent of Hewlett-Packard Company.
|
||||
********************************************************************
|
||||
**
|
||||
********************************************************************
|
||||
** (c) Copyright 1993, 1994 Hewlett-Packard Company
|
||||
** (c) Copyright 1993, 1994 International Business Machines Corp.
|
||||
** (c) Copyright 1993, 1994 Sun Microsystems, Inc.
|
||||
** (c) Copyright 1993, 1994 Novell, Inc.
|
||||
********************************************************************
|
||||
**
|
||||
**
|
||||
**************************************************************************
|
||||
**********************************<+>*************************************/
|
||||
#include "dtpad.h"
|
||||
#include <dirent.h>
|
||||
#include <Dt/DtpadM.h>
|
||||
|
||||
#define TIMEOUT_FACTOR 1000
|
||||
|
||||
XtInputId ProcessToolTalkInputId = 0;
|
||||
|
||||
extern Editor *pPadList; /* list of Editor instances - declared in main.c */
|
||||
extern char *initialServerGeometry; /* declared in main.c */
|
||||
extern Tt_message TTSaveContractCB( /* declared in ttSaveSupport.c */
|
||||
Tt_message m,
|
||||
void * clientData,
|
||||
Tt_message contract);
|
||||
extern Tt_pattern TTCreateSavePattern( /* declared in ttSaveSupport.c */
|
||||
Tt_message contract,
|
||||
Ttdt_contract_cb clientCB,
|
||||
void * clientData,
|
||||
int register_it);
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* TTdisplayError - posts a ToolTalk error dialog containing the specified
|
||||
* error message followed by the related ToolTalk status message.
|
||||
************************************************************************/
|
||||
void
|
||||
TTdisplayError(
|
||||
Editor *pPad,
|
||||
char *errorMsg,
|
||||
Tt_status status)
|
||||
{
|
||||
char *statusMsg = tt_status_message(status);
|
||||
char buf[1024];
|
||||
|
||||
if (errorMsg != (char *) NULL) {
|
||||
sprintf(buf, "%s\n(%d: %s)", errorMsg, status, statusMsg);
|
||||
} else {
|
||||
sprintf(buf, "(%d: %s)", status, statusMsg);
|
||||
}
|
||||
tt_free(statusMsg);
|
||||
Warning(pPad, buf, XmDIALOG_ERROR);
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* TTdt_session_joinCB - Callback passed to ttdt_session_join() to handle
|
||||
* standard "Desktop" messages.
|
||||
*
|
||||
* In our case, this only deals with the standard Desktop Quit message with
|
||||
* signature:
|
||||
*
|
||||
* Quit(in boolean silent, in boolean force, in messageID operation2Quit)
|
||||
*
|
||||
* XXX - This routine was setup by SUN but currently does nothing since:
|
||||
* Requests to quit a specific Media Edit/Display request are handled in
|
||||
* TTdt_message_acceptCB() (which is registered in TTmedia_ptype_declareCB()
|
||||
* when the Media Edit/Display request is first accepted).
|
||||
******************************************************************************/
|
||||
Tt_message
|
||||
TTdt_session_joinCB(
|
||||
Tt_message m,
|
||||
void * client_data,
|
||||
Tt_message contract)
|
||||
{
|
||||
/* should never get here, if we do, notify sender with a fail */
|
||||
tttk_message_fail(m,
|
||||
TT_DESKTOP_ENOTSUP, /* status */
|
||||
(char *) NULL, /* status str */
|
||||
1); /* destroy request */
|
||||
|
||||
return((Tt_message) 0); /* we handled this message */
|
||||
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* TTdt_message_acceptCB - callback (setup in ttdt_message_accept()) to handle
|
||||
* TT_HANDLER-addressed messages. Currently this routine handles:
|
||||
*
|
||||
* Quit(4) request which can contain the following arguments:
|
||||
*
|
||||
* silent - controls whether or not the user is notified
|
||||
* when there are unsaved changes
|
||||
* force - controls whether or not the Quit is aborted
|
||||
* when there are unsaved changes
|
||||
* operation2Quit - controls whether all edit window(s) are closed or
|
||||
* whether a specific edit window is closed
|
||||
*
|
||||
* This routine is analogous to TTSaveContractCB() which handles
|
||||
* Save requests. Patterns to handle Quit requests are automatically
|
||||
* registered via ttdt_message_accept() whereas patterns to handle Save
|
||||
* requests must be explicitly registered (see TTCreateSavePattern()).
|
||||
*
|
||||
* See dtpad(1) for more details.
|
||||
*
|
||||
******************************************************************************/
|
||||
Tt_message
|
||||
TTdt_message_acceptCB(
|
||||
Tt_message m,
|
||||
void * client_data,
|
||||
Tt_message contract)
|
||||
{
|
||||
Editor *pPad;
|
||||
int silent, force;
|
||||
Tt_status status;
|
||||
char *operation2Quit;
|
||||
int mark = tt_mark();
|
||||
|
||||
char *opString = tt_message_op(m);
|
||||
Tttk_op op = tttk_string_op(opString);
|
||||
|
||||
if (op == TTDT_QUIT) {
|
||||
|
||||
/* Search the list of Editor instances for one with a TT media
|
||||
* msg id matching the originating media msg id supplied as the
|
||||
* 'operation2Quit' (3rd) argument of the TTDT_QUIT msg */
|
||||
if (operation2Quit = tt_message_arg_val(m, 2)) {
|
||||
for (pPad = pPadList; pPad != (Editor *)NULL; pPad = pPad->pNextPad) {
|
||||
if (pPad->inUse == True && pPad->ttEditReq.msg_id &&
|
||||
strcmp(pPad->ttEditReq.msg_id, operation2Quit) == 0) {
|
||||
pPad->ttQuitReq.contract = m; /* process Quit msg */
|
||||
status = tt_message_arg_ival(m, 0, &silent);
|
||||
status = tt_message_arg_ival(m, 1, &force);
|
||||
pPad->ttQuitReq.silent = (Boolean) silent;
|
||||
pPad->ttQuitReq.force = (Boolean) force;
|
||||
pPad->ttQuitReq.operation2Quit = strdup(operation2Quit);
|
||||
FileExitCB( (Widget) NULL, (caddr_t) pPad, (caddr_t) NULL);
|
||||
tt_release(mark);
|
||||
return((Tt_message) 0); /* handling Quit */
|
||||
}
|
||||
}
|
||||
/* no Edit window matching the operation2Quit */
|
||||
tttk_message_fail(m,
|
||||
TT_DESKTOP_ENOMSG, /* status */
|
||||
(char *) NULL, /* status str */
|
||||
1); /* destroy request */
|
||||
|
||||
} else { /* no operation2Quit - quit all Edit windows */
|
||||
/* XXX - not currently processing this type of Quit */
|
||||
tttk_message_fail(m,
|
||||
TT_DESKTOP_ENOTSUP, /* status */
|
||||
(char *) NULL, /* status str */
|
||||
1); /* destroy request */
|
||||
}
|
||||
|
||||
/* We're handling all Quit requests. If the request has not been
|
||||
* failed already, pPad->ttQuitReq.contract will be non-NULL and
|
||||
* the Quit message will be responded to or failed later. */
|
||||
tt_release(mark);
|
||||
return((Tt_message) 0); /* handling Quit */
|
||||
|
||||
} else { /* unsupported message type */
|
||||
|
||||
tt_release(mark);
|
||||
return(m); /* didn't handle message */
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* TTmedia_ptype_declareCB - callback (set up in ttmedia_ptype_declare()) to
|
||||
* handle the standard ToolTalk Instantiate/Edit/Display media messages
|
||||
* from a "requestor" dtpad or from other applications.
|
||||
*
|
||||
* It sets up TTdt_message_acceptCB() when it "accepts" the message which
|
||||
* handles Quit messages relating to the accepted Instantiate/Edit/Display
|
||||
* message.
|
||||
*
|
||||
* Returns: 0 if the message is handled; otherwise, returns Tt_message.
|
||||
******************************************************************************/
|
||||
Tt_message
|
||||
TTmedia_ptype_declareCB(
|
||||
Tt_message m,
|
||||
void * client_data,
|
||||
Tttk_op op,
|
||||
Tt_status diag,
|
||||
unsigned char * contents,
|
||||
int len,
|
||||
char * file,
|
||||
char * docname)
|
||||
{
|
||||
Editor *pPad;
|
||||
char *filename;
|
||||
Tt_message TTdt_message_acceptCB(), incoming;
|
||||
Tt_pattern *ttrc;
|
||||
DtEditorContentRec contentRec;
|
||||
DtEditorErrorCode errorCode;
|
||||
Boolean foundPad = False;
|
||||
char *context = (char *)NULL;
|
||||
char *oldFileName = (char *)NULL;
|
||||
Boolean isCurrentlyVisible = False;
|
||||
int mark = tt_mark();
|
||||
char *localPath = tt_message_file(m);
|
||||
|
||||
if (diag != TT_OK
|
||||
&& !(op == TTME_INSTANTIATE && diag == TT_DESKTOP_ENODATA)) { /* TTT - workaround for tttk bug */
|
||||
fprintf(stderr,
|
||||
"Ignored Media request with ToolTalk detected error: %s\n",
|
||||
tt_status_message(diag));
|
||||
return(m);
|
||||
}
|
||||
if (op != TTME_EDIT && op != TTME_DISPLAY && op != TTME_INSTANTIATE) {
|
||||
return(m); /* Message not handled by this routine. */
|
||||
}
|
||||
|
||||
/* if editing a file, make sure we can read it first,
|
||||
* if not, fail the request immediately
|
||||
*/
|
||||
if (file) {
|
||||
char *pathEnd;
|
||||
|
||||
if (MbStrrchr(localPath, '/') != (char *)NULL) {
|
||||
char *dir; DIR *pDir;
|
||||
|
||||
dir = (char *) XtMalloc(strlen(localPath) + 1);
|
||||
strcpy(dir, localPath);
|
||||
pathEnd = MbStrrchr(dir, '/');
|
||||
if (pathEnd == dir) {
|
||||
/* file is in the root directory
|
||||
*/
|
||||
pathEnd++;
|
||||
}
|
||||
*pathEnd = (char)'\0';
|
||||
if ((pDir = opendir(dir)) != (DIR *)NULL) {
|
||||
closedir(pDir);
|
||||
XtFree(dir);
|
||||
} else {
|
||||
tt_free(localPath);
|
||||
localPath = (char *) NULL;
|
||||
XtFree(dir);
|
||||
tttk_message_fail(m,
|
||||
TT_DESKTOP_ENOENT, /* status */
|
||||
(char *) NULL, /* status str */
|
||||
1); /* destroy request */
|
||||
tt_release(mark);
|
||||
return((Tt_message) 0); /* Message handled by this routine. */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Create an Editor "instance" and manage/realize it.
|
||||
* This involves creating its GUI components, setting it resources,
|
||||
* mapping its windows and, if specified, loading the file to be edited.
|
||||
*/
|
||||
if (foundPad == False)
|
||||
foundPad = FindOrCreatePad(&pPad); /* returns new Editor in pPad */
|
||||
|
||||
/*
|
||||
* If this message is from a dtpad requestor then replace selective
|
||||
* server resources with requestor resources shipped to the dtpad server
|
||||
* in the message context fields
|
||||
*/
|
||||
if (tt_message_contexts_count(m)) {
|
||||
|
||||
/*----> a session file, want to restore a session */
|
||||
if (*(context = tt_message_context_val(m, "SESSION"))) {
|
||||
pPad->xrdb.session = strdup(context);
|
||||
}
|
||||
else {
|
||||
/* -----> non text editor specific resource */
|
||||
if (*(context = tt_message_context_val(m, "GEOMETRY"))) {
|
||||
pPad->geometry = strdup(context);
|
||||
}
|
||||
|
||||
/* -----> basic options */
|
||||
if (context = tt_message_context_val(m, "STATUSLINE")) {
|
||||
if (*context == 't')
|
||||
pPad->xrdb.statusLine = True;
|
||||
else
|
||||
pPad->xrdb.statusLine = False;
|
||||
}
|
||||
|
||||
if (context = tt_message_context_val(m, "WINDOWWORDWRAP")) {
|
||||
if (*context == 't')
|
||||
pPad->xrdb.wordWrap = True;
|
||||
else
|
||||
pPad->xrdb.wordWrap = False;
|
||||
}
|
||||
|
||||
if (context = tt_message_context_val(m, "OVERSTRIKE")) {
|
||||
if (*context == 't')
|
||||
pPad->xrdb.overstrike = True;
|
||||
else
|
||||
pPad->xrdb.overstrike = False;
|
||||
}
|
||||
|
||||
if (context = tt_message_context_val(m, "SAVEONCLOSE")) {
|
||||
if (*context == 't')
|
||||
pPad->xrdb.saveOnClose = True;
|
||||
else
|
||||
pPad->xrdb.saveOnClose = False;
|
||||
}
|
||||
|
||||
if (context = tt_message_context_val(m, "MISSINGFILEWARNING")) {
|
||||
if (*context == 't')
|
||||
pPad->xrdb.missingFileWarning = True;
|
||||
else
|
||||
pPad->xrdb.missingFileWarning = False;
|
||||
}
|
||||
|
||||
if (context = tt_message_context_val(m, "NOREADONLYWARNING")) {
|
||||
if (*context == 't')
|
||||
pPad->xrdb.readOnlyWarning = True;
|
||||
else
|
||||
pPad->xrdb.readOnlyWarning = False;
|
||||
}
|
||||
|
||||
if (context = tt_message_context_val(m, "NONAMECHANGE")) {
|
||||
if (*context == 't')
|
||||
pPad->xrdb.nameChange = True;
|
||||
else
|
||||
pPad->xrdb.nameChange = False;
|
||||
}
|
||||
|
||||
if (context = tt_message_context_val(m, "VIEWONLY")) {
|
||||
if (*context == 't')
|
||||
pPad->xrdb.viewOnly = True;
|
||||
else
|
||||
pPad->xrdb.viewOnly = False;
|
||||
}
|
||||
|
||||
if (context = tt_message_context_val(m, "WORKSPACELIST")) {
|
||||
pPad->xrdb.workspaceList = strdup(context);
|
||||
}
|
||||
|
||||
/* -----> client/server control options */
|
||||
if (*(context = tt_message_context_val(m, "BLOCKING"))) {
|
||||
pPad->xrdb.blocking = True;
|
||||
pPad->blockChannel = strdup(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pPad->ttEditReq.contract = m;
|
||||
pPad->ttEditReq.msg_id = strdup(tt_message_id(m));
|
||||
pPad->ttEditReq.op = op;
|
||||
|
||||
if (op == TTME_INSTANTIATE) {
|
||||
pPad->ttEditReq.contents = False;
|
||||
pPad->ttEditReq.returnBufContents = False;
|
||||
|
||||
} else { /* TTME_EDIT or TTME_DISPLAY */
|
||||
|
||||
if (file) {
|
||||
/* the mediaType of the first arg (contents) applies to either
|
||||
* contents or a file */
|
||||
pPad->ttEditReq.vtype = strdup(tt_message_arg_type(m, 0));
|
||||
pPad->ttEditReq.contents = False; /* editing a file */
|
||||
pPad->ttEditReq.fileName = strdup(localPath);
|
||||
pPad->fileStuff.fileName = XtNewString(pPad->ttEditReq.fileName);
|
||||
} else {
|
||||
pPad->ttEditReq.contents = True; /* editing a buffer */
|
||||
pPad->xrdb.nameChange = False; /* disallow switching to another
|
||||
file */
|
||||
pPad->ttEditReq.returnBufContents = True;
|
||||
}
|
||||
if (docname) {
|
||||
pPad->ttEditReq.docName = strdup(docname);
|
||||
} else {
|
||||
pPad->ttEditReq.docName = (char *) NULL;
|
||||
}
|
||||
if (op == TTME_DISPLAY)
|
||||
pPad->xrdb.viewOnly = True;
|
||||
}
|
||||
|
||||
/* -----> Create GUI components of Editor instance, set resouces,
|
||||
* map window and load file (if specified). */
|
||||
if (!foundPad) {
|
||||
if (oldFileName != (char *)NULL)
|
||||
XtFree(oldFileName);
|
||||
|
||||
RealizeNewPad(pPad); /* pPad->mainWindow is created here */
|
||||
} else {
|
||||
if (oldFileName != (char *)NULL)
|
||||
XtFree(oldFileName);
|
||||
ManageOldPad(pPad, isCurrentlyVisible);
|
||||
}
|
||||
|
||||
/* -----> Accept the message.
|
||||
*
|
||||
* Registers patterns in the default session to handle TT_HANDLER-addressed
|
||||
* requests (created by specifying the "handler" argument in
|
||||
* tttk_message_create) in the following manner (based on the shell and
|
||||
* Ttdt_contract_cb args):
|
||||
*
|
||||
* type requests handled notes
|
||||
* ---- -------------------- ---------------------------- -----
|
||||
* (1) Get|Set_Geometry, transparently (a)
|
||||
* Get|Set_Iconified,
|
||||
* Get|Set_Mapped,
|
||||
* Get|Set_XInfo,
|
||||
* Raise, Lower
|
||||
* (2) Pause, Resume passed to Ttdt_contract_cb (b)
|
||||
* (3) Quit, Get_Status passed to Ttdt_contract_cb (c)
|
||||
*
|
||||
* NOTES:
|
||||
* (a) type (1) requests are handled transparently because the shell
|
||||
* arg is specified (that is, a pattern is registered to handle
|
||||
* these requests via an internal TT callback)
|
||||
* (b) type (2) requests are handled like type (3) because
|
||||
* Ttdt_contract_cb is specified; otherwise they would be
|
||||
* handled transparently
|
||||
* (c) type (3) request are handled in Ttdt_contract_cb because it
|
||||
* was specified; otherwise they fail with TT_DESKTOP_ENOTSUP
|
||||
* (that is, Ttdt_contract_cb is the pattern callback registered
|
||||
* in the pattern to handle these requests).
|
||||
*/
|
||||
ttrc = ttdt_message_accept(
|
||||
m, /* Tt_message */
|
||||
TTdt_message_acceptCB, /* Ttdt_contract_cb */
|
||||
pPad->app_shell, /* shell widget */
|
||||
pPad->mainWindow, /* client data */
|
||||
1, /* call tt_message_accept() */
|
||||
1); /* send STATUS notice to requestor */
|
||||
if (tt_ptr_error((void *) ttrc) != TT_OK) {
|
||||
fprintf(stderr,
|
||||
"Could not ttdt_message_accept the edit request: %s\n",
|
||||
tt_status_message((tt_ptr_error((void *) ttrc))));
|
||||
}
|
||||
|
||||
/* -----> Create pattern to handle "Save" requests in a manner analogous
|
||||
* to "Quit" requests.
|
||||
* NOTE: This pattern (unlike the Quit pattern automatically registered
|
||||
* via ttdt_message_accept()) is *not* automatically destroyed
|
||||
* when the original Edit request is destroyed. */
|
||||
pPad->ttEditReq.savePattern = TTCreateSavePattern(
|
||||
m, /* Tt_message */
|
||||
TTSaveContractCB, /* Ttdt_contract_cb */
|
||||
pPad->mainWindow, /* client data - not currently used */
|
||||
1); /* register it */
|
||||
|
||||
/* -----> Set the DtEditor widget contents. */
|
||||
if (pPad->ttEditReq.contents) {
|
||||
contentRec.type = DtEDITOR_TEXT;
|
||||
contentRec.value.string = (char *) contents;
|
||||
errorCode = DtEditorSetContents(pPad->editor, &contentRec);
|
||||
|
||||
/* [SuG 5/18/95] Done
|
||||
The NOT_SAMPLE warnings/errors need to be added to the message
|
||||
catalog. Removed ifdefs.*/
|
||||
|
||||
switch (errorCode) {
|
||||
case DtEDITOR_NO_ERRORS:
|
||||
break;
|
||||
case DtEDITOR_NULLS_REMOVED:
|
||||
Warning(pPad, (char *) GETMESSAGE(6, 6,
|
||||
"Embedded Nulls stripped from file."),
|
||||
XmDIALOG_WARNING);
|
||||
break;
|
||||
case DtEDITOR_INSUFFICIENT_MEMORY:
|
||||
Warning(pPad, (char*) GETMESSAGE(6, 7,
|
||||
"Unable to load file (insufficient memory)."),
|
||||
XmDIALOG_ERROR);
|
||||
break;
|
||||
default:
|
||||
Warning(pPad, (char *) GETMESSAGE(6, 12,
|
||||
"Unable to read from the file (unknown reason)."),
|
||||
XmDIALOG_ERROR);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
tt_release(mark);
|
||||
return((Tt_message) 0); /* Message handled by this routine. */
|
||||
|
||||
}
|
||||
|
||||
/********************** Exported Functions (via dtpad.h) **********************/
|
||||
|
||||
/******************************************************************************
|
||||
* TTstartDesktopMediaExchange - Initializes Took Talk for handling the
|
||||
* "Desktop" and "Document & Media Exchange" message sets.
|
||||
*
|
||||
* Returns: True if successful; 0 if failure.
|
||||
******************************************************************************/
|
||||
Tt_status
|
||||
TTstartDesktopMediaExchange(
|
||||
Widget topLevelWithWmCommand,
|
||||
Editor * pPad)
|
||||
{
|
||||
char *my_procid = NULL;
|
||||
int my_ttfd = 0;
|
||||
Tt_pattern *tt_pat = NULL;
|
||||
Tt_status status = TT_OK;
|
||||
int mark = tt_mark();
|
||||
char *sess = NULL;
|
||||
|
||||
|
||||
/*
|
||||
* Open a connection to the ToolTalk service
|
||||
* and send a Started notice so other applications know we're up.
|
||||
*/
|
||||
|
||||
sess = (char *)getenv("TT_SESSION");
|
||||
if (!sess || (*sess == '\0')) {
|
||||
sess = getenv("_SUN_TT_SESSION");
|
||||
}
|
||||
if (!sess || (*sess == '\0')) {
|
||||
tt_default_session_set(
|
||||
tt_X_session(XDisplayString(XtDisplay(topLevelWithWmCommand))) );
|
||||
}
|
||||
|
||||
status = TTdesktopOpen( &my_ttfd, pPad, (int) pPad->xrdb.server);
|
||||
if (TT_OK != status)
|
||||
return(status);
|
||||
|
||||
if (pPad->xrdb.server == True) {
|
||||
/*
|
||||
* Declare we will handle messages defined under our ptype
|
||||
* which in this case currently consist of the Instantialte, Display
|
||||
* and Edit messages from the Media set, as defined in dtpad.ptypes.
|
||||
* This will enable auto start of dtpad if any of the messages in the
|
||||
* ptype are received.
|
||||
*/
|
||||
if ((status = ttmedia_ptype_declare(
|
||||
DTPAD_TOOL_CLASS, /* ptype */
|
||||
0, /* base opnum */
|
||||
TTmedia_ptype_declareCB,/* Ttmedia_load_pat_cb */
|
||||
(void *) pPadList, /* client data */
|
||||
1)) /* call tt_ptype_declare() */
|
||||
!= TT_OK) {
|
||||
fprintf(stderr,
|
||||
"Could not register as %s tool class handler: %s\n",
|
||||
DTPAD_TOOL_CLASS,
|
||||
tt_status_message(status)) ;
|
||||
return(status);
|
||||
}
|
||||
|
||||
/*
|
||||
* Join the default sesssion,
|
||||
* and register to deal with standard Desktop requests in the following
|
||||
* manner (controlled by the Ttdt_contract_cb and shell arguments):
|
||||
*
|
||||
* type requests handled notes
|
||||
* ---- -------------------- ---------------------------- -----
|
||||
* (1) Get|Set_Environment, transparently
|
||||
* Get|Set_Locale,
|
||||
* Get|Set_Situation,
|
||||
* Signal, Get_Sysinfo
|
||||
* (2) Get|Set_Geometry, fail with TT_DESKTOP_ENOTSUP (b)
|
||||
* Get|Set_Iconified,
|
||||
* Get|Set_Mapped,
|
||||
* Raise, Lower,
|
||||
* Set_Xinfo,
|
||||
* Get_Xinfo transparently
|
||||
* (3) Pause, Resume, Quit passed to Ttdt_contract_cb (c)
|
||||
* (4) Get_Status, Do_Command passed to Ttdt_contract_cb
|
||||
*
|
||||
* NOTES:
|
||||
* (b) type (2) requests (except Get_Xinfo) fail because the shell
|
||||
* arg is not a "realized mappedWhenManaged applicationShellWidget"
|
||||
* (c) type (3) requests are not handled transparently because
|
||||
* Ttdt_contract_cb is specified
|
||||
*/
|
||||
tt_pat = ttdt_session_join(
|
||||
(const char *) 0, /* join default session */
|
||||
TTdt_session_joinCB, /* Ttdt_contract_cb */
|
||||
topLevelWithWmCommand, /* shell widget */
|
||||
(void *) 0, /* client data */
|
||||
1); /* really join the session */
|
||||
if ((status = tt_ptr_error(tt_pat)) != TT_OK) {
|
||||
fprintf(stderr,
|
||||
"Could not join default ToolTalk session: %s\n",
|
||||
tt_status_message(tt_ptr_error(tt_pat)));
|
||||
ttdt_close(0, 0, 1);
|
||||
return(status);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Have Xt monitor the connection to the ToolTalk service.
|
||||
* tttk_Xt_input_handler() will ultimately call tt_message_receive(),
|
||||
* which will invoke the callbacks we've registered.
|
||||
*/
|
||||
XtAppAddInput(XtWidgetToApplicationContext(topLevelWithWmCommand),
|
||||
my_ttfd, (XtPointer) XtInputReadMask, tttk_Xt_input_handler,
|
||||
my_procid);
|
||||
|
||||
return(status);
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* TTmediaDepositContents - sends a ToolTalk Deposit request (containing
|
||||
* the current contents of the DtEditor widget) directly to the
|
||||
* sender of the original media request.
|
||||
*
|
||||
* Returns: 0 if successful; !0 if failure.
|
||||
************************************************************************/
|
||||
Boolean
|
||||
TTmediaDepositContents(
|
||||
Editor *pPad)
|
||||
{
|
||||
DtEditorErrorCode errorCode;
|
||||
DtEditorContentRec contentRec;
|
||||
Boolean addNewlines = pPad->xrdb.wordWrap == True &&
|
||||
pPad->fileStuff.saveWithNewlines == True;
|
||||
Tt_status status;
|
||||
|
||||
_DtTurnOnHourGlass(pPad->app_shell);
|
||||
|
||||
contentRec.type = DtEDITOR_TEXT;
|
||||
errorCode = DtEditorGetContents(
|
||||
pPad->editor,
|
||||
&contentRec,
|
||||
addNewlines,
|
||||
False); /* don't mark contents as saved yet */
|
||||
if (errorCode != DtEDITOR_NO_ERRORS) {
|
||||
Warning(pPad,
|
||||
"Internal Error: Unable to get contents from Editor Widget.",
|
||||
XmDIALOG_ERROR);
|
||||
return(1);
|
||||
}
|
||||
|
||||
status = ttmedia_Deposit(
|
||||
pPad->ttEditReq.contract, /* original request */
|
||||
(char *) NULL, /* send directly to requestor */
|
||||
pPad->ttEditReq.vtype, /* media type */
|
||||
(unsigned char *) contentRec.value.string, /*new contents */
|
||||
strlen(contentRec.value.string),
|
||||
(char *) NULL, /* don't use temp file for xfer */
|
||||
pPad->app_context, /* we're the blocking application */
|
||||
10 * TIMEOUT_FACTOR); /* milliseconds to block for reply */
|
||||
|
||||
if (status == TT_OK) {
|
||||
/* XXX - an inefficient way of marking contents as saved -
|
||||
* need to use a global to keep track of unsaved changes
|
||||
* and replace DtEditorCheckForUnsavedChanges() */
|
||||
errorCode = DtEditorGetContents(
|
||||
pPad->editor,
|
||||
&contentRec,
|
||||
addNewlines,
|
||||
True); /* mark contents as saved */
|
||||
_DtTurnOffHourGlass(pPad->app_shell);
|
||||
} else {
|
||||
_DtTurnOffHourGlass(pPad->app_shell);
|
||||
TTdisplayError(pPad,
|
||||
(char *) GETMESSAGE(13, 1, "Checkpoint save failed."),
|
||||
status);
|
||||
return(1);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* TTmediaReply - replies to (and closes) a ToolTalk media request.
|
||||
*
|
||||
* If a file is being edited, it is assumed at this point that it
|
||||
* has already been updated with the current contents.
|
||||
*
|
||||
* If a buffer is being edited, the current text is included in the
|
||||
* reply only if pPad->ttEditReq.returnBufContents is True.
|
||||
*
|
||||
* Returns: 0 if successful; !0 if failure.
|
||||
************************************************************************/
|
||||
Boolean
|
||||
TTmediaReply(
|
||||
Editor *pPad)
|
||||
{
|
||||
DtEditorErrorCode errorCode;
|
||||
DtEditorContentRec contentRec;
|
||||
Tt_status status;
|
||||
Boolean addNewlines = pPad->xrdb.wordWrap == True &&
|
||||
pPad->fileStuff.saveWithNewlines == True;
|
||||
|
||||
_DtTurnOnHourGlass(pPad->app_shell);
|
||||
|
||||
if (! pPad->ttEditReq.contract) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ----> Not editing a buffer */
|
||||
if (! pPad->ttEditReq.contents) {
|
||||
status = ttmedia_load_reply(
|
||||
pPad->ttEditReq.contract, /* original request */
|
||||
(unsigned char *) 0, /* new contents */
|
||||
0, /* contents length */
|
||||
True); /* destroy message after reply */
|
||||
_DtTurnOffHourGlass(pPad->app_shell);
|
||||
if (status == TT_OK) {
|
||||
pPad->ttEditReq.contract = 0; /* request has been closed */
|
||||
return(0);
|
||||
} else {
|
||||
TTdisplayError(pPad,
|
||||
(char *) GETMESSAGE(13, 2, "Checkpoint reply failed."),
|
||||
status);
|
||||
return(1);
|
||||
}
|
||||
}
|
||||
|
||||
/* ----> Editing a buffer */
|
||||
if (pPad->ttEditReq.returnBufContents) {
|
||||
/* -----> Include the contents in the reply */
|
||||
contentRec.type = DtEDITOR_TEXT;
|
||||
errorCode = DtEditorGetContents(
|
||||
pPad->editor,
|
||||
&contentRec,
|
||||
addNewlines,
|
||||
False); /* don't mark contents as saved yet */
|
||||
if (errorCode != DtEDITOR_NO_ERRORS) {
|
||||
Warning(pPad,
|
||||
"Internal Error: Unable to get contents from Editor Widget.",
|
||||
XmDIALOG_ERROR);
|
||||
tttk_message_fail(pPad->ttEditReq.contract,
|
||||
TT_DESKTOP_ENODATA, /* status */
|
||||
(char *) NULL, /* status str */
|
||||
1); /* destroy request */
|
||||
return(1);
|
||||
}
|
||||
|
||||
status = ttmedia_load_reply(
|
||||
pPad->ttEditReq.contract, /* original request */
|
||||
(unsigned char *) contentRec.value.string, /* new contents */
|
||||
strlen(contentRec.value.string),
|
||||
True); /* destroy message after reply */
|
||||
if (status == TT_OK) {
|
||||
/* XXX - an inefficient way of marking contents as saved -
|
||||
* need to use a global to keep track of unsaved changes
|
||||
* and replace DtEditorCheckForUnsavedChanges() */
|
||||
errorCode = DtEditorGetContents(
|
||||
pPad->editor,
|
||||
&contentRec,
|
||||
addNewlines,
|
||||
True); /* mark contents as saved */
|
||||
_DtTurnOffHourGlass(pPad->app_shell);
|
||||
pPad->ttEditReq.contract = NULL; /* request has been closed */
|
||||
} else {
|
||||
_DtTurnOffHourGlass(pPad->app_shell);
|
||||
TTdisplayError(pPad,
|
||||
(char *) GETMESSAGE(13, 2, "Checkpoint reply failed."),
|
||||
status);
|
||||
return(1);
|
||||
}
|
||||
|
||||
} else {
|
||||
/* -----> Don't include anything in the buffer reply (e.g.
|
||||
* when the user responds "no" to saving unsaved contents).
|
||||
*
|
||||
* NOTE: TT_DESKTOP_ECANCELED changes the "failure" into a "reply".
|
||||
*/
|
||||
status = tttk_message_fail(
|
||||
pPad->ttEditReq.contract, /* original request */
|
||||
TT_DESKTOP_ECANCELED, /* status */
|
||||
(char *) NULL, /* status str */
|
||||
1); /* destroy request */
|
||||
_DtTurnOffHourGlass(pPad->app_shell);
|
||||
if (status == TT_OK) {
|
||||
pPad->ttEditReq.contract = NULL; /* request has been closed */
|
||||
} else {
|
||||
TTdisplayError(pPad,
|
||||
(char *) GETMESSAGE(13, 2, "Checkpoint reply failed."),
|
||||
status);
|
||||
return(1);
|
||||
}
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* TTresetQuitArgs - resets TTDT_QUIT argments set in TTdt_message_acceptCB()
|
||||
************************************************************************/
|
||||
void
|
||||
TTresetQuitArgs(
|
||||
Editor *pPad)
|
||||
{
|
||||
if (!pPad->ttQuitReq.contract)
|
||||
return;
|
||||
pPad->ttQuitReq.contract = NULL;
|
||||
if (pPad->ttQuitReq.operation2Quit != (char *) NULL) {
|
||||
XtFree(pPad->ttQuitReq.operation2Quit);
|
||||
pPad->ttQuitReq.operation2Quit = (char *) NULL;
|
||||
}
|
||||
pPad->ttQuitReq.silent = 0;
|
||||
pPad->ttQuitReq.force = 0;
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* TTfailPendingQuit - fails any pending Quit request - even if 'force' is
|
||||
* specified
|
||||
************************************************************************/
|
||||
void
|
||||
TTfailPendingQuit(
|
||||
Editor *pPad)
|
||||
{
|
||||
if (pPad->ttQuitReq.contract) {
|
||||
tttk_message_fail(pPad->ttQuitReq.contract, /* original Quit req */
|
||||
TT_DESKTOP_ECANCELED, /* status */
|
||||
(char *) NULL, /* status string */
|
||||
1); /* destroy request */
|
||||
TTresetQuitArgs(pPad);
|
||||
}
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
* TTdesktopOpen - This procedure just opens a connection to
|
||||
* ToolTalk so a simple message can be sent.
|
||||
************************************************************************/
|
||||
Tt_status
|
||||
TTdesktopOpen( int *ttFd, Editor *pPad, Boolean sendStarted )
|
||||
{
|
||||
char * procId;
|
||||
Tt_status status;
|
||||
char *vendor;
|
||||
|
||||
#ifdef sun
|
||||
vendor = "Sun Microsystems";
|
||||
#else
|
||||
#ifdef _AIX
|
||||
vendor = "IBM";
|
||||
#else
|
||||
#ifdef hpux
|
||||
vendor = "Hewlett-Packard";
|
||||
#else
|
||||
vendor = "Unknown";
|
||||
#endif /* hpux */
|
||||
#endif /* _AIX */
|
||||
#endif /* sun */
|
||||
|
||||
procId = ttdt_open( ttFd, "dtpad", vendor, "2.1", sendStarted );
|
||||
if ( (status = tt_ptr_error( procId )) != TT_OK )
|
||||
{
|
||||
ttdt_close( NULL, NULL, sendStarted );
|
||||
return( status );
|
||||
}
|
||||
|
||||
ProcessToolTalkInputId =
|
||||
XtAppAddInput( pPad->app_context,
|
||||
*ttFd, (XtPointer)XtInputReadMask,
|
||||
tttk_Xt_input_handler, procId );
|
||||
return( TT_OK );
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
* TTwarning - This procedure displays a message dialog and exits.
|
||||
************************************************************************/
|
||||
/* ARGSUSED */
|
||||
static void
|
||||
okCB(Widget w, XtPointer clientData, XtPointer callData)
|
||||
{
|
||||
*((int*) clientData) = 1;
|
||||
}
|
||||
|
||||
void
|
||||
TTwarning( Editor *pPad, Tt_status status, char *errsuff )
|
||||
{
|
||||
FileWidgets *pFileWidgets;
|
||||
char *errfmt;
|
||||
char *errmsg;
|
||||
char *statmsg;
|
||||
int done = 0;
|
||||
|
||||
if (TT_OK == status || NULL == pPad) return;
|
||||
|
||||
errfmt =
|
||||
GETMESSAGE(7, 13, "Could not connect to ToolTalk service:\n%s\n%s\n");
|
||||
statmsg = tt_status_message(status);
|
||||
errmsg = XtMalloc(strlen(errfmt) + strlen(statmsg) + strlen(errsuff) + 2);
|
||||
|
||||
if (NULL == errsuff) errsuff = "";
|
||||
fprintf(stderr, errfmt, statmsg, errsuff);
|
||||
sprintf(errmsg, errfmt, statmsg, errsuff);
|
||||
Warning(pPad, errmsg, XmDIALOG_ERROR);
|
||||
|
||||
pFileWidgets = &pPad->fileStuff.fileWidgets;
|
||||
XtAddCallback(pFileWidgets->gen_warning, XmNokCallback,
|
||||
(XtCallbackProc) okCB, (XtPointer) &done);
|
||||
XFlush(pPad->display);
|
||||
XSync(pPad->display, False);
|
||||
|
||||
while ( !done )
|
||||
{
|
||||
XtAppProcessEvent(
|
||||
XtWidgetToApplicationContext(pFileWidgets->gen_warning),
|
||||
XtIMAll);
|
||||
}
|
||||
}
|
||||
409
cde/programs/dtpad/ttSaveSupport.c
Normal file
409
cde/programs/dtpad/ttSaveSupport.c
Normal file
@@ -0,0 +1,409 @@
|
||||
/* $XConsortium: ttSaveSupport.c /main/4 1996/05/08 20:09:07 drk $ */
|
||||
/**********************************<+>*************************************
|
||||
***************************************************************************
|
||||
**
|
||||
** File: ttSaveSupport.c
|
||||
**
|
||||
** Project: DT dtpad, a memo maker type editor based on the Dt Editor
|
||||
** widget.
|
||||
**
|
||||
** Description:
|
||||
** -----------
|
||||
**
|
||||
** Provides support for the ToolTalk "Save" message in a manner analogous
|
||||
** to "Quit" message support provided by the ttdt_message_accept() function.
|
||||
**
|
||||
*******************************************************************
|
||||
** (c) Copyright Hewlett-Packard Company, 1990, 1991, 1992, 1993.
|
||||
** All rights are
|
||||
** reserved. Copying or other reproduction of this program
|
||||
** except for archival purposes is prohibited without prior
|
||||
** written consent of Hewlett-Packard Company.
|
||||
********************************************************************
|
||||
**
|
||||
********************************************************************
|
||||
** (c) Copyright 1993, 1994 Hewlett-Packard Company
|
||||
** (c) Copyright 1993, 1994 International Business Machines Corp.
|
||||
** (c) Copyright 1993, 1994 Sun Microsystems, Inc.
|
||||
** (c) Copyright 1993, 1994 Novell, Inc.
|
||||
********************************************************************
|
||||
**
|
||||
**
|
||||
**************************************************************************
|
||||
**********************************<+>*************************************/
|
||||
#include "dtpad.h"
|
||||
|
||||
/* definitions from tttk/tttkutils.h */
|
||||
char _TTKeys[7];
|
||||
#define _TTCBKey ((int)&_TTKeys[0])
|
||||
#define _TTClientCBKey ((int)&_TTKeys[1])
|
||||
#define _TTClientDataKey ((int)&_TTKeys[2])
|
||||
#define _TTDepositPatKey ((int)&_TTKeys[3])
|
||||
#define _TTJoinInfoKey ((int)&_TTKeys[4])
|
||||
#define _TTContractKey ((int)&_TTKeys[5])
|
||||
#define _TTSubContractKey ((int)&_TTKeys[6])
|
||||
|
||||
extern Editor *pPadList; /* list of Editor instances - declared in main.c */
|
||||
|
||||
/******************************************************************************
|
||||
* TTSaveContractCB - callback (setup in ttdt_message_accept()) to handle
|
||||
* Save(4) requests. Currently this routine handles one argument:
|
||||
*
|
||||
* messageID - This must be the message ID the originating Edit
|
||||
* request whose contents are to that is to be saved
|
||||
* (or deposited if a buffer is being edited).
|
||||
*
|
||||
* This routine is analogous to TTdt_message_acceptCB() which handles
|
||||
* Quit requests. Patterns to handle Quit requests are automatically
|
||||
* registered via ttdt_message_accept() whereas patterns to handle Save
|
||||
* requests must be explicitly registered (see TTCreateSavePattern()).
|
||||
*
|
||||
* See dtpad(1) for more details.
|
||||
*
|
||||
******************************************************************************/
|
||||
Tt_message
|
||||
TTSaveContractCB(
|
||||
Tt_message m,
|
||||
void * clientData,
|
||||
Tt_message contract)
|
||||
{
|
||||
Editor *pPad;
|
||||
int silent, force;
|
||||
Tt_status status;
|
||||
char *messageID;
|
||||
int mark = tt_mark();
|
||||
|
||||
char *opString = tt_message_op(m);
|
||||
Tttk_op op = tttk_string_op(opString);
|
||||
|
||||
if (op == TTDT_SAVE) {
|
||||
|
||||
/* Search the list of Editor instances for one with a TT media
|
||||
* msg id matching the originating media msg id supplied as the
|
||||
* 'messageID' (1st) argument of the TTDT_SAVE msg */
|
||||
if (messageID = tt_message_arg_val(m, 0)) {
|
||||
for (pPad = pPadList; pPad != (Editor *)NULL; pPad = pPad->pNextPad) {
|
||||
if (pPad->inUse == True && pPad->ttEditReq.msg_id &&
|
||||
strcmp(pPad->ttEditReq.msg_id, messageID) == 0) {
|
||||
pPad->ttSaveReq.contract = m; /* process Save msg */
|
||||
pPad->ttSaveReq.messageID = strdup(messageID);
|
||||
FileSaveCB((Widget) NULL, (caddr_t) pPad, (caddr_t) NULL);
|
||||
tt_release(mark);
|
||||
return((Tt_message) 0); /* handling Save */
|
||||
}
|
||||
}
|
||||
/* no Edit window matching the messageID */
|
||||
tttk_message_fail(m,
|
||||
TT_DESKTOP_ECANCELED, /* status */
|
||||
(char *) NULL, /* status str */
|
||||
1); /* destroy request */
|
||||
|
||||
} else { /* no messageID - which is required */
|
||||
tttk_message_fail(m,
|
||||
TT_DESKTOP_ECANCELED, /* status */
|
||||
(char *) NULL, /* status str */
|
||||
1); /* destroy request */
|
||||
}
|
||||
|
||||
/* We're handling all Save requests. If the request has not been
|
||||
* failed already, pPad->ttSaveReq.contract will be non-NULL and
|
||||
* the Save message will be responded to or failed later. */
|
||||
tt_release(mark);
|
||||
return((Tt_message) 0); /* handling Quit */
|
||||
|
||||
} else { /* unsupported message type */
|
||||
|
||||
tt_release(mark);
|
||||
return(m); /* didn't handle message */
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* _TT_pattern_contract - obtains the contracting message from the pattern
|
||||
******************************************************************************/
|
||||
Tt_message
|
||||
_TT_pattern_contract(
|
||||
Tt_pattern pat)
|
||||
{
|
||||
void *contract = tt_pattern_user(pat, _TTContractKey);
|
||||
Tt_status status = tt_ptr_error(contract);
|
||||
if (status != TT_OK) {
|
||||
return 0;
|
||||
}
|
||||
return (Tt_message) contract;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* _TTpatternCB - Retrieves the client callback and callback arguments from
|
||||
* the pattern and calls it (ala tttkpattern.C:_ttDtPatternCB()).
|
||||
******************************************************************************/
|
||||
static Tt_callback_action
|
||||
_TTpatternCB(
|
||||
Tt_message msg,
|
||||
Tt_pattern pat)
|
||||
{
|
||||
Ttdt_contract_cb clientCB;
|
||||
void * clientData;
|
||||
Tt_status status;
|
||||
|
||||
/* ----> Obtain client callback */
|
||||
clientCB = (Ttdt_contract_cb) tt_pattern_user(pat, _TTClientCBKey);
|
||||
status = tt_ptr_error(clientCB);
|
||||
if (status != TT_OK) {
|
||||
return TT_CALLBACK_PROCESSED;
|
||||
}
|
||||
if (clientCB == 0) {
|
||||
return TT_CALLBACK_CONTINUE;
|
||||
}
|
||||
|
||||
/* ----> Obtain client data */
|
||||
clientData = tt_pattern_user(pat, _TTClientDataKey);
|
||||
status = tt_ptr_error(clientData);
|
||||
if (status != TT_OK) {
|
||||
return TT_CALLBACK_PROCESSED;
|
||||
}
|
||||
|
||||
/* -----> Call client callback */
|
||||
msg = (*clientCB)(msg, clientData, _TT_pattern_contract(pat));
|
||||
|
||||
status = tt_ptr_error(msg);
|
||||
if ((status != TT_OK) || (msg == 0)) {
|
||||
return TT_CALLBACK_PROCESSED;
|
||||
} else {
|
||||
return TT_CALLBACK_CONTINUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* _TTCreatePattern - creates a pattern for a desktop message
|
||||
* (ala cdesrc/lib/tt/lib/tttk/tttkpattern.C:_ttDtPatternCreate())
|
||||
******************************************************************************/
|
||||
Tt_pattern
|
||||
_TTCreatePattern(
|
||||
Tt_category category,
|
||||
Tt_scope theScope,
|
||||
int addDefaultSess,
|
||||
const char * file,
|
||||
const char * op_string,
|
||||
Ttdt_contract_cb clientCB,
|
||||
void * clientData)
|
||||
{
|
||||
|
||||
Tt_pattern pat = tt_pattern_create();
|
||||
Tt_status status = tt_ptr_error(pat);
|
||||
if (status != TT_OK) {
|
||||
return pat;
|
||||
}
|
||||
|
||||
status = tt_pattern_category_set(pat, category);
|
||||
if (status != TT_OK) {
|
||||
tt_pattern_destroy(pat);
|
||||
return (Tt_pattern)tt_error_pointer(status);
|
||||
}
|
||||
|
||||
/* we only observe notices and only handle requests */
|
||||
if (category == TT_HANDLE) {
|
||||
status = tt_pattern_class_add(pat, TT_REQUEST);
|
||||
}
|
||||
if (category == TT_OBSERVE) {
|
||||
status = tt_pattern_class_add(pat, TT_NOTICE);
|
||||
}
|
||||
if (status != TT_OK) {
|
||||
tt_pattern_destroy(pat);
|
||||
return (Tt_pattern)tt_error_pointer(status);
|
||||
}
|
||||
|
||||
status = tt_pattern_scope_add(pat, theScope);
|
||||
if (status != TT_OK) {
|
||||
tt_pattern_destroy(pat);
|
||||
return (Tt_pattern)tt_error_pointer(status);
|
||||
}
|
||||
|
||||
if (addDefaultSess) {
|
||||
char *sess = tt_default_session();
|
||||
status = tt_pattern_session_add(pat, sess);
|
||||
tt_free(sess);
|
||||
if (status != TT_OK) {
|
||||
tt_pattern_destroy(pat);
|
||||
return (Tt_pattern)tt_error_pointer(status);
|
||||
}
|
||||
}
|
||||
|
||||
if (file != 0) {
|
||||
status = tt_pattern_file_add(pat, file);
|
||||
if (status != TT_OK) {
|
||||
tt_pattern_destroy(pat);
|
||||
return (Tt_pattern)tt_error_pointer(status);
|
||||
}
|
||||
}
|
||||
|
||||
if (op_string) {
|
||||
status = tt_pattern_op_add(pat, op_string);
|
||||
if (status != TT_OK) {
|
||||
tt_pattern_destroy(pat);
|
||||
return (Tt_pattern)tt_error_pointer(status);
|
||||
}
|
||||
}
|
||||
|
||||
/* -----> Add the general purpose pattern callback (as well as the
|
||||
* client callback and client data) as fields to the pattern.
|
||||
* When the general purpose pattern callback is called, it
|
||||
* obtains the client callback and client data from the pattern
|
||||
* and calls the client callback with the appropriate arguments. */
|
||||
status = tt_pattern_callback_add( pat, _TTpatternCB );
|
||||
if (status != TT_OK) {
|
||||
tt_pattern_destroy(pat);
|
||||
return (Tt_pattern)tt_error_pointer(status);
|
||||
}
|
||||
status = tt_pattern_user_set(pat, _TTClientCBKey, (void *) clientCB);
|
||||
if (status != TT_OK) {
|
||||
tt_pattern_destroy(pat);
|
||||
return (Tt_pattern)tt_error_pointer(status);
|
||||
}
|
||||
status = tt_pattern_user_set(pat, _TTClientDataKey, clientData);
|
||||
if (status != TT_OK) {
|
||||
tt_pattern_destroy(pat);
|
||||
return (Tt_pattern)tt_error_pointer(status);
|
||||
}
|
||||
|
||||
return pat;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* _TTmessage_id - Returns sender-set message id if any, otherwise the
|
||||
* tt_message_id() (ala lib/tt/lib/tttk/tttkmessage.C:_tttk_message_id())
|
||||
******************************************************************************/
|
||||
char *
|
||||
_TTmessage_id(
|
||||
Tt_message msg)
|
||||
{
|
||||
int i, miss, numArgs = tt_message_args_count( msg );
|
||||
Tt_status status = tt_int_error( numArgs );
|
||||
char *msgID;
|
||||
|
||||
if (status != TT_OK) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (i = 0; i < numArgs; i++) {
|
||||
char *type = tt_message_arg_type(msg, i);
|
||||
status = tt_ptr_error(type);
|
||||
if (status != TT_OK) {
|
||||
return 0;
|
||||
}
|
||||
if (type == 0) {
|
||||
continue;
|
||||
}
|
||||
miss = strcmp(type, Tttk_message_id);
|
||||
tt_free(type);
|
||||
if (miss) {
|
||||
continue;
|
||||
}
|
||||
msgID = tt_message_arg_val(msg, i);
|
||||
status = tt_ptr_error(type);
|
||||
if (status != TT_OK) {
|
||||
return 0;
|
||||
}
|
||||
return msgID;
|
||||
}
|
||||
|
||||
return tt_message_id(msg);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* TTCreateSavePattern - Creates and (optionally) registers a pattern to handle
|
||||
* Save requests (ala cdesrc/lib/tt/lib/tttk/ttdesktop.C:_ttdt_pat() and
|
||||
* _ttDesktopPatternFinish())
|
||||
******************************************************************************/
|
||||
Tt_pattern
|
||||
TTCreateSavePattern(
|
||||
Tt_message contract,
|
||||
Ttdt_contract_cb clientCB,
|
||||
void * clientData,
|
||||
int register_it)
|
||||
{
|
||||
char *msgID;
|
||||
|
||||
/* -----> Create pattern */
|
||||
Tt_pattern pat = _TTCreatePattern(
|
||||
TT_HANDLE, /* catagory */
|
||||
TT_SESSION, /* scope */
|
||||
1, /* add default session to pat */
|
||||
0, /* don't add file to pat */
|
||||
"Save", /* desktop message (op) type */
|
||||
clientCB,
|
||||
clientData);
|
||||
|
||||
Tt_status status = tt_ptr_error( pat );
|
||||
if (status != TT_OK) {
|
||||
return pat;
|
||||
}
|
||||
|
||||
/* -----> Add message id and contracting message to pattern */
|
||||
if (contract != 0) {
|
||||
char *msgID = _TTmessage_id(contract);
|
||||
status = tt_pattern_arg_add(pat, TT_IN, Tttk_message_id, msgID);
|
||||
tt_free(msgID);
|
||||
if (status != TT_OK) {
|
||||
tt_pattern_destroy(pat);
|
||||
return (Tt_pattern) tt_error_pointer(status);
|
||||
}
|
||||
tt_pattern_user_set(pat, _TTContractKey, contract);
|
||||
}
|
||||
|
||||
/* -----> Register pattern */
|
||||
if (register_it) {
|
||||
status = tt_pattern_register(pat);
|
||||
if (status != TT_OK) {
|
||||
tt_pattern_destroy(pat);
|
||||
return (Tt_pattern) tt_error_pointer(status);
|
||||
}
|
||||
}
|
||||
|
||||
return pat;
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* TTresetSaveArgs - resets TTDT_SAVE argments set in TTSaveContractCB()
|
||||
************************************************************************/
|
||||
void
|
||||
TTresetSaveArgs(
|
||||
Editor *pPad)
|
||||
{
|
||||
if (!pPad->ttSaveReq.contract)
|
||||
return;
|
||||
pPad->ttSaveReq.contract = NULL;
|
||||
if (pPad->ttSaveReq.messageID != (char *) NULL) {
|
||||
XtFree(pPad->ttSaveReq.messageID);
|
||||
pPad->ttSaveReq.messageID = (char *) NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* TTfailPendingSave - fails any pending Save request
|
||||
************************************************************************/
|
||||
void
|
||||
TTfailPendingSave(
|
||||
Editor *pPad)
|
||||
{
|
||||
if (pPad->ttSaveReq.contract) {
|
||||
tttk_message_fail(pPad->ttSaveReq.contract, /* original Save req */
|
||||
TT_DESKTOP_ECANCELED, /* status */
|
||||
(char *) NULL, /* status string */
|
||||
1); /* destroy request */
|
||||
TTresetSaveArgs(pPad);
|
||||
}
|
||||
}
|
||||
37
cde/programs/dtpad/version.c
Normal file
37
cde/programs/dtpad/version.c
Normal file
@@ -0,0 +1,37 @@
|
||||
/********************************************************
|
||||
|
||||
Copyright (c) 1988, 1990 by Hewlett-Packard Company
|
||||
Copyright (c) 1988 by the Massachusetts Institute of Technology
|
||||
|
||||
Permission to use, copy, modify, and distribute this software
|
||||
and its documentation for any purpose and without fee is hereby
|
||||
granted, provided that the above copyright notice appear in all
|
||||
copies and that both that copyright notice and this permission
|
||||
notice appear in supporting documentation, and that the names of
|
||||
Hewlett-Packard or M.I.T. not be used in advertising or publicity
|
||||
pertaining to distribution of the software without specific, written
|
||||
prior permission.
|
||||
|
||||
********************************************************************
|
||||
** (c) Copyright 1993, 1994 Hewlett-Packard Company
|
||||
** (c) Copyright 1993, 1994 International Business Machines Corp.
|
||||
** (c) Copyright 1993, 1994 Sun Microsystems, Inc.
|
||||
** (c) Copyright 1993, 1994 Novell, Inc.
|
||||
********************************************************************
|
||||
|
||||
********************************************************/
|
||||
|
||||
#include <include/hpversion.h>
|
||||
|
||||
#ifndef lint
|
||||
/* NOTE: Be sure to update the corresponding version argument for
|
||||
* ttdt_open() in TTstartDesktopMediaExchange() (in ttMsgSupport.c).
|
||||
*/
|
||||
version_tag("dtpad: $XConsortium: version.c /main/5 1996/08/30 15:27:22 drk $")
|
||||
#endif /* lint */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user