DTKSH(1)
๐ธ NAME ๐ธ
okay so bestie, welcome to dtksh โ from the (user cmd) corner of the manual โ which is literally a shell command language interpreter that also happens to have access to a whole bunch of X, Xt, Xm and XCDE functions. like, it's a Korn shell but with main character energy ๐
โจ SYNOPSIS โจ
three whole ways to summon it, and yes you need all three:
dtksh [-abCefimnuvx] [-o option] [+abCefmnuvx] [+o option]
[command_file [argument | ... ] ]
dtksh [-abCefimnuvx] [-o option] [+abCefmnuvx] [+o option]
[command_string] [command_name [argument | ... ] ]
dtksh [-s] [-abCefimnuvx] [-o option] [+abeCefmnuvx] [+o option]
[argument | ... ]
(no cap, that third one really does say +abeCefmnuvx โ iykyk ๐ซถ)
๐ฆ DESCRIPTION ๐ฆ
The dtksh utility is a version of the KornShell that's been extended to support all of this:
- Access to many X, Xt and Motif facilities from within a shell script
- Fully localized shell scripts
- Access to the XCDE application help system
- Customization of script-based GUI attributes (such as font and colors) using the XCDE customization tool
- Response to session-management Save state directives
- Response to window-management Close directives
- Access to most of the XCDE Desktop Services Message Set
- Access to many of the XCDE Data Typing API functions
- Access to the XCDE Action API functions
like... she's a shell but she also does GUI things. obsessed. ๐
๐ OPTIONS ๐
See ksh-cde(1).
(that's it. that's the section. she's lowkey mysterious about it โจ)
๐ธ OPERANDS ๐ธ
See ksh-cde(1).
(same vibe. go read the other page bestie ๐ญ)
๐ง RESOURCES ๐ง
The dtksh interpreter has no relevant resources outside of those that affect the various widgets that can be instantiated from within a dtksh script. So basically: if you wanna know about the resources that apply to a widget, go read that widget's own manual page. she's not doing your homework for you ๐
๐ STDIN ๐
See ksh-cde(1).
๐ INPUT FILES ๐
See ksh-cde(1).
๐ ENVIRONMENT VARIABLES ๐
okay here's the meaty part, stay with me ๐ซถ What follows describes the environment variables that dtksh uses in addition to those documented in the manual page for the ksh-cde command language interpreter.
๐ซ Immediate Return Value (-) ๐ซ
Many of the category 3 commands (as described in the Return Values From Built-in Commands section) return a single value using an environment variable that's specified as the first argument to the command. (In the synopses for these special commands, the first argument has the name variable.)
So here's the slay part: if that return value gets used immediately in an expression, you can use the special environment variable `-` in place of a variable name. When dtksh encounters `-` as the name of the environment variable where the return value should go, it returns the result as the value of the command instead. Which means your shell script can embed the command call inside another command call. (This feature works only for commands that return a single value โ the value is the first argument and that argument has the name variable.)
For example, this:
XtDisplay DISPLAY $FORM
XSync $DISPLAY true
can be replaced by the equivalent:
XSync $(XtDisplay "-" $FORM) true
The reference to $DISPLAY is replaced with the value returned by the call to XtDisplay. Iconic. ๐
This capability is available for all category 3 commands except:
- those that create a widget
- those that return more than a single value
- those whose first argument is not named variable
Commands that do not accept `-` as the environment variable name include: XtInitialize, XtCreateApplicationShell, XtCreatePopupShell, XtCreateManagedWidget and XtCreateWidget; all commands of the form:
XmCreate...()
and most commands of the form:
tt_...()
(note the most, bestie โ not all of them ๐)
๐ Variables Set By XtInitialize ๐
The XtInitialize command sets the following variables:
DTKSH_APPNAME DTKSH_ARGV DTKSH_TOPLEVEL
๐ฆ Callback Context Variables ๐ฆ
So an application registers a callback with a widget to say which condition it's interested in, and what action should happen when that condition occurs. That action can be any arbitrary dtksh command line. For example:
XtAddCallback $WIDGET activateCallback "ActivateProc"
XtAddCallback $WIDGET activateCallback "XtSetSensitive $BUTTON false"
A callback needs to be passed some context so it can figure out what condition led to its call. For a C procedure, that info is typically passed in a call_data structure. For example, a Scale widget invoking a valueChangedCallback passes in call_data an instance of the following structure:
typedef struct {
int reason;
XEvent *event;
int value;
} XmScaleCallbackStruct;
And the C application's callback does something like:
if (scaleCallData->reason == XmCR_VALUE_CHANGED) {
eventType = scaleCallData->event->type;
display = scaleCallData->event->xany.display;
}
Similarly in dtksh, when a callback is invoked, the following special environment variables get set up before the callback command executes:
CB_WIDGETโ Set to the widget handle for the widget invoking the callback.CB_CALL_DATAโ Set to the address of thecall_datastructure passed by the widget to the callback, but its usefulness lies in the nested sub-variables associated with it.
The CB_CALL_DATA environment variable represents a pointer to a structure; access to its fields uses a syntax similar to the C code. Nested environment variables are defined, named the same as the fields of the structure (but folded to all upper case), and use a dot to indicate containment of an element in a structure. So the preceding C code, to access the call_data 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
Same deal for the event structure within the call_data structure. ๐
For most callback structures, the shell script is able to reference any of the fields defined for that particular callback structure, using the technique described above in this manual page. In most cases, the shell script is not able to alter the values of the fields within these structures. The exception? The XmTextVerifyCallbackStruct, available during the losingFocusCallback, the modifyVerifyCallback and the motionVerifyCallback for the text widget. The dtksh utility supports modifying certain fields within this structure, to the extent that it's supported by Motif. The following fields within the callback structure can be modified:
CB_CALL_DATA.DOIT
CB_CALL_DATA.STARTPOS
CB_CALL_DATA.ENDPOS
CB_CALL_DATA.TEXT.PTR
CB_CALL_DATA.TEXT.LENGTH
CB_CALL_DATA.TEXT.FORMAT
An example of how these fields can be modified:
CB_CALL_DATA.DOIT="false"
CB_CALL_DATA.TEXT.PTR="*"
CB_CALL_DATA.TEXT.LENGTH=1
๐ฅ Event Handler Context Variables ๐ฅ
As with callbacks, an application registers event handlers with a widget to specify what action should occur when one of the specified events occurs. And again, the action can be any arbitrary dtksh command line. For example:
XtAddEventHandler $W "Button2MotionMask" false "ActivateProc"
XtAddEventHandler $W "ButtonPressMask|ButtonReleaseMask" false "echo action"
Just like with callbacks, two environment variables are defined to provide context to the event handler:
EH_WIDGETโ Set to the widget handle for the widget for which the event handler is registered.EH_EVENTโ Set to the address of theXEventthat triggered the event handler.
Access to the fields within the XEvent structure is the same as for the CB_CALL_DATA environment variable described above in this manual page. For example:
if [${EH_EVENT.TYPE} = "ButtonPress"]; then
echo X = ${EH_EVENT.XBUTTON.X}
echo Y = ${EH_EVENT.XBUTTON.Y}
elif [${EH_EVENT.TYPE} = "KeyPress"]; then
echo X = ${EH_EVENT.XKEY.X}
echo Y = ${EH_EVENT.XKEY.Y}
fi
โญ Translation Context Variables โญ
Xt provides for event translations to be registered for a widget; their context is provided in the same way as with 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 theXEventthat triggered the translation.
Dot-notation provides access to the fields of the event:
echo Event type = ${TRANSLATION_EVENT.TYPE}
echo Display = ${TRANSLATION_EVENT.XANY.DISPLAY}
๐ง Workspace Callback Context Variables ๐ง
An application can register a callback function that gets invoked any time the user changes to a new workspace. When the callback is invoked, the following two special environment variables are set, and can be accessed by the shell callback code:
CB_WIDGETโ Set to the widget handle for the widget 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 theXmGetAtomNamecommand.
๐ Accessing Event Subfields ๐
The XEvent structure has like a million different configurations depending on the event's type. The dtksh utility provides access only to the most frequently used XEvents. Any of the other standard XEvents are accessed using the event type XANY, followed by any of the subfields defined by the XANY event structure, which includes the following subfields:
${TRANSLATION_EVENT.XANY.TYPE}
${TRANSLATION_EVENT.XANY.SERIAL}
${TRANSLATION_EVENT.XANY.SEND_EVENT}
${TRANSLATION_EVENT.XANY.DISPLAY}
${TRANSLATION_EVENT.XANY.WINDOW}
The dtksh utility supports full access to all of the event fields for the following event types:
XANY XBUTTON XEXPOSE XNOEXPOSE XGRAPHICSEXPOSE XKEY XMOTION
The following examples show how the subfields for the previously listed event types are accessed:
${TRANSLATION_EVENT.XBUTTON.X}
$(CB_CALL_DATA.EVENT.XKEY.STATE}
${EH_EVENT.XGRAPHICSEXPOSE.WIDTH}
(yes bestie, that second one really has a mismatched brace in the original โ i'm not fixing it, that's not my job ๐)
๐ Input Context Variables ๐
Xt provides the XtAddInput(3) facility that lets an application register interest in activity on a particular file descriptor. This generally includes data available for reading, the file descriptor being ready for writing, and exceptions on the file descriptor. If you're programming in C, the application provides a handler function that gets invoked when the activity occurs. When reading data from the file descriptor, it's up to the handler to read the data from the input source and handle character escaping and line continuations.
okay that's the end of this chunk โ but there's so much more coming, don't go anywhere ๐
so like, โจ input handlers โจ โ the dtksh utility also supports the XtAddInput(3) facility, but it's been limited to reading data only, and it took the reading function a whole step further to make life easier for shell programmers. By 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. And a "complete line of text" is defined as a line terminated either by an unescaped <newline> character, or by end-of-file. The input handler also gets called if no data is available and end-of-file is reached โ which gives the handler the opportunity to use XtRemoveInput(3) to remove the input source, and to close the file descriptor. ๐ซถ
The advantage of this default behavior? Input handlers don't need to do escape processing or handle line continuations, and that's a slay. ๐
The disadvantage? It assumes all of the input is line-oriented and contains no binary information. ๐ญ So if the input source does contain binary information, or if the input handler wants to read the data from the input source directly, dtksh also supports a raw input mode. In raw mode, dtksh does not read any of the data from the input source โ any time dtksh is notified that input is available on the input source, it invokes the shell script's input handler. Then it becomes the handler's responsibility to read the incoming data, to perform any required buffering and escape processing, and to detect when end-of-file is reached (so that the input source can be removed and the file descriptor closed). main character energy: the handler does literally everything.
Whether the input handler is 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 give the handler everything it needs to handle the incoming data:
INPUT_LINEโ in default mode, this variable contains the next complete line of input available from the input source. IfINPUT_EOFis set toTrue, there is no data in this buffer. In raw mode, this environment variable always contains an empty string. ๐ซINPUT_EOFโ in default mode, this variable is set toFalseany timeINPUT_LINEcontains data, and is set toTruewhen end-of-file is reached. When end-of-file is reached, the input handler for the shell script should unregister the input source and close the file descriptor. In raw mode,INPUT_EOFis always set toFalse.INPUT_SOURCEโ indicates the file descriptor for which input is available. In raw mode, this file descriptor is used to obtain the pending input. It's also used to close the input source when it's no longer needed.INPUT_IDโ indicates the ID returned byXtAddInputwhen the input source was originally registered. You need this to remove the input source usingXtRemoveInput. iykyk ๐
โจ ASYNCHRONOUS EVENTS โจ
Default. That's it, that's the whole section, no cap. ๐
๐ STDOUT ๐
See ksh-cde(1). go look, bestie ๐ฆ
๐ธ STDERR ๐ธ
See ksh-cde(1). same deal ๐
๐ OUTPUT FILES ๐
None. Nothing gets written out. periodt. ๐ซ
๐ EXTENDED DESCRIPTION ๐
Everything described here? Extensions to the capabilities of the ksh-cde command language interpreter. See ksh-cde(1). The following subsections give a synopsis of each of the built-in commands added by dtksh to ksh-cde. In general, argument ordering and types are the same as for the corresponding C procedures, with exceptions noted. For more detail on the functionality and arguments of a command, see the standard documentation for the corresponding X11, Xt, Motif or Desktop Services procedure. ๐
In the definitions listed in this document, arguments named variable, variable2, variable3 and so on, indicate that the shell script must supply the name of an environment variable, into which some value is returned. so you're passing a name, not a value โ the value comes back to you through it. ๐ซ
All of the Xt commands used to create a new widget require that the widget class for the new widget be specified. The widget (or gadget) class name is the standard class name provided by Motif. For example, the class name for a Motif pushbutton widget is XmPushButton, while the class name for the Motif label gadget is XmLabelGadget. Commands that use their exit status to return a Boolean value (which can be used directly as part of an if statement) are noted as such. โญ
Arguments enclosed within [] are optional. ๐
๐๏ธ Dtksh Built-in Xlib Commands ๐๏ธ
XBell [display volume]โ the bell one. ring ring, bestie ๐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]XDrawArc [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 ...]- the coordinateMode operand is either
CoordModeOriginorCoordModePrevious. ๐งญ
- the coordinateMode operand is either
XDrawPoint [display drawable][optional GC arguments][x y]XDrawPoints [display drawable][-coordinateMode][optional GC arguments][x1 y1][x2 y2 x3 y3 ...]- the coordinateMode operand is either
CoordModeOriginorCoordModePrevious.
- the coordinateMode operand is either
XDrawRectangle [display drawable][optional GC arguments][x y width height]XDrawSegments [display drawable][optional GC arguments][x1 y1 x2 y2][x3 y3 x4 y4 ...]XDrawString [display drawable][optional GC arguments][x y string]XDrawImageString [display drawable][optional GC arguments][x y string]XFillArc [display drawable][optional GC arguments][x y width height angle1 angle2]XFillPolygon [display drawable][-shape][-coordinateMode][optional GC arguments][x1 y1 x2 y2 ...]- the shape operand is one of
Complex,ConvexorNonconvex, and where coordinateMode is eitherCoordModeOriginorCoordModePrevious. ๐บ
- the shape operand is one of
XFillRectangle [display drawable][optional GC arguments][x y width height]XFlush [display]XHeightOfScreen [variable screen]XRaiseWindow [display window]XRootWindowOfScreen [variable screen]XSync [display discard]- the discard operand is either
TrueorFalse. โ๏ธ
- the discard operand is either
XTextWidth [variable fontName string]- โ ๏ธ the
XTextWidthcommand differs from the C procedure; it takes the name of a font instead of a pointer to a font structure. don't come for me, that's just how it is ๐
- โ ๏ธ the
XUndefineCursor [display window]XWidthOfScreen [variable screen]
๐ง Built-in XtIntrinsic Commands ๐ง
XtAddCallback [widgetHandle callbackName dtksh-command]- the callbackName operand is one of the standard Motif or Xt callback names, with the
XtorXmprefix omitted; for example,activateCallback. ๐ฏ
- the callbackName operand is one of the standard Motif or Xt callback names, with the
XtAddEventHandler [widgetHandle eventMask nonMaskableFlag dtksh-command]- the eventMask operand is of the form
mask| mask| maskand themaskcomponent is any of the standard set ofXEventmasks; for example,ButtonPressMask, where nonMaskableFlag is eitherTrueorFalse.
- the eventMask operand is of the form
XtAddInput [variable][-r][fileDescriptor dtksh-command]- the
XtAddInputcommand registers the indicated file descriptor with the X Toolkit as an alternative input source (that is, for reading). The input handler for the shell script is responsible for unregistering the input source when it's no longer needed, and also to close the file descriptor. ๐ - if the
-roption is specified (raw mode),dtkshdoes not automatically read any of the data available from the input source; it is up to the specifieddtkshcommand to read all data. If-ris not specified, the specifieddtkshcommand is invoked only when a full line has been read (that is, a line terminated by either an unescaped<newline>character, or end-of-file) and when end-of-file is reached. raw mode is useful for handlers expecting to process non-textual data, or for handlers not wantingdtkshto automatically read in a line of data. ๐ - when end-of-file is detected, it's the responsibility of the input handler for the shell script to use
XtRemoveInputto remove the input source, and to close the file descriptor, if necessary. in all cases, several environment variables are set up for the handler to use. these include the following:INPUT_LINEโ empty if raw mode; otherwise, contains next line to be processed.INPUT_EOFโ set toTrueif end-of-file reached; otherwise, set toFalse.INPUT_SOURCEโ file descriptor associated with this input source.INPUT_IDโ ID associated with this input handler; returned byXtAddInput.
- the
XtAddTimeout [variable interval dtksh-command]โ โฐXtAddWorkProc [variable dtksh-command]- in
dtksh, the dtksh-command is typically adtkshfunction name. Like regular work procedures, this function is expected to return a value indicating whether the work procedure wants to be called again, or whether it has completed its work and can be automatically unregistered. if thedtkshfunction returns zero, the work procedure remains registered; any other value causes the work procedure to be automatically unregistered. ๐ซก
- in
XtAugmentTranslations [widgetHandle translations]XtCreateApplicationShell [variable applicationName widgetClass][resource:value ...]XtCallCallbacks [widgetHandle callbackName]- the callbackName operand is one of the standard Motif or Xt callback names, with the
XtorXmprefix omitted; for example,activateCallback.
- the callbackName operand is one of the standard Motif or Xt callback names, with the
XtClass [variable widgetHandle]- the command 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]XtDisplayOfObject [variable widgetHandle]XtGetValues [widgetHandle resource:variable1][resource:variable2 ...]XtHasCallbacks [variable widgetHandle callbackName]- the callbackName operand is one of the standard Motif or Xt callback names, with the
XtorXmprefix omitted: for example,activateCallback. variable is set to one of the stringsCallbackNoList,CallbackHasNoneorCallbackHasSome. ๐๏ธ
- the callbackName operand is one of the standard Motif or Xt callback names, with the
XtInitialize [variable shellName applicationClassName applicationName arguments]
Okay so, this is the exact same energy as basically every Motif-based program ever ๐ โ the arguments argument is where you hand over whatever command-line args the person running your shell script might've typed, and you'll usually spell that with the shell syntax $@. The applicationName argument is in the list too because $@ doesn't include $0 (rude, but that's the deal ๐
). Both applicationName and arguments get used to build the argument list that's passed to XtInitialize. Once that's done, the environment variable DTKSH_ARGV gets set to the argument list as returned by XtInitialize, DTKSH_TOPLEVEL gets set to the widget handle of the widget created by XtInitialize, and DTKSH_APPNAME gets set to the value of the applicationName argument. The command returns a value you can use in a conditional. ๐ซถ
XtIsManaged [widgetHandle]โ returns a value you can drop straight into a conditional โจXtIsSubclass [widgetHandle widgetClass]โ thewidgetClassoperand is the name of a widget class (name, not handle, bestie โ read it twice ๐). The command returns a value that can be used in a conditional.XtNameToWidget [variable referenceWidget name]โ no extra deets in the source, just the signature, so here's the signature ๐ฆXtIsRealized [widgetHandle]โ returns a value that can be used in a conditional ๐XtIsSensitive [widgetHandle]โ returns a value that can be used in a conditional ๐XtIsShell [widgetHandle]โ returns a value that can be used in a conditional ๐XtLastTimestampProcessed [variable display]โ signature as shown, no notes ๐XtMainLoopโ the whole signature is literally just this. iconic โจXtManageChild [widgetHandle]โ yep, that's the whole thing ๐ธXtManageChildren [widgetHandle] [widgetHandle ...]โ one handle, or a whole squad of handles ๐XtMapWidget [widgetHandle]โ signature exactly as shown ๐ฆXtOverrideTranslations [widgetHandle translations]โ takes your widget handle plus the translations, periodt ๐XtParent [variable widgetHandle]โ no extra description in the original, just the synopsis ๐ซถXtPopdown [widgetHandle]โ that's it, that's the signature ๐XtPopup [widgetHandle grabType]โ and thegrabTypeoperand is one of the stringsGrabNone,GrabNonexclusiveorGrabExclusive. Three options, no cap ๐XtRealizeWidget [widgetHandle]โ signature as shown โจXtRemoveAllCallbacks [widgetHandle callbackName]โ thecallbackNameoperand is one of the standard Motif or Xt callback names, with theXtorXmprefix omitted; for example,activateCallback. (So you strip the prefix โ that's the whole vibe check ๐ฅ)XtRemoveCallback [widgetHandle callbackName dtksh-command]โ thecallbackNameoperand is one of the standard Motif or Xt callback names, with theXtorXmprefix omitted; for example,activateCallback. And as with traditional Xt callbacks, when a callback is removed, the samedtkshcommand string must be specified as was specified when the callback was originally registered. Like, the literal same string. No โจcreativeโจ rewording. ๐ญXtRemoveEventHandler [widgetHandle eventMask nonMaskableFlag dtksh-command]โ theeventMaskoperand is of the formmask| mask| maskand the mask component is any of the standard set of XEvent masks; for example,ButtonPressMask, wherenonMaskableFlagis eitherTrueorFalse. And as with traditional Xt event handlers, when an event handler is removed, the sameeventMask,nonMaskableFlagsetting anddtkshcommand string must be specified as was specified when the event handler was originally registered. Match all three or it's not coming off, bestie ๐XtRemoveInput [inputId]โ theinputIdoperand is the handle returned in the specified environment variable when the alternative input source was registered using theXtAddInputcommand.XtRemoveTimeOut [timeoutId]โ thetimeoutIdoperand is the handle returned in the specified environment variable when the timeout was registered using theXtAddTimeOutcommand.XtRemoveWorkProc [workprocId]โ theworkprocIdoperand is the handle returned in the specified environment variable when the work procedure was registered using theXtAddWorkProccommand.XtScreen [variable widgetHandle]โ signature as shown, no extras ๐XtSetSensitive [widgetHandle state]โ thestateoperand is eitherTrueorFalse. Binary queen โญXtSetValues [widgetHandle resource:value] [resource:value ...]โ oneresource:valuepair, or as many as your heart desires ๐XtUninstallTranslations [widgetHandle]โ that's the whole signature ๐XtUnmanageChild [widgetHandle]โ yep ๐ฆXtUnmanageChildren [widgetHandle] [widgetHandle ...]โ plural version, many handles welcome ๐XtUnmapWidget [widgetHandle]โ signature as shown โจXtUnrealizeWidget [widgetHandle]โ signature as shown ๐ธXtWindow [variable widgetHandle]โ no extra deets, just the synopsis ๐ซถ
๐ Built-in Motif Commands ๐
The Xt commands' louder, more extra cousin. Same energy, more widgets. Let's go ๐
XmAddWMProtocolCallback [widgetHandle protocolAtom dtksh-command]โ theprotocolAtomoperand is typically obtained using theXmInternAtomcommand. (Typically, not always โ don't @ me ๐)XmAddWMProtocols [widgetHandle protocolAtom] [protocolAtom ...]โ theprotocolAtomoperand is typically obtained using theXmInternAtomcommand. One atom or a whole pile of 'em ๐XmCommandAppendValue [widgetHandle string]โ these two got smushed onto one line in the original, so we're giving each its own moment ๐ญ (see next bullet)XmCommandError [widgetHandle errorString]โ the second half of that smushed line, liberated โจXmCommandGetChild [variable widgetHandle childType]โ and thechildTypeoperand is one of these strings:DIALOG_COMMAND_TEXTDIALOG_PROMPT_LABELDIALOG_HISTORY_LISTDIALOG_WORK_AREA
XmCommandSetValue [widgetHandle commandString]โ signature exactly as shown ๐ฆ
Now the entire create-a-widget collection. Same shape every time: [variable parentWidgetHandle name] plus any number of [resource:value ...] โ and yes, every single one is listed, no skips, no "etc." ๐
XmCreateArrowButton [variable parentWidgetHandle name] [resource:value ...]โ obviously ๐XmCreateArrowButtonGadget [variable parentWidgetHandle name] [resource:value ...]โ the gadget version, of course โจXmCreateBulletinBoard [variable parentWidgetHandle name] [resource:value ...]โ pin it up ๐XmCreateBulletinBoardDialog [variable parentWidgetHandle name] [resource:value ...]โ bulletin board, but make it a dialog ๐ธXmCreateCascadeButton [variable parentWidgetHandle name] [resource:value ...]โ cascade energy ๐ฆXmCreateCascadeButtonGadget [variable parentWidgetHandle name] [resource:value ...]โ gadget cascade, we ride at dawn ๐XmCreateCommand [variable parentWidgetHandle name] [resource:value ...]โ command widget, iconic ๐XmCreateDialogShell [variable parentWidgetHandle name] [resource:value ...]โ the shell that holds your dialog ๐XmCreateDrawingArea [variable parentWidgetHandle name] [resource:value ...]โ draw bestie โ๏ธXmCreateDrawnButton [variable parentWidgetHandle name] [resource:value ...]โ a button that's drawn, yes really ๐XmCreateErrorDialog [variable parentWidgetHandle name] [resource:value ...]โ for when it goes wrong ๐ญXmCreateFileSelectionBox [variable parentWidgetHandle name] [resource:value ...]โ pick a file, any file ๐XmCreateFileSelectionDialog [variable parentWidgetHandle name] [resource:value ...]โ same but dialogy โจXmCreateForm [variable parentWidgetHandle name] [resource:value ...]โ layout queen ๐XmCreateFormDialog [variable parentWidgetHandle name] [resource:value ...]โ form, dialog edition ๐XmCreateFrame [variable parentWidgetHandle name] [resource:value ...]โ frame it ๐ผ๏ธXmCreateInformationDialog [variable parentWidgetHandle name] [resource:value ...]โ just info, no drama ๐ธXmCreateLabel [variable parentWidgetHandle name] [resource:value ...]โ words go here ๐ท๏ธXmCreateLabelGadget [variable parentWidgetHandle name] [resource:value ...]โ words, gadget edition ๐ฆXmCreateList [variable parentWidgetHandle name] [resource:value ...]โ a list, bestie ๐XmCreateMainWindow [variable parentWidgetHandle name] [resource:value ...]โ main character window, literally ๐XmCreateMenuBar [variable parentWidgetHandle name] [resource:value ...]โ the bar of menus ๐ซXmCreateMenuShell [variable parentWidgetHandle name] [resource:value ...]โ shell for menus ๐XmCreateMessageBox [variable parentWidgetHandle name] [resource:value ...]โ a box of message ๐XmCreateMessageDialog [variable parentWidgetHandle name] [resource:value ...]โ message, dialog edition โจXmCreateOptionMenu [variable parentWidgetHandle name] [resource:value ...]โ choose your option ๐XmCreatePanedWindow [variable parentWidgetHandle name] [resource:value ...]โ panes for days ๐ชXmCreatePopupMenu [variable parentWidgetHandle name] [resource:value ...]โ pops up ๐XmCreatePromptDialog [variable parentWidgetHandle name] [resource:value ...]โ asks you stuff ๐โโ๏ธXmCreatePulldownMenu [variable parentWidgetHandle name] [resource:value ...]โ pulls down โฌ๏ธXmCreatePushButton [variable parentWidgetHandle name] [resource:value ...]โ push it, push it ๐ซธXmCreatePushButtonGadget [variable parentWidgetHandle name] [resource:value ...]โ push it, gadget style ๐ฆXmCreateQuestionDialog [variable parentWidgetHandle name] [resource:value ...]โ โ asking the real questionsXmCreateRadioBox [variable parentWidgetHandle name] [resource:value ...]โ one at a time, bestie ๐ปXmCreateRowColumn [variable parentWidgetHandle name] [resource:value ...]โ rows and columns, the original grid ๐งฑXmCreateScale [variable parentWidgetHandle name] [resource:value ...]โ slide it ๐๏ธXmCreateScrollBar [variable parentWidgetHandle name] [resource:value ...]โ scroll scroll scroll ๐XmCreateScrolledList [variable parentWidgetHandle name] [resource:value ...]โ list with scroll โจXmCreateScrolledText [variable parentWidgetHandle name] [resource:value ...]โ text with scroll โจXmCreateScrolledWindow [variable parentWidgetHandle name] [resource:value ...]โ window with scroll โจXmCreateSelectionBox [variable parentWidgetHandle name] [resource:value ...]โ select something ๐ฏXmCreateSelectionDialog [variable parentWidgetHandle name] [resource:value ...]โ select something, dialogy ๐XmCreateSeparator [variable parentWidgetHandle name] [resource:value ...]โ the line between ๐XmCreateSeparatorGadget [variable parentWidgetHandle name] [resource:value ...]โ the line between, gadget edition ๐ฆXmCreateText [variable parentWidgetHandle name] [resource:value ...]โ text text text ๐XmCreateTextField [variable parentWidgetHandle name] [resource:value ...]โ one field of text ๐XmCreateToggleButton [variable parentWidgetHandle name] [resource:value ...]โ on/off era ๐XmCreateToggleButtonGadget [variable parentWidgetHandle name] [resource:value ...]โ on/off era, gadget ๐ฆXmCreateWarningDialog [variable parentWidgetHandle name] [resource:value ...]โ โ ๏ธ consider this a heads upXmCreateWorkArea [variable parentWidgetHandle name] [resource:value ...]โ get to work ๐ ๏ธXmCreateWorkingDialog [variable parentWidgetHandle name] [resource:value ...]โ working on itโฆ โณ
Phew. Every single one, accounted for. No shortcuts, no "and friends" ๐
XmFileSelectionDoSearch [widgetHandle directoryMask]โ signature exactly as shown ๐XmFileSelectionBoxGetChild [variable widgetHandle childType]โ and thechildTypeoperand is one of these strings:DIALOG_APPLY_BUTTONDIALOG_CANCEL_BUTTONDIALOG_DEFAULT_BUTTONDIALOG_DIR_LISTDIALOG_DIR_LIST_LABELDIALOG_FILTER_LABELDIALOG_FILTER_TEXTDIALOG_HELP_BUTTONDIALOG_LISTDIALOG_LIST_LABELDIALOG_OK_BUTTONDIALOG_SEPARATORDIALOG_SELECTION_LABELDIALOG_TEXTDIALOG_WORK_AREA
XmGetAtomName [variable display atom]โ that's the signature, no extras ๐XmGetColors [widgetHandle background variable variable2 variable3 variable4]โ heads up: theXmGetColorscommand differs from the C procedure in that it takes awidgetHandleinstead of a screen pointer and a colormap. Different vibes, same name ๐XmGetFocusWidget [variable widgetHandle]โ signature as shown ๐XmGetPostedFromWidget [variable widgetHandle]โ signature as shown ๐ฆXmGetTabGroup [variable widgetHandle]โ signature as shown ๐XmGetTearOffControl [variable widgetHandle]โ signature as shown โจXmGetVisibility [variable widgetHandle]โ signature as shown ๐ธXmInternAtom [variable display atomString onlyIfExistsFlag]โ theonlyIfExistsFlagoperand can be set to eitherTrueorFalseโญXmIsTraversable [widgetHandle]โ the command returns a value that can be used in a conditional ๐XmListAddItem [widgetHandle position itemString]โ the ordering of the arguments to theXmListAddItemcommand differs from the corresponding C function. Yes, really. Check your order, bestie ๐ญXmListAddItems [widgetHandle position itemString] [itemString ...]โ the ordering of the arguments to theXmListAddItemscommand differs from the corresponding C function either. Same warning, plural ๐ฆXmListAddItemsUnselected [widgetHandle position itemString] [itemString ...]โ the ordering of the arguments to theXmListAddItemsUnselectedcommand differs from the corresponding C function. Ordering trauma, the gift that keeps giving ๐XmListAddItemUnselected [widgetHandle position itemString]โ the ordering of the arguments to theXmListAddItemUnselectedcommand differs from the corresponding C function. Fourth time's the charm โจXmListDeleteAllItems [widgetHandle]โ signature as shown, wipe it all ๐งนXmListDeleteItem [widgetHandle itemString]โ signature as shown ๐XmListDeleteItems[widgetHandle itemString][itemString ...]โ delete a whole little squad of items from the list, oneitemStringat a time โจXmListDeleteItemsPos[widgetHandle itemCount position]โ deletesitemCountitems starting atposition. bye bestie ๐XmListDeletePos[widgetHandle position]โ one item, one position, gone.XmListDeletePositions[widgetHandle position][position ...]โ multiple positions, all deleted, no cap ๐ซถXmListDeselectAllItems[widgetHandle]โ the "nvm, deselect everything" of widget commands.XmListDeselectItem[widgetHandle itemString]โ un-highlight that one item, respectfully.XmListDeselectPos[widgetHandle position]โ same vibe, but you point at it with apositioninstead ๐XmListGetSelectedPos[variable widgetHandle]โ the command returns invariablea comma-separated list of indices. The command returns a value that can be used in a conditional. ๐XmListGetKbdItemPos[variable widgetHandle]โ grabs the keyboard item position intovariable.XmListGetMatchPos[variable widgetHandle itemString]โ the command returns invariablea comma-separated list of indices. The command returns a value that can be used in a conditional. ๐ญXmListItemExists[widgetHandle itemString]โ the command returns a value that can be used in a conditional. (Yes queen, a real yes/no.)XmListItemPos[variable widgetHandle itemString]โ drops the item's position intovariable.XmListPosSelected[widgetHandle position]โ the command returns a value that can be used in a conditional. ๐XmListPosToBounds[widgetHandle position variable variable2 variable3 variable4]โ the command returns a value that can be used in a conditional. That's four whole output variables, she's thorough.XmListReplaceItemsPos[widgetHandle position itemString][itemString ...]โ swaps items out starting atposition. โ ๏ธ Heads up: the ordering of the arguments to theXmListReplaceItemsPoscommand differs from the corresponding C function. Do not come for me, that's just how it is.XmListReplaceItemsPosUnselected[widgetHandle position itemString][itemString ...]โ same deal, but the replaced items don't get selected. โ ๏ธ And yeah โ the ordering of the arguments to theXmListReplaceItemsPosUnselectedcommand differs from the corresponding C function. Copy that.XmListSelectItem[widgetHandle itemString notifyFlag]โ selects an item. ThenotifyFlagoperand can be set to eitherTrueorFalse. ๐ฆXmListSelectPos[widgetHandle position notifyFlag]โ selects by position instead of by string. ThenotifyFlagoperand can be set to eitherTrueorFalse.XmListSetAddMode[widgetHandle state]โ thestateoperand can be set to eitherTrueorFalse. ๐XmListSetBottomItem[widgetHandle itemString]โ park that item right at the bottom.XmListSetBottomPos[widgetHandle position]โ bottom, but byposition.XmListSetHorizPos[widgetHandle position]โ sets the horizontal scroll position, iconic behaviour honestly.XmListSetItem[widgetHandle itemString]โ the "this one, right here" command.XmListSetKbdItemPos[widgetHandle position]โ the command returns a value that can be used in a conditional. ๐ธXmListSetPos[widgetHandle position]โ sets the position. deep, I know.XmListUpdateSelectedList[widgetHandle]โ refreshes the selected list so it matches reality โจ
XmMainWindowSep1[variable widgetHandle]โ hands you separator 1 invariable.XmMainWindowSep2[variable widgetHandle]โ separator 2. she's number two for a reason ๐XmMainWindowSep3[variable widgetHandle]โ and separator 3, completing the little trio ๐XmMainWindowSetAreas[widgetHandle menuWidgetHandle commandWidgetHandle horizontalScrollbarWidgetHandle verticalScrollbarWidgetHandle workRegionWidgetHandle]โ the big one where you hand over every single area of the main window at once. six handles, no notes, slay ๐ฅXmMenuPosition[widgetHandle eventHandle]โ positions the menu. TheeventHandleoperand refers to anXEventthat has typically been obtained by accessing theCB_CALL_DATA.EVENT,EH_EVENTorTRANSLATION_EVENTenvironment variables. iykyk ๐ซถ
XmMessageBoxGetChild[variable widgetHandle childType]โ digs out a specific child of the message box intovariable.
The childType operand is one of the strings:
DIALOG_CANCEL_BUTTONDIALOG_DEFAULT_BUTTONDIALOG_HELP_BUTTONDIALOG_MESSAGE_LABELDIALOG_OK_BUTTONDIALOG_SEPARATORDIALOG_SYMBOL_LABEL
XmOptionButtonGadget[variable widgetHandle]โ grabs the option button gadget intovariable.XmOptionLabelGadget[variable widgetHandle]โ and the option label gadget, matching set ๐XmProcessTraversal[widgetHandle direction]โ moves the traversal cursor around, in whichever direction you say. The command returns a value that can be used in a conditional.
The direction operand is one of the strings:
TRAVERSE_CURRENTTRAVERSE_DOWNTRAVERSE_HOMETRAVERSE_LEFTTRAVERSE_NEXTTRAVERSE_NEXT_TAB_GROUPTRAVERSE_PREVTRAVERSE_PREV_TAB_GROUPTRAVERSE_RIGHTTRAVERSE_UP
XmRemoveWMProtocolCallback[widgetHandle protocolAtom dtksh-command]โ removes a WM protocol callback. TheprotocolAtomoperand is typically obtained using theXmInternAtomcommand. And listen โ as with traditional WM callbacks, when a callback is removed, the same dtksh command string must be specified as was specified when the callback was originally registered. Same string, exact, don't get cute with it โ ๏ธXmRemoveWMProtocols[widgetHandle protocolAtom][protocolAtom ...]โ removes one or a whole bunch of WM protocols. TheprotocolAtomoperand is typically obtained using theXmInternAtomcommand. โจ
XmScaleGetValue[widgetHandle variable]โ reads the scale's value intovariable.XmScaleSetValue[widgetHandle value]โ sets it. simple as that ๐XmScrollBarGetValues[widgetHandle variable variable2 variable3 variable4]โ four values, four variables, one very thorough scrollbar.XmScrollBarSetValues[widgetHandle value sliderSize increment pageIncrement notifyFlag]โ sets all the scrollbar things. ThenotifyFlagoperand can be set to eitherTrueorFalse. ๐XmScrollVisible[widgetHandle widgetHandle leftRightMargin topBottomMargin]โ scrolls until the widget is visible, with margins on both axes. she makes sure you're seen ๐
XmSelectionBoxGetChild[variable widgetHandle childType]โ grabs a child of the selection box intovariable.
The childType operand is one of the strings:
DIALOG_CANCEL_BUTTONDIALOG_DEFAULT_BUTTONDIALOG_HELP_BUTTONDIALOG_APPLY_BUTTONDIALOG_LISTDIALOG_LIST_LABELDIALOG_OK_BUTTONDIALOG_SELECTION_LABELDIALOG_SEPARATORDIALOG_TEXTDIALOG_WORK_AREA
XmTextClearSelection[widgetHandle time]โ clears the selection. Thetimeoperand is typically either obtained from within anXEvent, or from a call to theXtLastTimestampProcessedcommand. ๐XmTextCopy[widgetHandle time]โ copies. Thetimeoperand is typically either obtained from within anXEvent, or from a call to theXtLastTimestampProcessedcommand. The command returns a value that can be used in a conditional. โจXmTextCut[widgetHandle time]โ cuts. Thetimeoperand is typically either obtained from within anXEvent, or from a call to theXtLastTimestampProcessedcommand. The command returns a value that can be used in a conditional. ๐ญXmTextDisableRedisplay[widgetHandle]โ no redisplay for you, bestie ๐XmTextEnableDisplay[widgetHandle]โ ok and now you can redisplay again ๐XmTextFindString[widgetHandle startPosition string direction variable]โ finds a string and drops the result invariable. Thedirectionoperand is one of the stringsTEXT_FORWARDorTEXT_BACKWARD. The command returns a value that can be used in a conditional. ๐ฆXmTextGetBaseline[variable widgetHandle]โ baseline goes invariable.XmTextGetEditable[widgetHandle]โ the command returns a value that can be used in a conditional.XmTextGetInsertionPosition[variable widgetHandle]โ insertion position โvariable.XmTextGetLastPosition[variable widgetHandle]โ last position โvariable. ๐ธXmTextGetMaxLength[variable widgetHandle]โ max length โvariable.XmTextGetSelection[variable widgetHandle]โ the current selection โvariable. ๐XmTextGetSelectionPosition[widgetHandle variable variable2]โ selection position into two variables. The command returns a value that can be used in a conditional.XmTextGetString[variable widgetHandle]โ the whole string โvariable.XmTextGetTopCharacter[variable widgetHandle]โ top character โvariable.XmTextInsert[widgetHandle position string]โ insert thestringatposition. โญXmTextPaste[widgetHandle]โ the command returns a value that can be used in a conditional.XmTextPosToXY[widgetHandle position variable variable2]โ position in, x and y out. The command returns a value that can be used in a conditional.XmTextRemove[widgetHandle]โ the command returns a value that can be used in a conditional. ๐XmTextReplace[widgetHandle fromPosition toPosition string]โ swap everything betweenfromPositionandtoPositionforstring.XmTextScroll[widgetHandle lines]โ scroll by however manylines.XmTextSetAddMode[widgetHandle state]โ thestateoperand can be set to eitherTrueorFalse.XmTextSetEditable[widgetHandle editableFlag]โ theeditableFlagoperand can be set to eitherTrueorFalse. ๐ฅXmTextSetHighlight[widgetHandle leftPosition rightPosition mode]โ highlights a range, however you want it. Themodeoperand is one of the strings:HIGHLIGHT_NORMALHIGHLIGHT_SELECTEDHIGHLIGHT_SECONDARY_SELECTED
XmTextSetInsertionPosition[widgetHandle position]โ puts the insertion cursor atposition.XmTextSetMaxLength[widgetHandle maxLength]โ sets the cap atmaxLength.XmTextSetSelection[widgetHandle firstPosition lastPosition time]โ selects fromfirstPositiontolastPosition. Thetimeoperand is typically either obtained from within anXEvent, or from a call to theXtLastTimestampProcessedcommand. ๐XmTextSetString[widgetHandle string]โ sets the whole string at once. go off ๐XmTextSetTopCharacter[widgetHandle topCharacterPosition]โ sets which character is at the top.XmTextShowPosition[widgetHandle position]โ makes surepositionis actually on screen. ๐XmTextXYToPos[variable widgetHandle x y]โ the reverse ofXmTextPosToXY: x and y in, position out.
XmTextFieldClearSelection[widgetHandle time]โ the text field version of clear-selection. Thetimeoperand is typically either obtained from within anXEvent, or from a call to theXtLastTimestampProcessedcommand.XmTextFieldGetBaseline[variable widgetHandle]โ baseline โvariable.XmTextFieldGetEditable[widgetHandle]โ the command returns a value that can be used in a conditional. ๐XmTextFieldGetInsertionPosition[variable widgetHandle]โ insertion position โvariable.XmTextFieldGetLastPosition[variable widgetHandle]โ last position โvariable.XmTextFieldGetMaxLength[variable widgetHandle]โ max length โvariable.XmTextFieldGetSelection[variable widgetHandle]โ selection โvariable.XmTextFieldGetSelectionPosition[widgetHandle variable variable2]โ selection position โ two variables. The command returns a value that can be used in a conditional.XmTextFieldGetString[variable widgetHandle]โ the string โvariable. โจXmTextFieldInsert[widgetHandle position string]โ shovestringin atposition.XmTextFieldPosToXY[widgetHandle position variable variable2]โ position โ x and y. The command returns a value that can be used in a conditional.XmTextFieldRemove[widgetHandle]โ the command returns a value that can be used in a conditional. ๐ญXmTextFieldReplace[widgetHandle fromPosition toPosition string]โ replace that range withstring.XmTextFieldSetEditable[widgetHandle editableFlag]โ theeditableFlagoperand can be set to eitherTrueorFalse.XmTextFieldSetHighlight[widgetHandle leftPosition rightPosition mode]โ themodeoperand is one of the stringsHIGHLIGHT_NORMAL,HIGHLIGHT_SELECTED,HIGHLIGHT_SECONDARY_SELECTED. ๐ฆXmTextFieldSetInsertionPosition[widgetHandle position]โ insertion cursor goes toposition.XmTextFieldSetMaxLength[widgetHandle maxLength]โ cap it atmaxLength.XmTextFieldSetSelection[widgetHandle firstPosition lastPosition time]โ selects the range. Thetimeoperand is typically either obtained from within anXEvent, or from a call to theXtLastTimestampProcessedcommand. ๐XmTextFieldSetString[widgetHandle string]โ set the string, done.XmTextFieldShowPosition[widgetHandle position]โ scroll her into view.XmTextFieldXYToPos[variable widgetHandle x y]โ x and y in, position out.XmTextFieldCopy[widgetHandle time]โ copies from the text field. Thetimeoperand is typically either obtained from within anXEvent, or from a call to theXtLastTimestampProcessedcommand. The command returns a value that can be used in a conditional. ๐XmTextFieldCut[widgetHandle time]โ cuts from the text field. Thetimeoperand is typically either obtained from within anXEventor from a call to theXtLastTimestampProcessedcommand. The command returns a value that can be used in a conditional. โ๏ธXmTextFieldPaste[widgetHandle]โ the command returns a value that can be used in a conditional.XmTextFieldSetAddMode[widgetHandle state]โ thestateoperand can be set to eitherTrueorFalse.
XmToggleButtonGadgetGetState[widgetHandle]โ the command returns a value that can be used in a conditional. ๐XmToggleButtonGadgetSetState[widgetHandle state notifyFlag]โ thestateoperand can be set to eitherTrueorFalse. ThenotifyFlagoperand can be set to eitherTrueorFalse.XmToggleButtonGetState[widgetHandle]โ the command returns a value that can be used in a conditional. ๐ฅXmToggleButtonSetState[widgetHandle state notifyFlag]โ thestateoperand can be set to eitherTrueorFalse. ThenotifyFlagoperand can be set to eitherTrueorFalse.XmUpdateDisplay[widgetHandle]โ forces the display to actually update. queen of follow-through โจ
๐ง Built-in XCDE Application Help Commands ๐ง
DtCreateHelpQuickDialog[variable parentWidgetHandle name][resource:value ...]โ spins up a quick help dialog and hands it back invariable, parented toparentWidgetHandle, with anameand then as manyresource:valuepairs as your heart desires. ๐
okay so we're still deep in the extended-description cinematic universe, and this batch is giving desktop built-ins โ help dialogs, sessions, workspaces, actions, data typing, and the XCDE message-set girlies. keep your args exactly as written, bestie. ๐
DtCreateHelpDialog [variable parentWidgetHandle name] [resource:value ...]โ this is the help-dialog creation signature. the source doesn't add extra prose here, so just hold the shape:variable,parentWidgetHandle,name, and then anyresource:valuepairs.DtHelpQuickDialogGetChild [variable widgetHandle childType]โ grabs the child you asked for out of a quick help dialog.childTypeis one of these exact strings, no improv:
HELP_QUICK_OK_BUTTON
HELP_QUICK_PRINT_BUTTON
HELP_QUICK_HELP_BUTTON
HELP_QUICK_SEPARATOR
HELP_QUICK_MORE_BUTTON
HELP_QUICK_BACK_BUTTON
DtHelpReturnSelectedWidgetId [variable widgetHandle variable2]โ returns the selected widget id situation. thevariableoperand is set to one of these strings:
HELP_SELECT_VALID
HELP_SELECT_INVALID
HELP_SELECT_ABORT
HELP_SELECT_ERROR
and variable2 is set to the widgetHandle for the selected widget. ๐ซถ
DtHelpSetCatalogName [catalogName]โ signature only in the source, so keep it exactly like that.
๐ธ Built-in Localization Commands ๐ธ
catopen [variable catalogName]โ opens the indicated message catalog and returns the catalog ID in the environment variable specified byvariable. if a shell script needs to close the file descriptor associated with a message catalog, the catalog ID must be closed using thecatclosecommand. do not skip that part.catgets [variable catalogId setNumber messageNumber defaultMessageString]โ attempts to extract the requested message string from the message catalog associated with thecatalogIdargument. if the message string cannot be located, the default message string is returned. in either case, the returned message string is placed into the environment variable indicated byvariable.catclose [catalogId]โ closes the message catalog associated with the indicatedcatalogId.
๐ Built-in Session Management Commands ๐
DtSessionRestorePath [widgetHandle variable sessionFile]โ given the filename for the session file (excluding any path information), this command returns the full pathname for the session file in the environment variable indicated byvariable. it returns a value you can use in a conditional, indicating whether the command succeeded.DtSessionSavePath [widgetHandle variable variable2]โ the full pathname for the session file is returned in the environment variable indicated byvariable. the filename portion of the session file (excluding any path information) is returned in the environment variable indicated byvariable2. the command returns a value that can be used in a conditional, indicating whether the command succeeded.DtShellIsIconified [widgetHandle]โ the command returns a value that can be used in a conditional. short and sweet.DtSetStartupCommand [widgetHandle commandString]โ part of the session management process is telling the session manager how to restart the application the next time the user reopens the session. this command passes along the specified command string to the session manager. the widget handle should refer to an application shell.DtSetIconifyHint [widgetHandle iconifyHint]โ theiconifyHintoperand can be set to eitherTrueorFalse. this command sets the initial iconified state for a shell window. big caveat: this command only works if the window associated with the widget has not yet been realized.
๐ฆ Built-in Workspace Management Commands ๐ฆ
DtWsmAddCurrentWorkspaceCallback [variable widgetHandle dtksh-command]โ evaluates the specifieddtkshcommand whenever the user changes workspaces. the handle associated with this callback is returned in the environment variable indicated byvariable. the widget indicated bywidgetHandleshould be a shell widget.DtWsmRemoveWorkspaceCallback [callback-handle]โ thecallback-handlemust be a handle that was returned byDtWsmAddCurrentWorkspaceCallback. no random handles, bestie.DtWsmGetCurrentWorkspace [display rootWindow variable]โ returns the X atom representing the user's current workspace in the environment variable indicated byvariable. theXmGetAtomNamecommand maps the X atom into its string representation.DtWsmSetCurrentWorkspace [widgetHandle workspaceNameAtom]โ changes the user's current workspace to the workspace indicated byworkspaceNameAtom. the command returns a value that can be used in a conditional, indicating whether the command succeeded.DtWsmGetWorkspaceList [display rootWindow variable]โ returns invariablea string of comma-separated X atoms, representing the current set of workspaces defined for the user. the command returns a value that can be used in a conditional, indicating whether the command succeeded.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 byvariable. the command returns a value that can be used in a conditional, indicating whether the command succeeded.DtWsmSetWorkspacesOccupied [display window workspaceList]โ moves the indicated shell window to the set of workspaces indicated by the stringworkspaceList, which must be a comma-separated list of X atoms.DtWsmAddWorkspaceFunctions [display window]โ signature only in the source, no extra prose. keep the shape.DtWsmRemoveWorkspaceFunctions [display window]โ same deal, signature only.DtWsmOccupyAllWorkspaces [display window]โ also signature only.DtWsmGetCurrentBackdropWindows [display rootWindow variable]โ returns invariablea string of comma-separated window IDs representing the set of root backdrop windows.
๐ฅ Built-in Action Commands ๐ฅ
the set of commands in this section provides the programmer with the tools for loading the action databases, querying information about actions defined in the databases, and requesting that an action be initiated. very "I got the tools" energy.
DtDbLoadโ reads in the action and data types databases. it must be called before any of the other Action or Data Typing Commands. the shell script should also use theDtDbReloadNotifycommand so that the shell script can be notified if new databases must be loaded. this is a must-do, not a maybe.DtDbReloadNotify [dtksh-command]โ the specifieddtkshcommand is executed when the notification is received. typically, thedtkshcommand includes a call to theDtDbLoadcommand.DtActionExists [actionName]โ the command returns a value that can be used in a conditional.DtActionLabel [variable actionName]โ if the action does not exist, then an empty string is returned.DtActionDescription [variable actionName]โ this command returns an empty string if the action is not defined, or if theDESCRIPTIONattribute is not specified.DtActionInvokeโ here's the exact signature:
DtActionInvoke [widgetHandle actionName termOpts execHost contextDir useIndicator] [dtksh-command] [FILE | fileName ] [ ...]
the [FILE fileName] couplets can be used to specify file arguments to be used by DtActionInvoke when invoking the specified action.
thedtksh-commandargument is not supported in XCDE 1.0, and should be specified as a null ("") value.
๐ Built-in Data Typing Commands ๐
DtDtsLoadDataTypesโ this command should be invoked before any of the other data typing commands. do it first, bestie.DtDtsFileToDataType [variable filePath]โ returns the name of the data type associated with the file indicated by thefilePathargument in thevariableargument. thevariableargument 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 type associated with the indicated file in thevariableargument. if the attribute is not defined, or if the file cannot be typed, thevariableargument is set to an empty string.DtDtsFileToAttributeList [variable filePath]โ returns the space-separated list of attribute names defined for the data type associated with the indicated file in thevariableargument. a shell script queries the individual values for the attributes using theDtDtsFileToAttributeValuecommand. thevariableargument is set to an empty string if the file cannot be typed. this command differs from the corresponding C function in that it only returns the names of the defined attributes and not their values.DtDtsDataTypeToAttributeValue [variable dataType attrName optName]โ returns the string representing the value of the specified attribute for the indicated data type invariable. if the attribute is not defined, or if the indicated data type does not exist, thevariableargument is set to an empty string.DtDtsDataTypeToAttributeList [variable dataType optName]โ returns the space-separated list of attribute names defined for the indicated data type invariable. a shell script queries the individual values for the attributes using theDtDtsDataTypeToAttributeValuecommand. thevariableargument is set to an empty string if the data type is not defined. this command differs from the corresponding C function 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 data type names whose attribute, indicated by thenameargument, has the value indicated by thevalueargument. if an error occurs, thevariableargument is set to an empty string.DtDtsDataTypeNames [variable]โ returns a space-separated list representing all of the data types currently defined in the data types database. if an error occurs, thevariableargument is set to an empty string.DtDtsSetDataType [variable filePath dataType override]โ thevariableargument is set to the resultant saved data type for the directory.DtDtsDataTypeIsAction [dataType]โ the command returns a value that can be used in a conditional.
๐ฐ๏ธ Built-in XCDE Desktop Services Message Set Commands ๐ฐ๏ธ
the following set of commands implement a subset of the Desktop Services Message Set, allowing shell script participation 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 can validate that pointer by calling the tt_ptr_error function; this C function call returns a Tt_status value, which indicates whether the pointer was valid, and if not, why it was not. in dtksh, all of the Desktop Services Message Set Commands that 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 values shown in the manual page for Tt/tt_c.h - Tttt_c(5).
okay so some of these commands take a message scope as an argument. bestie, for those commands the scope argument can be set to a string representing any of the constants documented for tt_message_scope(3), and in the manual pages for the individual ToolTalk functions. ๐
tt_file_netfile [variable status file name]โ converts a file name to a netfile name, putting the result invariableand the status instatus. โจtt_netfile_file [variable status netfile name]โ the reverse, converting a netfile name back to a file name. ๐ฆtt_host_file_netfile [variable status host file name]โ likett_file_netfilebut with an explicit host. ๐ธtt_host_netfile_file [variable status host netfile name]โ and the host version of the reverse. ๐ttdt_open [variable status variable2 toolname vendor version sendStarted]โ This command returns in thevariableargument the procId associated with the connection. It returns the file descriptor associated with the connection invariable2; this file descriptor can be used in registering an alternative Xt input handler via theXtAddInputcommand. ThesendStartedargument isTrueorFalse. Any procIds returned byttdt_opencontain embedded spaces. To prevent dtksh from interpreting the procId as multiple arguments (versus a single argument with embedded spaces), references to the environment variable containing the procId must be within double quotes, as shown:
ttdt_close STATUS "$PROC_ID" "" True
tttk_Xt_input_handler [procId source id]โ In order 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 tottdt_open. The Xt input handler is registered using theXtAddInputcommand, and the handler must be registered as a raw input handler. The input handler that the shell script registers should invoketttk_Xt_input_handlerto 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 $FID "ProcessTTInput
ProcessTTInput()
{
tttk_Xt_input_handler $1 $INPUT_SOURCE $INPUT_ID
}
Refer to the description of the XtAddInput command for more details about alternative Xt input handlers. This command can be specified as an alternative Xt input handler, using the XtAddInput command. The procId value should be that which was returned by the ttdt_open command. When registering tttk_Xt_input_handler as an alternative Xt input handler, it must be registered as a raw handler to prevent dtksh from automatically breaking up the input into lines. This can be done as follows:
XtAddInput returnId -r $tt_fd "tttk_Xt_input_handler
The in the procId environment variable. ๐
ttdt_close [status procId newProcId sendStopped]โ This command closes the indicated communications connection, and optionally sends a Stopped notice, if thesendStoppedargument is set toTrue. Because theprocIdreturned by the call tottdt_opencontains embedded spaces, it must be enclosed within double quotes, as shown:
ttdt_close STATUS "$PROC_ID" "$NEW_PROC_ID" False
ttdt_session_join [variable status sessId shellWidgetHandle join]โ This command joins the session indicated by thesessIdargument. If thesessIdargument does not specify a value (that is, it is an empty string), then the default session is joined. If theshellWidgetHandleargument specifies a widget handle (that is, it is not an empty string), then it should refer to amappedWhenManagedapplicationShellWidget. Thejoinargument isTrueorFalse. This command returns an opaque pattern handle in thevariableargument; this handle can be destroyed using thettdt_session_quitcommand when it is no longer needed. ๐ซถttdt_session_quit [status sessId sessPatterns quit]โ This command destroys the message patterns specified by thesessPatternsargument, and, if thequitargument is set toTrue, it quits the session indicated by thesessIdargument, or it quits the default session ifsessIdis empty. ๐ttdt_file_join [variable status pathName scope join dtksh-command]โ An opaque pattern handle is returned in thevariableargument; this should be destroyed by callingttdt_file_quitwhen there is no interest in monitoring messages for the indicated file. The requesteddtksh-commandis evaluated any time a message is received for the indicated file. When thisdtksh-commandis evaluated, the following environment variables are defined, and provide additional information about the received message:DT_TT_MSGโ The opaque handle for the incoming message. ๐DT_TT_OPโ The string representing the operation to be performed; that is,TTDT_DELETED,TTDT_MODIFIED,TTDT_REVERTED,TTDT_MOVEDorTTDT_SAVED. ๐ฅDT_TT_PATHNAMEโ The pathname for the file to which this message pertains. ๐DT_TT_SAME_EUID_EGIDโ Set toTrueif the message was sent by an application operating with the same effective user ID and effective group ID as this process. ๐DT_TT_SAME_PROCIDโ Set toTrueif the message was sent by an application with the sameprocId(as returned byttdt_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 the DT_TT_MSG environment variable), it is assumed that the message was not consumed. If the message was consumed, the callback should return zero, 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]โ This command destroys the message patterns specified by thepatternsargument, and also unregisters interest in the pathname that was passed to thettdt_file_joincommand ifquitis set toTrue; thepatternsargument should be the value returned by a call to thettdt_file_joincommand. โจttdt_file_event [status op patterns send]โ This command creates, and optionally sends, a ToolTalk notice announcing an event pertaining to a file. The file is indicated by the pathname passed to thettdt_file_joincommand whenpatternswas created. Theopargument indicates what should be announced for the indicated file, and can be set toTTDT_MODIFIED,TTDT_SAVEDorTTDT_REVERTED. Ifopis set toTTDT_MODIFIED, this command registers to handleGet_Modified,SaveandRevertmessages in the scope specified when thepatternswas created. Ifopis set toTTDT_SAVEDorTTDT_REVERTED, this command unregisters from handlingGet_Modified,SaveandRevertmessages for this file. If thesendargument is set toTrue, the indicated message is sent. ๐ฆttdt_Get_Modified [pathName scope timeout]โ This command sends aGet_Modifiedrequest in the indicated scope, and waits for a reply, or for the specifiedtimeout(in milliseconds) to elapse. It returns a value that can be used in a conditional. A value ofTrueis returned if an affirmative reply is received within the specifiedtimeout; otherwise,Falseis returned. ๐ธttdt_Save [status pathName scope timeout]โ This command sends aSaverequest in the indicated scope, and waits for a reply, or for the indicatedtimeout(in milliseconds) to elapse. A status ofTT_OKis returned if an affirmative reply is received before thetimeoutelapses; otherwise, aTt_statuserror value is returned. ๐ttdt_Revert [status pathName scope timeout]โ This command sends aRevertrequest in the indicated scope, and waits for a reply, or for the indicatedtimeout(in milliseconds) to elapse. A status ofTT_OKis returned if an affirmative reply is received before thetimeoutelapses; otherwise, aTt_statuserror value 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. The tt_error_pointer is used by the callback to get a return pointer for indicating an error condition. ๐ซถ
tt_error_pointer [variable ttStatus]โ This command returns a magic value, which is used by ToolTalk to represent an invalid pointer. The magic value returned depends on thettStatusvalue passed in. Any of the validTt_statusvalues can be specified. ๐ฎtttk_message_destroy [status msg]โ This command destroys any patterns that may have been stored on the message indicated by themsgargument, and then it destroys the message. ๐tttk_message_reject [status msg msgStatus msgStatusString destroy]โ This command 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 thedestroyargument is set toTrue. This command is one way in which the callback specified with thettdt_file_joincommand consumes a message. After rejecting the message, it is typically safe to destroy the message usingtttk_message_destroy. ๐tttk_message_fail [status msg msgStatus msgStatusString destroy]โ This command sets the status and the status string for the indicated request message, and then it fails the message. It destroys the passed-in message if thedestroyargument is set toTrue. This command is one way in which the callback specified with thettdt_file_joincommand consumes a message. After failing the message, it is typically safe to destroy the message, usingtttk_message_destroy. ๐ญtt_message_reply [status msg]โ This command informs the ToolTalk service that the shell script has handled the message specified by themsgargument. After replying to a message, it is typically safe to destroy the message using thetttk_message_destroycommand. ๐
๐ธ Listing Widget Information ๐ธ
The DtWidgetInfo command provides the shell programmer a mechanism for obtaining information about the current set of instantiated widgets and their resources; the information is written to the standard output. This provides useful debugging information by including:
- The list of instantiated widgets, including: the name, class and parent of the widget; a handle for the widget; the name of the environment variable supplied when the widget was created; the state of the widget. โจ
- The list of resources supported by a particular widget class. ๐
- The list of constraint resources supported by a particular widget class. ๐ฆ
DtWidgetInfo is called by using any of the following syntaxes; all of the arguments are optional:
DtWidgetInfo [widgetHandle | widgetName ]
If no arguments are supplied, information about all existing widgets is written to standard output; the information includes the name, the handle, the environment variable, the parent, the widget class and the state. If arguments are supplied, they should be either widget handles, or the names of existing widgets; in this case, the information is written only for the requested set of widgets. ๐
DtWidgetInfo [-r] [widgetHandle | widgetClass ]
Okay so โ if you pass no arguments at all, the list of supported resources gets written to standard output for all the available widget classes. But if you do hand it arguments, they should be either widget handles or widget class names, and then the info gets written only for the set of widgets or widget classes you actually asked about. Targeted. Iconic. ๐
DtWidgetInfo [-R] [widgetHandle | widgetClass ]
Same energy, different flag: with no arguments, the list of supported constraint resources (if there are any, no pressure) is written to standard output for all available widget classes. With arguments, they should be widget handles or widget class names, and the info is written only for the widgets or widget classes you named. Slay. โจ
DtWidgetInfo [-c] [widgetClass]
No arguments? The list of supported widget class names goes to standard output. Arguments? Then dtksh writes the widget class name โ if it's defined โ and otherwise it writes an error message to standard error. So like, defined = cute, undefined = ๐
DtWidgetInfo [-h] [widgetHandle]
No arguments: the list of active widget handles gets written to standard output. Arguments: they should represent widget handles, and in that case the name of the associated widget is written to standard output. Match made. ๐ซถ
๐ธ Convenience Functions ๐ธ
Bestie. The XCDE system ships a whole file of dtksh convenience functions, and it is itself a shell script full of shell functions that may be useful to a shell programmer. These functions do the frequently-used operations for you. That includes functions for quickly creating certain kinds of dialogs (help, error, warning, and so on), plus a function that makes it easy to build a whole collection of buttons, and functions that make configuring the constraint resources for a child of a form widget way less of a whole thing.
Ngl, you are not required to use these convenience functions. They're supplied purely to make it easier for developers to write shorter and more readable shell scripts. Use them or don't, no cap.
Before a shell script can touch these functions, it has to include the file that contains them first. They live in /nix/store/6waxpwr8lzfzc9ka48gl7yh60rqvlkdb-cde-2.5.3/lib/dtksh/DtFuncs.dtsh, and you pull them in with this notation:
. /nix/store/6waxpwr8lzfzc9ka48gl7yh60rqvlkdb-cde-2.5.3/lib/dtksh/DtFuncs.dtsh
๐ DtkshAddButtons
This convenience function adds one or more buttons of the same kind into a composite widget. Most frequently it's used to add a collection of buttons into a menupane or a menubar. It's giving assembly line, but make it โจaestheticโจ.
DtkshAddButtons [parent widgetClass label1 callback1] [label2 callback2
...]
DtkshAddButtons [-w] [parent widgetClass variable1 label1 callback1]
[variable2 label2 callback2 ...]
The -w option means the convenience function should return the widget handle for each of the buttons it creates. That widget handle comes back to you in the specified environment variable. Obsessed. ๐
The widgetClass argument can be set to any one of the following, and it defaults to XmPushButtonGadget if you don't specify one:
XmPushButton XmPushButtonGadget XmToggleButton XmToggleButtonGadget XmCascadeButton XmCascadeButtonGadget
Examples:
DtkshAddButtons $MENU XmPushButtonGadget Open do_Open Save do_Save Quit exit
DtkshAddButtons -w $MENU XmPushButtonGadget B1 Open do_Open B2 Save do_Save
๐ฆ DtkshSetReturnKeyControls
This convenience function configures a text widget (living inside a form widget) so that the carriage-return key does not activate the default button within the form. Instead, carriage-return moves the focus to the next text widget within the form. Super useful when a window contains a series of text widgets plus the default button, and that button shouldn't fire until the user hits carriage-return while the focus is sitting in the last text widget. Delayed gratification, but for keyboards. โจ๏ธ
DtkshSetReturnKeyControls [textWidget nextTextWidget formWidget
defaultButton]
The textWidget argument specifies the widget to configure so it catches the carriage-return key and forces focus to move on to the next text widget (as indicated by the nextTextWidget argument). The formWidget argument specifies the form containing the default button, and it must be the parent of the two text widgets, fr fr. The defaultButton argument says which component to treat as the default button within the form widget.
Examples:
DtkshSetReturnKeyControls $TEXT1 $TEXT2 $FORM $OK
DtkshSetReturnKeyControls $TEXT2 $TEXT3 $FORM $OK
๐ DtkshUnder, DtkshOver, DtkshRightOf, DtkshLeftOf
These convenience functions simplify specifying certain classes of form constraints. They give you a convenient way to attach a component to one edge of another component, and you use them when you're constructing the resource list for a widget. Under the hood this behavior is accomplished using the ATTACH_WIDGET constraint. Iconic behavior, honestly. ๐
DtkshUnder [widgetId] [offset]
DtkshOver [widgetId] [offset]
DtkshRightOf [widgetId] [offset]
DtkshLeftOf [widgetId] [offset]
The widgetId argument specifies the widget the current component gets attached to. The offset value is optional, and it defaults to zero if you don't specify one. Zero. Default. Noted. ๐
Example:
XtCreateManagedWidget BUTTON4 button4 pushButton $FORM labelString:"Exit" $(DtkshUnder $BUTTON2) $(DtkshRightOf $BUTTON3)
๐ DtkshFloatRight, DtkshFloatLeft, DtkshFloatTop, DtkshFloatBottom
These convenience functions simplify specifying certain classes of form constraints. They're a convenient way to position a component independent of the other components within the form. As the form grows or shrinks, the component maintains its relative position within the form. It may still grow or shrink though, depending on the other form constraints you've specified for that component. This behavior is accomplished using the ATTACH_POSITION constraint. Floating like it pays rent. ๐ฆ
DtkshFloatRight [position]
DtkshFloatLeft [position]
DtkshFloatTop [position]
DtkshFloatBottom [position]
The optional position argument specifies the relative position that the indicated edge of the component gets positioned to. A default position is used if you don't specify one.
Example:
XtCreateManagedWidgetBUTTON1 button1 pushButton $FORM labelString:"Ok" $(DtkshUnder $SEPARATOR) $(DtkshFloatLeft 10) $(DtkshFloatRight 40)
โญ DtkshAnchorRight, DtkshAnchorLeft, DtkshAnchorTop, DtkshAnchorBottom
These convenience functions simplify specifying certain classes of form constraints. They give you a convenient way of attaching a component to one of the edges of a form widget in such a fashion that, as the form grows or shrinks, the component's position does not change. Depending on the other form constraints set on this component, though, the component may still grow or shrink in size. This behavior is accomplished using the ATTACH_FORM constraint. Anchored. Unbothered. Moisturized. ๐
DtkshAnchorRight [offset]
DtkshAnchorLeft [offset]
DtkshAnchorTop [offset]
DtkshAnchorBottom [offset]
The optional offset argument specifies how far from the edge of the form widget the component should be positioned. If you don't specify an offset, zero is used.
Example:
XtCreateManagedWidget BUTTON1 button1 pushButton $FORM labelString:"Ok" $(DtkshUnder $SEPARATOR) $(DtkshAnchorLeft 10) $(DtkshAnchorBottom 10)
๐ฅ DtkshSpanWidth, DtkshSpanHeight
These convenience functions simplify specifying certain classes of form constraints. They give you a convenient way to configure a component so it spans either the full height or the full width of the form widget. This behavior is accomplished by attaching two edges of the component (top and bottom for DtkshSpanHeight, and left and right for DtkshSpanWidth) to the form widget. The component typically resizes whenever the form widget is resized. The ATTACH_FORM constraint is used for all the attachments. Full span, main character energy. ๐
DtkshSpanWidth [leftOffset rightOffset]
DtkshSpanHeight [topOffset bottomOffset]
The optional offset arguments specify how far from the edges of the form widget the component should be positioned. If you don't specify an offset, zero is used.
Example:
XtCreateManagedWidget SEP sep separator $FORM $(DtkshSpanWidth 1 1)
๐ซถ DtkshDisplayInformationDialog, DtkshDisplayQuestionDialog, DtkshDisplayWarningDialog, DtkshDisplayWorkingDialog, DtkshDisplayErrorDialog
(The original lists these like so, stray quote and all โ keeping it true to source, bestie:)
DtkshDisplayInformationDialog, DtkshDisplayQuestionDialog, DtkshDisplayWarningDialog,
DtkshDisplayWorkingDialog, DtkshDisplayErrorDialog"
These convenience functions create a single instance of each of the Motif feedback dialogs. If an instance of the type of dialog you asked for already exists, it gets reused โ no duplicates, we're sustainable here. ๐ฑ
The parent of the dialog comes 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 comes back in one of these environment variables:
DTKSH_ERROR_DIALOG_HANDLEDTKSH_QUESTION_DIALOG_HANDLEDTKSH_WORKING_DIALOG_HANDLEDTKSH_WARNING_DIALOG_HANDLEDTKSH_INFORMATION_DIALOG_HANDLE
Real talk: when you're attaching callbacks to the dialog buttons, the application should not destroy the dialog. Just unmanage it so it can be used again later. If you absolutely must destroy it, then clear the associated environment variable too, so the convenience function doesn't try to reuse a dialog that's gone. ๐ญ
DtkshDisplay*Dialog title message [okCallback closeCallback
helpCallback dialogStyle]
The Ok button is always managed, and by default it unmanages the dialog. The Cancel and Help buttons are only managed when you supply a callback for them. The dialogStyle argument accepts any of the standard resource settings supported by the associated bulletin board resource.
Example:
DtkshDisplayErrorDialog "Read Error" "Unable to read the file" "OkCallback" "CancelCallback" "" DIALOG_PRIMARY_APPLICATION_MODAL
๐ DtkshDisplayQuickHelpDialog, DtkshDisplayHelpDialog
These convenience functions create a single instance of each of the help dialogs. If an instance of the type of help dialog you asked for already exists, it gets reused. The parent of the dialog comes 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 these environment variables:
DTKSH_HELP_DIALOG_HANDLEDTKSH_QUICK_HELP_DIALOG_HANDLE
If you do need to destroy a help dialog, the application should also clear the associated environment variable, so the convenience function doesn't go trying to reuse a dialog that isn't there anymore. Clean up after yourself, periodt. ๐งน
DtkshDisplay*HelpDialog title helpType helpInformation [locationId]
okay so the meaning of the arguments depends on the value you gave for the helpType argument, and hereโs the mapping bestie:
HELP_TYPE_DYNAMIC_STRINGโhelpInformationis the help string;locationIdis&<not used>.HELP_TYPE_FILEโhelpInformationis the help file name;locationIdis&<not used>.HELP_TYPE_MAN_PAGEโhelpInformationis the manual page name;locationIdis&<not used>.HELP_TYPE_STRINGโhelpInformationis the help string;locationIdis&<not used>.HELP_TYPE_TOPICโhelpInformationis the help volume name;locationIdis the help topic location ID.
Example, slay:
DtkshDisplayHelpDialog "Help On Dtksh" HELP_TYPE_FILE "helpFileName"
๐ Dtksh App-Defaults File ๐
The dtksh app-defaults file is named dtksh, and it lives in a location based on this path description:
/nix/store/6waxpwr8lzfzc9ka48gl7yh60rqvlkdb-cde-2.5.3/app-defaults/&<LANG>
The only info inside this app-defaults file is the inclusion of the standard desktop base app-defaults file. The contents of the dtksh app-defaults file are literally:
#include "Dt"
๐ธ Non-String Values ๐ธ
The C bindings of the interfaces to X, Xt and Motif include many non-string values defined in headers. For example, the constraint values for a child of a form widget are declared, such as XmATTACH_FORM, with an Xt or Xm prefix followed by a descriptive name. Equivalent values are specified in dtksh by omitting the prefix, just as in an app-defaults file. So for example: XmDIALOG_COMMAND_TEXT becomes DIALOG_COMMAND_TEXT; XtATTACH_FORM becomes ATTACH_FORM.
A Boolean value can be specified as an argument to a dtksh command using the words True or False; case is not significant.
โจ Return Values From Built-in Commands โจ
Graphical commands in dtksh fall into one of four categories, based on the definition of the corresponding C function in a windowing library:
- The function returns no values. Example:
XtMapWidget. - The function is void, but returns one or more values through reference arguments. Example:
XmGetColors. - The function returns a non-Boolean value. Example:
XtCreateManagedWidget. - The function returns a Boolean value. Example:
XtIsSensitive.
A category 1 command follows the calling sequence of its corresponding C function exactly; the number and order of arguments can be determined by looking at the standard documentation for the function. Example:
XtMapWidget $FORM
A category 2 command also generally follows the calling sequence of its corresponding C function. Where a C caller would pass in a pointer to a variable in which a value is returned, the dtksh command returns a value in an environment variable. Example:
XmGetColors $FORM $BG FOREGROUND TOPSHADOW BOTTOMSHADOW SELECT
echo "Foreground color = " $FOREGROUND
A 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 additional argument, which is always the first argument, and is the name of an environment variable into which the return value is placed. Example:
XmTextGetString TEXT_VALUE $TEXT_WIDGET
echo "The value of the text field is "$TEXT_VALUE
A category 4 command returns a Boolean value that can be used in a conditional expression, just as with the corresponding C function. If the C function also returns values through reference variables (as in category 2), the dtksh command also uses variable names for the corresponding arguments. Example:
if XmIsTraversable $PUSH_BUTTON; then
echo "The pushbutton is traversable"
else
echo "The pushbutton is not traversable"
fi
Generally, the order and type of arguments passed to a command matches those passed to the corresponding C function, except as noted for category 3 commands. Other exceptions are described in the applicable command descriptions.
๐ซถ Widget Handles ๐ซถ
Where a C function returns a widget handle, the corresponding dtksh commands set an environment variable equal to the widget handle. These are category 3 commands; they take as one of their arguments the name of an environment variable in which to return the widget handle. (This is an ASCII string used by dtksh to access the actual widget pointer.) For example, either of the following commands could be used to create a new form widget; in both cases, the widget handle for the new form widget is returned in the environment variable FORM:
XtCreateManagedWidget FORM name XmForm $PARENT
XmCreateForm FORM $PARENT name
After either of the above commands, $FORM can be used to reference the form widget. For instance, to create a label widget within the form widget just created, the following command could be used:
XmCreateLabel LABEL $FORM namelabelString:"Hi Mom" topAttachment:ATTACH_FORM leftAttachment:ATTACH_FORM
There is a special widget handle called NULL, provided for cases where a shell script may need to specify a NULL widget. For example, the following disables the defaultButton resource for a form widget:
XtSetValues $FORM defaultButton:NULL
๐ Widget Resources ๐
Some of the Xt and Motif commands allow the shell script to pass in a variable number of arguments, representing resource and value pairs. This is similar to the arglist passed in to the corresponding Xt or Motif C function. Examples of these commands include any of the commands used to create a widget, and the XtSetValues command. In dtksh, resources are specified by a string with the following syntax: resource: value.
The name of the resource is given in the resource portion of the string; it is constructed by taking the corresponding Xt or Motif resource name and omitting the Xt or Xm prefix. The value to be assigned to the resource is given in the value portion of the string. The dtksh utility 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 widget resources are retrieved using XtGetValues, the return value has the same syntax. For example:
XtGetValues $WIDGET height:HEIGHT resizePolicy:POLICY sensitive:SENSITIVE
echo $HEIGHT
echo $POLICY
echo $SENSITIVE
Certain types of resource values have special representation. These include string tables and bit masks. For instance, the XmList widget allows a string table to be specified both for the items and the selectedItems resources. In dtksh, a string table is represented as a comma-separated list of strings, which is compatible with how Motif handles them from a resource file. When a resource that returns a string table is queried using XtGetValues(3), the resulting value is again a comma-separated set of strings. A resource that expects a bit mask value to be passed in expects the mask to be specified as a string composed of the various mask values separated by the | character. When a resource that returns a bit mask is queried, the return value also is a string representing the enabled bits, separated by the | character. For example, the following sets the mwmFunctions resource for the VendorShell widget class:
XtSetValues mwmFunctions MWM_FUNC_ALL|MWM_FUNC_RESIZE
๐ Unsupported Resources ๐
The dtksh utility supports most of the resources provided by Motif; however, there are certain resources that dtksh does not support. The list of unsupported resources follows. Several of these resources can be specified at widget creation time by using XtSetValues, but cannot be retrieved using XtGetValues; these are indicated by the asterisk (*) following the resource name.
- All Widget And Gadget Classes:
Any font list resource (*)Any pixmap resource ( *)
Composite:insertPositionchildren
Core:acceleratorstranslations (*)colormap
XmText:selectionArrayselectionArrayCount
ApplicationShell:argv
WMShell:iconWindowwindowGroup
Shell:createPopupChildrenProc
XmSelectionBox:textAccelerators
- Manager, Primitive and Gadget Subclasses:
userData
XmFileSelectionBox:dirSearchProcfileSearchProcqualifySearchDataProc
๐ฅ EXIT STATUS ๐ฅ
See ksh-cde(1).
๐ซ CONSEQUENCES OF ERRORS ๐ซ
See ksh-cde(1).
๐ APPLICATION USAGE ๐
โจ Initializing The Toolkit Environment โจ
Before any of the Xlib, Xt or Motif commands can be invoked, the shell script must first initialize the Xt toolkit by invoking the XtInitialize command, which returns an application shell widget. XtInitialize, as with all of the commands that return a widget handle, returns the widget handle in the environment variable named in its first argument. For example:
XtInitialize TOPLEVEL myShellName Dtksh $0$@
Shell script writers should invoke the XtInitialize command as one of the first commands within a dtksh shell script. This allows dtksh to locate its message catalog and the correct app-defaults file. If a shell error occurs before XtInitialize has been called, it is possible that unlocalized error messages may be displayed. The dtksh utility provides a default app-defaults file to use if the call to XtInitialize specifies an application class name of Dtksh. This app-defaults file loads in the standard set of desktop application default values, so that these applications have a consistent look with other desktop applications.
๐ช Responding to a Window Manager Close Notice ๐ช
When the user selects the Close item on the window manager menu for an application, the application is terminated unless it has arranged to catch the Close notification. Multiple windows managed by the application 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 and override the response, so the application is not shut down.
The following code illustrates this processing:
# This is the `callback' invoked when the user selects
# the `Close' menu item
WMCallback()
{
echo "User has selected the Close menu item"
}
# Create the toplevel application shell
XtInitialize TOPLEVEL test Dtksh "$@"
XtDisplay DISPLAY $TOPLEVEL
# Request notification when the user selects the `Close'
# menu item
XmInternAtom DELETE_ATOM $DISPLAY "WM_DELETE_WINDOW" false
XmAddWMProtocolCallback $TOPLEVEL $DELETE_ATOM "WMCallback"
# Ask Motif to not automatically close down your
# application window
XtSetValues $TOPLEVEL deleteResponse:DO_NOTHING
๐ซถ Responding to a Session Management Save State Notice ๐ซถ
Okay so session management is the whole vibe where applications can save their current state when the user ends the current session, so that when the user later restarts the session, an application returns to the state it was in. In dtksh this is accomplished by setting up a handler analogously to handling a Close notification. If no such handler is set up, the application has to be restarted manually in the new session, and does not retain any state. To set up a handler to save state, the application must do the following:
- Define functions to save state at end-of-session, and restore it on start-up.
- Register interest in the session management notification.
- Register the function to save state.
- Determine if saved state should be restored at start-up.
The following code illustrates this process:
#! /nix/store/6waxpwr8lzfzc9ka48gl7yh60rqvlkdb-cde-2.5.3/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 $TOPLEVEL PATH SAVEFILE; then
exec 9>$PATH
# Save off whether we are currently in an iconified state
if DtShellIsIconified $TOPLEVEL; then
print -u9 `Iconified'
else
print -u9 `Deiconified'
fi
# Save off the list of workspaces we currently reside in
if DtWsmGetWorkspacesOccupied $(XtDisplay "-" $TOPLEVEL)
$(XtWindow "-" $TOPLEVEL)
CURRENT_WS_LIST;
then
# Map the comma-separated list of atoms into
# their string representation
oldIFS=$IFS
IFS=","
for item in $CURRENT_WS_LIST;
do
XmGetAtomName NAME $(XtDisplay "-" $TOPLEVEL)
$item
print -u9 $NAME
done
IFS=$oldIFS
fi
exec 9&<&&-
# Let the session manager know how to invoke us when
# the session is restored
DtSetStartupCommand $TOPLEVEL
"/nix/store/6waxpwr8lzfzc9ka48gl7yh60rqvlkdb-cde-2.5.3/contrib/dtksh/SessionTest $SAVEFILE"
else
echo "DtSessionSavePath FAILED!!"
exit -3
fi
}
# Function invoked during a restore session; restores the
# application to its previous state
RestoreSession()
{
# Retrieve the path where our session file resides
if DtSessionRestorePath $TOPLEVEL PATH $1; then
exec 9&<$PATH
read -u9 ICONIFY
# Extract and restore our iconified state
case $ICONIFY in
Iconified) DtSetIconifyHint $TOPLEVEL True;;
*) DtSetIconifyHint $TOPLEVEL False;
esac
# Extract the list of workspaces we belong in, convert
# them to atoms, and ask the workspace manager to relocate
# us to those workspaces
WS_LIST=""
while read -u9 NAME
do
XmInternAtom ATOM $(XtDisplay "-" $TOPLEVEL)
$NAME False
if [ ${#WS_LIST} -gt 0 ]; then
WS_LIST=$WS_LIST,$ATOM
else
WS_LIST=$ATOM
fi
done
DtWsmSetWorkspacesOccupied $(XtDisplay "-" $TOPLEVEL)
$(XtWindow "-" $TOPLEVEL) $WS_LIST
exec 9&<&&-
else
echo "DtSessionRestorePath FAILED!!"
exit -3
fi
}
################## Create the Main UI #######################
XtInitialize TOPLEVEL wmProtTest Dtksh "$@"
XtCreateManagedWidget DA da XmDrawingArea $TOPLEVEL
XtSetValues $DA height:200 width:200
XmInternAtom SAVE_SESSION_ATOM $(XtDisplay "-" $TOPLEVEL)
"WM_SAVE_YOURSELF" False
# If a command-line argument was supplied, then treat it as the
# name of the session file
if (( $# > 0))
then
# Restore to the state specified in the passed-in session file
XtSetValues $TOPLEVEL mappedWhenManaged:False
XtRealizeWidget $TOPLEVEL
XSync $(XtDisplay "-" $TOPLEVEL) False
RestoreSession $1
XtSetValues $TOPLEVEL mappedWhenManaged:True
XtPopup $TOPLEVEL GrabNone
else
# This is not a session restore, so come up in the default state
XtRealizeWidget $TOPLEVEL
XSync $(XtDisplay "-" $TOPLEVEL) False
fi
# Register the fact that we are interested in participating in
# session management
XmAddWMProtocols $TOPLEVEL $SAVE_SESSION_ATOM
XmAddWMProtocolCallback $TOPLEVEL $SAVE_SESSION_ATOM
SessionCallback
XtMainLoop
๐ง Cooperating with WorkSpace Management ๐ง
The dtksh utility gives you access to all of the major workspace management functions of the desktop libraries, including functions for:
- Querying and setting the set of workspaces with which an application is associated.
- Querying the list of all workspaces.
- Querying and setting the current workspace.
- 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 perspective, 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, 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 Management shell script example, if the shell script is going to save and restore workspace identifiers, the workspace 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 uses the following two commands:
XmInternAtom ATOM $DISPLAY $WORKSPACE_NAME false
XmGetAtomName NAME $DISPLAY $ATOM
๐ธ Creating Localized Shell Scripts ๐ธ
Scripts written for dtksh are internationalized, and then localized, in a process very 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 catalog, 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 by 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:
# Attempt to open our message catalog
catopen MSG_CAT_ID "myCatalog.cat"
# The localized button label is in set 1, and is message # 2
XtCreatePushButton OK $PARENT ok
labelString:$(catgets $MSG_CAT_ID 1 2 "OK")
# The localized button label is in set 1, and is message #3
XtCreatePushButton CANCEL $PARENT cancel
labelString:$(catgets $MSG_CAT_ID 1 3 "Cancel")
# Close the message catalog, when no longer needed
catclose $MSG_CAT_ID
๐จ Important: The file descriptor returned bycatopenmust be closed usingcatclose, and not using theksh-cdeexeccommand.
๐จ Using the dtksh Utility to Access X Drawing Functions ๐จ
The commands of the dtksh utility include standard Xlib drawing functions to draw lines, points, segments, rectangles, arcs and polygons. In the standard C programming environment, these functions take a graphics context, or GC as an argument, in addition to the drawing data. In dtksh drawing functions, a collection of GC options are specified in the argument 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 the 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.
-gcGC โGCis the name of an environment variable that has not yet been initialized, or which has been left holding a graphic context by a previous drawing command. If this option is specified, it must be the first GC option specified.-foregroundcolor โ Foreground color, which can be either the name of a color or a pixel number.-backgroundcolor โ Background color, which can be either the name of a color or a pixel number.-fontfont name โ Name of the font to be used.-line_widthnumber โ Line width to be used during drawing.-functiondrawing function โ Drawing function, which can be any of the following:xor,or,clear,and,copy,noop,nor,nand,set,invert,equiv,andReverse,orReverseorcopyInverted.-line_stylestyle โ Line style, which can be any of the following:LineSolid,LineDoubleDashorLineOnOffDash.
โจ Setting Widget Translations โจ
ok so this is the part where dtksh lets you mess with widget translations โ and by "mess with" i mean augment them, override them, and remove them ๐ pretty much exactly how it works in the C programming environment, no cap.
In C, an app installs a whole set of translation action procedures, and then those get attached to specific sequences of events. (quick refresher bestie: a translation = an event sequence + the action procedure that goes with it ๐)
Translations inside dtksh work the same way, with one tiny difference: there's only a single action procedure available. That's it. One. Just the one ๐ซถ
And that one action procedure is named ksh_eval โ she's the main character here ๐. She takes whatever arguments you hand her, interprets them as dtksh commands, and evaluates them the moment the translation gets triggered. iconic behaviour honestly.
Here's a little shell script segment showing how translations get used in the wild:
BtnDownProcedure()
{
echo "Button Down event occurred in button "$1
}
XtCreateManagedWidget BUTTON1 button1 XmPushButton $PARENT
labelString:"Button 1"
translations:'#augment
&<EnterNotify>:ksh_eval("echo Button1 entered")
&<Btn1Down>:ksh_eval("BtnDownProcedure 1")'
XtCreateManagedWidget BUTTON2 button2 XmPushButton $PARENT
labelString:"Button 2"
XtOverrideTranslations $BUTTON2
'#override
&<Btn1Down>:ksh_eval("BtnDownProcedure 2")'
see what's happening? BUTTON1 gets her translations augmented with #augment (so &<EnterNotify> and &<Btn1Down> both get layered on top of whatever was already there) ๐ธ and then BUTTON2 gets hers overridden with #override, where &<Btn1Down> now fires ksh_eval("BtnDownProcedure 2") instead. two buttons, two totally different vibes, both slaying โจ
๐ฆ EXAMPLES ๐ฆ
None.
like... literally none. that's the whole section. none. we move ๐
๐ SEE ALSO ๐
ksh-cde(1)โ go read that one too bestie, iykyk ๐
ok that's the whole page, we made it to the end ๐ mwah, go write some absolutely unhinged dtksh scripts and remember: ksh_eval is your only action procedure, so treat her right ๐ซถ
this lil manual page is dtksh(user cmd) โ that's the source/version tag and the date stamp, right there at the bottom, doing its quiet little thing. periodt ๐
โจ
๐ฆ where this page comes from
- nixos 26.05: cde 2.5.3
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms