--- iselect-1.2.0.orig/Makefile.in +++ iselect-1.2.0/Makefile.in @@ -25,7 +25,8 @@ prefix = @prefix@ exec_prefix = @exec_prefix@ bindir = @bindir@ -mandir = ${exec_prefix}/man +mandir = @mandir@ +# ${exec_prefix}/man # ------------------------------------------------ # THE DEFAULT TARGETS --- iselect-1.2.0.orig/etc/asc2c +++ iselect-1.2.0/etc/asc2c @@ -1,4 +1,4 @@ -#!/sw/bin/perl +#!/usr/bin/perl ## ## asc2c -- convert an ASCII file into a statically initialised ## C array of characters --- iselect-1.2.0.orig/example/scvs/scvs +++ iselect-1.2.0/example/scvs/scvs @@ -1,4 +1,4 @@ -#!/sw/bin/perl +#!/usr/bin/perl ## ## sCVS -- Switch CVS Repository ## Copyright (c) 1997 Ralf S. Engelschall, All Rights Reserved. @@ -6,8 +6,8 @@ require 5.004; -use Term::Cap; -use File::PathConvert; +use Term::ANSIColor; +use File::Spec; use IO::File 1.06; use Cwd; @@ -16,34 +16,12 @@ ## 1. Determine terminal capabilities ## -$term = Tgetent Term::Cap { TERM => undef, OSPEED => 9600 }; -$bold = $term->Tputs('md', 1, undef); -$norm = $term->Tputs('me', 1, undef); - - ## ## 2. Find .scvsrc files and read contents into %CVSROOTS hash ## %CVSROOTS = (); -# determine canonical path -sub canonical_path { - my ($path) = @_; - my ($pathL); - - $pathL = ''; - while ($path ne $pathL) { - $pathL = $path; - $path =~ s|//|/|g; - $path =~ s|/\./|/|g; - $path =~ s|/\.$|/|g; - $path =~ s|^./||g; - $path =~ s|([^/.][^/.]*)/\.\.||; - } - return $path; -} - # create list of dirs back to root ($cwd = Cwd::cwd) =~ s|/$||; $cwdT = $cwd; @@ -55,9 +33,10 @@ # search for .scvsrc files foreach $dir (reverse(@DIR)) { if (-f "$dir/.scvsrc") { - $reldir = &canonical_path(File::PathConvert::abs2rel($dir)); - $subdir = &canonical_path(File::PathConvert::abs2rel($cwd, $dir)); - $rcfile = &canonical_path("$reldir/.scvsrc"); + $reldir = File::Spec->abs2rel($dir); + $reldir = '.' if $reldir eq ''; + $subdir = File::Spec->abs2rel($cwd, $dir); + $rcfile = "$reldir/.scvsrc"; &process_rcfile($rcfile, $cwd, $reldir, $subdir); } } @@ -103,7 +82,6 @@ $locC =~ s|\n$||; $root->close(); - ## ## 4. Create iSelect page with list of available CVS repositories ## and fire up iSelect with it @@ -158,14 +136,14 @@ $prefixN = $locN; $prefixN =~ s|^[^/]+||; -foreach $dir (split(/\n/, `find . -name CVS -type d -depth -print`)) { +foreach $dir (split(/\n/, `find . -noleaf -depth -type d -name CVS -print `)) { $dir =~ s|^\./||; $dirname = $dir; if (length($dirname) > 60) { $dirname = '..'.substr($dirname, length($dirname)-60, 60); } $dirname = sprintf("%-60s", $dirname); - print STDERR "Processing: ${bold}$dirname$norm\r"; + print STDERR "Processing: ".colored("$dirname\r", 'bold'); open(FP, "<$dir/Root"); $locO = ; --- iselect-1.2.0.orig/example/mtin/mtin +++ iselect-1.2.0/example/mtin/mtin @@ -1,4 +1,4 @@ -#!/sw/bin/perl +#!/usr/bin/perl ## ## MetaTIN -- a TIN frontend for better USENET NetNews reading ## Copyright (c) 1996-1997 Ralf S. Engelschall, All Rights Reserved. --- iselect-1.2.0.orig/example/melm/melm +++ iselect-1.2.0/example/melm/melm @@ -1,4 +1,4 @@ -#!/sw/bin/perl +#!/usr/bin/perl ## ## MetaELM -- ELM frontend ## Copyright (c) 1997 Ralf S. Engelschall, All Rights Reserved. --- iselect-1.2.0.orig/example/ilogin/ilogin +++ iselect-1.2.0/example/ilogin/ilogin @@ -1,4 +1,4 @@ -#!/sw/bin/perl +#!/usr/bin/perl ## ## iLogin -- interactive login ## Copyright (c) 1997 Ralf S. Engelschall, All Rights Reserved. --- iselect-1.2.0.orig/example/gotourl/gotourl +++ iselect-1.2.0/example/gotourl/gotourl @@ -1,4 +1,4 @@ -#!/sw/bin/perl +#!/usr/bin/perl ## ## GotoURL -- go to a particular URL ## Copyright (c) 1997 Ralf S. Engelschall, All Rights Reserved. --- iselect-1.2.0.orig/example/gotourl/dot.gotourlrc +++ iselect-1.2.0/example/gotourl/dot.gotourlrc @@ -4,8 +4,8 @@ ^ftp://.+/$ cftp %U ^ftp://.+[^/]$ lftp %U -^(http|ftp)://.+ /usr/local/bin/lynx %U -^(http|ftp)://.+ /usr/local/bin/netscape -remote 'openURL(%U)' +^(http|ftp)://.+ lynx %U +^(http|ftp)://.+ netscape -remote 'openURL(%U)' ^(http|ftp)://.+[^/]$ fetch %U ##EOF## --- iselect-1.2.0.orig/iselect.1 +++ iselect-1.2.0/iselect.1 @@ -1,9 +1,8 @@ -.rn '' }` -''' $RCSfile$$Revision$$Date$ -''' -''' $Log$ -''' -.de Sh +.\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.14 +.\" +.\" Standard preamble: +.\" ======================================================================== +.de Sh \" Subsection heading .br .if t .Sp .ne 5 @@ -11,150 +10,98 @@ \fB\\$1\fR .PP .. -.de Sp +.de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. -.de Ip -.br -.ie \\n(.$>=3 .ne \\$3 -.el .ne 3 -.IP "\\$1" \\$2 -.. -.de Vb +.de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. -.de Ve +.de Ve \" End verbatim text .ft R - .fi .. -''' -''' -''' Set up \*(-- to give an unbreakable dash; -''' string Tr holds user defined translation string. -''' Bell System Logo is used as a dummy character. -''' +.\" Set up some character translations and predefined strings. \*(-- will +.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left +.\" double quote, and \*(R" will give a right double quote. | will give a +.\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to +.\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C' +.\" expand to `' in nroff, nothing in troff, for use with C<>. .tr \(*W-|\(bv\*(Tr +.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ -.ds -- \(*W- -.ds PI pi -.if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch -.if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch -.ds L" "" -.ds R" "" -''' \*(M", \*(S", \*(N" and \*(T" are the equivalent of -''' \*(L" and \*(R", except that they are used on ".xx" lines, -''' such as .IP and .SH, which do another additional levels of -''' double-quote interpretation -.ds M" """ -.ds S" """ -.ds N" """"" -.ds T" """"" -.ds L' ' -.ds R' ' -.ds M' ' -.ds S' ' -.ds N' ' -.ds T' ' +. ds -- \(*W- +. ds PI pi +. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch +. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch +. ds L" "" +. ds R" "" +. ds C` "" +. ds C' "" 'br\} .el\{\ -.ds -- \(em\| -.tr \*(Tr -.ds L" `` -.ds R" '' -.ds M" `` -.ds S" '' -.ds N" `` -.ds T" '' -.ds L' ` -.ds R' ' -.ds M' ` -.ds S' ' -.ds N' ` -.ds T' ' -.ds PI \(*p +. ds -- \|\(em\| +. ds PI \(*p +. ds L" `` +. ds R" '' 'br\} -.\" If the F register is turned on, we'll generate -.\" index entries out stderr for the following things: -.\" TH Title -.\" SH Header -.\" Sh Subsection -.\" Ip Item -.\" X<> Xref (embedded -.\" Of course, you have to process the output yourself -.\" in some meaninful fashion. -.if \nF \{ -.de IX -.tm Index:\\$1\t\\n%\t"\\$2" +.\" +.\" If the F register is turned on, we'll generate index entries on stderr for +.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index +.\" entries marked with X<> in POD. Of course, you'll have to process the +.\" output yourself in some meaningful fashion. +.if \nF \{\ +. de IX +. tm Index:\\$1\t\\n%\t"\\$2" .. -.nr % 0 -.rr F +. nr % 0 +. rr F .\} -.TH ISELECT 1 "EN" "31/Mar/99" "Ralf S. Engelschall" -.UC -.if n .hy 0 +.\" +.\" For nroff, turn off justification. Always turn off hyphenation; it makes +.\" way too many mistakes in technical documents. +.hy 0 .if n .na -.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' -.de CQ \" put $1 in typewriter font -.ft CW -'if n "\c -'if t \\&\\$1\c -'if n \\&\\$1\c -'if n \&" -\\&\\$2 \\$3 \\$4 \\$5 \\$6 \\$7 -'.ft R -.. -.\" @(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2 -. \" AM - accent mark definitions -.bd B 3 -. \" fudge factors for nroff and troff +.\" +.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). +.\" Fear. Run. Save yourself. No user-serviceable parts. +. \" fudge factors for nroff and troff .if n \{\ -. ds #H 0 -. ds #V .8m -. ds #F .3m -. ds #[ \f1 -. ds #] \fP +. ds #H 0 +. ds #V .8m +. ds #F .3m +. ds #[ \f1 +. ds #] \fP .\} .if t \{\ -. ds #H ((1u-(\\\\n(.fu%2u))*.13m) -. ds #V .6m -. ds #F 0 -. ds #[ \& -. ds #] \& +. ds #H ((1u-(\\\\n(.fu%2u))*.13m) +. ds #V .6m +. ds #F 0 +. ds #[ \& +. ds #] \& .\} -. \" simple accents for nroff and troff +. \" simple accents for nroff and troff .if n \{\ -. ds ' \& -. ds ` \& -. ds ^ \& -. ds , \& -. ds ~ ~ -. ds ? ? -. ds ! ! -. ds / -. ds q +. ds ' \& +. ds ` \& +. ds ^ \& +. ds , \& +. ds ~ ~ +. ds / .\} .if t \{\ -. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" -. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' -. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' -. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' -. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' -. ds ? \s-2c\h'-\w'c'u*7/10'\u\h'\*(#H'\zi\d\s+2\h'\w'c'u*8/10' -. ds ! \s-2\(or\s+2\h'-\w'\(or'u'\v'-.8m'.\v'.8m' -. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' -. ds q o\h'-\w'o'u*8/10'\s-4\v'.4m'\z\(*i\v'-.4m'\s+4\h'\w'o'u*8/10' +. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" +. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' +. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' +. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' +. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' +. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} -. \" troff and (daisy-wheel) nroff accents +. \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' -.ds v \\k:\h'-(\\n(.wu*9/10-\*(#H)'\v'-\*(#V'\*(#[\s-4v\s0\v'\*(#V'\h'|\\n:u'\*(#] -.ds _ \\k:\h'-(\\n(.wu*9/10-\*(#H+(\*(#F*2/3))'\v'-.4m'\z\(hy\v'.4m'\h'|\\n:u' -.ds . \\k:\h'-(\\n(.wu*8/10)'\v'\*(#V*4/10'\z.\v'-\*(#V*4/10'\h'|\\n:u' -.ds 3 \*(#[\v'.2m'\s-2\&3\s0\v'-.2m'\*(#] .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' @@ -162,64 +109,65 @@ .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E -.ds oe o\h'-(\w'o'u*4/10)'e -.ds Oe O\h'-(\w'O'u*4/10)'E -. \" corrections for vroff +. \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' -. \" for low resolution devices (crt and lpr) +. \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ -. ds : e -. ds 8 ss -. ds v \h'-1'\o'\(aa\(ga' -. ds _ \h'-1'^ -. ds . \h'-1'. -. ds 3 3 -. ds o a -. ds d- d\h'-1'\(ga -. ds D- D\h'-1'\(hy -. ds th \o'bp' -. ds Th \o'LP' -. ds ae ae -. ds Ae AE -. ds oe oe -. ds Oe OE +. ds : e +. ds 8 ss +. ds o a +. ds d- d\h'-1'\(ga +. ds D- D\h'-1'\(hy +. ds th \o'bp' +. ds Th \o'LP' +. ds ae ae +. ds Ae AE .\} .rm #[ #] #H #V #F C +.\" ======================================================================== +.\" +.IX Title "ISELECT 1" +.TH ISELECT 1 "2005-04-10" "EN" "Ralf S. Engelschall" .SH "NAME" -iSelect -- Interactive Selection Tool +iSelect \-\- Interactive Selection Tool .SH "SYNOPSIS" -\fBiselect\fR -[\fB\-d\fR \fISTR\fR,\fISTR\fR] +.IX Header "SYNOPSIS" +\&\fBiselect\fR +[\fB\-d\fR \fI\s-1STR\s0\fR,\fI\s-1STR\s0\fR] [\fB\-c\fR] [\fB\-f\fR] [\fB\-a\fR] [\fB\-e\fR] -[\fB\-p\fR \fINUM\fR] -[\fB\-k\fR \fIKEY\fR[:\fIOKEY\fR]] +[\fB\-p\fR \fI\s-1NUM\s0\fR] +[\fB\-k\fR \fI\s-1KEY\s0\fR[:\fI\s-1OKEY\s0\fR]] [\fB\-m\fR] -[\fB\-n\fR \fISTR\fR] -[\fB\-t\fR \fISTR\fR] +[\fB\-n\fR \fI\s-1STR\s0\fR] +[\fB\-t\fR \fI\s-1STR\s0\fR] [\fB\-S\fR] [\fB\-K\fR] [\fB\-P\fR] -[\fB\-Q\fR \fISTR\fR] +[\fB\-Q\fR \fI\s-1STR\s0\fR] [\fIline1\fR \fIline2\fR ...] .PP -\fBiselect\fR +\&\fBiselect\fR [\fB\-V\fR] .SH "VERSION" -1.2.0 (31-Mar-1999) +.IX Header "VERSION" +1.2.0 (31\-Mar\-1999) .SH "DESCRIPTION" +.IX Header "DESCRIPTION" .Sh "Intend" +.IX Subsection "Intend" iSelect is an interactive line selection tool for \s-1ASCII\s0 files, operating via a full-screen Curses-based terminal session. It can be used either as an user -interface frontend controlled by a Bourne-Shell, Perl or other type of script -backend as its wrapper or in batch as a pipe filter (usually between \fIgrep\fR +interface frontend controlled by a Bourne\-Shell, Perl or other type of script +backend as its wrapper, or in batch as a pipe filter (usually between \fIgrep\fR and the final executing command). In other words: iSelect was designed to be -used for any types of interactice line-based selections. +used for any type of interactive line-based selection. .Sh "Input Data" +.IX Subsection "Input Data" Input is read either from the command line (\fIline1\fR \fIline2\fR ...) where each argument corresponds to one buffer line or from \fIstdin\fR (when no arguments are given) where the buffer lines are determined according to the newline @@ -227,242 +175,198 @@ .PP You can additionally let substrings displayed in Bold mode for non-selectable lines (because the selectable lines are always displayed bold) by using the -construct ``\f(CW\fR...\f(CW\fR'\*(R' as in \s-1HTML\s0. +construct \f(CW\*(C`\*(C'\fR...\f(CW\*(C`\*(C'\fR as in \s-1HTML\s0. .Sh "Selections" +.IX Subsection "Selections" The selection is either just a single line (default) or multiple lines (option -\fB\-m\fR). Per default no lines are selectable. If a line contains the string -``\f(CW\fR'\*(R' (or a string with different delimiters configured via +\&\fB\-m\fR). Per default no lines are selectable. If a line contains the string +\&\f(CW\*(C`\*(C'\fR (or a string with different delimiters configured via option \fB\-d\fR) at any position this string is stripped and the line is selectable. Its result (printed to \fIstdout\fR) is the line contents itself (but -without the ``\f(CW\fR'\*(R' string of course). If option \fB\-a\fR is used all +without the \f(CW\*(C`\*(C'\fR string of course). If option \fB\-a\fR is used all lines are selectable and their result is again the line itself, i.e. using -option \fB\-a\fR is the same as adding ``\f(CW\fR'\*(R' to every line of the +option \fB\-a\fR is the same as adding \f(CW\*(C`\*(C'\fR to every line of the input data. When you want a specific result (i.e. not just the line contents -itself), you have to use the special variant ``\f(CW\fR'\*(R' -which results in the output ``\f(CWresult text\fR'\*(R' when the corresponding line is +itself), you have to use the special variant \f(CW\*(C`\*(C'\fR +which results in the output \f(CW\*(C`result text\*(C'\fR when the corresponding line is selected. .PP -When you use a specific result via ``\f(CW\fR'\*(R' the \fIresult -text\fR can contain ``\f(CW%s[query text]s\fR'\*(R' and ``\f(CW%s[query text]S\fR'\*(R' +When you use a specific result via \f(CW\*(C`\*(C'\fR the \fIresult text\fR +can contain \f(CW\*(C`%s[query text]s\*(C'\fR and \f(CW\*(C`%s[query text]S\*(C'\fR constructs. For every such construct an interactive query is done and the -result replaces the construct. The ``\f(CW%s[query text]S\fR'\*(R' construct is like -``\f(CW%s[query text]s\fR'\*(R' except that the empty string as the query result is not +result replaces the construct. The \f(CW\*(C`%s[query text]S\*(C'\fR construct is like +\&\f(CW\*(C`%s[query text]s\*(C'\fR except that the empty string as the query result is not accepted on input. .PP The Curses-based full-screen selection is always done via \fI/dev/tty\fR, because the \fIstdin\fR and \fIstdout\fR filehandles are usually tied to the input and output data streams. .Sh "Output Data" -The output is the line itself or the string given with ``\f(CW\fR'\*(R'. When multiple line selection mode (option \fB\-m\fR) is used the -output is all selected lines theirself or their configured result strings. +.IX Subsection "Output Data" +The output is the line itself or the string given with \f(CW\*(C`\*(C'\fR. +When multiple line selection mode (option \fB\-m\fR) is used the +output is all selected lines, or their configured result strings. Output always is written to \fIstdout\fR. .SH "OPTIONS" +.IX Header "OPTIONS" .Sh "Input Options" +.IX Subsection "Input Options" These options control how \fIiSelect\fR parses its input. -.Ip "\fB\-d\fR \fI\s-1STR\s0\fR, \fB--delimiter=\fR\fI\s-1STR\s0\fR" 4 -Sets the delimiters for the selection tags. The default is `\f(CW<,>\fR\*(R', -i.e. the selection tags have to read ``\f(CW\fR'\*(R' and ``\f(CW\fR'\*(R' -.Ip "\fB\-c\fR, \fB--strip-comments\fR" 4 +.IP "\fB\-d\fR \fI\s-1STR\s0\fR, \fB\-\-delimiter=\fR\fI\s-1STR\s0\fR" 4 +.IX Item "-d STR, --delimiter=STR" +Sets the delimiters for the selection tags. The default is \f(CW\*(C`<,>\*(C'\fR, +i.e. the selection tags have to read \f(CW\*(C`\*(C'\fR and \f(CW\*(C`\*(C'\fR. +.IP "\fB\-c\fR, \fB\-\-strip\-comments\fR" 4 +.IX Item "-c, --strip-comments" Strips all sharp comment lines from the input buffer before parsing. -.Ip "\fB\-f\fR, \fB--force-browse\fR" 4 +.IP "\fB\-f\fR, \fB\-\-force\-browse\fR" 4 +.IX Item "-f, --force-browse" Browse always, i.e. even when the input buffer contains no or only one line. -.Ip "\fB\-a\fR, \fB--all-select\fR" 4 +.IP "\fB\-a\fR, \fB\-\-all\-select\fR" 4 +.IX Item "-a, --all-select" Force all lines to be selectable. -.Ip "\fB\-e\fR, \fB--exit-no-select\fR" 4 +.IP "\fB\-e\fR, \fB\-\-exit\-no\-select\fR" 4 +.IX Item "-e, --exit-no-select" Exit immediately if no lines are selectable. In this case not even the Curses screen is initialized. .Sh "Display Options" -.Ip "\fB\-p\fR \fI\s-1NUM\s0\fR, \fB--position=\fR\fI\s-1NUM\s0\fR" 4 +.IX Subsection "Display Options" +.IP "\fB\-p\fR \fI\s-1NUM\s0\fR, \fB\-\-position=\fR\fI\s-1NUM\s0\fR" 4 +.IX Item "-p NUM, --position=NUM" Sets the cursor position to line \fI\s-1NUM\s0\fR. -.Ip "\fB\-k\fR \fI\s-1KEY\s0\fR[:\fI\s-1OKEY\s0\fR], \fB--key=\fR\fI\s-1KEY\s0[:\fI\s-1OKEY\s0\fR]\fR" 4 -Defines an additional input key. Per default \fI\s-1OKEY\s0\fR is \f(CWRETURN\fR, i.e. for -instance \fB\-kf\fR defines another selection key `\f(CWf\fR\*(R'. -.Ip "\fB\-m\fR, \fB--multi-line\fR" 4 +.IP "\fB\-k\fR \fI\s-1KEY\s0\fR[:\fI\s-1OKEY\s0\fR], \fB\-\-key=\fR\fIKEY[:\fI\s-1OKEY\s0\fI]\fR" 4 +.IX Item "-k KEY[:OKEY], --key=KEY[:OKEY]" +Defines an additional input key. Per default \fI\s-1OKEY\s0\fR is \f(CW\*(C`RETURN\*(C'\fR, i.e. for +instance \fB\-kf\fR defines another selection key \f(CW\*(C`f\*(C'\fR. +.IP "\fB\-m\fR, \fB\-\-multi\-line\fR" 4 +.IX Item "-m, --multi-line" Enable multi-line selection where you can select more then one line via \s-1SPACE\s0 key. -.Ip "\fB\-n\fR \fI\s-1STR\s0\fR, \fB--name=\fR\fI\s-1STR\s0\fR" 4 +.IP "\fB\-n\fR \fI\s-1STR\s0\fR, \fB\-\-name=\fR\fI\s-1STR\s0\fR" 4 +.IX Item "-n STR, --name=STR" Sets the name string, displayed flush left at the bottom of the browser window. -.Ip "\fB\-t\fR \fI\s-1STR\s0\fR, \fB--title=\fR\fI\s-1STR\s0\fR" 4 +.IP "\fB\-t\fR \fI\s-1STR\s0\fR, \fB\-\-title=\fR\fI\s-1STR\s0\fR" 4 +.IX Item "-t STR, --title=STR" Sets the title bar string, displayed centered at the bottom of the browser window. .Sh "Output Options" -.Ip "\fB\-S\fR, \fB--strip-result\fR" 4 +.IX Subsection "Output Options" +.IP "\fB\-S\fR, \fB\-\-strip\-result\fR" 4 +.IX Item "-S, --strip-result" Strip all leading and trailing whitespaces from the result string. -.Ip "\fB\-K\fR, \fB--key-result\fR" 4 +.IP "\fB\-K\fR, \fB\-\-key\-result\fR" 4 +.IX Item "-K, --key-result" Prefix the result string (given on \fIstdout\fR) with the corresponding selection -key which was used. This usually is \f(CWRETURN\fR or \f(CWKEY_RIGHT\fR but can be any +key which was used. This usually is \f(CW\*(C`RETURN\*(C'\fR or \f(CW\*(C`KEY_RIGHT\*(C'\fR but can be any of the additional keys defined by option \fB\-k\fR. When you use \fB\-kf\fR and -select a line \f(CWFoo Bar\fR with key `\f(CWf\fR\*(R' the result string is ``\f(CWf:Foo -Bar\fR'\*(R'. -.Ip "\fB\-P\fR, \fB--position-result\fR" 4 +select a line \f(CW\*(C`Foo Bar\*(C'\fR with key \f(CW\*(C`f\*(C'\fR the result string is \f(CW\*(C`f:Foo Bar\*(C'\fR. +.IP "\fB\-P\fR, \fB\-\-position\-result\fR" 4 +.IX Item "-P, --position-result" Prefix the result string (given on \fIstdout\fR) with the corresponding cursor position followed by a colon. When you selected line \fIN\fR and this line has -the result \f(CWFoo Bar\fR configured the result string is ``\f(CWN:Foo Bar\fR'\*(R'. -.Ip "\fB\-Q\fR \fI\s-1STR\s0\fR, \fB--quit-result=\fR\fI\s-1STR\s0\fR" 4 +the result \f(CW\*(C`Foo Bar\*(C'\fR configured the result string is \f(CW\*(C`N:Foo Bar\*(C'\fR. +.IP "\fB\-Q\fR \fI\s-1STR\s0\fR, \fB\-\-quit\-result=\fR\fI\s-1STR\s0\fR" 4 +.IX Item "-Q STR, --quit-result=STR" Sets the result string on quit. Default is the empty string. .Sh "Giving Feedback" -.Ip "\fB\-V\fR, \fB--version\fR" 4 +.IX Subsection "Giving Feedback" +.IP "\fB\-V\fR, \fB\-\-version\fR" 4 +.IX Item "-V, --version" Displays version identification string. .SH "KEYSTROKES" +.IX Header "KEYSTROKES" .Sh "Cursor Movement" +.IX Subsection "Cursor Movement" Use these to browse through the selection list. .PP .Vb 6 -\& CURSOR-UP ..... Move cursor one line up -\& CURSOR-DOWN ... Move cursor one line down -\& PAGE-UP ....... Move cursor one page up -\& PAGE-DOWN ..... Move cursor one page down +\& CURSOR\-UP ..... Move cursor one line up +\& CURSOR\-DOWN ... Move cursor one line down +\& PAGE\-UP ....... Move cursor one page up +\& PAGE\-DOWN ..... Move cursor one page down \& g ............. Goto first line \& G ............. Goto last line .Ve .Sh "Line Selection" +.IX Subsection "Line Selection" Use these to select one line and exit in standard mode or one or more lines in multi-line mode. .PP -.Vb 3 +.Vb 4 \& RETURN ........ Select line and exit -\& CURSOR-RIGHT .. Select line and exit -\& SPACE ......... Select line and stay (multi-line mode only) +\& CURSOR\-RIGHT .. Select line and exit +\& SPACE ......... Select line and stay (multi\-line mode only) +\& C ............. Clear current marks (multi\-line mode only) .Ve +.PP +Note: the \f(CW\*(C`C\*(C'\fR keystroke is a Debian extension to iSelect 1.2.0, which +has been reported to Ralf S. Engelschall. .Sh "Others" +.IX Subsection "Others" Use these to quit iSelect or to show its help and version page. .PP .Vb 4 \& q ............. Quit (exit without selection) -\& CURSOR-LEFT ... Quit (exit without selection) +\& CURSOR\-LEFT ... Quit (exit without selection) \& h ............. Help Page \& v ............. Version Page .Ve .SH "EXAMPLE" +.IX Header "EXAMPLE" As an example we present a real-life situation where iSelect can enhance an existing functionality. We define two Bash functions (for your -\fI$HOME/.bashrc\fR file) which enhance the built-in `\fIcd\fR\*(R' command of the +\&\fI$HOME/.bashrc\fR file) which enhance the built-in \fIcd\fR command of the shell. .PP .Vb 7 \& # database scan for enhanced cd command \& cds () { \& (cd $HOME; -\& find . -type d -print |\e -\& sed -e "s;^\e.;$HOME;" |\e -\& sort -u >$HOME/.cdpaths ) & +\& find . \-type d \-print |\e +\& sed \-e "s;^\e.;$HOME;" |\e +\& sort \-u >$HOME/.cdpaths ) & \& } .Ve +.PP .Vb 11 \& # definition of the enhanced cd command \& cd () { -\& if [ -d $1 ]; then +\& if [ \-d $1 ]; then \& builtin cd $1 \& else \& builtin cd `egrep "/$1[^/]*$" $HOME/.cdpaths |\e -\& iselect -a -Q $1 -n "chdir" \e -\& -t "Change Directory to..."` +\& iselect \-a \-Q $1 \-n "chdir" \e +\& \-t "Change Directory to..."` \& fi \& PS1="\eu@\eh:$PWD\en:> " \& } .Ve -This new `\fIcd\fR\*(R' command is compatible with Bashs built-in variant for the case +.PP +This new \fIcd\fR command is compatible with Bashs built-in variant for the case where the specified directory actually exists. When it doesn't, the original -`\fIcd\fR\*(R' would immediately give an error (assuming we have no \fICDPATH\fR +\&\fIcd\fR would immediately give an error (assuming we have no \fI\s-1CDPATH\s0\fR variable defined). Here this enhanced version tries harder. First it searches for such a directory in a previously built (via \fIcds\fR) \fI$HOME/.cdpaths\fR files. When no line was found, iSelect just returns the given directory as the -default result and `\fIcd\fR\*(R' then fails as usual with an error message. When +default result and \fIcd\fR then fails as usual with an error message. When only one directory was found, iSelect directly results this particular line to -`\fIcd\fR\*(R'. And only when more then one directory was found, iSelect opens its +\&\fIcd\fR. And only when more then one directory was found, iSelect opens its Curses-based selection screen and lets the user choose interactively between -those directories. The chosen directory is then finally given to `\fIcd\fR\*(R'. +those directories. The chosen directory is then finally given to \fIcd\fR. .PP For more useful examples on how to use iSelect, see the \fIcontrib/\fR directory of the iSelect distribution tarball. .SH "AUTHOR" -.PP +.IX Header "AUTHOR" .Vb 3 \& Ralf S. Engelschall \& rse@engelschall.com \& www.engelschall.com .Ve .SH "SEE ALSO" -.PP +.IX Header "SEE ALSO" .Vb 1 \& iSelect Home: http://www.engelschall.com/sw/iselect/ .Ve - -.rn }` '' -.IX Title "ISELECT 1" -.IX Name "iSelect - Interactive Selection Tool" - -.IX Header "NAME" - -.IX Header "SYNOPSIS" - -.IX Header "VERSION" - -.IX Header "DESCRIPTION" - -.IX Subsection "Intend" - -.IX Subsection "Input Data" - -.IX Subsection "Selections" - -.IX Subsection "Output Data" - -.IX Header "OPTIONS" - -.IX Subsection "Input Options" - -.IX Item "\fB\-d\fR \fI\s-1STR\s0\fR, \fB--delimiter=\fR\fI\s-1STR\s0\fR" - -.IX Item "\fB\-c\fR, \fB--strip-comments\fR" - -.IX Item "\fB\-f\fR, \fB--force-browse\fR" - -.IX Item "\fB\-a\fR, \fB--all-select\fR" - -.IX Item "\fB\-e\fR, \fB--exit-no-select\fR" - -.IX Subsection "Display Options" - -.IX Item "\fB\-p\fR \fI\s-1NUM\s0\fR, \fB--position=\fR\fI\s-1NUM\s0\fR" - -.IX Item "\fB\-k\fR \fI\s-1KEY\s0\fR[:\fI\s-1OKEY\s0\fR], \fB--key=\fR\fI\s-1KEY\s0[:\fI\s-1OKEY\s0\fR]\fR" - -.IX Item "\fB\-m\fR, \fB--multi-line\fR" - -.IX Item "\fB\-n\fR \fI\s-1STR\s0\fR, \fB--name=\fR\fI\s-1STR\s0\fR" - -.IX Item "\fB\-t\fR \fI\s-1STR\s0\fR, \fB--title=\fR\fI\s-1STR\s0\fR" - -.IX Subsection "Output Options" - -.IX Item "\fB\-S\fR, \fB--strip-result\fR" - -.IX Item "\fB\-K\fR, \fB--key-result\fR" - -.IX Item "\fB\-P\fR, \fB--position-result\fR" - -.IX Item "\fB\-Q\fR \fI\s-1STR\s0\fR, \fB--quit-result=\fR\fI\s-1STR\s0\fR" - -.IX Subsection "Giving Feedback" - -.IX Item "\fB\-V\fR, \fB--version\fR" - -.IX Header "KEYSTROKES" - -.IX Subsection "Cursor Movement" - -.IX Subsection "Line Selection" - -.IX Subsection "Others" - -.IX Header "EXAMPLE" - -.IX Header "AUTHOR" - -.IX Header "SEE ALSO" - --- iselect-1.2.0.orig/iselect.pod +++ iselect-1.2.0/iselect.pod @@ -65,9 +65,9 @@ iSelect is an interactive line selection tool for ASCII files, operating via a full-screen Curses-based terminal session. It can be used either as an user interface frontend controlled by a Bourne-Shell, Perl or other type of script -backend as its wrapper or in batch as a pipe filter (usually between F +backend as its wrapper, or in batch as a pipe filter (usually between F and the final executing command). In other words: iSelect was designed to be -used for any types of interactice line-based selections. +used for any type of interactive line-based selection. =head2 Input Data @@ -78,28 +78,28 @@ You can additionally let substrings displayed in Bold mode for non-selectable lines (because the selectable lines are always displayed bold) by using the -construct ``CbE>...C/bE>'' as in HTML. +construct CbE>...C/bE> as in HTML. =head2 Selections The selection is either just a single line (default) or multiple lines (option B<-m>). Per default no lines are selectable. If a line contains the string -``CsE>'' (or a string with different delimiters configured via +CsE> (or a string with different delimiters configured via option B<-d>) at any position this string is stripped and the line is selectable. Its result (printed to F) is the line contents itself (but -without the ``CsE>'' string of course). If option B<-a> is used all +without the CsE> string of course). If option B<-a> is used all lines are selectable and their result is again the line itself, i.e. using -option B<-a> is the same as adding ``CsE>'' to every line of the +option B<-a> is the same as adding CsE> to every line of the input data. When you want a specific result (i.e. not just the line contents -itself), you have to use the special variant ``Cs:result textE>'' -which results in the output ``C'' when the corresponding line is +itself), you have to use the special variant Cs:result textE> +which results in the output C when the corresponding line is selected. -When you use a specific result via ``Cs:result textE>'' the I can contain ``C<%s[query text]s>'' and ``C<%s[query text]S>'' +When you use a specific result via Cs:result textE> the I +can contain C<%s[query text]s> and C<%s[query text]S> constructs. For every such construct an interactive query is done and the -result replaces the construct. The ``C<%s[query text]S>'' construct is like -``C<%s[query text]s>'' except that the empty string as the query result is not +result replaces the construct. The C<%s[query text]S> construct is like +C<%s[query text]s> except that the empty string as the query result is not accepted on input. The Curses-based full-screen selection is always done via F, because @@ -108,9 +108,9 @@ =head2 Output Data -The output is the line itself or the string given with ``Cs:result -textE>''. When multiple line selection mode (option B<-m>) is used the -output is all selected lines theirself or their configured result strings. +The output is the line itself or the string given with Cs:result textE>. +When multiple line selection mode (option B<-m>) is used the +output is all selected lines, or their configured result strings. Output always is written to F. =head1 OPTIONS @@ -123,9 +123,8 @@ =item B<-d> I, B<--delimiter=>I -Sets the delimiters for the selection tags. The default is `C,E>', -i.e. the selection tags have to read ``CsE>'' and ``Cs:result -textE>'' +Sets the delimiters for the selection tags. The default is C,E>, +i.e. the selection tags have to read CsE> and Cs:result textE>. =item B<-c>, B<--strip-comments> @@ -157,7 +156,7 @@ =item B<-k> I[:I], B<--key=>I]> Defines an additional input key. Per default I is C, i.e. for -instance B<-kf> defines another selection key `C'. +instance B<-kf> defines another selection key C. =item B<-m>, B<--multi-line> @@ -189,14 +188,13 @@ Prefix the result string (given on F) with the corresponding selection key which was used. This usually is C or C but can be any of the additional keys defined by option B<-k>. When you use B<-kf> and -select a line C with key `C' the result string is ``C''. +select a line C with key C the result string is C. =item B<-P>, B<--position-result> Prefix the result string (given on F) with the corresponding cursor position followed by a colon. When you selected line I and this line has -the result C configured the result string is ``C''. +the result C configured the result string is C. =item B<-Q> I, B<--quit-result=>I @@ -235,6 +233,10 @@ RETURN ........ Select line and exit CURSOR-RIGHT .. Select line and exit SPACE ......... Select line and stay (multi-line mode only) + C ............. Clear current marks (multi-line mode only) + +Note: the C keystroke is a Debian extension to iSelect 1.2.0, which +has been reported to Ralf S. Engelschall. =head2 Others @@ -250,7 +252,7 @@ As an example we present a real-life situation where iSelect can enhance an existing functionality. We define two Bash functions (for your -F<$HOME/.bashrc> file) which enhance the built-in `F' command of the +F<$HOME/.bashrc> file) which enhance the built-in F command of the shell. # database scan for enhanced cd command @@ -273,17 +275,17 @@ PS1="\u@\h:$PWD\n:> " } -This new `F' command is compatible with Bashs built-in variant for the case +This new F command is compatible with Bashs built-in variant for the case where the specified directory actually exists. When it doesn't, the original -`F' would immediately give an error (assuming we have no F +F would immediately give an error (assuming we have no F variable defined). Here this enhanced version tries harder. First it searches for such a directory in a previously built (via F) F<$HOME/.cdpaths> files. When no line was found, iSelect just returns the given directory as the -default result and `F' then fails as usual with an error message. When +default result and F then fails as usual with an error message. When only one directory was found, iSelect directly results this particular line to -`F'. And only when more then one directory was found, iSelect opens its +F. And only when more then one directory was found, iSelect opens its Curses-based selection screen and lets the user choose interactively between -those directories. The chosen directory is then finally given to `F'. +those directories. The chosen directory is then finally given to F. For more useful examples on how to use iSelect, see the F directory of the iSelect distribution tarball. --- iselect-1.2.0.orig/iselect_browse.c +++ iselect-1.2.0/iselect_browse.c @@ -55,6 +55,9 @@ void strip(char *string); void diehard(void); void diesoft(void); +void diealloc(void); +void *smalloc(size_t size); +void *srealloc(void *ptr, size_t size); void setup(void); char *iSelect_InputField(int wYSize, int wXSize, int wYPos, int wXPos, int bAllowEmpty); void iSelect_Draw(WINDOW *wField, @@ -78,7 +81,7 @@ /* * GLOBALS */ -struct Line *spaLines[MAXLINES]; /* filled by iSelect() */ +struct Line **spaLines; /* filled by iSelect() */ int nLines; @@ -132,6 +135,29 @@ endwin(); /* make terminal the way it was */ } +void diealloc(void) +{ + fprintf(stderr, "Memory allocation error... aborting\n"); + diesoft(); + exit(EX_OSERR); +} + +void *smalloc(size_t size) +{ + char *ptr = (char *) malloc(size); + if (NULL == ptr) + diealloc(); + return (void *)ptr; +} + +void *srealloc(void *ptr, size_t size) +{ + ptr = (void *) realloc(ptr, size); + if (NULL == ptr) + diealloc(); + return (void *)ptr; +} + /* * Startup with trapping of interrupt signal */ @@ -154,11 +180,13 @@ int nBufCurPos; int nScrCurPos; int bEOI; - char caBuf[1024]; char *cpBuf; + int cpBufLen; int i; - cpBuf = caBuf; + cpBufLen = 1024; + cpBuf = (char *) smalloc(cpBufLen+1); + cpBuf[0] = NUL; wField = newwin(wYSize, wXSize, wYPos, wXPos); keypad(wField, TRUE); @@ -188,7 +216,7 @@ bEOI = TRUE; } else if (c == 0x1b) { /* ESCAPE */ - strcpy(caBuf, "ESC"); + strcpy(cpBuf, "ESC"); bEOI = TRUE; } else if (c == 0x04) { /* DELETE */ @@ -231,6 +259,10 @@ } nScrCurPos--; /* neutralize following increment */ } + if (nBufEnd >= cpBufLen) { + cpBufLen += 1024; + cpBuf = (char *) srealloc((void *)cpBuf, cpBufLen+1); + } cpBuf[nBufEnd++] = c; nBufCurPos++; nScrCurPos++; @@ -243,7 +275,7 @@ fflush(stdin); delwin(wField); - return strdup(caBuf); + return cpBuf; } /* @@ -260,17 +292,21 @@ { int i, j, k, mode; int percent; + /* Buffer containing "%4d,%3d%%" */ char ca[80]; - char boldbegin[1024]; + char *boldbegin; int nboldbegin; - char boldend[1024]; + char *boldend; int nboldend; /* * create actual bold tags */ + boldbegin = (char *) smalloc(strlen(tagbegin)+strlen(tagend)+2); sprintf(boldbegin, "%sb%s", tagbegin, tagend); nboldbegin = strlen(boldbegin); + + boldend = (char *) smalloc(strlen(tagbegin)+strlen(tagend)+3); sprintf(boldend, "%s/b%s", tagbegin, tagend); nboldend = strlen(boldend); @@ -294,7 +330,7 @@ waddstr(wField, "*"); else waddstr(wField, " "); /* cursor pos == first blank */ - for (j = k = 0; spaLines[nAbsFirstLine+nRelFirstDraw+i]->cpLine[j] != NUL && j <= (wXSize-1)-2;) { + for (j = k = 0; spaLines[nAbsFirstLine+nRelFirstDraw+i]->cpLine[j] != NUL && k <= (wXSize-1)-2;) { if (strniEQ(&spaLines[nAbsFirstLine+nRelFirstDraw+i]->cpLine[j], boldbegin, nboldbegin)) { mode = mode | A_BOLD; wattrset(wField, mode); @@ -316,6 +352,8 @@ wattrset(wField, A_NORMAL); } wmove(wField, nRelMarked, (wXSize-1)-1); + free(boldbegin); + free(boldend); /* * draw status bar @@ -331,9 +369,10 @@ waddstr(sField, name); wmove(sField, 0, COLS-10); - percent = (int)(((nAbsFirstLine+nRelMarked)*100)/nLines); - if (1+nAbsFirstLine+nRelMarked == nLines) + if ((1+nAbsFirstLine+nRelMarked == nLines) || nLines == 0) percent = 100; + else + percent = (int)(((nAbsFirstLine+nRelMarked)*100)/nLines); sprintf(ca, "%4d,%3d%%", 1+nAbsFirstLine+nRelMarked, percent); waddstr(sField, ca); @@ -377,13 +416,17 @@ int bQuit = FALSE; int y; int x; - char msg[1024]; - char ca[1024]; - char ca3[1024]; + int voffset; + /* Static messages */ + char msg[128]; + int caLen; + char *ca; + char *ca3; char *cp; char *cp2; char *cp3; char **cpp; + int cppsize; int ok; int bAllowEmpty; @@ -602,14 +645,18 @@ /* additionally ask for query strings */ if (bEOI == TRUE) { cp = spaLines[nAbsFirstLine+nRelMarked]->cpResult; + caLen = 1024; + ca = (char *) smalloc(caLen+1); cp2 = ca; while (bEOI == TRUE && *cp != NUL) { if (strnEQ(cp, "%[", 2)) { cp += 2; for (cp3 = cp; !strniEQ(cp3, "]s", 2); cp3++) ; + ca3 = (char *) smalloc(cp3-cp+3); strncpy(ca3, cp, cp3-cp); ca3[cp3-cp] = NUL; + strcat(ca3, ": "); cp = cp3+1; if (*cp == 's') bAllowEmpty = TRUE; @@ -617,10 +664,10 @@ bAllowEmpty = FALSE; cp++; - sprintf(msg, "%s: ", ca3); - iSelect_Draw(wField, wYSize, wXSize, wYPos, wXPos, nAbsFirstLine, nAbsLastLine, -1, nRelFirstDraw, nRelLastDraw, nLines, sField, title, name, mField, msg, tagbegin, tagend); + iSelect_Draw(wField, wYSize, wXSize, wYPos, wXPos, nAbsFirstLine, nAbsLastLine, -1, nRelFirstDraw, nRelLastDraw, nLines, sField, title, name, mField, ca3, tagbegin, tagend); wrefresh(wField); - cp3 = iSelect_InputField(mYSize, mXSize-strlen(msg), mYPos, mXPos+strlen(msg), bAllowEmpty); + cp3 = iSelect_InputField(mYSize, mXSize-strlen(ca3), mYPos, mXPos+strlen(ca3), bAllowEmpty); + free(ca3); if (strEQ(cp3, "ESC")) { bEOI = FALSE; spaLines[nAbsFirstLine+nRelMarked]->fSelected = FALSE; @@ -628,6 +675,12 @@ continue; } strcpy(msg, ""); + if (cp2-ca+strlen(cp3) >= caLen) { + caLen += strlen(cp3); + i = cp2-ca; + ca = (char *) srealloc(ca, caLen+1); + cp2 = ca + i; + } strcpy(cp2, cp3); cp2 += strlen(cp3); } @@ -640,6 +693,7 @@ if (strNE(spaLines[nAbsFirstLine+nRelMarked]->cpResult, ca)) spaLines[nAbsFirstLine+nRelMarked]->cpResult = strdup(ca); } + free(ca); } } } @@ -663,6 +717,15 @@ strcpy(msg, "No multi-line selection allowed."); } } + else if (c == 'C') { + if (multiselect) { + for (i = nFirstLine; i < nLastLine; i++) + spaLines[i]->fSelected = FALSE; + } + else { + strcpy(msg, "No multi-line selection."); + } + } else if (c == 'q') { bEOI = TRUE; bQuit = TRUE; @@ -718,14 +781,22 @@ wrefresh(wField); hField = newwin(wYSize, wXSize, wYPos, wXPos); - werase(hField); if (c == 'h') cpp = iSelect_Help; else cpp = iSelect_README; - for (y = 0; y < wYSize && cpp[y] != NULL; y++) { - sprintf(ca, cpp[y]); - cp = ca; + voffset = 0; + while (1) { + for (cppsize = 0; cpp[cppsize] != NULL; cppsize++) + ; + if (voffset > cppsize - wYSize) + voffset = cppsize - wYSize; + if (voffset < 0) + voffset = 0; + werase(hField); + for (y = 0; y < wYSize && cpp[y+voffset] != NULL; y++) { + cp3 = strdup(cpp[y+voffset]); + cp = cp3; x = 0; while (1) { if ((cp2 = strstr(cp, "")) != NULL) { @@ -744,13 +815,28 @@ break; } } + free(cp3); } - wrefresh(hField); - while (1) { + wrefresh(hField); c = wgetch(wField); - c = c & 0xff; /* strip down to 8bit */ if (c == 'q') break; + else if (c == KEY_UP) + --voffset; + else if (c == KEY_DOWN) + ++voffset; + else if (c == KEY_PPAGE) + voffset -= wYSize; + else if (c == KEY_NPAGE) + voffset += wYSize; + else if (c == 'g') + voffset = 0; + else if (c == 'G') + voffset = cppsize - wYSize; + else if (c == 'h') + cpp = iSelect_Help; + else if (c == 'v') + cpp = iSelect_README; } delwin(hField); @@ -794,8 +880,7 @@ { WINDOW *wMain; int i, j, k; - char ca[MAXLINELEN], ca2[MAXLINELEN]; - char ca3[MAXLINELEN]; + char *ca, *ca2, *ca3; char *cp, *cps, *cpe; struct Line *spLine; int rc; @@ -806,6 +891,16 @@ * spaLines array of browsable strings */ j = 0; + /* + * count lines + */ + nLines = 1; + for (i = 0; caBuf[i] != NUL; i++) + if (caBuf[i] == NL) + nLines++; + spaLines = (struct Line **) smalloc(sizeof(struct Line *) * nLines); + ca = (char *) smalloc(strlen(caBuf)+1); + nLines = 0; for (i = 0; caBuf[i] != NUL; i++) { if (caBuf[i] != NL) { @@ -823,8 +918,10 @@ continue; } - spLine = (struct Line *)malloc(sizeof(struct Line)); + spLine = (struct Line *)smalloc(sizeof(struct Line)); + ca2 = (char *) smalloc(strlen(ca)+strlen(tagbegin)+2); + ca3 = (char *) smalloc(strlen(ca)+strlen(tagbegin)+2); sprintf(ca2, "%ss", tagbegin); sprintf(ca3, "%sS", tagbegin); if ( (cp = strstr(ca, ca2)) != NULL @@ -870,8 +967,11 @@ if (stripws) strip(spLine->cpResult); spaLines[nLines++] = spLine; + free(ca2); + free(ca3); } } + free(ca); #ifdef DEBUG for (i = 0; i < nLines; i++) { printf("spaLines[%d] = {\n", i); --- iselect-1.2.0.orig/iselect_browse.h +++ iselect-1.2.0/iselect_browse.h @@ -38,11 +38,7 @@ char *cpResult; /* the result string */ } Line; -#define MAXLINELEN 1024 -#define MAXLINES 1024 -#define MAXBUF MAXLINELEN*MAXLINES - -extern struct Line *spaLines[MAXLINES]; +extern struct Line **spaLines; extern int nLines; /* --- iselect-1.2.0.orig/iselect_help.c +++ iselect-1.2.0/iselect_help.c @@ -23,6 +23,7 @@ " RETURN ........ Select line and exit", " CURSOR-RIGHT .. Select line and exit", " SPACE ......... Select line and stay (multi-line mode only)", +" C ............. Clear current marks (multi-line mode only)", "", " Others:", " q ............. Quit (exit without selection)", --- iselect-1.2.0.orig/iselect_help.txt +++ iselect-1.2.0/iselect_help.txt @@ -18,6 +18,7 @@ RETURN ........ Select line and exit CURSOR-RIGHT .. Select line and exit SPACE ......... Select line and stay (multi-line mode only) + C ............. Clear current marks (multi-line mode only) Others: q ............. Quit (exit without selection) --- iselect-1.2.0.orig/iselect_keys.c +++ iselect-1.2.0/iselect_keys.c @@ -64,7 +64,7 @@ { "KEY_DOWN", KEY_DOWN }, { "KEY_NPAGE", KEY_NPAGE }, { "KEY_PPAGE", KEY_PPAGE }, - { NULL, NULL } + { NULL, NUL } }; char *key2asc(int key) --- iselect-1.2.0.orig/iselect_main.c +++ iselect-1.2.0/iselect_main.c @@ -89,6 +89,7 @@ } struct option options[] = { + { "delimiter", TRUE, NULL, 'd' }, { "strip-comments", FALSE, NULL, 'c' }, { "force-browse", FALSE, NULL, 'f' }, { "all-select", FALSE, NULL, 'a' }, @@ -107,8 +108,6 @@ { NULL, FALSE, NULL, '\0' }, }; -char caBuf[MAXBUF]; - int main(int argc, char **argv) { int fpStdout; @@ -118,7 +117,8 @@ int pos = -1; char *progname; int nBuf, p; - char ca[1024]; + /* This buffer is used to store the string representation of an int */ + char ca[22]; char *title = ""; char *name = "iSelect"; int stripco = FALSE; @@ -134,6 +134,8 @@ char *abortstr = NULL; char *tagbegin = "<"; char *tagend = ">"; + char *caBuf; + int caBufLen; /* * argument handling @@ -222,20 +224,31 @@ * read input */ + nBuf = 0; + caBufLen = 1024; + caBuf = (char *) malloc(caBufLen+1); + caBuf[0] = NUL; if (optind < argc) { /* browsing text is given as arguments */ - nBuf = 0; for (; optind < argc; ++optind) { cp = (argv[optind] == NULL ? "" : argv[optind]); - sprintf(caBuf+nBuf, "%s\n", cp); - nBuf += strlen(cp)+1; + if (nBuf+strlen(cp)+1 >= caBufLen) { + caBufLen += strlen(cp)+1; + caBuf = (char *) realloc((void *)caBuf, caBufLen+1); + } + strcpy(caBuf+nBuf, cp); + nBuf += strlen(cp); + caBuf[nBuf++] = NL; } caBuf[nBuf++] = NUL; } else if (optind == argc && !feof(stdin)) { /* browsing text is given on stdin */ - nBuf = 0; while ((c = fgetc(stdin)) != (char)(EOF)) { + if (nBuf >= caBufLen) { + caBufLen += 1024; + caBuf = (char *) realloc((void *)caBuf, caBufLen+1); + } caBuf[nBuf++] = c; } caBuf[nBuf++] = NUL; @@ -272,16 +285,16 @@ for (i = 0; i < nLines; i++) { if (spaLines[i]->fSelected) { if (resultline) { - sprintf(ca, "%d:", i+1); + sprintf(ca, "%d", i+1); write(fpStdout, ca, strlen(ca)); + write(fpStdout, ":", 1); } if (keyresultline) { - sprintf(ca, "%s:", keystr); - write(fpStdout, ca, strlen(ca)); + write(fpStdout, keystr, strlen(keystr)); + write(fpStdout, ":", 1); } write(fpStdout, spaLines[i]->cpResult, strlen(spaLines[i]->cpResult)); - sprintf(ca, "\n"); - write(fpStdout, ca, strlen(ca)); + write(fpStdout, "\n", 1); } } } --- iselect-1.2.0.orig/debian/watch +++ iselect-1.2.0/debian/watch @@ -0,0 +1,5 @@ +# watch control file for uscan +version=2 + +ftp://ftp.ossp.org/pkg/tool/iselect/ \ + iselect-(.*).tar.gz --- iselect-1.2.0.orig/debian/changelog +++ iselect-1.2.0/debian/changelog @@ -0,0 +1,157 @@ +iselect (1.2.0-12) unstable; urgency=low + + * Fix typos in iselect.1 manual page. Closes: #301887 + Thanks, A Costa. + * debian/control: Add Homepage to the desription. + * debian/copyright: Update project homepage. + + -- Denis Barbier Sun, 10 Apr 2005 22:15:15 +0200 + +iselect (1.2.0-11) unstable; urgency=low + + * Bold markers were not removed when computing line length, and thus + lines were wrongly truncated. Closes: #283620 + Thanks, A Costa. + * debian/control: Update URL to http://www.ossp.org/pkg/tool/iselect/ + * debian/watch: Update URL and convert to new format. + + -- Denis Barbier Sun, 5 Dec 2004 22:51:24 +0100 + +iselect (1.2.0-10) unstable; urgency=low + + * Recognize the --delimiter flag as an alias for -d, it is documented + and thus should be defined. Closes: #282577 + Thanks, A Costa. + + -- Denis Barbier Wed, 24 Nov 2004 00:14:44 +0100 + +iselect (1.2.0-9) unstable; urgency=low + + * Remove all fixed size buffers. + Closes: Bug#219269 Thanks Philipp Meier. + + -- Denis Barbier Wed, 5 Nov 2003 22:01:10 +0100 + +iselect (1.2.0-8) unstable; urgency=low + + * Activate navigation keys when displaying help or readme pages + (Closes: Bug#208186) Thanks Helge Kreutzmann + * Bump Standards-Version: 3.6.1, no changes needed + + -- Denis Barbier Sat, 13 Sep 2003 22:21:03 +0200 + +iselect (1.2.0-7) unstable; urgency=low + + * Remove spurious quotes from iselect.1 man page. + Closes: Bug#207589 Thanks Dan Jacobson. + + -- Denis Barbier Sat, 30 Aug 2003 18:46:58 +0200 + +iselect (1.2.0-6) unstable; urgency=low + + * example/scvs/scvs: Replace File::PathConvert by File::Spec + + -- Denis Barbier Wed, 9 Oct 2002 23:59:05 +0200 + +iselect (1.2.0-5) unstable; urgency=low + + * New maintainer (closes: Bug#119088). + * Prevent crash with empty input (closes: Bug#81159). + * Make /usr/share/doc/iselect/examples/scvs/scvs work with Term::ANSIColor + instead of Term::Cap, and another fix was applied to deal with new + versions of File::PathConvert (closes: Bug#98547). + * Add a keystroke to clear marks (closes: Bug#63156). + * Upgraded to standards version 3.5.6 + * Remove Emacs crap from debian/changelog + + -- Denis Barbier Mon, 17 Dec 2001 00:02:42 +0100 + +iselect (1.2.0-4) unstable; urgency=low + + * Upgraded to standards version 3.2.1 + + -- Brian Bassett Fri, 29 Sep 2000 11:26:16 -0700 + +iselect (1.2.0-3) unstable; urgency=low + + * New maintainer. + + -- Brian Bassett Wed, 1 Dec 1999 11:54:48 -0800 + +iselect (1.2.0-2) unstable; urgency=low + + * Partially upgraded to standards version 3.0.1: + - Updated copyright to point to /usr/share/common-licenses + - Put man page under /usr/share/man (closes: Bug#42325). + * [debian/control]: Suggests: perl5, libtimedate-perl. + Thanks to Lintian's suggestions. :-) + + -- Anthony Fok Wed, 25 Aug 1999 07:32:08 -0600 + +iselect (1.2.0-1) unstable; urgency=low + + * New upstream release. + * Upgraded to standards version 2.5.0 (no changes). + + -- Anthony Fok Thu, 15 Apr 1999 00:16:03 -0600 + +iselect (1.1.0-2) frozen unstable; urgency=low + + * [debian/control]: Changed the short package description from + "Interactive Selection Tool" to "An interactive line selection tool + for ASCII files", thanks to the suggestion by Chris Fearnley + . + + -- Anthony Fok Mon, 26 Oct 1998 00:42:32 -0700 + +iselect (1.1.0-1) unstable; urgency=low + + * New upstream release. + * [./etc/asc2c]: Changed "#!/sw/bin/perl" to "#!/usr/bin/perl". + * [debian/copyright]: Added "1998". :-) + + -- Anthony Fok Wed, 17 Jun 1998 09:19:29 -0600 + +iselect (1.0.4-3) frozen unstable; urgency=low + + * debian/rules + - Removed dh_du. (Fixed Lintian error: unknown-control-file du) + - Added a hack so that the example perl scripts are not compressed. + (Fixed Lintian warnings: + executable-not-elf-or-script usr/doc/iselect/examples/mtin/mtin.gz + executable-not-elf-or-script usr/doc/iselect/examples/scvs/scvs.gz) + * Upgraded to standards version 2.4.1.0 (no changes). + + -- Anthony Fok Mon, 11 May 1998 05:02:00 -0600 + +iselect (1.0.4-2) unstable; urgency=low + + * /usr/doc/iselect/copyright now refers to the uncompressed versions + of GPL and Artistic copyright files. (Thanks to the Lintian Report!) + + -- Anthony Fok Tue, 10 Feb 1998 01:02:31 -0700 + +iselect (1.0.4-1) unstable; urgency=low + + * New upstream release. + * Patched various files in /usr/doc/iselect/examples to fix the path + names for Debian. + + -- Anthony Fok Wed, 7 Jan 1998 17:30:00 -0700 + +iselect (1.0.3-2) unstable; urgency=low, closes=16637 + + * /usr/doc/iselect/{INSTALL,PORTING,VERSIONS} are no longer installed. + (Bug#16637) + * Changed the first line from the non-existent #!/sw/bin/perl + to #!/usr/bin/perl in various contributed iSelect tools under + /usr/doc/iselect/contrib. + + -- Anthony Fok Mon, 5 Jan 1998 20:01:30 -0700 + +iselect (1.0.3-1) unstable; urgency=low + + * Initial Release. + + -- Anthony Fok Tue, 23 Dec 1997 04:24:44 -0700 + --- iselect-1.2.0.orig/debian/control +++ iselect-1.2.0/debian/control @@ -0,0 +1,19 @@ +Source: iselect +Section: utils +Priority: optional +Maintainer: Denis Barbier +Standards-Version: 3.6.1 +Build-Depends: debhelper, libncurses5-dev + +Package: iselect +Architecture: any +Depends: ${shlibs:Depends} +Suggests: perl | perl5, libtimedate-perl +Description: An interactive line selection tool for ASCII files + iSelect is an interactive line selection tool for ASCII files, operating + via a full-screen Curses-based terminal session. It can be used either as + an user interface frontend controlled by a Bourne-Shell/Perl/Tcl backend + as its control script or in batch mode as a pipeline filter (usually + between grep and the final executing command). + . + Homepage: http://www.ossp.org/pkg/tool/iselect/ --- iselect-1.2.0.orig/debian/copyright +++ iselect-1.2.0/debian/copyright @@ -0,0 +1,33 @@ +This package was debianized by Denis Barbier on +Sun, 10 Apr 2005 22:23:58 +0200. + +It was downloaded from: + http://www.ossp.org/pkg/tool/iselect/ + +Previous Debian maintainers: + * Anthony Fok 1997-1999. + +Copyright: + + iSelect -- Interactive Selection Tool + Copyright (c) 1996,1997,1998 Ralf S. Engelschall. + + This program is free software; it may be redistributed and/or modified + only under the terms of either the Artistic License or the GNU General + Public License, which may be found in the ePerl source distribution. + Look at the files ARTISTIC and COPYING or run ``eperl -l'' to receive + a built-in copy of both license files. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See either the + Artistic License or the GNU General Public License for more details. + + Ralf S. Engelschall + rse@engelschall.com + www.engelschall.com + + +On Debian GNU/Linux systems, the GNU General Public License (GPL) and the +Artistic License may be found in `/usr/share/common-licenses/GPL' and +`/usr/share/common-licenses/Artistic' respectively. --- iselect-1.2.0.orig/debian/rules +++ iselect-1.2.0/debian/rules @@ -0,0 +1,64 @@ +#!/usr/bin/make -f +# Sample debian/rules that uses debhelper. GNU copyright 1997 by Joey Hess. + +package = iselect + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + +build: build-stamp +build-stamp: + dh_testdir + ./configure --prefix=/usr --mandir='$${prefix}/share/man' + $(MAKE) + touch build-stamp + +clean: + dh_testdir + dh_testroot + rm -f build-stamp + -$(MAKE) distclean + dh_clean + +# Build architecture-independent files here. +binary-indep: build +# There are no architecture-independent files to be uploaded +# generated by this package. If there were any they would be +# made here. + +# Build architecture-dependent files here. +binary-arch: build + dh_testdir + dh_testroot + dh_clean -k + dh_installdirs + + # Add here commands to install the files into debian/tmp + $(MAKE) install prefix=`pwd`/debian/tmp/usr + + dh_installdocs README +# dh_installmenu +# dh_installinit +# dh_installcron +# dh_installmanpages +# dh_undocumented + dh_installchangelogs ChangeLog + dh_strip + dh_compress + + # We don't want to compress the perl scripts. :-) + dh_installexamples example/* + + dh_fixperms + dh_installdeb + dh_shlibdeps + dh_gencontrol +# dh_makeshlibs + dh_md5sums + dh_builddeb + +source diff: + @echo >&2 'source and diff are obsolete - use dpkg-source -b'; false + +binary: binary-indep binary-arch +.PHONY: build clean binary-indep binary-arch binary