# osd-dialog(3)

[Home] [Commands] [Variables] [Macro-Dev] [Glossary]

## NAME

osd-dialog - OSD dialog box
osd-xdialog - OSD Extended dialog box
osd-entry - OSD entry dialog box

## SYNOPSIS

n osd-dialog "title" "prompt" [ "x-pos" "y-pos" ] "but1"
n osd-xdialog "title" "prompt" default [ "x-pos" "y-pos" ]

"but1" "but2" ...

n osd-entry "title" "prompt" variable [ "x-pos" "y-pos" ]

[ [ "entry-xsize" | "entry-xsizexentry-ysize" ] [ "type" ] ]

## DESCRIPTION

osd-dialog constructs a OSD dialog prompt with a title string title, a prompt string within the dialog of prompt. A single button, with text rendering but1, is placed within the dialog. The dialog remains on the screen until the button is selected or the user aborts.

osd-xdialog creates an extended dialog with multiple buttons similar to osd-dialog, the number of buttons created (#) is determined from the number of but arguments. The default integer argument specifies the default button (1..#), a value of 0 specifies that there is no default button.

The commands return the button pressed in the variable $result(5).

osd-entry constructs a simple OSD entry dialog which prompts the user to type in a value. The value of the supplied variable is used as an initial entry value, the variable is set to the entered value when the user presses the "`Okay`" button but remains unchanged if the user Cancel or aborts.

The size of the entry defaults to 30 characters if not specified by the user, when a size parameter is given it can take one of two forms, either simply "`w`" specifying the width, the height defaulting to 1, or "`w` x `h`" (i.e. "`40x5`") specifying both. The last optional argument type sets the type of value being entered (e.g. file name, buffer name, etc) see flag h on the help page for @ml(4) for a list of entry types and the numerical value to be supplied.

The argument n can be used to change the default behavior of the commands described above, n is a bit based flag where:-

0x01

Enables command abort (default), except osd-entry which ignores the setting of this bit. When enabled, if the user abort by either closing the dialog (top right button) or using the abort-command the dialog command will also abort. If bit 0x01 is not set the command will not abort and $result will be set to -1.

0x02

When set, flags that a dialog position has also been provided, extra arguments x-pos and y-pos must also be given. By default the dialog is placed under the mouse.

## EXAMPLE

A simple query dialog is typically constructed using osd-dialog, as follows:-

    !if &seq %osd-search-str ""
        osd-dialog "Replace" "Error: Search string is empty!" "  &OK  "
        !return
    !endif

The following example uses multiple buttons within a single dialog, using osd-xdialog, as follows:-

    0 define-macro osd-close
        !if &bmod "edit"
            set-variable #l0 &spr "Buffer \"%s\" changed" $buffer-bname
            osd-xdialog "Buffer Close" #l0 1 "&Save First" \
                                            "&Loose Changes" "&Cancel"
            !if &equ $result 3
                !abort
            !elif &equ $result 2
                -1 buffer-mode "edit"
            !else
                !if &seq $buffer-fname ""
                    !nma write-buffer
                !else
                    !nma save-buffer
                !endif
            !endif
        !endif
        delete-buffer $buffer-bname @mna
    !emacro

The next example macro can be used to change the value of a user variable to a user supplied file name:

    set-variable %source-root "~/"

    define-macro set-source-root
        osd-entry "Source Root" "&Path : " %source-root 35 1
    !emacro

## NOTES

osd-dialog, osd-xdialog and osd-entry are macros defined in `osd.emf`, using osd(2) to create the dialog.

## SEE ALSO

$result(5), osd(2).

(c) Copyright JASSPA 2009
Last Modified: 2009/08/29
Generated On: 2009/10/12

</HMTL>