dtksh supports all the features and commands provided by ksh-93. In addition, dtksh supports a large selection of the libDt 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.
In addition, your system should have these libraries:
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 XtSetValues 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 $WIDGET height:100 width:200 resizePolicy:RESIZE_ANY
XmCreateLabel LABEL $PARENT 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 $WIDGET height:HEIGHT resizePolicy:POLICY
sensitive:SENSITIVE
echo $HEIGHT
echo $POLICY
echo $SENSITIVE
The preceding dtksh segment might produce this output:
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
/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.
*foregroundThreshold: 70
!###
!#
!# Help system specific resources
!#
!###
!#
!# 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
!# in all cases.
!#
*XmDialogShell.DtHelpDialog*DisplayArea.background: White
*XmDialogShell*XmDialogShell.DtHelpDialog*DisplayArea.background: White
*XmDialogShell.DtHelpDialog*DisplayArea.foreground: Black
*XmDialogShell*XmDialogShell.DtHelpDialog*DisplayArea.foreground: Black
!#
!# Menu Accelerators
!#
!# The following resources establish keyboard accelerators
!# for the most frequently accessed menu commands.
!#
*DtHelpDialogWidget*searchMenu.keyword.acceleratorText: Ctrl+I
*DtHelpDialogWidget*searchMenu.keyword.accelerator: Ctrl<Key>i
*DtHelpDialogWidget*navigateMenu.backTrack.acceleratorText: Ctrl+B
*DtHelpDialogWidget*navigateMenu.backTrack.accelerator: Ctrl<Key>b
*DtHelpDialogWidget*navigateMenu.homeTopic.acceleratorText: Ctrl+H
*DtHelpDialogWidget*navigateMenu.homeTopic.accelerator: Ctrl<Key>h
*DtHelpDialogWidget*fileMenu.close.acceleratorText: Alt+F4
*DtHelpDialogWidget*fileMenu.close.accelerator: Alt<Key>f4
XtMapWidget $FORM
XmGetColors $FORM $BG FOREGROUND TOPSHADOW BOTTOMSHADOW SELECT
echo "Foreground color = " $FOREGROUND
XmTextGetString TEXT_VALUE $TEXT_WIDGET
echo "The value of the text field is "$TEXT_VALUE
if XmIsTraversable $PUSH_BUTTON; then
echo "The pushbutton is traversable"
else
echo "The pushbutton is not traversable"
fi
Generally, the order and type of parameters passed to a command matches those passed to the corresponding C function, except as noted for category 3 commands.
can be replaced by the equivalent statement:XtDisplay DISPLAY $FORM
XSync $DISPLAY true
XSync $(XtDisplay "-" $FORM) 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:
XmCreate...()
tt_...()
XtInitialize TOPLEVEL myShellName Dtksh $0 "$@"
the widget ID is returned in the environment variable TOPLEVEL.dtksh provides a default app-defaults 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.
XtCreateWidget
variable name widgetclass $parent [resource:value ...]
XmCreatePushButton
variable $parent name [resource:value ...]
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 foreground color to be black. You can set the values of these resources this way:XtCreateWidget BUTTON button XmPushButton $TOPLEVEL
XmCreatePushButton BUTTON $TOPLEVEL button
XtCreateWidget BUTTON button XmPushButton $TOPLEVEL \
background:Red \
foreground:Black
XmCreatePushButton BUTTON $TOPLEVEL 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: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
XtAddCallback $WIDGET activateCallback "ActivateProc"
XtAddCallback $WIDGET activateCallback \
"XtSetSensitive $BUTTON false"
typedef struct {
int reason;
XEvent event;
int value;
}XmScaleCallbackStruct;
The C application's callback then does something like:
if (scaleCallData->reason == XmCR_VALUE_CHANGED)
{
eventType = scaleCallData->event->type;
display = scaleCallData->event->xany.display;
}
Similarly, when a callback is invoked in dtksh, 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
eventType=${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 structures. 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 modification of certain fields within this structure, to the extent that it is supported by Motif. The following fields within the callback structure are capable of being modified: