#!/usr/bin/perl -w
use strict;

# We do not want STDERR to clutter our screen.
open STDERR, ">/dev/null";

use FindBin;
use lib "$FindBin::RealBin/../lib";
use Curses::UI;
my $cui = new Curses::UI ( -clear_on_exit => 1 );

my $win = $cui->add('window_id', 'Window');

$win->add(
	'label1', 'Label',
	-text => "Press <CTRL+Q> to leave this demo."
);

$win->add(
        'edit1', 'TextEditor',
	-y          => 3,
        -width      => 25,
	-height     => 10,
	-border     => 1,
	-title      => 'Default texteditor',
	-vscrollbar => 1,
	-hscrollbar => 1,
);

$win->add(
        'edit2', 'TextEditor',
	-y          => 3,
	-x          => 26,
        -width      => 25,
	-height     => 10,
	-border     => 1,
	-title      => 'With wrapping',
	-wrapping   => 1,
	-vscrollbar => 1,
	-hscrollbar => 1,
);

$win->add(
        'edit3', 'TextEditor',
	-y          => 3,
	-x          => 52,
        -width      => 25,
	-height     => 10,
	-border     => 1,
	-title      => 'View only',
	-readonly   => 1,
	-vscrollbar => 1,
	-hscrollbar => 1,
	-wrapping   => 0,
	-text       => "This is a read\nonly texteditor,\n"
                     . "so the only\nthing you can\ndo is "
	             . "take\na look at\nthis nonsense...\n"
         	     . "Sorry that at\nthis time of the\n"
                     . "night I could\nnot think of anything\n"
                     . "more exciting than this dull text.",
);

$win->add(
	'edit4', 'TextEditor',
	-y => 14,
        -x => 0,
        -width => 25,
	-border => 1,
        -title => 'single-line',
        -singleline => 1,
);

$win->add(
	'edit5', 'TextEditor',
	-y => 14,
        -x => 26,
        -width => 25,
	-border => 1,
        -title => '-password',
        -singleline => 1,
	-password   => '*',
);

$win->add(
	'edit6', 'TextEditor',
	-y => 14,
        -x => 52,
        -width => 25,
	-border => 1,
        -title => 'regexp /^\d*$/',
	-regexp => '/^\d*$/',
        -singleline => 1,
);

$win->add(
	'edit7_lbl', 'Label',
	-y => 18, -x => 0,
	-text => 'With -sbborder:',
);
$win->add(
	'edit7', 'TextEditor',
	-y => 20,
        -x => 0,
        -width => 25,
	-sbborder => 1,
        -title => '-singleline',
        -singleline => 1,
);

$win->add(
	'edit8_lbl', 'Label',
	-y => 18, -x => 26,
	-text => '-showlines',
);
$win->add(
	'edit8', 'TextEditor',
	-y => 20,
        -x => 26,
        -width => 25,
	-singleline => 1,
        -title => 'single-line',
        -showlines => 1,
);

$win->add(
	'edit9_lbl', 'Label',
	-y => 18, -x => 52,
	-text => '-showlines (lynx)',
);
$win->add(
	'edit9', 'TextEditor',
	-y => 20,
        -x => 52,
        -width => 25,
	-padbottom => 2,
        -title => 'single-line',
        -showlines => 1,
);

$win->returnkeys("\cQ");
$win->focus;
