Curses-UI-POE
view release on metacpan or search on metacpan
examples/color_editor view on Meta::CPAN
-bbg => "white",
-sfg => "blue",
-sbg => "white",
-padtop => 0,
-padbottom => 3,
-showlines => 0,
-sbborder => 0,
-vscrollbar => 1,
-hscrollbar => 1,
-showhardreturns => 0,
-wrapping => 0, # wrapping slows down the editor :-(
-text => $text,
-bg => "white",
-fg => "red",
);
# There is no need for the editor widget to loose focus, so
# the "loose-focus" binding is disabled here. This also enables the
# use of the "TAB" key in the editor, which is nice to have.
$editor->clear_binding('loose-focus');
# Help information for the user.
$screen->add(
'help', 'Label',
-y => -2,
-width => -1,
-reverse => 1,
-paddingspaces => 1,
-fg => "blue",
-bg => "white",
-text =>
" ^Q Quit from the program ^S save file"
. " ^W toggle wrapping\n"
. " ^X Open the menu ^O open file"
. " ^R toggle hard returns viewing",
);
# ----------------------------------------------------------------------
# Callback routines
# ----------------------------------------------------------------------
sub open_dialog()
{
my $file = $cui->loadfilebrowser(
-file => $currentfile,
-bg => "green",
-fg => "white",
-bbg => "green",
-bfg => "white",
-tbg => "green",
-tfg => "white",
);
if (defined $file)
{
if (open F, "<$file") {
my $text = "";
while (<F>) { $text .= $_ }
close F;
$editor->text($text);
$editor->cursor_to_home;
$currentfile = $file;
} else {
$cui->error(-message => "Can't read file \"$file\":\n$!");
}
}
}
sub save_dialog()
{
my $file = $cui->savefilebrowser(
-file => $currentfile,
-bg => "green",
-fg => "white",
-bbg => "green",
-bfg => "white",
-tbg => "green",
-tfg => "white",
);
return unless defined $file;
if (open F, ">$file") {
print F $editor->text;
if (close F) {
$cui->dialog(-message => "File \"$file\"\nsuccessfully saved");
$currentfile = $file;
} else {
$cui->error(-message => "Error on closing file \"$file\":\n$!");
}
} else {
$cui->error(-message => "Can't write to $file:\n$!");
}
}
sub about_dialog()
{
$cui->dialog(
-title => 'About editor',
-message => "Program : Curses::UI::POE Editor\n"
. "Author : Maurice Makaay\n"
. " Marcus Thiesen\n"
. "\n"
. "The sole purpose of this editor\n"
. "is the demonstration of the perl\n"
. "Curses::UI::POE widget set and the newly\n"
. "developed color support.\n",
-bg => "white",
-fg => "red",
-bbg => "white",
-bfg => "red",
-tbg => "white",
-tfg => "red",
);
}
sub exit_dialog()
{
my $return = $cui->dialog(
-title => "Are you sure???",
-buttons => ['yes', 'no'],
( run in 0.679 second using v1.01-cache-2.11-cpan-39bf76dae61 )