Home

Common Desktop Environment: Desktop KornShell User's Guide

image

Contents

1. XmTextClearSelection widgetHandle time where time is typically either obtained from within an X Event or is queried by a call to the XtLastTimestampProcessed command XmTextCopy widgetHandle time where time is typically either obtained from within an X Event or is queried by a call to the XtLastTimestampProcessed command Returns a value which can be used in a conditional statement XmTextCut widgetHandle time where time is typically either obtained from within an X Event or is queried by a call to the XtLastTimestampProcessed command Returns a value which can be used in a conditional statement XmTextDisableRedisplay widgetHandle CDE Desktop KomShell User s Guide p lll XmTextEnableDisplay widgetHandle XmTextFindString widgetHandle startPosition string direction variable where direction is one of the strings TEXT_FORWARD or TEXT_BACKWARD Returns a value which can be used in a conditional statement XmTextGetBaseline variable widgetHandle XmTextGetEditable widgetHandle Returns a value which can be used in a conditional statement XmTextGet InsertionPosition variable widgetHandle XmTextGetLastPosition variable widgetHandle XmTextGetMaxLength variable widgetHandle XmTextGetSelection variable widgetHandle XmTextGetSelectionPosition widgetHandle variable var2 Returns a value which can be used in a conditional statement XmTextGet
2. selectionArray selectionArrayCount ApplicationShell argv Introduction to Desktop KomShell 3 WMShell iconWindow windowGroup Shell createPopupChildrenProc XmSelectionBox e text Accelerators Manager Primitive and Gadget Subclasses userData XmFileSelectionBox dirSearchProc fileSearchProc qualifySearchDataProc dtksh app defaults File The dtksh app defaults file named Dtksh is found in a location based on the following path description usr dt app defaults LANG The only information contained in this app defaults file is the inclusion of the standard Dt base app defaults file The following is a listing of the dtksh app defaults file include Dt The file Dt is also located in usr dt app defaults LANG and is shown in the following listing xforegroundThreshold 70 l fidi l l Help svstem specific resources l l d Display Area Colors These resources set the colors for the display area where actual help text is displayed The resources are complex because they have to override the standard color resources CDE Desktop KomShell User s Guide IA lll E in all cases E XmDialogShell DtHelpDialog DisplayArea background White XmDialogShell XmDialogShell DtHelpDialog DisplayArea background White XmDialogShell DtHelpDialog DisplayArea foreground Black XmDialogShell XmDialogShell DtHelpDialog DisplayArea foregrou
3. Destroys any patterns that may have been stored on the message indicated by the msg argument and then destroys the message tttk message reject status msg msgStatus msgStatusString destroy Sets the status and the status string for the indicated request message and then rejects the message It then destroys the passed in message if the destroy argument is set to True This command is one way in which the callback specified with the ttdt file join command can consume a message It is typically safe to destroy the message using tttk message destroy after rejecting the message CDEDesktop KomShell User s Guide p lll tttk_message_fail status msg msgStatus msgStatusString destroy Sets the status and the status string for the indicated request message and then fails the message It then destroys the passed in message if the destroy argument is set to True This command is one way in which the callback specified with the ttdt_file_join command can consume a message It is typically safe to destroy the message using tttk_message_destroy after failing the message tt message reply status msg Informs the ToolTalk service that the shell script has handled the message and filled in all return values The ToolTalk service then sends the reply back to the sending process filling in the state as TT HANDLED After replying to a message it is typically safe to destroy the message using the tttk message destroy command dtksh Comm
4. TT ERR NOMEM TT ERR SLOTNAME TT ERR XDR TT DESKTOP EPERM TT DESKTOP ENOENT TT DESKTOP EINTR TT DESKTOP EIO TT DESKTOP EAGAIN TT DESKTOP ENOME TT DESKTOP EACCE TT DESKTOP EFAULT TT DESKTOP EEXIST TT DESKTOP ENODEV TT DESKTOP ENOTDIR TT DESKTOP EISDIR TT DESKTOP EINVA TT DESKTOP ENFILE TT DESKTOP EMFILE TT DESKTOP ETXBSY TT DESKTOP EFBIG TT DESKTOP ENOSPC TT DESKTOP EROFS TT DESKTOP EMLINK TT DESKTOP EPIPE TT DESKTOP ENOMSG TT DESKTOP EDEADLK TT DESKTOP ECANCELED TT DESKTOP ENOTSUP TT DESKTOP ENODATA TT DESKTOP EPROTO TT DESKTOP ENOTEMPTY TT DESKTOP ETIMEDOUT TT DESKTOP EALREADY TT DESKTOP UNMODIFIED TT MEDIA ERR SIZE TT MEDIA ERR FORMAT dtksh Commands 70 Some of the commands take a message scope as a parameter The scope indicates which clients have the potential of receiving the outgoing message For these commands the scope parameter can be set to anv of the following values TT SCOPE NONE TT SESSION TT FILI TT BOT TT FILI Cl n EI IN SESSION tt file netfile variable status filename Converts the indicated filename assumed to be a valid file name on the local host to its corresponding netfilename format A netfilename can be passed to other hosts on a network and then converted back to a path relative to the other host using the tt netfile file command tt netfile file variable status netfilename Converts the indicated netfilename to
5. resizePolicy RESIZE_NONE height 150 width 250 background SkyBlue XtCreateManagedWidget BUTTON pushbutton XmPushButton SBBOARD background goldenrod foreground MidnightBlue labelString Push Here height 30 width 100 x 75 y 60 shadowThickness 3 XtRealizeWidget STOPLEVEL XtMainLoop Figure 2 1 shows the window that the first script produces dtzest Push Hare Figure 2 1 Window from script dttest The first line of the script usr dt bin dtksh tells the operating system that this script should be executed using usr dt bin dtksh rather than the standard shell The next line initializes the Xt Intrinsics XtInitialize TOPLEVEL dttestl Dtksh 0 The name of the top level widget is saved in the environment variable STOPLEVEL the shell widget name is dttest1 the application class name is Dtksh and the application name is given by the dtksh variable 0 The next line sets the title resource to the name of the script XtSetValues STOPLEVEL title dttesti Notice that there is no space between the colon after the resource name title and its value An error message appears if vou have a space between them The next four lines create a bulletin board widget and set some of its resources XtCreateManagedWidget BBOARD bboard XmBbulletinBoard TOPLEVEL X resizePolicv RESIZE NONE background S
6. Apply callback in the case of the Ok callback it unposts the main application window and then exits if the dialog contains valid information For both Ok and Apply the set of search directories is first validated if any of the paths are not valid then an error dialog is posted Otherwise the find process is started in a terminal window OkCallback RetrieveAndSaveCurrentValues if SD VAL then PostErrorDialog You must specify a directory to search else for i in SD VAL do if d i then MSG The following search directory does not exist i PostErrorDialog MSG return 1 fu done if SCB WIDGET SOK then XtPopdown S TOPLEVEL ti CMD bin find SD_VAL if SFNP_VAL then CMD CMD name S FNP VAL E if 1 XmToggleButtonGetState STI then CMD CMD xdev E if XmToggleButtonGetState T3 then CMD SCMD hidden ti if XmToggleButtonGetState T4 then CDE Desktop KomShell User s Guide O lll CMD CMD follow tl if XmToggleButtonGetState T5 then CMD SCMD depth i case SFSTYPE VAL in E SNFS CMD SCMD SCDFS CMD SCMD SHFS CMD SCMD us esac case SFILETVPE VAL in SREGULAR CMD C SDIRECTORY CMD C SBLOCK CMD C SCHAR CMD C SFIFO CMD C SSYMLINK CMD C SSOCKET CMD C SNET CMD C SMOUN
7. Returns the value of the DESCRIPTION attribute associated with the indicated action An empty string is returned if the action is not defined or if the DESCRIPTION attribute was not specified Built in libDt Data Typing Commands DtLoadDataTypes Loads the data typing databases and should be invoked before any of the other data typing commands DtDtsFileToDataTvpe variable filePath Returns the name of the data type associated with the file indicated by the filePath argument in the variable argument The variable argument is set to an empty string if the file cannot be typed DtDtsFileToAttributeValue variable filePath attrName Returns the string representing the value of the specified attribute for the data tvpe associated with the indicated file If the attribute is not defined or if the file could not be tvped then the variable argument is set to an emptv string dtksh Commands 65 lll p DtDtsFileToAttributeList variable filePath Returns the space separated list of attribute names defined for the data type associated with the indicated file A shell script can then query the individual values for the attributes using the DtDtsFileToAttributeValue command The variable argument is set to an empty string if the file cannot be typed This command differs from its corresponding C programming counterpart in that it only returns the names of the defined attributes and not their values DtDtsDataTypeToAttributeValue variable
8. button to initiate the find operation The results of the find operation are displayed in a dtterm terminal window The script find Script 95 CDE Desktop KomShell User s Guide Index A action commands 64 app defaults file 4 application help commands 60 applications Motif 1 B Boolean Values 6 bulletin board 14 C callback 10 15 pass data to 10 register 10 script_find 32 workspace 18 category 1 6 category 2 6 category 3 7 category 4 7 CB_CALL_DATA 11 command CDE application help 60 commands 41 action 64 data typing 65 libDt 67 libdt 65 libDt session management 62 localization 61 message set 67 Motif 48 workspace management 63 Xt Intrinsics 44 context variable event handler 17 input 18 translation 18 workspace callback 18 convenience functions 77 create form widget 35 create menu 37 create separator widget 36 create widget 8 D data typing commands 65 Defined Values 5 drawing functions 26 DtDisplayWarningDialog 84 dtksh definition 1 97 relationshipt to ksh 93 1 Dtksh app defaults file 4 DtkshAddButtons 37 78 DtkshAnchorBottom 82 DtkshAnchorLeft 82 DtkshAnchorRight 82 DtkshAnchorTop 82 DtkshDisplayErrorDialog 32 84 DtkshDisplayHelpDialog 85 DtkshDisplayInformationDialog 84 DtkshDisplayQuestionDialog 84 DtkshDisplayQuickHelpDialog 85 DtkshDisplayWorkingDialog 84 DtkshFloatBottom 81 DtkshFloa
9. 9 amp else echo DtSessionRestorePath FAIL exit 3 fi Create the Main WM_SAVE_YOURS If a command line argument was supplied name of the session file gt 0 Restore to th UI FEAET EE TERE E TE HE eat E E E E E E E E EE E S DA da XmDrawingArea S TOPLEVEL height 200 width 200 SSION ATOM Xt _ STOPLEVE L then treat it as the specified in th passed in session file Fals estoreSession 1 tSetValues TOPL tRealizeWidget TOPL Sync XtDisplay henManaged tSetValues TOP Tru henManaged I GrabNone tPopup STOPLEV f Register the fact that w f session management This is not a session res tRealizeWidget STOPL XSync XtDisplay XmAddWMProtocols TOPL XmAddWMProtocolCallbac SessionCallback XtMainLoop CDE Desktop KomShell User s Guide n so come up in the default state rested in participating in ESSION_ATOM ESSION_ATOM W lll Cooperating with Workspace Manager dtksh provides access to all of the major Workspace Manager functions of the Dt libraries including functions for querying and setting the set of workspaces with which an application is associated for querying the list of all workspaces for querying and setting the current
10. GROUP TRAVERSE PREV TRAVERSE PREV TAB GROUP TRAVERSE RIGHT or TRAVERSE UP Lr Returns a value which can be used in a conditional statement XmRemoveWMProtocolCallback widgetHandle protocolAtom ksh command where protocolAtom is typically obtained using the XmInternAtom command As is true with traditional Window Manager callbacks when a callback is removed the same kshell command string must be specified as was specified when the callback was originallv registered dtksh Commands 55 XmRemoveWMProtocols widgetHandle protocolAtom protocolAtom where protocolAtom is typically obtained using the XmInternAtom command XmScaleGetValue widgetHandle variable XmScaleSetValue widgetHandle value XmScrollBarGetValues widgetHandle variable var2 var3 vard XmScrollBarSetValues widgetHandle value sliderSize increment pagelncrement notifyFlag where notifyFlag can be set to either true or false XmScrollVisible widgetHandle widgetHandle leftRightMargin topBottomMargin XmSelectionBoxGetChild variable widgetHandle childType where childType is one of the strings DIALOG_CANCEL_BUTTON DIALOG_DEFAULT_BUTTON DIALOG_HELP_BUTTON DIALOG_APPLY_BUTTON DIALOG_LIST DIALOG_LIST_LABEL DIALOG_OK_BUTTON DIALOG_SELECTION_LABEL DIALOG SEPARATOR DIALOG_TEXT or DIALOG WORK AREA Ti H
11. Help tkshUnder SEP3 10 tFloatLeft 76 tkshFloatRight 96 tkshAnchorBottom 10 CDE Desktop KomShell User s Guide O lll Find sticky Find help XtAddCallback SHELP activateCallback DtkshDisplayQuickHelpDialog Using The Find Command HELP_TYPE_FILE Find help XtSetValues SFORM X initialFocus SD X defaultButton OK X cancelButton SCLOSE X navigationType EXCLUSIVE TAB GROUP DtkshSetReturnKeyControls SD SFNP SFORM SOK LoadStickyValues XtRealizeWidget STOPLEVEL XtMainLoop The following script Find sticky is executed by script find Find sticky remembers the file and directory names used in the most recent execution of script_find XmTextSetString SD users dlm XmTextFieldSetInsertionPosition SD 10 XmTextSetString SFNP elmbug XmTextFieldSetInsertionPosition FNP 6 XtSetValues SFSTYPE menuHistory NODIR XtSetValues SFILETYPE menuHistory DIRECTORY XmToggleButtonSetState TI true false XmToggleButtonSetState T2 true false Find help is a text file that is displayed on screen when the user clicks the Help button in the main script find window This dialog presents a graphical interface to the UNIX find command The only required field is the name of the directory to be searched all other fields are optional Once the fields have been set to the desired values you can use the Ok or Apply
12. Motif For example the class name for a Motif push button widget is XmPushButton while the class name for the Motif label gadget is XmLabelGadget XtAddCallback widgetHandle callbackName ksh command where callbackName is one of the standard Motif or Xt callback names with the Xt or Xm prefix dropped For example activateCallback XtAddEventHandler widgetHandle eventMask nonMaskableFlag ksh command where eventMask is of the form mask mask mask and the mask components are any of the standard set of X event masks and nonMaskableFlag is either true or false XtAddInput variable r fileDescriptor ksh command Registers the indicated file descriptor with the X Toolkit as an alternate input source It is the responsibility of the shell script s input handler to unregister the input source when it is no longer needed and to close the file descriptor If the r option is specified raw mode then dtksh does not automatically read any of the data available from the input source it will be up to the specified kshell command to read all data If the r option is not specified then the command specified in ksh command is invoked only when a full line is read that is a line terminated by either an unescaped newline character or the end of the file or when the end of the file is reached The raw mode is useful for handlers that expect to process nontextual data or for handlers that do not want dtksh automatically reading in a line o
13. String variable widgetHandle XmTextGetTopCharacter variable widgetHandle XmText Insert widgetHandle position string XmTextPaste widgetHandle Returns a value which can be used in a conditional statement XmTextPosToXY widgetHandle position variable var2 Returns a value which can be used in a conditional statement XmTextRemove widgetHandle Returns a value which can be used in a conditional statement XmTextReplace widgetHandle fromPosition toPosition string XmTextScroll widgetHandle lines dtksh Commands 57 XmText SetAddMode widgetHandle state xm xm xm xm xm XmT Xml XmT Xm XmT XmT where state can be set to either true or false TextSetEditable widgetHandle editableFlag where editableFlag can be set to either true or false TextSetHighlight widgetHandle leftPosition rightPosition mode whe re mode is one of the strings HIGHLIGHT NORMAL HIGHLIGHT SELECTED or HIGHLIGHT SECONDARY SELECTED TextSetInsertionPosition widgetHandle position TextSetMaxLength widgetHandle maxLength TextSetSelection widgetHandle firstPosition lastPosition time where tim byacallt e is typically either obtained from within an X Event or is queried o the XtLastTimestampProcessed command TextSetString widgetHandle string TextSetTopCharacter widgetHandle topCharacterPosition TextShowPosition widgetHandle position Text XYToPos variable widgetHandle x y TextFieldClearSelection
14. conditional statement XmToggleButtonSetState widgetHandle state notifyFlag where state can be set to either true or false and where notifyFlag can be set to either true or false XmUpdateDisplay widgetHandle Built in Common Desktop Environment Applic ation Help Commands DtCreateQuickHelpDialog variable parentWidgetHandle name resource value DtCreateHelpDialog variable parentWidgetHandle name resource value CDE Desktop KomShell User s Guide p lll DtHelpQuickDialogGetChild variable widgetHandle childType where childType is one of the strings HELP_QUICK_OK_BUTTON HELP_QUICK_PRINT_BUTTON HELP_QUICK_HELP_BUTTON HELP_QUICK_SEPARATOR HELP_QUICK_MORE_BUTTON or HELP_QUICK_BACK_BUTTON DtHelpReturnSelectedWidgetId variable widgetHandle var2 variable is set to one of the strings HELP_SELECT_VALID HELP SELECT INVALID HELP SELECT ABORT or HELP SELECT ERROR var2 is set to the widgetHandle for the selected widget DtHelpSetCatalogName catalogName Built in Localization Commands catopen variable catalogName Opens the indicated message catalog and returns the catalog ID in the environment variable specified by variable 1f a shell script needs to close the file descriptor associated with a message catalog then the catalog ID must be closed using the catclose command catgets variable catalogld setNumbe
15. dataType attrName optName Returns the string representing the value of the specified attribute for the indicated data type If the attribute is not defined or if the indicated data type does not exist then the variable argument is set to an empty string DtDtsDataTypeToAttributeList variable dataType optName Returns the space separated list of attribute names defined for the indicated data type A shell script can then query the individual values for the attributes using the DtDt sDataTypeToAttributeValue command The variable argument is set to an empty string if the data type is not defined This command differs from its corresponding C programming counterpart in that it only returns the names of the defined attributes and not their values DtDtsFindAttribute variable name value Returns a space separated list of datatype names whose attribute indicated by the name argument has the value indicated by the value argument If an error occurs the variable argument is set to an empty string DtDtsDataTypeNames variable Returns a space separated list representing all the data types currently defined in the data types database If an error occurs then the variable argument is set to an empty string DtDtsSetDataType variable filePath dataType override Sets a data type for the specified directory The variable argument is set to the resultant saved data type for the directory 66 CDE Desktop KomShell User s Guide p lll DtDt
16. descriptor for which input is available If operating in raw mode this file descriptor is used to obtain the pending input The file descriptor is also used to close the input source when no longer needed This indicates the ID returned by XtAddInput when the input source was originally registered This information is needed to remove the input source with XtRemovelnput Events can be accessed using the event type XANY followed by any of the subfields defined by the XANY event structure which includes the following subfields TRANSLATION_E S TRANSLATION E ENT XANY TYPE ENT XANY SERIAL S TRANSLATION E ENT XANY SEND EVENT S TRANSLATION E ENT XANY DISPLAY te et tt TRANSLATION_E ENT XANY WINDOW dtksh supports full access to all of the event fields for the following event KEY EXPOSE XMOTION The following examples show how the subfields for the preceding event types can be accessed TRANS CB CA ATION E VE T XBUTTON X jL DATA EVENT XKEY STATE CDEDesktop KomShell User s Guide W lll EH_EVENT XGRAPHICSEXPOSE WIDTH Responding to a Window Manager Close Notice When the user selects Close from the Window Manager menu for an application the application is terminated unless it has arranged
17. dropped for example activateCallback XtClass variable widgetHandle Returns the name of the widget class associated with the passed in widget handle XtCreateManagedWidget variable widgetName widgetClass parentWidgetHandle resource value XtCreatePopupShell variable widgetName widgetClass parentWidgetHandle resource value XtCreateWidget variable widgetName widgetClass parentWidgetHandle resource value XtDestroyWidget widgetHandle widgetHandle XtDisplay variable widgetHandle dtksh Commands 45 XtDisplavOfObject variable widgetHandle XtGetValues widgetHandle resource var1 resource var2 XtHasCallbacks variable widgetHandle callbackName where callbackName is one of the standard Motif or Xt callback names with the Xt or Xm prefix dropped for example activateCallback variable is set to one of the strings CallbackNoList CallbackHasNone or CallbackHasSome Xt Initialize variable shellName applicationClassName applicationName arguments Using Dtksh as the applicationClassName causes the application to use the default dtksh app defaults file The arguments parameter is used to reference any command line arguments that might have been specified by the user of the shell script these are typically referred to using the shell syntax of Returns a value which can be used in a conditional statement Xt IsManaged widgetHandle Returns a value which can be used in a conditional stateme
18. originally registered XtRemoveEventHandler widgetHandle eventMask nonMaskableFlag ksh command where eventMask is of the form mask mask mask and the mask components are any of the standard set of X event masks that is ButtonPressMask where nonMaskableFlag is either true or false As is true with traditional Xt event handlers when an event handler is removed the same eventMask nonMaskableFlag setting and kshell command string must be specified as was specified when the event handler was originally registered dtksh Commands 47 XtRemoveInput inputld where inputld is the handle that was returned in the specified environment variable when the alternate input source was registered using the XtAddInput command XtRemoveTimeOut timeoutld where timeoutld is the handle that was returned in the specified environment variable when the timeout was registered using the XtAddTimeOut command XtRemoveWorkProc workprocID where workprocID is the handle that was returned in the specified environment variable when the work procedure was registered using the XtAddWorkProc command XtScreen variable widgetHandle XtSetSensitive widgetHandle state where state is either true or false XtSetValues widgetHandle resource value resource value XtUninstallTranslations widgetHandle XtUnmanageChild widgetHandle XtUnmanageChildren widgetHandle widgetHandle t XtUnmapWidget widgetHandle XtUnrealizeWidget
19. unsuccessful DtWsmGetWorkspaceList display rootWindow variable Returns a string of comma separated X atoms representing the current set of workspaces defined for the user in the environment variable indicated by variable Returns 0 if successful 1 if unsuccessful DtWsmGetWorkspacesOccupied display window variable Returns a string of comma separated X atoms representing the current set of workspaces occupied by the indicated shell window in the environment variable indicated by variable Returns 0 if successful 1 if unsuccessful dtksh Commands 63 DtWsmSetWorkspacesOccupied display window workspaceList Moves the indicated shell window to the set of workspaces indicated bv the string workspaceList which must be a comma separated list of X atoms DtWsmAddWorkspaceFunctions display window Forces the Window Manager menu to include the functions used to move the window to other workspaces This command only works if the window is in the withdrawn state DtWsmRemoveWorkspaceFunctions display window Forces the Window Manager menu to not display the functions used to move the window to other workspaces this prevents the window from being moved to any other workspaces This command only works if the window is in the withdrawn state DtWsmOccupyAllWorkspaces display window Requests that a window occupy all workspaces including new workspaces as they are created DtWsmGetCurrentBackdropWindows display rootWindow variab
20. workspace and for requesting that an application be notified any time the user changes to a different workspace From a user s perspective workspaces are identified by a set of names but from the Workspace Manager s standpoint workspaces are identified by X atoms Whenever the shell script asks for a list of workspace identifiers a string of X atoms is returned If more than one X atom is present then the list is comma separated The Workspace Manager expects that the shell script uses the same format when passing workspace identifiers back to it During a given session it is safe for the shell script to work with the X atoms since they remain constant over the lifetime of the session However as was shown in the Session Manager shell script example in the previous section if the shell script is going to save and restore workspace identifiers the identifiers must be converted from their X atom representation to a string before they are saved Then when the session is restored the shell script needs to remap the names into X atoms before passing the information on to the Workspace Manager Mapping between X atoms and strings and between strings and X atoms is accomplished using the following two commands XmInternAtom ATOM SDISPLAY SWORKSPACE_NAME false XmGetAtomName NAME SDISPLAY SATOM Specific dtksh commands for dealing with workspace management are documented in Built in libDt Session Management Commands in
21. Appendix A Creating Localized Shell Scripts dtksh scripts are internationalized and then localized in a process similar to C applications All strings that may be presented to the user are identified in the script A post processor extracts the strings from the script and from them builds a catalogue which can then be translated to any desired locale When the script executes the current locale determines which message catalog is searched for strings to display When a string is to be presented it is identified Advanced Topics 25 bv a message set ID corresponding to the catalog and a message number within the set These values determine what text the user sees The following code illustrates the process f Attempt to open our message catalog catopen MSG CAT ID myCatalog cat f The localized button label is in set 1 and is message f 2 XtCreatePushButton OK PARENT ok X labelString catgets MSG CAT ID 1 2 OK f The localized button label is in set 1 and is message 3 XtCreatePushButton CANCEL PARENT cancel X labelString catgets MSG CAT ID 1 3 Cancel f Close the message catalog when no longer needed catclose MSG CAT ID It is important to note that the file descriptor returned bv catopen must be closed using catclose and not bv using the kshell exec command Using dtksh to Access X Drawing Functions 26 dtksh commands include standard Xlib drawing functions to draw lines points segm
22. BENI LU de ee 27 4 AComplex ScHpt eoe i RERUM bi noes cere es 29 Using SCtpt Id esee Ree os aie bed dale ited eco a 29 Analyzing script_find di fee DUC EE EE E dr a ai Tork 32 Functions and Callbackse 143 4835 64 0580 a ertt d 32 Mam SCHIP ts eese oe ee PER we OEY pene OPE quta 34 A diksh Commands seins aoa nass SG a ees 41 Built in Xlib Commands 23 vv dee et ooo e TT edv vs 42 Built in Xt Intrinsic Commands 0 0 0 0 e eee 44 CDE Desktop KomShell User s Guide Built in Motif Commands eee 48 Built in Common Desktop Environment Application Help Commands stirat ip ERA EE da RR RES 60 Built in Localization Commands L ssssusausau snesu 61 Built in libDt Session Management Commands 62 Built in libDt Workspace Management Commands 63 Built in libDt Action Commands 2 0 5 64 Built in libDt Data Typing Commands 65 Miscellaneous Built in libDt Commands 67 Built in Desktop Services Message Set Commands 67 B dtksh Convenience Functions seen 77 DtkshAddButto s ie ccein E EE oo So ees 78 DtkshSetReturnKeyControls ss se secre ea i i Ba EX 79 DtkshUnder DtkshOver DtkshRightOf and DtkshLeftOf 80 DtkshFloatRight DtkshFloatLeft DtkshFloatTop and DtkshbloatBOLltoi xv eR tote RR on B Heads 81 DtkshAnchorRight DtkshAnchorLeft DtkshAnchorTop and DtkshAnchorBottom oos sree FI i ESO RR WE ES 82 DtkshSpa
23. Create Motif Applications 1 RESOUICES Loser suu dad RERO SR EN ae es OH oak 2 Unsupported Resources 25s Sed ur ot eee ee ss 3 diksh app defaults File sirna ezz oo REPE ete 4 Variable Valuess esee I ER qe e 5 Return Values sa oa ace cred tt ttc a Sar 6 Immediate Return Value 5o eor is ee eer ba ee 7 Initializing the Xt Intrinsics ous v usu ione Coa e b see ina 8 Creating Wid Petes tii cients edu u UM qa Fas auod sli 8 Using a Callback 22 dte Rogat heh eee i dadi era 10 Registering a Callback acis i tee t b ubt 10 Passing Data to a Callback 20 000 000 0000 10 2 A Sample SCEpE osse oe Li ects tee Neve ca eee eee 13 Writing the Scripte wi odes sv au everswe de dakk se ete eS 13 Adding Callback come e tel Rotate tet aes 15 Be Advanced IGpl68 sss ehs e l JA 17 Using Context Variables ix o da doeet hme eres 17 Event Handler Context Variables 00000 00 17 Translation Context Variables llis esses 18 Workspace Callback Context Variables 18 Input Context Variables 2s vv RE ARR OteSURRE USES 18 Accessing Event Subfields 12s oA ARA UC ODORE RADAR d 20 Responding to a Window Manager Close Notice 21 Responding to a Session Manager Save State Notice 2 Cooperating with Workspace Manager sess 25 Creating Localized Shell Scripts cec du ep rp peo ds 25 Using dtksh to Access X Drawing Functions 26 Setting Widget Translations us s suu
24. D LINE X D D XtCrea tkshUnder FNP 10 tkshSpanWidth teManagedWidget RC rc XmRowColumn FORM X orientation HORIZONTAL X CDEDesktop KomShell User s Guide O lll numColumns 3 packing PACK_COLUMN DtkshUnder SSEP 10 DtkshSpanWidth 10 1 navigationType EXCLUS QN IVE TAB GROUP DtkshAddButtons w RC XmToggleButtonGadget X T1 Cross Mount Points DRY T2 Print Matching Filenames ME T3 Search Hidden Subdirectories N TA Follow Symbolic L T5 Descend Subdirectories First inks Bb XtCreateManagedWidget SEP2 sep XmSeparator FORM X separatorType SINGL DtkshUnder RC 10 DtkshSpa XmCreatePulldownMenu PAN DtkshAddButto nWidth ns w SPANE DASHED LINE X N E SFORM pane XmPushButtonGadget X NODIR no restrictions WN NFS nfs CDFS cdf HFS hfs s H AJ AW A NN ww XmCreateOptionMenu FSTYPE SFORM fstype label menuH subMe DtkshUnd DtkshSpa navigation XtManageChild XmCreatePulld DtkshAddButto OTYPE EGULAR IRECTORX LOCK CHAR FIFO SYMLINK SOCKET NET MOUNT String Res istory NOD nuld SPANE er SSEP2 20 nWidth 10 1 Type EXCLUS trict Search To File System Type IR 0 IVE TAB GROUP SFSTYPE ownMenu PANE2 FORM pane2 ns w SPANE2 XmPushButtonGadget no restrictions SIN
25. Flag can be set to either true or false XmIsTraversable widgetHandle Returns a value which can be used in a conditional statement XmListAddItem widgetHandle position itemString The order of the parameters for the XmLi stAddItem command is not identical to its corresponding C programming counterpart XmListAddItems widgetHandle position itemString itemString The order of the parameters for the XnListAddItems command is not identical to its corresponding C programming counterpart XmListAddItemsUnselected widgetHandle position itemString itemString The order of the parameters for the XmLi stAddItemsUnselected command is not identical to its corresponding C programming counterpart CDE Desktop KomShell User s Guide p lll XmListAddItemUnselected widgetHandle position itemString The ordering of the parameters to the XmListAddItemUnselected command are not identical to its corresponding C programming counterpart XmListDeleteAllItems widgetHandle XmListDeleteItem widgetHandle itemString XmListDeleteItems widgetHandle itemString itemString XmListDeleteItemsPos widgetHandle itemCount position XmListDeletePos widgetHandle position XmListDeletePositions widgetHandle position position XmListDeselectAllItems widgetHandle XmListDeselectItem widgetHandle itemString XmListDeselectPos widgetHandle position XmListGetSelectedPos variable widgetHandle Returns a comma separated list of ind
26. N regular NAN directory vey block special MSN character special N Meo IAEA symbolic link INA socket TAN network special NX mount point WEN The script find Script 93 HIDDEN hidden directory XmCreateOptionMenu FILETYPE FORM filetype X labelString Match Only Files Of Type X menuHistory SNOTYPE X subMenuId PANE2 X DtkshUnder FSTYPE 10 X DtkshSpanWidth 10 10 X navigationType EXCLUSIVE TAB GROUP XtManageChild SFILETVPE XtSetValues SFILETVPE spacing 90 XtCreateManagedWidget SEP3 sep3 XmSeparator FORM X DtkshUnder SFILETVPE 10 X DtkshSpanWidth XtCreateManagedWidget OK ok XmPushButton FORM X labelString Ok DtkshUnder SSEP3 10 X DtkshFloatLeft 4 X DtkshFloatRight 24 X DtkshAnchorBottom 10 XtAddCallback SOK activateCallback OkCallback XtCreateManagedWidget APPLY apply XmPushButton SFORM labelString Apply DtkshUnder SSEP3 10 X DtkshFloatLeft 28 DtkshFloatRight 48 DtkshAnchorBottom 10 XtAddCallback SAPPLY activateCallback OkCallback XtCreateManagedWidget CLOSE close XmPushButton FORM X labelString Close DtkshUnder SSEP3 10 X DtkshFloatLeft 52 X DtkshFloatRight 72 X DtkshAnchorBottom 10 XtAddCallback SCLOSE activateCallback exit 1 XtCreateManagedWidget HELP help XmPushButton FORM labelString
27. SunSoft Inc A Sun Microsystems Inc Business 2550 Garcia Avenue Mountain View CA 94043 Common Desktop Environment Desktop KomShell UsersGuide RS THE NETWORK IS THE COMPUTER eg Please Recycle Copyright 1994 1995 Hewlett Packard Company Copyright 1994 1995 International Business Machines Corp Copyright 1994 1995 Sun Microsystems Inc Copyright 1994 1995 Novell Inc All rights reserved This product and related documentation are protected by copyright and distributed under licenses restricting its use copying distribution and decompilation No part of this product or related documentation may be reproduced in any form by any means without prior written authorization RESTRICTED RIGHTS Use duplication or disclosure by the U S Government is subject to restrictions of FAR 52 227 14 g 2 6 87 and FAR 52 227 19 6 87 or DFAR 252 227 7015 b 6 95 and DFAR 227 7202 1 a THIS PUBLICATION IS PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND EITHER EXPRESS OR IMPLIED INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY FITNESS FOR A PARTICULAR PURPOSE OR NON INFRINGEMENT UNIX is a registered trademark in the United States and other countries exclusively licensed through X Open Company Ltd OPEN LOOK is a registered trademark of Novell Inc Sun Sun Microsystems the Sun Logo ToolTalk OpenWindows NFS and Solaris are trademarks or registered trademarks of Sun Microsystems Inc in the
28. T CMD C SHIDDEN CMD C y or esac p p p p p p p p p p fsonly nfs fsonly cdfs fsonly hfs type f type Gd type b type c jj type p type 1 type S type n type M type E if XmToggleButtonGetState T2 then CMD CMD print ti usr dt bin dtterm title Find A File e usr dt bin dtexec if SCB WIDG exit 0 fi fi H de dE ou The script find Script E a SOK open 1 SCMD amp then This function attempt to load in the previous dialog values Each line read from the fil is then interpreted as a ksh command LoadStickyValues if r Find sticky then exec 6 Find sticky XtAddInput FID fi This function is in EvalCmd 6 EvalCmd voked for each line in the sticky values file It will evalutate each line as a dtksh command if S INPUT LINE gt 0 then eval SINPUT LINE I3 if SINPUT EOF true then XtRemoveInput SINPUT ID eval exec SINPUT SOURCE amp fi This function retrieves the current values and then saves them off into a file so that they can be restored the next time th dialog is displayed It is called anytime the user selects either the Ok or Apply buttons RetrieveAndSaveCurrentValues XmTextGetString SD VAL SSD XmTextGetString FNP VAL SFNP XtG
29. T DT T DT T T MSG TT PATHNAMI T OP CJ TT SAME EUID Contains the opaque handle for the incoming message Contains the string representing the operation to be performed that is TTDT DELETED TTDT MODIFIED TTDT REVERTED TTDT MOVED or TTDT SAVED Contains the pathname for the file to which this message pertains EGID Set to True if the message was sent by an application operating with the same effective user ID euid and effective group ID egid as this process CDEDesktop KomShell User s Guide A DT TT SAME PROCID Set to True if the message was sent bv an application with the same procID as returned by ttdt open When the callback completes it must indicate whether the passed in message was consumed replied to failed or rejected If the callback returns the message as passed in in the DT TT MSG environment variable then it is assumed that the message was not consumed If the message was consumed then the callback should return 0 or one of the values returned by the tt error pointer command The callback can return its value in the following fashion return DT TT MSG or return 0 ttdt file quit status patterns quit Destroys the message patterns specified by the patterns argument and unregisters interest in the path name that was passed to the ttdt file join command if quit is set to true The patterns argument should
30. These convenience functions create a single instance of each of the Motif feedback dialogs If an instance of the requested type of dialog already exists then it is reused The parent of the dialog is obtained from the environment variable STOPLEVEL which should be set by the calling shell script and then should not be changed The handle for the requested dialog is returned in one of the following environment variables DTKSH ERROR DIALOG HANDLE DTKSH QUESTION DIALOG HANDLE DTKSH WORKING DIALOG HANDLE 7 DIKSH WARNING DIALOG HANDLE DTKSH INFORMATION DIALOG HANDLI PI Note If you are attaching your own callbacks to the dialog buttons do not destroy the dialog when you are done with it Unmanage the dialog so that it can be used again at a later time If it is necessary to destroy the dialog then be sure to clear the associated environment variable so the convenience function does not attempt to reuse the dialog Usage DtkshDisplay lt name gt Dialog title message okCallback closeCallback helpCallback dialogStyle The Ok button is always managed and by default unmanages the dialog The Cancel and Help buttons are only managed when a callback is supplied for them The dialogStyle parameter accepts any of the standard resource settings supported by the associated bulletin board resource Example DtkshDisplayErrorDialog Read Error Unable to read the file OkCallba
31. United States and other countries Copyright 1994 1995 Hewlett Packard Company Copyright 1994 1995 International Business Machines Corp Copyright 1994 1995 Sun Microsystems Inc Copyright 1994 1995 Novell Inc Tous droits r serv s Ce produit et sa documentation associ e sont prot g s par un copyright et distribu s avec des licences qui en restreignent l utilisation la copie la distribution et la d compilation Aucune partie de ce produit ou de sa documentation associ e ne peut tre reproduite sous aucune forme par quelque moyen que ce soit sans autorisation pr alable et crite CETTE PUBLICATION EST FOURNIE EN L ETAT SANS GARANTIE D AUCUNE SORTE NI EXPRESSE NI IMPLICITE Y COMPRIS ET SANS QUE CETTE LISTE SOIT LIMITATIVE DES GARANTIES CONCERNANT LA VALEUR MARCHANDE L APTITUDE DES PRODUITS A REPONDRE A UNE UTILISATION PARTICULIERE OU LE FAIT QU ILS NE SOIENT PAS CONTREFAISANTS DE PRODUITS DE TIERS UNIX est une marque enregistr e aux Etats Unis et dans d autres pays et licenci e exclusivement par X Open Company Ltd OPEN LOOK est une marque enregistr e de Novell Inc Sun Sun Microsystems le logo Sun ToolTalk OpenWindows NFS et Solaris sont des marques d pos es ou enregistr es de Sun Microsystems Inc aux Etats Unis et dans d autres pays Contents PECTACE epos beskies eda dagen ini densi UE DL po dada do vii 1 Introduction to Desktop KornShell 1 Using Desktop KornShell to
32. a dtksh command using the words True or False case is not significant A Boolean result is returned as either True or False using all lowercase letters Retum Values Graphical commands in dtksh fall into one of four categories based on the definition of the corresponding C function 1 The function is void and returns no values Example XtMapWidget 2 The function is void but returns one or more values through reference parameters Example XmGetColors 3 The function returns a non Boolean value Example XtCreateManagedWidget 4 The function returns a Boolean value Example XtIsSensitive Category 1 A dtksh category 1 command follows the calling sequence of its corresponding C function The number and order of parameters can be determined by looking at the standard documentation for the function Example XtMapWidget SFORM Category 2 A dtksh category 2 command also generally follows the calling sequence of its corresponding C function It returns a value in an environment variable instead of passing a pointer to a return variable Example XmGetColors SFORM BG FOREGROUND TOPSHADOW BOTTOMSHADOW SELECT echo Foreground color SFOREGROUND CDE Desktop KomShell User s Guide IA lll Category 3 A dtksh category 3 command differs slightly from its corresponding C function Where the C function returns its value as the value of the procedure call a dtksh command requires an ad
33. a path name that is valid on the local host tt host file netfile variable status host filename Converts the indicated file assumed to be resident on the specified host into its corresponding netfilename format tt host netfile file variable status host netfilename Converts the indicated netfilename into a valid path on the indicated host ttdt open variable status var2 toolname vendor version sendStarted Opens a ToolTalk communications endpoint It returns in the variable argument the procID associated with this connection It returns the file descriptor associated with this connection in 7472 this file descriptor can be used to register an alternate Xt input handler The sendStarted argument is a value and if set to true causes a Started message to be automatically sent Any procIDs returned by ttdt open contain embedded spaces To prevent kshell from interpreting the procID as a multiple parameter versus a single parameter with embedded spaces you should always enclose any references to the environment variable containing the procID within double CDEDesktop KomShell User s Guide p lll quotes as shown ttdt close STATUS SPROC ID True tttk Xt input handler proclD source id For the ToolTalk messages to be received and processed the shell script must register an Xt input handler for the file descriptor returned by the call to ttdt open The Xt input handler is registered using the XtAddInput command and the hand
34. ame NAME XtDisplav Sitem print u9 SNAME done IFS SoldIFS CDE Desktop KomShell Users Guide STOPLEVEL W lll ti exec 9 amp f Let the session manager know how to invoke us when f the session is restored DtSetStartupCommand TOPLEVEL X usr dt contrib dtksh SessionTest SSAVEFILE else echo DtSessionSavePath FAILED exit 3 fi f Function invoked during a restore session restores the f application to its previous state RestoreSession f Retrieve the path where our session file resides if DtSessionRestorePath STOPLEVEL PATH 1 then exec 9 lt SPATH read u9 ICONIFY f Extract and restore our iconified state case SICONIFV in Iconified DtSetIconifyHint STOPLEVEL True DtSetIconifyHint STOPLEVEL False esac f Extract the list of workspaces we belong in convert f them to atoms and ask the Workspace Manager to relocat f us to those workspaces WS LIST while read u9 NAME do XmInternAtom ATOM XtDisplay STOPLEVEL X SNAME False if S 4WS LIST gt 0 then WS LIST SWS LIST SATOM else WS LIST SATOM fi done DtWsmSetWorkspacesOccupied XtDisplav STOPLEV XtWindow STOPLEVEL WS LIST Advanced Topics 23 HEHEHE HEH EE HE EEE XtInitialize TOPLEVEL wmProtTest Dt XtCreateManagedWidg XminternAtom SAVE SE exec
35. ands 75 76 CDE Desktop KomShell User s Guide dtksh Convenience Functions B The dtksh utilitv includes a file of convenience functions This file is itself a shell script containing shell functions that mav be useful to a shell programmer The shell functions perform operations that dtksh programmers frequently have to do for themselves These include functions for quickly creating certain kinds of dialogs help error warning and so on a function for easily creating a collection of buttons and functions that make it easier to configure the constraint resources for a child of a form widget It is not a requirement that shell script writers use these convenience functions they are supplied to make it easier for developers to write shorter and more readable shell scripts Before a shell script can access these functions it must first include the file containing the convenience functions The convenience functions are located in the file usr dt scripts DtFuncs sh Use the following notation to include them in a shell script usr dt lib dtksh DtFuncs dtsh lll es DtkshAddButtons 78 DtkshAddButtons adds one or more buttons of the same kind into a composite widget It is most often used to add a collection of buttons into a menupane or menubar Usage DtkshAddButtons parent widgetClass labell callbacki label2 callback2 DtkshAddButtons w parent widgetClass variablel label1 callback1 variable2 label2
36. aults file which is used if the call to XtInitialize specifies an application class name of Dtksh This app defaults file contains the standard set of Dt application default values so dtksh applications have a consistent look with other Dt applications Creating Wdgets There are several commands you can use to create widgets CDEDesktop KomShell User s Guide IA lll tCreateWidget Creates an unmanaged widget tCreateManagedWidget Creates a managed widget tCreatePopupShell Creates a pop up shell X X XtCreateApplicationShell Creates an application shell X X mCreate lt widgettypes gt Creates an unmanaged widget There is a specific format for each of these commands that you must follow For example suppose you want to create an unmanaged push button widget as a child of the top level widget You can use either Xt CreateWidget or XmCreatePushButton The formats for these commands are XtCreateWidget variable name widgetclass parent resource value XmCreatePushButton variable parent name resource value The actual commands to create a push button widget are XtCreateWidget BUTTON button XmPushButton STOPLEVEL XmCreatePushButton BUTTON STOPLEVEL button Each of the preceeding commands do exactly the same thing create an unmanaged push button Note that no resource values are set Suppose that you want the background color of the push button to be red and the foregr
37. be the value that was returned by the call to the ttdt file join command ttdt file event status op patterns send Creates and optionally sends a ToolTalk notice announcing an event pertaining to a file The file is indicated by the path name that was passed to the ttdt file join command when patterns was created The op argument indicates what should be announced for the indicated file and it can be set to TTDT MODIFIED TTDT SAVED or TTDT REVERTED If op is set to TTDT MODIFIED then this command registers to handle Get Modified Save and Revert messages in the scope specified when the patterns were created If op is set to TTDT SAVED or TTDT REVERTED this command unregisters from handling Get Modified Save and Revert messages for this file If the send argument is set to true then the indicated message is sent ttdt Get Modified pathName scope timeout Sends a Get Modified request in the indicated scope and waits for a reply or for the specified timeout in milliseconds to elapse A Get Modified request asks other ToolTalk clients if they have any changes pending on pathname that they intend to make persistent Returns a value which can be used in a conditional statement A value of true is returned if an affirmative reply is received within the specified timeout otherwise false is returned dtksh Commands 73 74 ttdt Save status pathName scope timeout Sends a Save request in the ind
38. bed in Chapter 2 Because of its length the entire script is listed in Appendix C Remember that this guide is not a tutorial on KornShell programming If you are not familiar with KornShell programming you should obtain a book on the subject and have it handy for reference The script script find demonstrates how you can use dtksh to provide a graphical interface to the find command script find produces a window within which you can specify parameters for the ind command To fully understand the script you should be familiar with the ind command and you should have its man page available A number of the toggle button menu choices in the window produced by script find require some knowledge of the find command The script s window allows you to specify a search directory and a file name Other options allow you to place restrictions on the type of file system to search and the file type on which to match Figure 4 1 shows the script s window 29 fina Piles Search Diresrimnii Filename Pathenn Crs Mound Poets Pring Matching Filenames Starih Hidden Subdiertories Follow Sym Links Duscend kulidiractarina Firat Restrict Search To Filo System Type no mestrict ons Paonia by niy Filis CHF Tpm na rmsirictinnm Ok Apply Cl su Hull Figure 4 1 Window for script find Enter the search directorv and file name vou re looking for in the text fields at the top of the window In addition select anv applicable choice or
39. callback 18 workspace management 25 workspace management commands 63 Index X XmCreateForm 9 XmCreateLabel 10 XmCreateOptionMenu 38 XmCreatePulldownMenu 37 XmCreatePushButton 9 XmNtopShadowColor 2 XmTextFieldSetInsertionPosition 33 36 XmTextSetString 33 XmToggleButtonSetState 33 Xt Intrinsics initialize 8 Xt Intrinsics commands 44 XtAddCallback 10 39 44 XtAddEventHandler 44 XtAddInput 18 19 44 XtCreateApplicationShell 9 XtCreateManagedWidget 9 13 35 36 37 38 45 XtCreatePopupShell 9 XtCreateWidget 9 XtDisplay 45 XtGetValues 2 3 XtInitialize 8 13 34 XtMainLoop 13 15 39 XtManageChild 38 XtRealizeWidget 13 39 XtrealizeWidget 15 XtRemovelnput 19 XtSetValues 3 13 33 39 100 CDE Desktop KomShell User s Guide
40. callback2 The w option indicates that the convenience function should return the widget handle for each of the buttons it creates The widget handle is returned in the specified environment variable The widgetClass parameter can be set to any of the following but it defaults to XmPushButtonGadget if nothing is specified XmPushButton XmPushButtonGadget XmToggleButton XmToggleButtonGadget XmCascadeButton XmCascadeButtonGadget Examples DtkshAddButtons SMENU XmPushButtonGadget Open do Open Save do Save Quit exit DtkshAddButtons w SMENU XmPushButtonGadget Bl Open do Open B2 Save do Save CDE Desktop KomShell User s Guide ss lll DtkshSetRetumKeyC ontrols DtkshSetReturnKeyControls configures a text widget within a form widget so that the Return key does not activate the default button within the form but instead moves the focus to the next text widget within the form This is useful if you have a window that contains a series of text widgets and the default button should not be activated until the user presses the Return key while the focus is in the last text widget Usage DtkshSetReturnKeyControls textWidget nextTextWidget formWidget defaultButton The textWidget parameter specifies the widget to be configured to catch the Return key and force the focus to move to the next text widget as indicated by the nextTextWidget parameter The formWidget parameter specifies the form containing the defaul
41. choices from the five toggle buttons You can further restrict the search with the option menus When you have made all the necessary selections click OK If all is well a window appears shortly thereafter and displays the results of the find operation An error dialog appears if you don t specify a search directory or file name or if the specified search directory is invalid For example suppose you want to find a file called two letter calls and you think it resides somewhere in the directory users dlm When you enter the directory in the Search Directory text field you inadvertently type users din instead of users dlm When you click OK or Apply script find can t find the directory users dln so it creates the error dialog to notify you of this CDE Desktop KomShell Users Guide I lll Fisul Error Phe Following search directory dema rat meio fuseraddla amp Figure 4 2 script find error dialog When you correct the mistake script find then executes properly and creates a dtterm window within which it displays the complete path of the file you requested providing that the file is found Fired A Fin Wise Ea pikes usara dim ham tes lattar calls Figure 4 3 Window showing complete path If script find cannot find the file in the specified directory nothing appears in the dtterm window A Complex Script 31 lll B Analyzing script fnd The structure of script find is similar to a C program some fun
42. ck CancelCallback DIALOG PRIMARY APPLICATION MODAL 84 CDE Desktop KomShell User s Guide ss lll DtkshDispla yQuic kHelpDialog and DtkshDisplavHelpDialog These convenience functions create a single instance of each of the help dialogs If an instance of the requested type of help dialog already exists then it is reused The parent of the dialog is obtained from the environment variable TOPLEVEL which should be set by the calling shell script and then should not be changed The handle for the requested dialog is returned in one of the following environment variables DTKSH HELP DIALOG HANDLE DTKSH QUICK HELP DIALOG HANDLE Note If it is necessary to destroy a help dialog then be sure to clear the associated environment variable so that the convenience function does not attempt to reuse the dialog Usage DtkshDisplay HelpDialog title helpType helpInformation locationId The meaning of the parameters is dependent upon the value specified for the helpType parameter Their meanings are helpType HELP TYPE TOPIC e helpInformation help volume name locationld help topic location ID helpType HELP TYPE STRING e helpInformation help string e locationId not used helpType HELP TYPE DYNAMIC STRING e helpInformation help string e locationld not used e helplype HELP TYPE MAN PAGE e helpInformatio
43. corresponding C procedures exceptions are noted For more detail on the functionality and parameters of a command see the standard documentation for the corresponding Xlib Xt Intrinsics or Motif procedure In the command definitions parameters named var var2 var3 and so on indicate that the shell script should supply the name of an environment variable into which some value will be returned The word variable indicates an environment variable that accepts a return value Commands that return a Boolean value which can be used directly as part of an if statement are noted as such Parameters enclosed within are optional 41 A Built in Xlib Commands XBell display volume XClearArea display drawable optional GC arguments x y width height exposures XClearWindow display drawable XCopyArea display src dest srcX srcY width height destX destY optional GC arguments XDefineCursor display window cursor x DrawArc display drawable optional GC arguments x y width height angle1 angle2 XDrawLine display drawable optional GC arguments x1 y1 x2 y2 XDrawLines display drawable coordinateMode optional GC arguments x1 y1 x2 y2 x3 y3 where coordinateMode is either CoordModeOrigin or CoordModePrevious XDrawPoint display drawable optional GC arguments x y XDrawPoints display drawable coordinateMode optional GC arguments x1 y1 x2 y2 x3 y3 where coordinateMode is either CoordModeOr
44. ctions and callbacks appear first followed by the main script The first two lines of the script are important and should be included in every dtksh script you write fl usr dt bin dtksh usr dt lib dtksh DtFunc dtsh The first line executes the dtksh svstem and the second loads the dtksh convenience functions The second line wasn t used in the scripts described in Chapter 2 because those scripts did not use anv dtksh convenience functions Functionsand Callbacks script find has the following functions and callbacks PostErrorDialog OkCallback LoadStickyValues EvalCmd RetrieveAndSaveCurrentValues PostEnorDialog This function is called when an error is detected such as when the user enters an invalid directory The function calls the convenience function DtkshDisplayErrorDialog which displays a dialog box whose title is Find Error and whose message is contained in the variable 1 which is passed from the calling location dialogPostErrorDialog DtDisplayErrorDialog Find Error 1 DIALOG PRIMARY APPLICATION MODAL The last parameter DIALOG_PRIMARY_APPLICATION_MODAL tells dtksh to create a dialog that must be responded to before any other interaction can occur 32 CDE Desktop KomShell User s Guide B lll OkCallback OkCallback is called when either the OK or Apply button on the main script_find window is pressed If the OK button is pressed the script_find window
45. d escape processing and detect when the end of the file has been reached so that the input source can be removed and the file descriptor closed This mode seldom needs to be used by a dt ksh script Whether the input handler has been configured to operate in the default mode or in raw mode dtksh sets up several environment variables before calling the shell script s input handler These environment variables provide the input handler with everything needed to handle the incoming data The environment variables are INPUT_LINE If operating in the default mode this variable contains the next complete line of input available from the input source If INPUT_EOF is true then there is no data in this buffer If operating in raw mode then this variable always contains an empty string INPUT_EOF If operating in the default mode this variable is set to false anytime INPUT_LINE contains data and it is set to true when the end of file is reached When the end of file is reached the shell script s input handler should Advanced Topics 19 INPUT SOURCE INPUT ID Accessing EventSubfields The XEvent structure has manv different configurations based on the event s type dtksh provides access only to the most frequently used XEvents Any of 20 the other standard XI unregister the input source and close the file descriptor If operating in raw mode this variable is always set to false This indicates the file
46. dge Center Cambridge MA 02142 published by Prentice Hall Englewood Cliffs NJ 07632 OSF Motif Programmer s Reference Open Software Foundation 11 Cambridge Center Cambridge MA 02142 published by Prentice Hall Englewood Cliffs NJ 07632 OSF Motif Reference Guide by Douglas A Young published by Prentice Hall Englewood Cliffs NJ 07632 Mastering OSF Motif Widgets Second Edition by Donald L McMinds published by Addison Wesley Reading MA 01867 e The X Window System Programming and Applications with Xt OSF Motif Edition by Douglas A Young published by Prentice Hall Englewood Cliffs NJ 07632 CDE Desktop KomShell User s Guide The Definitive Guides to the X Window System Volume 1 Xlib Programming Manual by Adrian Nye published by O Reilly and Associates Sebastopol CA 95472 The Definitive Guides to the X Window System Volume 2 Xlib Reference Manual edited by Adrian Nye published by O Reilly and Associates Sebastopol CA 95472 The Definitive Guides to the X Window System Volume 3 X Window System User s Guide by Valerie Quercia and Tim O Reilly published by O Reilly and Associates Sebastopol CA 95472 The Definitive Guides to the X Window System Volume 4 X Toolkit Intrinsics Programming Manual by Adrian Nye and Tim O Reilly published by O Reilly and Associates Sebastopol CA 95472 The Definitive Guides to the X Window System Volume 5 X Toolkit Intrinsics Refere
47. dget Form is a Manager widget that allows you to place constraints on its children Most of the widgets in the main script_find window are children of the Form The description of the creation of the rest of the widgets is separated into the four areas of the window see Figure 4 4 FirstArea The first area consists of two Label widgets two TextField widgets and a Separator widget that separates the first and second areas Find File Labb Search Dire 0 Tas Fkeki label Filename Pattern Test Fiski Figure 4 5 First area of script find Window The following code segment creates and positions the first Label widget and positions it within the Form using the DtkshAnchorTop and DtkshAnchorLeft convenience functions XtCreateManagedWidget SDLABEL sdlabel XmLabel FORM labelString Search Directory DtkshAnchorTop 12 DtkshAnchorLeft 10 The following code segment creates and positions the first TextField widget Note that it is positioned in relation to both the Form and the Label widget XtCreateManagedWidget SD sd XmText S FORM X columns 30 valus mr DtkshAnchorTop 6 DtkshRightOf SDLABEL 10 DtkshAnchorRight 10 A Complex Script 35 lll B navigationType EXCLUSIVE TAB GROUP XmTextFieldSetInsertionPosition SD 1 The remaining Label widget and TextField widget are created in the same manner The Separator widget is created as a child of the Form widget and posi
48. ditional parameter This parameter is the name of an environment variable into which the return value is to be placed It is always the first parameter Example XmTextGetString TEXT_VALUE TEXT_WIDGET echo The value of the text field is STEXT_VALUE Category 4 A dtksh category 4 command returns a value that can be used in a conditional expression just as in C If the C function also returns values through reference variables as in category 2 the dt ksh command also uses variable names for the corresponding parameters Example if XmIsTraversable PUSH BUTTON then echo The pushbutton is traversable else echo The pushbutton is not traversable ti Generallv the order and tvpe of parameters passed to a command matches those passed to the corresponding C function except as noted for categorv 3 commands Immediate Retum Value Manv of the categorv 3 commands return a single value using an environment variable specified as the first parameter to the command for these special commands the first parameter has the name variable If this return value is immediately used in an expression the special environment variable may be used in place of a variable name When dtksh encounters as the name of the environment variable in which the return value is to be returned it instead returns the result as the value of the command This allows the shell script to embed the command call in anothe
49. e XmCreatePromptDialog variable parentWidgetHandle name resource value XmCreatePulldownMenu variable parentWidgetHandle name resource value XmCreatePushButton variable parentWidgetHandle name resource value XmCreatePushButtonGadget variable parentWidgetHandle name resource value XmCreateQuestionDialog variable parentWidgetHandle name resource value XmCreateRadioBox variable parentWidgetHandle name resource value XmCreateRowColumn variable parentWidgetHandle name resource value CDE Desktop KomShell User s Guide p lll XmCreateScale variable parentWidgetHandle name resource value XmCreateScrollBar variable parentWidgetHandle name resource value XmCreateScrolledList variable parentWidgetHandle name resource value XmCreateScrolledText variable parentWidgetHandle name resource value XmCreateScrolledWindow variable parentWidgetHandle name resource value XmCreateSelectionBox variable parentWidgetHandle name resource value XmCreateSelectionDialog variable parentWidgetHandle name resource value XmCreateSeparator variable parentWidgetHandle name resource value XmCreateSeparatorGadget variable parentWidgetHandle name resource value XmCreateText variable parentWidgetHandle name resource value XmCreateTextField variable parentWidgetHandle name resource value XmCreateToggleButton variable parentWidgetHa
50. e second and third areas Note that this Separator widget ID is called SEP2 XtCreateManagedWidget SEP2 sep XmSeparator FORM X separatorType SINGLE DASHED LINE X DtkshUnder RC 10 DEkshSpanWidth Third Area The third area consists of two option menus and another Separator widget label Restrict Search Ta File Syetem Type ma neetrichions Omlian Mara Labei March Only Fies OF Type fen nostricions Oplien Mend Separalor Figure 4 7 Third area of script find Window The Option Menus are pull down menus When the user clicks the option menu button a menu pane with a number of choices appears The user drags the pointer to the appropriate choice and releases the mouse button The menu pane disappears and the option menu button label displays the new choice The first option menu menu pane consists of a number of push button gadgets representing various restrictions that can be imposed upon the find command XmCreatePulldownMenu PANE SFORM pane DtkshAddButtons w PANE XmPushButtonGadget NODIR no restrictions WN NFS nis MAX CDFS cdfs WON A Complex Script 37 HFS hfs onn Next the Option Menu button itself is created and managed with the menu pane just created S PANE identified as a subMenuld XmCreateOptionMenu FSTYPE FORM fstype X labelString Restrict Search To File System Type menuHistory SNODIR X subMenuId PANE X DtkshUnder SSEP2 20 X DtkshSpanwid
51. either by choosing Close on the Window Manager menu or by pressing CTRL C in the terminal window from which you executed the script To provide a function for the push button so that when it is pressed a message appears in the terminal window and the script terminates you have to add a callback Also you must tell the push button about the existence of this callback The following is the script with the new code added usr dt bin dtksh activateCB echo Pushbutton activated normal termination exit 0 XtInitialize TOPLEVEL dttest2 Dtksh 0 A Sample Script 15 16 XtSetValues STOPLEVEL title dttest2 XtCreateManagedWidget BBOARD bboard XmBulletinBoard TOPLEVEL X resizePolicy RESIZE NONE background SkyBlue X height 150 width 250 XtCreateManagedWidget BUTTON pushbutton XmPushButton BBOARD background goldenrod X foreground MidnightBlue X labelString Push Here X height 30 width 100 x 75 y 60 shadowThickness 3 XtAddCallback SBUTTON activateCallback activateCB XtRealizeWidget STOPLEVEL XtMainLoop The callback is the function activateCB You typically add the callback to the push button after it the push button has been created XtAddCallback SBUTTON activateCallback activateCB Now the pushbutton knows about the callback When you click the push button the function activateCB is executed and the message Pushbutton activated no
52. en input is available It is up to the handler to read the data from the input source and to handle character escaping and line continuations dtksh also supports the XtAddInput facilitv but takes it a step further and makes it easier for shell programmers to use Bv default when a shell script registers interest in a file descriptor dtksh invokes the shell script s input handler only when a complete line of text has been received A complete line of text is defined as a line terminated either by an unescaped newline character or by the end of the file The input handler is also called if no data is available and the end of the file has been reached The handler can then use XtRemoveInput to remove the input source and to close the file descriptor The advantage of this default behavior is that input handlers need not be concerned with escape processing or with handling line continuations The disadvantage is that it assumes that all of the input is line oriented and contains no binary information dtksh also supports a raw input mode if the input source contains binary information or if the input handler wants to read the data from the input source directly In raw mode dtksh does not read any of the data from the input source Whenever dtksh is notified that input is available on the input source it invokes the shell script s input handler It is then the handler s responsibility to read the incoming data perform any required buffering an
53. ents rectangles arcs and polygons In the standard C programming environment these functions take a graphics context GC as an argument in addition to the drawing data In dtksh drawing functions a collection of GC options are specified in the parameter list to the command By default the drawing commands create a GC that is used for that specific command and then discarded If the script specifies the gc option the name of a graphics context object can be passed to the command This GC is used in interpreting the command and the variable is updated with any modifications to the GC performed by the command gc GC GC is the name of an environment variable which has not yet been initialized or which has been left holding a graphic context by a previous drawing command If this option is specified then it must be the first GC option specified foreground color The foreground color which may be either the name of a color or a pixel number CDEDesktop KomShell User s Guide 3 Em mum background color The background color which may be either the name of a color or a pixel number font font name The name of the font to be used line width number The line width to be used during drawing function drawing function The drawing function which can be xor or clear and copy noop nor nand set invert equiv andReverse orReverse or copyInverted line style style The line sty
54. er components within the form As the form grows or shrinks the component maintains its relative position within the form The component may still grow or shrink depending upon the other form constraints specified for the component This behavior is accomplished using the ATTACH POSITION constraint Usage DtkshFloatRight position DtkshFloatLeft position DtkshFloatTop position DtkshFloatBottom position The optional position parameter specifies the relative position to which the indicated edge of the component is positioned The position value is optional and defaults to 0 if one is not specified Example XtCreateManagedWidget BUTTONI buttonl XmPushButton FORM X labelString Ok X DtkshUnder SEPARATOR X DtkshFloatLeft 10 DtkshFloatRight 40 dtksh Convenienc e Functions 81 DtkshAnc horRight DtkshAnc horleft DtkshAnc horlop and DtkshAnc horBottom 82 These convenience functions simplify the specification of certain classes of form constraints They provide a way of attaching a component to one of the edges of a form widget in such a way that as the form grows or shrinks the component s position does not change However depending upon the other form constraints set on this component it may still grow or shrink in size This behavior is accomplished using the ATTACH_FORM constraint Usage DtkshAnchorRight offset DtkshAnchorleft offset DtkshAnchorTop offset DtkshAnchorBottom off
55. etValues SFSTYPE menuHistory FSTYPE VAL XtGetValues SFILETYPE menuHistory FILETYPE VAL exec 3 Find sticky if SD VAL then print u 3 Xm print u 3 Xm fi if SFNP VAL TextSetString SD N SD VALV TextFieldSetInsertionPosition SSD SD_VAL then print u 3 Xm extSetString SFNP W SFNP VALV CDE Desktop KomShell User s Guide C print u 3 XmTextFields fi tInserti case SFSTYPE VAL in SNFS FST NSNFS SCDFS FST SCDFS SHES FST SHFS FST SNODIR esac print u 3 XtSetValues SFSTYPE me case SFILETVPE VAL in SREGULAR FT SREGULAR SDIRECTORY FT SDIRECTORY SBLOCK FT SBLOCK SCHAR FT SCHAR SFIFO FT SFIFO SSYMLINK FT SSYMLINK SSOCKET FT SSOCKET SNET FT SNET SMOUNT FT SMOUNT SHIDDEN FT SHIDDEN FT SNOTYPE esac print u 3 XtSetValues SFILETYPE if XmToggleButtonGetState T1 t print u 3 XmToggleButtonSetSta fi if XmToggleButtonGetState T2 t print u 3 XmToggleButtonSetSta fi if XmToggleButtonGetState T3 t print u 3 XmToggleButtonSetSta fi if XmToggleButtonGetState T4 t print u 3 XmToggleButtonSetSta fi if XmToggleButtonGetState T5 t print u 3 XmToggleB
56. f data When the end of file is detected it is the shell script s input handler s responsibility to use XtRemoveInput to remove the input source and to close the file descriptor if necessary In all cases several environment variables are set up which can be used by the handler These include INPUT LINE Empty if in raw mode otherwise it contains the next line to be processed CDEDesktop KomShell User s Guide A mmm z INPUT_EOF Set to true if end of file is reached otherwise set to false INPUT_SOURCE File descriptor associated with this input source INPUT_ID The ID associated with this input handler returned by XtAddInput XtAddTimeout variable interval ksh command XtAddWorkProc variable ksh command In dtksh the kshell command is typically a kshell function name Like regular work procedures this function is expected to return a value that indicates whether the work procedure wants to be called again or whether it has completed its work and can be automatically unregistered If the dtksh function returns 0 then the work procedure remains registered any other value causes the work procedure to be automatically unregistered XtAugmentTranslations widgetHandle translations XtCreateApplicationShell variable applicationName widgetClass resource value XtCallCallbacks widgetHandle callbackName where callbackName is one of the standard Motif or Xt callback names with the Xt or Xm prefix
57. g like if scaleCallData gt reason XmCR_VALUE_CHANGED ventType scaleCallData gt event gt type display scaleCallData gt event gt xany display Similarly when a callback is invoked in dt ksh the following special environment variable is set up before the callback command executes CB_WIDGET This is set to the widget ID for the widget that is invoking the callback CB_CALL_DATA This is set to the address of the callData structure passed by the widget to the callback The CB_CALL_DATA environment variable represents a pointer to a structure and access to its fields uses a syntax similar to that of C Nested environment variables are defined named the same as the fields of the structure but all in uppercase and a dot is used to indicate containment of an element in a structure Thus the previous C code to access the callData provided by the scale widget translates to if CB CALL DATA REASON CR VALUE CHANGED then event Type S CB_CALL_DATA EVENT TYPE display CB CALL DATA EVENT XANY DISPLAY fi The same is true of the event structure within the callData structure For most callback structures the shell script is able to reference any of the fields defined for the particular callback structure using the technique described earlier In most cases the shell script is not able to alter the values of the fields within these str
58. he command XtSetValues FORM defaultButton NULL A callback is a function or procedure that is executed when an event or combination of events occurs For example a callback is used to achieve the desired result when a push button is pressed It is easy for a dtksh shell script to assign a command to be activated whenever a particular callback is invoked for a widget The command could be as simple as a string of commands blocked together or the name of the shell function to invoke Registering a Callback An application registers a callback with a widget to specify a condition in which it is interested and to specify what action should occur when that condition occurs The callback is registered using XtAddCallback The action can be any valid dtksh command For example XtAddCallback SWIDGET activateCallback ActivateProc XtAddCallback SWIDGET activateCallback XtSetSensitive SBUTTON false Passing Data to a Callback 10 A callback needs to be passed context information so it can determine what condition led to its call For a C procedure this information is typically passed in a callData structure For example a scale widget invoking a valueChangedCallback passes an instance of the following structure in callData CDE Desktop KomShell User s Guide IA lll typedef struct int reason XEvent event int value XmScaleCallbackStruct The C application s callback then does somethin
59. icated scope and waits for a reply or for the indicated timeout in milliseconds to elapse A Save request asks the handling ToolTalk client to save any changes pending for the file specified in the pathName argument A status of TT OK is returned if an affirmative reply is received before the timeout elapses Otherwise one of the standard Tt status error values is returned ttdt Revert status pathName scope timeout Sends a Revert request in the indicated scope and waits for a reply or for the indicated timeout in milliseconds to elapse A Revert request asks the handling ToolTalk client to discard any changes pending for the file specified in the pathName argument A status of TT OK is returned if an affirmative reply is received before the timeout elapses Otherwise one of the standard Tt status error values is returned The following commands are typically used by the callback registered with the ttdt file join command They serve as the mechanism for consuming and destroying a message A message is consumed by either rejecting failing or replying to it tt error pointer can be used by the callback to obtain a return pointer for indicating an error condition tt error pointer variable ttStatus Returns a magic value which is used by ToolTalk to represent an invalid pointer The magic value returned depends upon the ttStatus value passed in Any of the valid Tt status values may be specified tttk message destroy status msg
60. ices in variable Returns a value which can be used in a conditional statement XmListGetKbdItemPos variable widgetHandle XmListGetMatchPos variable widgetHandle itemString Returns a comma separated list of indices in variable Returns a value which can be used in a conditional statement XmListItemExists widgetHandle itemString Returns a value which can be used in a conditional statement XmListItemPos variable widgetHandle itemString XmListPosSelected widgetHandle position Returns a value which can be used in a conditional statement dtksh Commands 53 XmListPosToBounds widgetHandle position variable var2 var3 vari4 Returns a value which can be used in a conditional statement XmListReplaceItemsPos widgetHandle position itemString itemString The order of the parameters for the XnListReplaceItemsPos command is not identical to its corresponding C programming counterpart XmListReplaceItemsPosUnselected widgetHandle position itemString litemString The order of the parameters for the XmListReplaceItemsPosUnselected command is not identical to its corresponding C programming counterpart XmListSelectItem widgetHandle itemString notifyFlag where notifyFlag can be set to either true or false XmListSelectPos widgetHandle position notifyFlag where notifyFlag can be set to either true or false XmListSetAddMode widgetHandle state where state can be set to either true or false XmListSetBottomItem widgetHandle itemS
61. ide I lll 100 RESIZE ANY TRUE Certain types of resource values including string tables and bit masks have special representation For example the List widget allows a string table to be specified for both the items and selectedItems resources In dtksh a string table is represented as a comma separated list of strings which is similar to how Motif treats them When a resource that returns a string table is queried using XtGetValues the resulting value is a comma separated set of strings A resource that expects a bit mask value to be passed to it expects the mask to be specified as a string composed of the various mask values separated by the bar character When a resource that returns a bit mask is queried the return value is a string representing the enabled bits separated by the character For example you could use the following command to set the mwmFunctions resource for the VendorShell widget class XtSetValues mwmFunctions MWM_FUNC_ALL MWM_FUNC_RESIZE Unsupported Resources dtksh supports most of the Motif resources The following lists unsupported resources Resources with an asterisk can be specified at widget creation time by using XtSet Values but can t be retrieved using XtGet Values All widget and gadget Classes Any fontlist resource e Any pixmap resource Composite insertPosition children Core accelerators e translations colormap XmText
62. igin or CoordModePrevious XDrawRectangle display drawable optional GC arguments x y width height x DrawSegments display drawable optional GC arguments x1 y1 x2 y2 x3 y3 x4 y4 XDrawString display drawable optional GC arguments x y string x DrawImageString display drawable optional GC arguments x y string XFillArc display drawable optional GC arguments x y width height anglel angle2 XFillPolygon display drawable shape coordinateMode optional GC arguments x1 y1 x2 y2 CDEDesktop KomShell User s Guide A Where shape is either Complex Convex or Nonconvex and coordinateMode is either CoordModeOrigin or CoordModePrevious XFillRectangle display drawable optional GC arguments x y width height XF lush display XHeightOfScreen variable screen XRaiseWindow display window XRootWindowOfScreen variable screen XSync display discard where discard is either true or false XTextWidth variable fontName string Note The XTextWidth command is different from the corresponding Xlib procedure because it takes the name of a font instead of a pointer to a font structure XUndefineCursor display window XWidthOfScreen variable screen dtksh Commands 43 A Built in XtIntrinsic Commands All the Xt Intrinsics commands used to create a new widget require that you specify a widget class for the new widget The widget or gadget class name is the standard class name provided by
63. ipt 33 Main Script The remainder of the script is the equivalent of Main in a C program It initializes the Xt Intrinsics and creates all the widgets used in the script find window The set f in the first line tells dtksh to suppress expansion of wildcard characters in path names This is necessary so that the find command can perform this expansion The script find window see Figure 4 4 consists of a Form widget with four areas The areas are marked by Separator widgets and each area has several widgets all of which are children of the Form Fired Files Label Search Directory I Text Final Lai FHename Parmer Test Filet Srpna Crnsg Moent Pola Priest Mathie Filurammna Fare Cmn with Ires tm Search Hidden ubeliractarien Fallaw Symileolic Links Decard Hubiliracinrida Firat LED PR ee ee ee eee eee eee Label Apstrict Search To File System Type mo restrictions Optien kard Lael Match Only Files Of Typa fo asirieni Op lien Wer Eiai l Four C Apply Close Help or EA Figure 4 4 Widgets in script find window The widgets are created in sequence by area from top to bottom Initialize Initialize is accomplished by the Xt Intrinsics function Xt Initialize XtInitialize TOPLEVEL find Dtksh 0 S CDE Desktop KomShell User s Guide 4 This creates a top level shell that serves as the parent of a Form widget which is created next Create a Form Widget A Form widget is used as the main parent wi
64. is is accomplished Advanced Topics 21 22 by setting up a handler in a similar way of handling a Close notification If a handler is not set up the application has to be restarted manually in the new session and the application does not retain any state To set up a handler to save the current state the application must Define functions to save the state at the end of the session and to restore it on startup Register interest in the Session Manager notification Register the function to save the state At startup determine whether the saved state should be restored The following code illustrates this process usr dt bin dtksh Function invoked when the session is being ended by the user SessionCallback Get the name of the file into which we should save our session information if DtSessionSavePath STOPLEVEL PATH SAVEFIL E then exec JPSPATH f Save off whether we are currently in an iconified state if DtShellIsIconified STOPLEVEL then print u9 Iconified else print u9 Deiconified fi f Save off the list of workspaces we currently reside in if DtWsmGetWorkspacesOccupied XtDisplay S TOPLEVEL X XtWindow STOPLEVEL X CURRENT WS LIST then f Map the comma separated list of atoms into f their string representation oldIFS SIFS IFS for item in SCURRENT WS LIST do XmGetAtomN
65. is unmanaged For either Apply or OK the input search directory is validated if it is invalid then OkCallback calls PostErrorDialog Ifit is valid checks are made on the status of the toggle buttons on the script_find window and corresponding adjustments are made to the variable CMD This variable contains the entire command that is ultimately executed LoadStic kyValues This function is called from the main program after the window has been created and managed It loads all the values from the most recent execution of the script These values are saved in a file called Find sticky by the function RetrieveandSaveCurrentValues EvalC md EvalCmd is used by LoadStickyValues to evaluate each line in Find sticky asa dtksh command The following is a list of a Find sticky file XmTextSetString SD users dlm XmTextFieldSetInsertionPosition SD 10 XmTextSetString SFNP two letter calls XmTextFieldSetInsertionPosition FNP 16 XtSetValues SFSTYPE menuHistory NODIR XtSetValues SFILETYPE menuHistory S NOTYP XmToggleButtonSetState T2 true false XmToggleButtonSetState T4 true false LI RetrievAndSavecC urrentValues RetrieveAndSaveCurrentValues retrieves the current settings and values of the widgets in the script_find window and saves them in the file Find sticky Find sticky is then used by LoadStickyValues the next time the script is executed A Complex Scr
66. kyBlue height 150 width 250 The bulletin board widget s ID is saved in the environment variable BBOARD The widget s name is bboard This name is used by the Xt Intrinsics to set the values of resources that might be named in an external resource file The widget class is XmBulletinBoard The bulletin board s parent widget is the widget ID contained in the environment variable TOPLEVEL This is the topl CDEDesktop KomShell User s Guide NJ lll Adding a Callback evel widget created by the initializion command in the first line The backslash at the end of the line tells dtksh that this command continues on the next line The next six lines create a push button widget as a child of the bulletin board and set some of the push button s resources XtCreateManagedWidget BUTTON pushbutton XmPushButton SBBOARD background goldenrod foreground MidnightBlue labelString Push Here height 30 width 100 x 75 y 60 shadowThickness 3 This is basically the same procedure used to create the bulletin board except that the variable name class and parent are different The next line causes the toplevel widget and all its children to be realized XtRealizeWidget STOPLEVEL Finally the XtMainLoop command initiates a loop processing of events for the widgets XtMainLoop In this script all that happens is the window appears on the display It stays there until you terminate the script
67. le Returns a string of comma separated window IDs representing the set of root backdrop windows Built in libDtAction Commands The set of commands in this section provide you with the tools for loading the action databases querying information about actions defined in the databases and requesting that an action be initiated DtDbLoad Reads in the action and data types databases If called multiple times then the old databases are freed before the new ones are read This command must be called before any of the other 1ibDt action commands or any of the libDt data typing commands The shell script should also use the DtDbReloadNotify command so that the shell script can be notified if new databases must be loaded CDEDesktop KomShell User s Guide p lll DtDbReloadNotify ksh command Requests notification whenever the action or data types databases need to be reloaded The specified kshell command is executed when the notification is received Typically the kshell command includes a call to the DtDbLoad command DtActionExists actionName Tests to see if an action exists in the database with the name specified by the actionName parameter Returns a value which can be used in a conditional statement DtActionLabel variable actionName Returns the localizable LABEL attribute associated with the indicated action If the action does not exist then an empty string is returned DtActionDescription variable actionName
68. le which can be any of the following LineSolid LineDoubleDash or LineOnOffDash Setting Widget Translations dtksh provides mechanisms for augmenting overriding and removing widget translations much as in the C programming environment In C an application installs a set of translation action procedures which can then be attached to specific sequences of events translations are composed of an event sequence and the associated action procedure Translations within dtksh are handled in a similar fashion except only a single action procedure is available This action procedure named ksh_eval interprets any parameters passed to it as dtksh commands and evaluates them when the translation is triggered The following shell script segment gives an example of how translations can be used BtnDownProcedure echo Button Down event occurred in button 1 XtCreateManagedWidget BUTTONI buttonl XmPushButton SPARENT labelString Button 1 translations augment EnterNotify gt ksh_eval echo Buttonl entered lt BtnlDown gt ksh_eval BtnDownProcedure 1 XtCreateManagedWidget BUTTON2 button2 XmPushButton SPARENT labelString Button 2 XtOverrideTranslations SBUTTON2 override lt BtnlDown gt ksh_eval BtnDownProcedure 2 A Advanced Topics 27 28 CDE Desktop Komshell User s Guide Using sc ript find A Complex Script 4 This chapter describes a much more complex script than that descri
69. ler must be registered as a raw input handler The input handler that the shell script registers should invoke tttk Xt input handler to get the message received and processed The following code block demonstrates how this is done ttdt open PROC ID STATUS FID Tool HP 1 0 True XtAddInput INPUT ID r SFID ProcessTTInput N S PROC IDV ProcessTTInput tttk Xt input handler 1 SINPUT SOURCE SINPUT ID Refer to the description of the XtAddInput command for more details about alternate Xt input handlers Note that the backslash and double quotation mark characters before and after the reference to the procID environment variable are necessary because the value contained in the procID environment variable contains embedded spaces and could be misinterpreted unless escaped as shown ttdt_close status procID newProcld sendStopped Closes the indicated communications connection and optionally sends a Stopped notice if the sendStopped argument is set to true Because the procID returned by the call to ttdt_open contains embedded spaces it is necessary to enclose any references to the procID environment variable within double quotation marks ttdt close STATUS SPROC_ID SNEW_PROC_ID False ttdt_session_join variable status sessld shellWidgetHandle join Joins the session indicated by the sessId argument as a good desktop citizen by registering patterns and default callbacks for many standard desktop mes
70. n manual page name e locationId not used helpType HELP TYPE FILE e helpInformation help file name locationld not used dtksh Convenienc e Functions 85 Example DtkshDisplayHelpDialog Help On Dtksh H helpFileName CDE Desktop KomShell User s Guide ELP TYP E FIL Listing forsc ript find The script find Script C This appendix contains the complete listing of script find described in Chapter 4 A Complex Script The script executes a second script called Find sticky which is listed after script find There is also a file called Find help which is a text file accessed when the user clicks the Help button on the main script window See Chapter 4 for more information on this script fl usr dt bin dtksh set u usr dt lib dtksh DtFuncs dtsh This sample shell script provides a graphical interface to the find command Each time it is executed it will attempt to restore the dialog to the last set of values entered by the user When the find command is initiated the output will be displayed in a dtterm window Post ant error dialog The main application window is disabled until the error dialog is unposted The message to be displayed in the error dialog is passed in as 1 PostErrorDialog DtDisplayErrorDialog Find Error 1 DIALOG PRIMARY APPLICATION MODAL This is both the Ok and the
71. nWidth and DtkshSpanHeight 83 DtkshDisplayInformationDialog DtkshDisplayQuestionDialog DtDisplayWarningDialog DtkshDisplayWorkingDialog and DtkshDisplayErrorDialog c iud ette See ee dada aes 84 DtkshDisplayQuickHelpDialog and DtkshDisplayHelpDialog 85 Contents v vi C The script find S riptuissantukeeezzo o isuaaet E eek eees 87 Listing Top script MAG olan steed ae es 6x ee xa pin iet hu ed 87 BIR SUCKY ac aise ka CUNT at St l e ted tate der eda 95 Find Belpuncuns Ce ee Ge ooo een nee bl bajda fan 95 ni TET 97 CDE Desktop KomShell User s Guide Preface The Desktop KornShell User s Guide provides the information you need to create Motif applications with KornShell kshell scripts In addition to the basic information you ll need to get started several example scripts of increasing complexity are described Throughout this guide the term dtksh means the Desktop KornShell Who Should Use This Guide This guide is intended for programmers who want a quick and easy means of creating Motif applications but don t have the time knowledge or inclination to use the C programming language A good understanding of kshell programming Motif the Xt Intrinsics and to a lesser extent Xlib is needed An understanding of C would also be helpful How This Guide Is Organized Chapter 1 Introduction to Desktop KornShell describes the basic information you need to begin writing Motif application
72. nce Manual edited by Tim O Reilly published by O Reilly and Associates Sebastopol CA 95472 The Definitive Guides to the X Window System Volume 6 Motif Programming Manual by Dan Heller published by O Reilly and Associates Sebastopol CA 95472 What Typographic Changes and Symbols Mean The following table describes the type changes and symbols used in this book Table P 1 Typographic Conventions Typeface or Symbol Meaning Example AaBbCc123 The names of commands files and directories onscreen computer output AaBbCc123 Command line placeholder replace with a real name or value AaBbCc123 Book titles new words or terms or words to be emphasized Edit your login file Use ls a to list all files system You have mail To delete a file type rm filename Read Chapter 6 in User s Guide These are called class options You must be root to do this Preface Table P 1 Typographic Conventions Typeface or Symbol Meaning Example Code samples may display the following UNIX C shell prompt system UNIX Bourne and Korn shell svstem prompt Superuser prompt all shells system CDE Desktop KomShell User s Guide Introductionto Desktop KomShell l Desktop KornShell 1dtksh provides kshell scripts with the means for easily accessing most of the existing Xt and Motif functions dtksh is based on ksh 93 which provides a powerful set of tools and commands for the
73. nd Black Menu Accelerators The following resources establish keyboard accelerators for the most frequently accessed menu commands l DtHelpDialogWidget searchMenu keyword acceleratorText Ctrl I DtHelpDialogWidget searchMenu keyword accelerator Ctrl lt Key gt i DtHelpDialogWidget navigateMenu backTrack acceleratorText Ctrl B DtHelpDialogWidget navigateMenu backTrack accelerator Ctrl lt Key gt b DtHelpDialogWidget navigateMenu homeTopic acceleratorText Ctr1 H DtHelpDialogWidget navigateMenu homeTopic accelerator Ctrl lt Key gt h DtHelpDialogWidget fileMenu close acceleratorText Alt F4 DtHelpDialogWidget fileMenu close accelerator Alt lt Key gt f4 Variable Values This section describes the types of values for some of the variables in a dtksh app defaults file Defined Values The C bindings of the interfaces to X Xt and Motif include many nonstring values that are defined in header files The general format of such values consists of an Xt or Xm prefix followed by a descriptive name For example one of the constraint values for a child of a form widget is XmATTACH FORM Equivalent values are specified in dtksh by dropping the prefix just as in a Motif defaults file XmDIALOG COMMAND TEXT becomes DIALOG COMMAND TEXT XtATTACH FORM becomes ATTACH FORM Introduction to Desktop KomShell 5 Boolean Values You can specify a Boolean value as a parameter to
74. ndle name resource value XmCreateToggleButtonGadget variable parentWidgetHandle name resource value XmCreateWarningDialog variable parentWidgetHandle name resource value XmCreateWorkArea variable parentWidgetHandle name resource value XmCreateWorkingDialog variable parentWidgetHandle name resource value XmFileSelectionDoSearch widgetHandle directoryMask XmFileSelectionBoxGetChild variable widgetHandle child Type where childType is one of the strings DIALOG APPLY BUTTON DIALOG CANCEL BUTTON DIALOG DEFAULT BUTTON DIALOG DIR LIST DIALOG DIR LIST LABEL DIALOG FILTER LABEL DIALOG FILTER TEXT j w dtksh Commands 51 52 T DIALOG HELP BUTTON DIALOG LIST DIALOG LIST LABEL DIALOG OK BUTTON DIALOG SEPARATOR DIALOG SELECTION LABEL DIALOG_TEXT or DIALOG WORK AR tA Dp XmGetAtomName variable display atom XmGetColors widgetHandle background variable var2 var3 var4 The XmGetColors command differs from the C procedure in that it takes a widgetHandle instead of a screen pointer and a colormap XmGetFocusWidget variable widgetHandle XmGetPostedFromWidget variable widgetHandle XmGetTabGroup variable widgetHandle XmGetTearOffControl variable widgetHandle XmGetVisibility variable widgetHandle XmInternAtom variable display atomString onlyIfExistsFlag where onlyIfExists
75. nitialFocus SD defaultButton SOK cancelButton CLOSI navigationType EXC EN JUSIVE TAB GROUP Initial focus is set to the first TextField widget in the first area Default button is set to the OK push button in the fourth area Cancel button is set to the Close button in the fourth area to EXCLUSIVE TAB GROUP Navigation type is set The following line configures the TextField widgets so that pressing the return key does not activate the default button within the Form See the description of EXCLUSIVE TAB GROUP in Appendix B for more information on its use DtkshSetReturnKeyControls SD SFNP SFORM SOK Realize and Loop The last three lines of the script load the previous values of the script_find window realize the top level widget and then enter a loop waiting for user input LoadStickyValues XtRealizeWidget S TOPLE XtMainLoop A Complex Script 39 CDE Desktop KomShell User s Guide dtksh Commands A This appendix contains a list of the commands supported by dtksh Many of these commands are almost identical to their Motif Xt Intrinsics or Xlib counterparts Commands that return a value must have the return variable as an environment variable that is the first parameter in the call Some commands have more differences The following subsections give a synopsis of each of the dtksh commands In general parameter ordering and types are the same as for
76. nt XtIsSubclass widgetHandle widgetClass where widgetClass is the name of a widget class Returns a value which can be used in a conditional statement XtNameToWidget variable referenceWidget name XtIsRealized widgetHandle Returns a value which can be used in a conditional statement XtIsSensitive widgetHandle Returns a value which can be used in a conditional statement XtIsShell widgetHandle Returns a value which can be used in a conditional statement XtLastTimestampProcessed variable display CDE Desktop KomShell User s Guide p lll XtMainLoop XtManageChild widgetHandle XtManageChildren widgetHandle widgetHandle XtMapWidget widgetHandle XtOverrideTranslations widgetHandle translations XtParent variable widgetHandle XtPopdown widgetHandle XtPopup widgetHandle grabType where grabType is one of the strings GrabNone GrabNonexclusive or GrabExclusive XtRealizeWidget widgetHandle XtRemoveAllCallbacks widgetHandle callbackName where callbackName is one of the standard Motif or Xt callback names with the Xt or Xm prefix dropped for example activateCallback XtRemoveCallback widgetHandle callbackName ksh command where callbackName is one of the standard Motif or Xt callback names with the Xt or Xm prefix dropped for example activateCallback As is true with traditional Xt callbacks when a callback is removed the same kshell command string must be specified as was specified when the callback was
77. nt words within the base name is always uppercase The convention for resource names in dtksh scripts is to delete the prefix and use the base name Thus the resource XmNtopShadowColor becomes topShadowColor Some Xt and Motif commands allow the shell script to pass in a variable number of parameters representing resource value pairs This is similar to the argument list passed to the corresponding Xt or Motif C function Examples include any of the commands used to create a widget plus the Xt SetValues command In dtksh resources are specified by a string with the following syntax resource value where resource is the name of the resource and value is the value assigned to the resource dtksh automatically converts the value string to an appropriate internal representation For example XtSetValues SWIDGET height 100 width 200 resizePolicy RESIZE ANY XmCreateLabel LABEL SPARENT myLabel labelString Close Dialog When you retrieve widget resource values using XtGetValues the return value is placed in an environment variable Thus unlike the Xt Intrinsics the dtksh version of XtGetValues uses a name environment variable pair rather than a name value pair For example XtGetValues SWIDGET height HEIGHT resizePolicy POLICY sensitive SENSITIVE echo SHEIGH echo SPOLICY echo SSENSITIVE The preceding dtksh segment might produce this output CDEDesktop KomShell User s Gu
78. ound color to be black You can set the values of these resources this way XtCreateWidget BUTTON button XmPushButton STOPLEVEL background Red foreground Black XmCreatePushButton BUTTON STOPLEVEL button background Red foreground Black All of the C functions that create a widget return a widget ID or ID The corresponding dtksh commands set an environment variable equal to the widget ID These are category 3 commands so the first argument is the name of the environment variable in which to return the widget ID The widget ID is an ASCII string used by dtksh to access the actual widget pointer Either of the following commands could be used to create a new form widget however in each case the widget ID for the new form widget is returned in the environment variable FORM XtCreateManagedWidget FORM name XmForm SPARENT XmCreateForm FORM SPARENT name Introduction to Desktop KomShell 9 lll I Using a Callback After either of these commands you can use FORM to reference the new form widget For example you could use this command to create a label widget within the new form widget XmCreateLabel LABEL FORM name labelString Hi Mom CH_FORM leftAttachment ATTACH_FORM Note There is a special widget ID called NULL provided for cases where a shell script may need to specify a NULL widget For example to disable the defaultButton resource for a form widget use t
79. r command call This feature only works for commands that return a single value and the value is returned in the first parameter For example XtDisplay DISPLAY SFORM XSync SDISPLAY true Introduction to Desktop KomShell 7 can be replaced bv the equivalent statement XSync XtDisplay SFORM true The reference to DISPLAY is replaced with the value returned by the call to XtDisplay This capability is available for all category 3 commands except those that create a widget those that return more than a single value and those whose first parameter is not a named variable Commands that do not accept as the environment variable name include the following XtInitialize XtCreateApplicationShell XtCreatePopupShell XtCreateManagedWidget XtCreateWidget All commands of the form XmCreate Most commands of the form Et Initializing the XtIntrinsics A dtksh script must first initialize the Xt Intrinsics before it can call any of the Xlib Xt Motif or libDt commands You accomplish this by invoking the XtInitialize command which returns an application shell widget As is true for all dtksh commands that return a widget ID XtInitialize returns the widget ID in the environment variable that is the first argument For example in XtInitialize TOPLEVEL myShellName Dtksh 0 S the widget ID is returned in the environment variable TOPLEVEL dtksh provides a default app def
80. r messageNumber defaultMessageString Attempts to extract the requested message string from the message catalog associated with the catalogld parameter If the message string cannot be located then the default message string is returned In either case the returned message string is placed into the environment variable indicated by variable catclose catalogld Closes the message catalog associated with the indicated catalogld dtksh Commands 61 A Built in libDt Session Management Commands 62 DtSessionRestorePath widgetHandle variable sessionFile Given the file name for the session file excluding any path information this command returns the full path for the session file in the environment variable variable Returns 0 if successful 1 if unsuccessful DtSessionSavePath widgetHandle variable var2 The full path name for the session file is returned in the environment variable variable The file name portion of the session file excluding any path information is returned in the environment variable indicated by var2 Returns 0 if successful 1 if unsuccessful DtShellIsIconified widgetHandle Allows a shell script to query the iconified state of a shell window Returns 0 if successful 1 if unsuccessful DtSetStartupCommand widgetHandle commandString Part of the session management process is telling the Session Manager how to restart your application the next time the user reopens the session This command passes
81. rmal termination appears in the terminal window from which you executed the script The script is terminated by the call to the function exit 0 CDE Desktop KomShell User s Guide Advanced Topics 3 Now that you have the basic information about dt ksh this chapter introduces you to more advanced topics Using Context Variables dtksh has a number of variables that provide context to certain aspects of an application Event HandlerC ontext Variables An application registers event handlers with a widget to specify an action to occur when one of the specified events occurs The action can be any arbitrary dtksh command line For example XtAddEventHandler W Button2MotionMask false ActivateProc XtAddEventHandler W ButtonPressMask ButtonReleaseMask false echo action Two environment variables are defined to provide context to the event handler EH WIDGET Set to the ID of the widget for which the event handler is registered EH EVENT Set to the address of the XEvent which triggered the event handler Access to the fields within the XI example Event structure is shown in the following 17 if S EH EVENT TVPE ButtonPress then echo X S EH EVENT XBUTTON X echo Y S EH_EVENT XBUTTON Y elif S EH EVENT TYPE KeyPress then echo X S EH EVENT XKEV X echo Y S EH EVENT XKEY Y fi Tansla
82. s in dtksh scripts Chapter 2 A Sample Script describes two simple dtksh scripts The first script creates a push button widget within a bulletin board widget The second script expands the first by adding a callback for the push button Chapter 3 Advanced Topics describes more advanced topics pertaining to dtksh scripts vii Related Books viii Chapter 4 A Complex Script describes a much more complex script than either of the ones described in Chapter 2 This script creates a graphic interface to the find command Appendix A dtksh Commands lists all the dtksh commands Appendix B dtksh Convenience Functions contains man pages for commands or functions that are not documented elsewhere Appendix C The script_find Script contains the complete listing of the complex script described in Chapter 4 The following books provide information on kshell programming Motif the Xt Intrinsics and Xlib Desktop KornShell Graphical Programming For the Common Desktop Environment Version 1 0 by J Stephen Pendergrast Jr published by Addison Wesley Reading MA 01867 The New KornShell Command and Programming Language by Morris I Bolsky and David G Korn published by Prentice Hall Englewood Cliffs NJ 07632 KornShell Programming Tutorial by Barry Rosenberg published by Addison Wesley Reading MA 01867 OSF Motif Programmer s Guide Open Software Foundation 11 Cambri
83. sDataTvpelsAction dataType Determines whether a particular data type represents an action entry Returns a value which can be used in a conditional statement Misc ellaneous Built in libDt Commands DtGetHourGlassCursor variable display Returns the X cursor ID associated with the standard Dt hourglass cursor DtTurnOnHourGlass widgetHandle Turns on the standard Dt hourglass cursor for the indicated widget Dt TurnOffHourGlass widgetHandle Turns off the standard Dt hourglass cursor for the indicated widget Built in Desktop Services Message SetC ommands The following set of commands implements the minimum subset of the Desktop Services Message Set required to allow a shell script to participate in the Desktop Services protocol Many of the ToolTalk commands differ slightly from their associated C programming call For ToolTalk commands that typically return a pointer a C application validates that pointer by calling the tt_ptr_error function this function call returns a Tt_status value which indicates whether the pointer was valid and if not why it was not valid Because of the kshell code s design the string pointer that the shell script sees is not typically the same as the string pointer returned by the underlying C code Typically during shell programming this is not a problem because the important information is the string value not the string pointer To allow shell scripts to get the status of a pointer any of the commands
84. sage interfaces If the sessId argument does not specify a value that is it dtksh Commands 71 72 is an emptv string then the default session is joined If the shellWidgetHandle argument specifies a widget handle that is it is not an empty string then it should refer to a mappedWhenManaged applicationShellWidget The join argument is a Boolean and should be set to true or false This command returns an opaque pattern handle in the variable argument when no longer needed this handle can be destroyed using the ttdt_session_quit command ttdt_session_quit status sessld sessPatterns quit Destroys the message patterns specified by the sessPatterns argument and if the quit argument is set to true quits the session indicated by the sessId argument or quits the default session if sessId is empty ttdt file join variable status pathName scope join ksh command Registers interest in the deleted modified reverted moved and saved messages for the indicated file in the indicated scope An opaque pattern handle is returned in the variable argument When no longer interested in monitoring messages for the indicated file this should be destroyed by calling ttdt file quit The requested ksh command is evaluated anytime one of the messages is received for the indicated file When this kshell command is evaluated the following environment variables are defined and provide additional information about the received message DT
85. set The optional offset parameter specifies how far from the edge of the form widget the component should be positioned If an offset is not specified then 0 is used Example XtCreateManagedWidget BUTTONI buttonl XmPushButton FORM X labelString Ok X DtkshUnder SEPARATOR X DtkshAnchorLeft 10 X DtkshAnchorBottom 10 CDE Desktop KomShell Users Guide ss lll DtkshSpanWidth and DtkshSpanHeight These convenience functions simplify the specification of certain classes of form constraints They provide a way of configuring a component so that it spans either the full height or width of the form widget This behavior is accomplished by attaching two edges of the component top and bottom for DtSpanHeight and left and right for Dt SpanWidth to the form widget The component typically resizes whenever the form widget is resized The ATTACH FORM constraint is used for all attachments Usage DtkshSpanWidth leftOffset rightOffset DtkshSpanHeight topOffset bottomOffset The optional offset parameters specify how far from the edges of the form widget the component should be positioned If an offset is not specified then 0 is used Example XtCreateManagedWidget SEP sep XmSeparator FORM DtkshSpanwWidth 1 1 dtksh Convenienc e Functions 83 B DtkshDispla yInformationDialog DtkshDisplayQ uestionDialog DtDisplayWamingDialog DtkshDispla yWorkingDialog and DtkshDispla yEnorDialog
86. shell programmer and which supports the standard set of kshell programming commands dtksh supports all the features and commands provided by ksh 93 In addition dtksh supports a large selection of the 1ibDt functions most of the widget related Motif functions a large subset of the Xt Intrinsics functions and a small subset of the Xlib functions All the supported functions are listed in Appendix A Using Desktop KomShell to Create Motif Applic ations This section describes how to use dtksh to create Motif applications To successfully use dtksh you should have experience with Xlib the Xt Intrinsics the Motif widgets and KornShell programming It is also helpful to know the C programming language If you are not familiar with any of these you should refer to the appropriate documentation Even if you are familiar with these systems you should have access to the applicable man pages for reference In addition your system should have these libraries libDtHelp libDtSvc libX11 lll I Resources libXm libXt libtt Resources are widget variables that you use to define attributes such as size location or color Each widget usually has a combination of its own resources plus resources it inherits from higher level widgets Xt Intrinsics and Motif resource names consist of a prefix XtN or XmN followed by the base name The first letter of the base name is always lowercase and the first letter of subseque
87. t button and should be the parent of the two text widgets The defaultButton parameter indicates which component is to be treated as the default button within the form widget Examples EXT2 SFORM SOK EXT3 SFORM SOK DtkshSetReturnKeyControls STEX DtkshSetReturnKeyControls STEX Ur N NR dtksh Convenienc e Functions 79 B DtkshUnder DtkshOver DtkshRightOf and DtkshLeftOf These convenience functions simplify the specification of certain classes of form constraints They provide a way of attaching a component to one edge of another component They are used when constructing the resource list for a widget This behavior is accomplished using the ATTACH WIDGET constraint Usage DtkshUnder widgetId offset DtkshOver widgetId offset DtkshRightOf widgetId offset DtkshLeftOf widgetId offset The widgetId parameter specifies the widget to which the current component is to be attached The offset value is optional and defaults to 0 if not specified Example XtCreateManagedWidget BUTTON4 button4 XmPushButton S FORM X labelString Exit DtkshUnder BUTTON2 X DtkshRightOf SBUTTON3 80 CDEDesktop KomShell User s Guide ss lll Dtksh oatRight DtkshHoatLeft DtkshHoatlop and DtkshHoatBottom These convenience functions simplify the specification of certain classes of form constraints They provide a way of positioning a component independent of the oth
88. tInsertionPosition widgetHandle position tFieldSetMaxLength widgetHandle maxLength XmTex tFieldSetSelection widgetHandle firstPosition lastPosition time where time is typically either obtained from within an X Event or is queried by a call to the Xt Last TimestampProcessed command XmTextFieldSetString widgetHandle string XmTextFieldShowPosition widgetHandle position XmTextFieldXYToPos variable widgetHandle x y XmTextFieldCopy widgetHandle time whe re time is typically either obtained from within an X Event or is queried by a call to the Xt Last TimestampProcessed command Returns a value which can be used in a conditional statement dtksh Commands 59 XmTextFieldCut widgetHandle time where time is typically either obtained from within an X Event or is queried by a call to the XtLastTimestampProcessed command Returns a value which can be used in a conditional statement XmTextFieldPaste widgetHandle Returns a value which can be used in a conditional statement XmTextFieldSetAddMode widgetHandle state where state can be set to either true or false XmToggleButtonGadgetGet State widgetHandle Returns a value which can be used in a conditional statement XmToggleButtonGadgetSetState widgetHandle state notifyFlag where state can be set to either true or false and where notifyFlag can be set to either true or false XmToggleButtonGet State widgetHandle Returns a value which can be used in a
89. tLeft 81 DtkshFloatRight 81 DtkshFloatTop 81 DtkshLeftOf 80 DtkshOver 80 DtkshRightOf 80 DtkshSetReturnKeyControls 79 DtkshSpanHeight 83 DtkshSpanWidth 83 DtkshUnder 80 E event handler 17 event subfield 20 F Find sticky 95 functions supported 1 H handle 9 I immediate return value 7 CDE Desktop KomShell User s Guide initialize 14 initialize Xt Intrinsics 8 input context variable 18 input mode 19 K ksh 93 1 L libDt commands 65 67 libDt session management commands 62 libraries required 1 localization commands 61 localized script 25 M menu create 37 message set commands 67 Motif applications 1 Motif commands 48 mwmFunctions 3 P parameters variable number 2 pushbutton 15 R register callback 10 required linbraries 1 resource unsupported 3 resources 2 return value category 1 category 2 category 3 category 4 immediate 7 Return Values 6 NN DD S sample script 13 script localized 25 sample 13 writing 13 script complex 29 script_find 29 87 session manager save state notice 21 supported functions 1 T toplevel widget 14 topShadowColor 2 translation 18 27 U unsupported resources 3 V variable values 5 VendorShell 3 WwW widget bulletin board 14 create 8 form 35 handle 9 pushbutton 15 separator 36 toplevel 14 translations 27 window manager close notice 21 workspace
90. tWidgetHandle name resource value CreateDrawnButton variable parentWidgetHandle name resource value CreateErrorDialog variable parentWidgetHandle name resource value CreateFileSelectionBox variable parentWidgetHandle name resource value CreateFileSelectionDialog variable parentWidgetHandle name resource value XmCreateForm variable parentWidgetHandle name resource value XmCreateFormDialog variable parentWidgetHandle name resource value XmCreateFrame variable parentWidgetHandle name resource value XmCreateInformationDialog variable parentWidgetHandle name resource value XmCreateLabel variable parentWidgetHandle name resource value XmCreateLabelGadget variable parentWidgetHandle name resource value XmCreateList variable parentWidgetHandle name resource value XmCreateMainWindow variable parentWidgetHandle name resource value XmCreateMenuBar variable parentWidgetHandle name resource value XmCreateMenuShell variable parentWidgetHandle name resource value XmCreateMessageBox variable parentWidgetHandle name resource value XmCreateMessageDialog variable parentWidgetHandle name Iresource value XmCreateOptionMenu variable parentWidgetHandle name resource value XmCreatePanedWindow variable parentWidgetHandle name resource value XmCreatePopupMenu variable parentWidgetHandle name resource valu
91. th 10 10 navigationType EXCLUSIVE TAB GROUP XtManageChild FSTYPE The second option menu button is created in the same manner It provides further restrictions on the find command The third separator is created in the same manner as the other separators Fourth Area The fourth area consists of four push button widgets all children of the Form widget Di Ayanly Close Help ras PANA The four push buttons are used as follows OK executes the find command with the parameters input in the script_find window and removes the script_find window Apply executes the find command with the parameters input in the script_find window but does not remove the script_find window Close terminates script find without executing the find command Help creates a dialog box with information on the use of script find The push buttons are created and positioned in much the same manner as any of the other widgets although they are each labeled differently The following code segment shows how the OK push button is created XtCreateManagedWidget OK ok XmPushButton FORM labelString Ok DtkshUnder SEP3 10 CDE Desktop KomShell User s Guide I lll DtkshFloatlLeft 4 DtkshFloatRight 24 DtkshAnchorBottom 10 XtAddCallback SOK activateCallback OkCallback Set Operating Parameters XtSetValues is used to set some initial operating parameters XtSetValues S FORM i
92. that normally return a pointer also return the associated Tt_status value for the pointer automatically This saves the shell script from needing to make an additional call to check the validity of the original pointer In the case of a pointer error occurring dtksh returns an empty string for the pointer value and sets the Tt_status code accordingly The Tt_status value is returned in the status argument The Tt_status value is a string representing the error and can assume any of the following values dtksh Commands 67 TT OK TT WRN NOTFOUND TT WRN STALE OBJID TT WRN STOPPED TT WRN SAME OBJID TT WRN START MESSAGE TT ERR CLASS TT ERR DBAVAIL TT ERR DBEXIST TT ERR FILE TT ERR INVALID TT ERR MODE TT ERR ACCESS TT ERR NOMP TT ERR NOTHANDLER TT ERR NUM TT ERR OBJID TT ERR OP TT ERR OTYPE TT ERR ADDRESS TT ERR PATH TT ERR POINTER TT ERR PROCID TT ERR PROPLEN TT ERR PROPNAME TT ERR PTYPE TT ERR DISPOSITION TT ERR SCOPE TT ERR SESSION TT ERR VTYPE TT ERR NO VALUE TT ERR INTERNAL TT ERR READONLY TT ERR NO MATCH TT ERR UNIMP TT ERR OVERFLOW TT ERR PTPE START TT ERR CATEGORY TT ERR DBUPDATE TT ERR DBFULL CDE Desktop KomShell User s Guide TT ERR DBCONSIST TT ERR STATE
93. the specified command string to the Session Manager The widget handle should refer to an application shell DtSetIconifyHint widgetHandle iconifyHint where iconifyHint can be set to either true or false Allows the initial iconified state for a shell window to be set This command only works if the window associated with the widget has been realized but not yet displayed CDE Desktop KomShell User s Guide p lll Built in libDt Workspace Management Commands DtWsmAddCurrentWorkspaceCallback variable widgetHandle ksh command Evaluates the specified kshell command whenever the user changes workspaces The handle associated with this callback is returned in the environment variable indicated by variable The widget indicated by widgetHandle should be a shell widget DtWsmRemoveWorkspaceCallback callbackHandle Removes a workspace notification callback When removing a workspace callback you must pass in the callback handle that was returned when you registered the callback with DEWsmAddCurrent WorkspaceCallback DtWsmGetCurrentWorkspace display rootWindow variable Returns the X atom that represents the user s current workspace in the environment variable indicated by variable Use the XmGetAtomName command to map the X atom into its string representation DtWsmSetCurrentWorkspace widgetHandle workspaceNameAtom Changes the user s current workspace to the workspace indicated by workspaceNameAtom Returns 0 if successful 1 if
94. tion ContextVariables The Xt Intrinsics provides for event translations to be registered for a widget Context for event translation is provided in the same way it is provided for event handlers The two variables defined for translation commands are TRANSLATION WIDGET Set to the widget handle for the widget for which the translation is registered TRANSLATION EVENT Set to the address of the XEvent that triggered the translation Dot notation provides access to the fields of the event echo Event type S TRANSLATION EVENT TVPE echo Display S TRANSLATION EVENT XANY DISPLAY Workspace Callback Context Variables An application has the ability to register a callback function that is invoked whenever the user changes to a new workspace When the callback is invoked two special environment variables are set and can be accessed by the shell callback code CB WIDGET Set to the ID for the widget that is invoking the callback CB CALL DATA Set to the X atom that uniquely identifies the new workspace This can be converted to its string representation using the XmGetAtomName command InputContextVariables The Xt Intrinsics provides the Xt AddInput facility which allows an application to register interest in any data available from a particular file descriptor When programming in C the application provides a handler CDE Desktop KomShell User s Guide 3 function which is invoked wh
95. tioned under the second TextField widget XtCreateManagedWidget SEP sep XmSeparator FORM separatorType SINGLE DASHED LINE X DtkshUnder SFNP 10 X DEkshSpanWidth Second Area The second area consists of a RowColumn widget five ToggleButton gadgets and another Separator widget Cross Mount Parita Print Matehing Filanamas Powe Coker melh five Tipis Seench Hidden Sutufiresinrimu Fallleres Symbolic Links ades Descend Sulidinsctories Firet 5 tT Hee rears a tate reer f sel Figure 4 6 Second Area of script_find Window A gadget is a widget that relies on its parent for many of its attributes thus saving memory resources The RowColumn widget is created as a child of the Form widget and positioned directly under the Separator widget created in the first area XtCreateManagedWidget RC rc XmRowColumn FORM orientation HORIZONTAL numColumns 3 packing PACK_COLUMN DtkshUnder SEP 10 DtkshSpanWidth 10 10 navigationType EXCLUSIVE_TAB_GROUP 36 CDE Desktop KomShell Users Guide 4 The five ToggleButton gadgets are created as children of the RowColumn using the convenience function DtkshAddButtons DtkshAddButtons w RC XmToggleButtonGadget T1 Cross Mount Points wy T2 Print Matching Filenames WW T3 Search Hidden Subdirectories N TA Follow Symbolic Links WW T5 Descend Subdirectories First Another Separator is then created to separate th
96. to catch the Close notification If the application does not catch the notification then multiple windows managed by the application all disappear and application data may be left in an undesirable state To avoid this dtksh provides for catching and handling the Close notification The application must Define a procedure to handle the Close notification Request notification when Close is selected Override the response so the application is not shut down The following code illustrates this processing f This is the callback invoked when the user selects f the Close menu item WMCallback echo User has selected the Close menu item Create the toplevel application shell XtInitialize TOPLEVEL test Dtksh 0 Q XtDisplay DISPLAY STOPLEVEL f Request notification when the user selects the Close menu item XmInternAtom DELETE ATOM SDISPLAV WM DELETE WINDOW false XmAddWMProtocolCallback STOPLEVEL SDELETE ATOM WMCallback f Ask Motif to not automatically close down your application window XtSetValues STOPLEVEL deleteResponse DO NOTHING Responding to a Session ManagerSave State Notice Session Manager allows applications to save their current state when the user terminates the current session so that when the user later restarts the session an application can return to the state it was in In dtksh th
97. tring XmListSetBottomPos widgetHandle position XmListSetHorizPos widgetHandle position XmListSetItem widgetHandle itemString XmListSetKbdItemPos widgetHandle position Returns a value which can be used in a conditional statement XmListSetPos widgetHandle position XmListUpdateSelectedList widgetHandle XmMainWindowSep1 variable widgetHandle XmMainWindowSep2 variable widgetHandle CDE Desktop KomShell User s Guide p lll XmMainWindowSep3 variable widgetHandle XmMainWindowSetAreas widgetHandle menuWidget Handle command Widget Handle horizontalScrollbar WidgetHandle verticalScrollbar WidgetHandle workRegion WidgetHandle XmMenuPosition widgetHandle eventHandle where eventHandle refers to an X event which has typically been obtained by accessing the CB CALL DATA EVENT EH EVENT or TRANSLATION EVENT environment variables XmMessageBoxGetChild variable widgetHandle child Type where childType is one of the strings DIALOG CANCEL BUTTON DIALOG DEFAULT BUTTON DIALOG HELP BUTTON DIALOG MESSAGE LABEL DIALOG OK BUTTON DIALOG SEPARATOR orDIALOG SYMBOL LABEL XmOptionButtonGadget variable widgetHandle XmOptionLabelGadget variable widgetHandle XmProcessTraversal widgetHandle direction where direction is one of the strings TRAVERSE CURRENT TRAVERSE DOWN TRAVERSE HOME TRAVERSE LEFT jest TRAVERSE NEXT TRAVERSE NEXT TAB
98. uctures The exception to this is the XmTextVerifyCallbackStruct which is available during the losingFocusCallback the modifyVerifyCallback and the motionVerifyCallback for the text widget dtksh supports the Introduction to Desktop KomShell 11 12 modification of certain fields within this structure to the extent that it is supported bv Motif The following fields within the callback structure are capable of being modified CB CALL DATA DOI CB CALL DATA STARTPOS CB CALL DATA TEXT PTR CB CALL DATA TEXT LENGTH DATA TEXT FORMAT This is an CB CALL example of how one of these fields can be modified DATA DOIT false CB CALL CB CALL l DATA TEXT PTR CB CALL DATA TEXT LENGTH 1 CDEDesktop KomShell User s Guide A Sample Script 2 This chapter shows vou how to use what vou learned about dtksh in Chapter 1 The two simple scripts described here should give vou a good start at writing vour own scripts Whiting the Script This script creates a bulletin board widget within which a push button widget is placed The script is kept simple by not including any callbacks The second script includes a callback Here s the first script usr dt bin dtksh XtInitialize TOPLEVEL dttestl Dtksh 0 XtSetValues STOPLEVEL title dttest1 XtCreateManagedWidget BBOARD bboard XmBulletinBoard TOPLEVEL
99. uttonSetSta dg The script find Script onPosition FNP nuHistory SFST menuHistory S FT nen te ST1 true false nen te ST2 true false nen te T3 true false nen te ST4 true false hen te ST5 true false S 4SFNP VAL 91 92 exe HHH HHH set f XtInit c 3 amp HHttHeteHE Create the Main UI tt eee eee eee e eee ialize TOPLEVEL find Dtksh 0 S XtSetValues STOPLEVEL title Find Files XtCrea XtCrea teManagedWidget FORM form XmForm STOPLEVEL teManagedWidget SDLABEL sdlabel XmLabel FORM X labelString Search Directory D D XtCrea tkshAnchorTop 12 X tkshAnchorLeft 10 teManagedWidget SD sd XmText S FORM X columns 30 value N D D D tkshAnchorTop 6 X tkshRightOf SSDLABEL 10 tkshAnchorRight 10 navigationType EXCLUSIVE_TAB_GROUP XmTextFieldSetInsertionPosition SD 1 XtCrea teManagedWidget FNPLABEL fnpabel XmLabel FORM X labelString Filename Pattern D D XtCrea tkshUnder SDLABEL 24 tkshAnchorLeft 10 columns 30 D D D teManagedWidget FNP fnp XmText FORM X tkshUnder SD 8 X tkshRightOf SFNPLABEL 10 X tkshAnchorRight 10 X navigationType EXCLUSIVE TAB GROUP XtCrea teManagedWidget SEP sep XmSeparator FORM X separatorType SINGLE DASHE
100. widgetHandle XtWindow variable widgetHandle Built in Motif Commands XmAddWMProtocolCallback widgetHandle protocolAtom ksh command where protocolAtom is typically obtained using the XmInternAtom command CDEDesktop KomShell User s Guide p Ill XmAddWMP rotocols widgetHandle protocolAtom protocolAtom where protocolAtom is typically obtained using the XmInternAtom command XmCommandAppendValue widgetHandle string XmCommandError widgetHandle errorString XmCommandGetChild variable widgetHandle childType xm xm xm xm xm xm xm xm xm xm xm xm xm xm dtksh Commands where childType is one of the strings DIALOG COMMAND TE DIALOG PROMPT LABEL DIALOG HISTORY LIST or DIALOG WORK AREA ri x H CommandSetValue widgetHandle commandString CreateArrowButton variable parentWidgetHandle name resource value CreateArrowButtonGadget variable parentWidgetHandle name resource value CreateBulletinBoard variable parentWidgetHandle name resource value CreateBulletinBoardDialog variable parentWidgetHandle name resource value CreateCascadeButton variable parentWidgetHandle name resource value CreateCascadeButtonGadget variable parentWidgetHandle name resource value CreateCommand variable parentWidgetHandle name resource value CreateDialogShell variable parentWidgetHandle name resource value CreateDrawingArea variable paren
101. widgetHandle time where time is typically either obtained from within an X Event or is queried by a call to the XtLastTimestampProcessed command xtFi ldGetBaseline variable widgetHandle TextFiel dGetEditable widgetHandle Returns a xtFi value which can be used in a conditional statement ldGetInsertionPosition variable widgetHandle TextFiel xtFi ldGetLastPosition variable widgetHandle ldGetMaxLength variable widgetHandle xtFi ldGet Selection variable widgetHandle CDE Desktop KomShell User s Guide p lll XmTextFieldGetSelectionPosition widgetHandle variable var2 Returns a value which can be used in a conditional statement XmTextFieldGetString variable widgetHandle XmTextFieldInsert widgetHandle position string XmTextFieldPosToXY widgetHandle position variable var2 Returns a value which can be used in a conditional statement XmTextFieldRemove widgetHandle Returns a value which can be used in a conditional statement XmTextFieldReplace widgetHandle fromPosition toPosition string XmTextFieldSetEditable widgetHandle editableFlag where editableFlag can be set to either true or false XmTex tFieldSetHighlight widgetHandle left Position rightPosition mode Where mode is one of the strings HIGHLIGHT NORMAL HIGHLIGHT SELECT T CI D or HIGHLIGHT SECONDARY S LECTED XmTex XmTex tFieldSe

Download Pdf Manuals

image

Related Search

Related Contents

Plus facile qu`il n`y paraît  SIM Image Processing Manual  Hyundai D467MLP    Read User Manual - INDUSFLOW SYSTEMS  USER`S MANUAL  Tripp Lite Cat5e 350MHz Molded Cross-over Patch Cable (RJ45 M/M) - Gray, 10-ft.  Les rencontres SPEED BUSINESS sont des rencontres  Sierra Monitor Corporation 55 User's Manual  Vitastage Betriebs- / Montageanleitung  

Copyright © All rights reserved.
Failed to retrieve file