#!/bin/bash -efu

IM_dlgmsg()
{
	IM_start_input

	local title="$1" text="$2" height=2
	local width=$(( 4 + ${#text} ))

	if [ $width -lt 40 ]; then
		width=40
	elif [ $width -gt ${_IM_max_width} ]; then
		height=$(( $width / ${_IM_max_width} + 2 ))
		width=${_IM_max_width}
	fi

	dialog	$IM_WIDGET_ARGS					\
		${NOLINES:+--ascii-lines}			\
		${IM_BACKTITLE:+--backtitle "$IM_BACKTITLE"}	\
		--title "$title"				\
		--msgbox "\n$text"				\
		$((4 + $height)) $width ||:
	[ -z "$CONSOLE" ] ||
		reset
}
