I have successfully built dialog 1.1, the program that used to be called
Cdialog, under windows Vista and cygwin. The resulting executable,
dialog,exe, works well both through cygwin and independently as a
windows command shell / cmd application under both Vista and Windows XP.
The UI::Dialog module did not run the dialog program successfully with
the UI::Dialog::Backend::CDialog backend but I was able to get it to run
well with some OS independence modifications to
UI::Dialog::Backend::CDialog and one seemingly minor, and plausibly safe
enough, modification to UI::Dialog::Backend. I have tested the results
under Windows Vista, XP, and ubuntu 7.10 successfully. My tests under
Windows were conducted with Activestate Perl 5.10. Patches are attached
and included below.
The dialog source that was used for my build came from the dialog home
page at: http://invisible-island.net/dialog/
Best Wishes,
Ronald Schmidt
ronaldxs@software-path.com
Patch for UI::Dialog::Backend::CDialog:
--- /usr/local/share/perl/5.8.8/UI/Dialog/Backend/CDialog.pm 2004-10-03
23:16:43.000000000 -0400
+++ ./UI/Dialog/Backend/CDialog.pm 2008-02-08 10:55:00.000000000 -0500
@@ -18,6 +18,7 @@
###############################################################################
use 5.006;
use strict;
+use Config;
use FileHandle;
use Carp;
use Cwd qw( abs_path );
@@ -44,12 +45,13 @@
$self->{'_opts'} = {};
#: Dynamic path discovery...
+ my $path_sep = $Config::Config{path_sep};
my $CFG_PATH = $cfg->{'PATH'};
if ($CFG_PATH) {
if (ref($CFG_PATH) eq "ARRAY") { $self->{'PATHS'} = $CFG_PATH; }
- elsif ($CFG_PATH =~ m!:!) { $self->{'PATHS'} = [ split(/:/,$CFG_PATH)
]; }
+ elsif ($CFG_PATH =~ m!$path_sep!) { $self->{'PATHS'} = [
split(/$path_sep/,$CFG_PATH) ]; }
elsif (-d $CFG_PATH) { $self->{'PATHS'} = [ $CFG_PATH ]; }
- } elsif ($ENV{'PATH'}) { $self->{'PATHS'} = [ split(/:/,$ENV{'PATH'}) ]; }
+ } elsif ($ENV{'PATH'}) { $self->{'PATHS'} = [
split(/$path_sep/,$ENV{'PATH'}) ]; }
else { $self->{'PATHS'} = ''; }
$self->{'_opts'}->{'literal'} = $cfg->{'literal'} || 0;
@@ -64,6 +66,7 @@
$self->{'_opts'}->{'percentage'} = $cfg->{'percentage'} || 1;
$self->{'_opts'}->{'colours'} = ($cfg->{'colours'} ||
$cfg->{'colors'}) ? 1 : 0;
$self->{'_opts'}->{'bin'} ||= $self->_find_bin('dialog');
+ $self->{'_opts'}->{'bin'} ||= $self->_find_bin('dialog.exe') if $^O
=~ /win32/i;
$self->{'_opts'}->{'autoclear'} = $cfg->{'autoclear'} || 0;
$self->{'_opts'}->{'clearbefore'} = $cfg->{'clearbefore'} || 0;
$self->{'_opts'}->{'clearafter'} = $cfg->{'clearafter'} || 0;
@@ -200,7 +203,8 @@
my $self = $_[0];
my $cmnd = $_[1];
$self->_debug("".$cmnd);
- system($cmnd . " 2> /dev/null");
+ my $null_dev = $^O =~ /win32/i ? 'NUL:' : '/dev/null';
+ system($cmnd . " 2> $null_dev");
return($? >> 8);
}
sub command_string {
@@ -274,7 +278,11 @@
&& (length($s_line) <= $self->{'max-scale'});
}
}
+
+ my $want_chop;
+ my $default_pad = $^O !~ /win32/i ? "\n" : ' ';
foreach my $line (@array) {
+ undef $want_chop;
my $pad;
my $s_line = $self->_strip_text($line);
if ($line =~ /\[A\=(\w+)\]/i) {
@@ -291,8 +299,13 @@
}
}
if ($pad) { $text .= (" " x $pad).$line."\n"; }
- else { $text .= $line."\n"; }
+ else {
+ $text .= "$line$default_pad";
+ $want_chop = 1; # only remains set for last line
+ }
}
+ chop $array[ $#array ] if $want_chop; # small actual change here
+
return($self->_filter_text($text));
}
sub _strip_text {
Patch for UI::Dialog::Backend:
--- /usr/local/share/perl/5.8.8/UI/Dialog/Backend.pm 2004-10-03
23:19:29.000000000 -0400
+++ ./UI/Dialog/Backend.pm 2008-02-08 10:32:52.000000000 -0500
@@ -222,8 +222,13 @@
if (eval("require File::Temp; 1")) {
use File::Temp qw( tempfile );
my ($fh,$filename) = tempfile( UNLINK => 1 ) or croak( "Can't create
tempfile: $!" );
- return($filename) unless wantarray;
+ if (wantarray) {
return($fh,$filename);
+ }
+ else {
+ close($fh); # actually required on win32
+ return($filename);
+ }
} else {
my $mktemp = $self->_find_bin('mktemp');
if ($mktemp && -x $mktemp) {
Subject: | UI_Dialog_win32_1.patch |
--- /usr/local/share/perl/5.8.8/UI/Dialog/Backend.pm 2004-10-03 23:19:29.000000000 -0400
+++ ./UI/Dialog/Backend.pm 2008-02-08 10:32:52.000000000 -0500
@@ -222,8 +222,13 @@
if (eval("require File::Temp; 1")) {
use File::Temp qw( tempfile );
my ($fh,$filename) = tempfile( UNLINK => 1 ) or croak( "Can't create tempfile: $!" );
- return($filename) unless wantarray;
+ if (wantarray) {
return($fh,$filename);
+ }
+ else {
+ close($fh); # actually required on win32
+ return($filename);
+ }
} else {
my $mktemp = $self->_find_bin('mktemp');
if ($mktemp && -x $mktemp) {
Subject: | UI_Dialog_win32_2.patch |
--- /usr/local/share/perl/5.8.8/UI/Dialog/Backend/CDialog.pm 2004-10-03 23:16:43.000000000 -0400
+++ ./UI/Dialog/Backend/CDialog.pm 2008-02-08 10:55:00.000000000 -0500
@@ -18,6 +18,7 @@
###############################################################################
use 5.006;
use strict;
+use Config;
use FileHandle;
use Carp;
use Cwd qw( abs_path );
@@ -44,12 +45,13 @@
$self->{'_opts'} = {};
#: Dynamic path discovery...
+ my $path_sep = $Config::Config{path_sep};
my $CFG_PATH = $cfg->{'PATH'};
if ($CFG_PATH) {
if (ref($CFG_PATH) eq "ARRAY") { $self->{'PATHS'} = $CFG_PATH; }
- elsif ($CFG_PATH =~ m!:!) { $self->{'PATHS'} = [ split(/:/,$CFG_PATH) ]; }
+ elsif ($CFG_PATH =~ m!$path_sep!) { $self->{'PATHS'} = [ split(/$path_sep/,$CFG_PATH) ]; }
elsif (-d $CFG_PATH) { $self->{'PATHS'} = [ $CFG_PATH ]; }
- } elsif ($ENV{'PATH'}) { $self->{'PATHS'} = [ split(/:/,$ENV{'PATH'}) ]; }
+ } elsif ($ENV{'PATH'}) { $self->{'PATHS'} = [ split(/$path_sep/,$ENV{'PATH'}) ]; }
else { $self->{'PATHS'} = ''; }
$self->{'_opts'}->{'literal'} = $cfg->{'literal'} || 0;
@@ -64,6 +66,7 @@
$self->{'_opts'}->{'percentage'} = $cfg->{'percentage'} || 1;
$self->{'_opts'}->{'colours'} = ($cfg->{'colours'} || $cfg->{'colors'}) ? 1 : 0;
$self->{'_opts'}->{'bin'} ||= $self->_find_bin('dialog');
+ $self->{'_opts'}->{'bin'} ||= $self->_find_bin('dialog.exe') if $^O =~ /win32/i;
$self->{'_opts'}->{'autoclear'} = $cfg->{'autoclear'} || 0;
$self->{'_opts'}->{'clearbefore'} = $cfg->{'clearbefore'} || 0;
$self->{'_opts'}->{'clearafter'} = $cfg->{'clearafter'} || 0;
@@ -200,7 +203,8 @@
my $self = $_[0];
my $cmnd = $_[1];
$self->_debug("".$cmnd);
- system($cmnd . " 2> /dev/null");
+ my $null_dev = $^O =~ /win32/i ? 'NUL:' : '/dev/null';
+ system($cmnd . " 2> $null_dev");
return($? >> 8);
}
sub command_string {
@@ -274,7 +278,11 @@
&& (length($s_line) <= $self->{'max-scale'});
}
}
+
+ my $want_chop;
+ my $default_pad = $^O !~ /win32/i ? "\n" : ' ';
foreach my $line (@array) {
+ undef $want_chop;
my $pad;
my $s_line = $self->_strip_text($line);
if ($line =~ /\[A\=(\w+)\]/i) {
@@ -291,8 +299,13 @@
}
}
if ($pad) { $text .= (" " x $pad).$line."\n"; }
- else { $text .= $line."\n"; }
+ else {
+ $text .= "$line$default_pad";
+ $want_chop = 1; # only remains set for last line
+ }
}
+ chop $array[ $#array ] if $want_chop; # small actual change here
+
return($self->_filter_text($text));
}
sub _strip_text {