diff --git a/Changes b/Changes index d43e9d4ca..0b874609c 100644 --- a/Changes +++ b/Changes @@ -15,6 +15,7 @@ - PDL::Graphics2D removed - use PDL::Graphics::Simple or PDL::Graphics::TriD - move PDL::Graphics::State to PGPLOT distro - split Graphics/Limits out to separate PDL::Graphics::Limits distro +- split IO/Browser out to separate PDL::IO::Browser distro 2.095 2024-11-03 - add PDL_GENTYPE_IS_{REAL,FLOATREAL,COMPLEX,SIGNED,UNSIGNED}_##ppsym (#502) diff --git a/IO/Browser/.gitignore b/IO/Browser/.gitignore deleted file mode 100644 index 9a391600c..000000000 --- a/IO/Browser/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -Browser.c -Browser.pm -Browser.xs diff --git a/IO/Browser/Makefile.PL b/IO/Browser/Makefile.PL deleted file mode 100644 index 665563bfc..000000000 --- a/IO/Browser/Makefile.PL +++ /dev/null @@ -1,109 +0,0 @@ -use strict; -use warnings; -use ExtUtils::MakeMaker; -use File::Spec; -eval { require Devel::CheckLib; Devel::CheckLib->import; }; -eval { require File::Which; }; - -my @pack = (["browser.pd", qw(Browser PDL::IO::Browser)]); - -my %hash = pdlpp_stdargs_int(@pack); - -$hash{'OBJECT'} .= ' browse$(OBJ_EXT)'; -$hash{'clean'}{FILES} .= ' browse$(OBJ_EXT) browse$(EXE_EXT) Browser.c Browser.pm Browser.xs Browser$(OBJ_EXT)'; - -# Here we check for working curses/ncurses -# and the corresponding "curses.h" and "ncurses/curses.h" -# -# (1) Determine which library we have: curses or ncurses -# (2) determine which include path -# (3) determine which include file -# (4) confirm configuration -# (5) write Makefile or dummy as appropriate - -sub _read_pipe { - my (@command) = @_; - open( my $fh, '-|', @command) or die "Unable to run @command: $!"; - chomp(my $output = do { local $/; <$fh> }); - $output; -} - -my @possible_headers = qw( curses.h ncurses/curses.h ncurses.h ncurses/ncurses.h ncursesw/ncurses.h ); -my $found_header; -foreach my $incl (@possible_headers) { - if (eval { check_lib(header=>$incl) }) { - $found_header = $incl; - last; - } -} - -sub conf_via_ncurses_config { - return () unless $found_header; - # NOTE the ncurses*-config executables are shell scripts so `sh` is - # required. - return () unless File::Which::which('sh'); - - my @nc_configs = qw( - ncurses6-config - ncursesw6-config - ncurses5-config - ncursesw5-config - ); - for my $nc_conf (@nc_configs) { - local $ENV{NCURSES_CONFIG_PROG} = $nc_conf; - # NOTE which() can not find the script on Windows because it does have - # have a PATHEXT suffix. For now, just try to run it anyway. - next unless File::Which::which($nc_conf) || $^O eq 'MSWin32'; - if( eval { (my $version = _read_pipe(qw(sh -c), '$NCURSES_CONFIG_PROG --version')) =~ / \A [0-9.]+ \Z /x } ) { - my $cflags = _read_pipe(qw(sh -c), '$NCURSES_CONFIG_PROG --cflags'); - my $libs = _read_pipe(qw(sh -c), '$NCURSES_CONFIG_PROG --libs'); - return ( - header => $found_header, - inc => $cflags, - libs => $libs, - ); - } - } - return (); -} - -sub conf_via_checklib { - return () unless $found_header; - - my $libstring; - foreach my $libr ( qw( curses ncurses ncursesw ) ) { - if (eval { check_lib(lib=>$libr) }) { - $libstring = '-l' . $libr; - last; - } - } - - if( defined $libstring ) { - return ( - header => $found_header, - inc => '', - libs => $libstring, - ); - } - - return (); -} - -my %conf_data; -%conf_data = conf_via_ncurses_config(); -%conf_data = conf_via_checklib() unless %conf_data; -if( %conf_data ) { - $hash{DEFINE} .= ' -DCURSES=' . '\\"' . $conf_data{header} . '\\"'; - $hash{INC} .= ' ' . $conf_data{inc} if $conf_data{inc}; - push @{$hash{LIBS}} , $conf_data{libs}; -} - -# Add genpp rule -undef &MY::postamble; # suppress warning -*MY::postamble = sub { pdlpp_postamble_int(@pack); }; - -if ( %conf_data ) { - WriteMakefile(%hash); -} else { - write_dummy_make("Curses capable library not found, not building PDL::IO::Browser"); -} diff --git a/IO/Browser/browse.c b/IO/Browser/browse.c deleted file mode 100644 index a0b29fb56..000000000 --- a/IO/Browser/browse.c +++ /dev/null @@ -1,410 +0,0 @@ -#include -#include -#include - -#ifdef bool -#undef bool -#endif - -#ifdef CURSES -#define CURSES_INC CURSES -#else -#define CURSES_INC "ncurses/curses.h" -#endif - -#include CURSES_INC - -#include - -#include "EXTERN.h" -#include "perl.h" -#include "XSUB.h" - -#include "pdl.h" - -#define CHBUF 256 -#ifndef MIN -#define MIN(a,b) ((a)<(b)?(a):(b)) -#endif - -#define HLAB 4 - -static int colwid, dcols, drows; - -/* enum pdl_datatypes { PDL_B, PDL_S, PDL_US, PDL_L, PDL_LL, PDL_F, PDL_D }; */ -char *format[] = { "%3d", "%6d", "%6hd", "%11ld", "%11lld", "%10.4g", "%11.4g" }; -int width[] = { 4, 7, 7, 12, 12, 11, 12 }; - -char *str_value(int x, int y, - int type, int nx, void *data, char *str) -{ - // int offsets into our array, not the PDL enum - switch (type) { - case 0: // PDL_B - sprintf(str,format[type],*(((char *)data)+y*nx+x)); - break; - case 1: // PDL_S - sprintf(str,format[type],*(((short *)data)+y*nx+x)); - break; - case 2: // PDL_US - sprintf(str,format[type],*(((unsigned short *)data)+y*nx+x)); - break; - case 3: // PDL_L - sprintf(str,format[type],*(((int *)data)+y*nx+x)); - break; - case 4: // PDL_LL - sprintf(str,format[type],*(((long long *)data)+y*nx+x)); - break; - case 5: // PDL_F - sprintf(str,format[type],*(((float *)data)+y*nx+x)); - break; - case 6: // PDL_D - sprintf(str,format[type],*(((double *)data)+y*nx+x)); - break; - default: - Perl_croak(aTHX_ "type (val=%d) not implemented",type); - break; - } - return str; -} - -void set_value(int x, int y, - int type, int nx, void *data, char *str) -{ - switch (type) { - case PDL_B: - *(((PDL_Byte *)data)+y*nx+x) = atol(str); - break; - case PDL_S: - *(((PDL_Short *)data)+y*nx+x) = atol(str); - break; - case PDL_US: - *(((PDL_Ushort *)data)+y*nx+x) = atol(str); - break; - case PDL_L: - *(((PDL_Long *)data)+y*nx+x) = atol(str); - break; - case PDL_LL: - *(((PDL_LongLong *)data)+y*nx+x) = atol(str); - break; - case PDL_F: - *(((PDL_Float *)data)+y*nx+x) = atof(str); - break; - case PDL_D: - *(((PDL_Double *)data)+y*nx+x) = atof(str); - break; - default: - Perl_croak(aTHX_ "type (val=%d) not implemented",type); - break; - } - return; -} - -void update_vlab(WINDOW *win, int x, int ioff) -{ - char line[BUFSIZ]; - int len, k, d; - chtype chline[BUFSIZ]; - extern int colwid; - - for (k=0;k= 32 && ch <= 127) { - clear_cell(warray,i-ioff,j-joff); - wrefresh(warray); - } - mvwaddch(warray,j-joff,(i-ioff)*colwid+MIN(eps,colwid-2),ch|A_UNDERLINE); - line[eps++]=ch; - continue; - } - - switch (ch) { - case KEY_LEFT: - i = (i<2)?0:i-1; - if (i-ioff == -1) { - ioff--; - wtmp = newwin(1,mycols-colwid,1,HLAB); - overwrite(wvlab,wtmp); - mvwin(wtmp,1,HLAB+colwid); - overwrite(wtmp,wvlab); - delwin(wtmp); - update_vlab(wvlab,0,ioff); - wtmp = newwin(drows,mycols-colwid,2,HLAB); - overwrite(warray,wtmp); - mvwin(wtmp,2,HLAB+colwid); - overwrite(wtmp,warray); - delwin(wtmp); - update_col(warray,0,ioff,joff,type,nc,in); - wrefresh(warray); - wrefresh(wvlab); - } - break; - case KEY_RIGHT: - case '\t': - i = (i>nc-2)?nc-1:i+1; - if (i-ioff == dcols) { - ioff++; - wtmp = newwin(1,mycols-colwid,1,HLAB+colwid); - overwrite(wvlab,wtmp); - mvwin(wtmp,1,HLAB); - overwrite(wtmp,wvlab); - delwin(wtmp); - update_vlab(wvlab,dcols-1,ioff); - wtmp = newwin(drows,mycols-colwid,2,HLAB+colwid); - overwrite(warray,wtmp); - mvwin(wtmp,2,HLAB); - overwrite(wtmp,warray); - delwin(wtmp); - update_col(warray,dcols-1,ioff,joff,type,nc,in); - wrefresh(warray); - wrefresh(wvlab); - } - break; - case KEY_UP: - j = (j<2)?0:j-1; - if (j-joff == -1) { - joff--; - wscrl(wscroll,-1); - wrefresh(wscroll); - update_hlab(whlab,0,joff); - wrefresh(whlab); - update_row(warray,0,ioff,joff,type,nc,in); - wrefresh(warray); - } - break; - case KEY_DOWN: - case '\015': - j = (j>nr-2)?nr-1:j+1; - if (j-joff == drows) { - joff++; - wscrl(wscroll,1); - wrefresh(wscroll); - update_hlab(whlab,drows-1,joff); - wrefresh(whlab); - update_row(warray,drows-1,ioff,joff,type,nc,in); - wrefresh(warray); - } - break; - } - } - nl(); - echo(); - nocbreak(); - endwin(); -} - -#ifdef WITH_IO_BROWSER_MAIN -main () -{ - double b[27*15]; - - int i, j; - - j = 0; - for (i=0; i<27*15; i++) { - b[i] = j++; - } - - browse(PDL_D, 27, 15, &b); -} -#endif diff --git a/IO/Browser/browser.pd b/IO/Browser/browser.pd deleted file mode 100644 index e99fd8783..000000000 --- a/IO/Browser/browser.pd +++ /dev/null @@ -1,73 +0,0 @@ -pp_addpm({At=>'Top'},<<'EOD'); - -=head1 NAME - -PDL::IO::Browser -- 2D data browser for PDL - -=head1 DESCRIPTION - -cursor terminal browser for ndarrays. - -=head1 SYNOPSIS - - use PDL::IO::Browser; - -=cut - -use strict; -use warnings; - -EOD - -use strict; -use warnings; -use PDL::Types; - -pp_addhdr('void browse(int type, int nc, int nr, void *in);'); - -pp_def( - 'browse', - Pars => 'a(n,m);', - Code => " - browse(\$TBSULQFD(0,1,2,3,4,5,6), - \$SIZE(n),\$SIZE(m),\$P(a)); - ", - GenericTypes => [qw(B S U L Q F D)], -Doc=><<'EOD'); -=head2 browse - -=for ref - -browse a 2D array using terminal cursor keys - -=for usage - - browse $data - -This uses the CURSES library to allow one to scroll -around a PDL array using the cursor keys. - - - -=cut - - -EOD -pp_addpm({At=>'Bot'},<<'EOD'); - -=head1 AUTHOR - -Copyright (C) Robin Williams 1997 (rjrw@ast.leeds.ac.uk). -All rights reserved. There is no warranty. You are allowed -to redistribute this software / documentation under certain -conditions. For details, see the file COPYING in the PDL -distribution. If this file is separated from the PDL distribution, -the copyright notice should be included in the file. - - -=cut - - -EOD - -pp_done(); diff --git a/MANIFEST b/MANIFEST index 7ac214493..16fc32794 100644 --- a/MANIFEST +++ b/MANIFEST @@ -298,9 +298,6 @@ Graphics/TriD/TriD/Window.pm Graphics/TriD/VRML/Makefile.PL Graphics/TriD/VRML/VRML.pm Graphics/TriD/VRML/VRML/Protos.pm -IO/Browser/browse.c -IO/Browser/browser.pd -IO/Browser/Makefile.PL IO/Dicom/Dicom.pm IO/Dicom/Makefile.PL IO/ENVI/readenvi.pdl