Functions

Alert

Display a simple modal dialog box

Syntax

Signature
int Alert( const char *message, const char *options[] );

Arguments

message is the text displayed in the alert box. Use \n to split the message into lines. A line wider than the screen is wrapped at a space. The dialog centers each line.

options is an array of button labels in the order they appear. End the array with NULL. Pass NULL or an array whose first entry is NULL to display a single Ok button.

Return value

The one-based index of the selected button, or 0 when Esc is pressed.

Description

Open a modal dialog in the center of the text window. Use it for a short message that requires acknowledgement or a choice. Separate explicit message lines with `\n`. The dialog centers the lines and wraps text to the available width.

Left and Right or Tab and Shift+Tab move between buttons. Enter or Space accepts the highlighted button. The first letter of a label or a click on a button selects it directly. Esc dismisses the dialog and returns `0`.

The dialog preserves the screen cells beneath it and restores them and the cursor when it closes. An empty option list gives a single Ok button.

Example

alert.c
#include "xdev-wtui.h"

int main( void )
{
   const char *options[] = { "Continue", "Cancel", NULL };
   int choice = Alert( "Continue\nwith the operation?", options );

   DispOut( choice == 1 ? "Continuing." : "Cancelled.", NULL );

   Inkey( 0, NIL );

   return 0;
}