summaryrefslogtreecommitdiffstats
path: root/contrib/nvi/perl_scripts
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>1996-11-01 06:45:43 +0000
committerpeter <peter@FreeBSD.org>1996-11-01 06:45:43 +0000
commit59cc89c2c2e686da3bdab2d5cfac4f33462d29fe (patch)
tree88f923c9c0be2e2a225a9b21716fd582de668b42 /contrib/nvi/perl_scripts
downloadFreeBSD-src-59cc89c2c2e686da3bdab2d5cfac4f33462d29fe.zip
FreeBSD-src-59cc89c2c2e686da3bdab2d5cfac4f33462d29fe.tar.gz
Import of nvi-1.79, minus a few bits that we dont need (eg: postscript
files, curses, db, regex etc that we already have). The other glue will follow shortly. Obtained from: Keith Bostic <bostic@bostic.com>
Diffstat (limited to 'contrib/nvi/perl_scripts')
-rw-r--r--contrib/nvi/perl_scripts/forall.pl10
-rw-r--r--contrib/nvi/perl_scripts/make.pl27
-rw-r--r--contrib/nvi/perl_scripts/tk.pl20
-rw-r--r--contrib/nvi/perl_scripts/wc.pl11
4 files changed, 68 insertions, 0 deletions
diff --git a/contrib/nvi/perl_scripts/forall.pl b/contrib/nvi/perl_scripts/forall.pl
new file mode 100644
index 0000000..b9f8501
--- /dev/null
+++ b/contrib/nvi/perl_scripts/forall.pl
@@ -0,0 +1,10 @@
+sub forall {
+ my ($code) = shift;
+ my ($i) = $VI::StartLine-1;
+ while (++$i <= $VI::StopLine) {
+ $_ = $curscr->GetLine($i);
+ VI::SetLine($VI::ScreenId, $i, $_) if(&$code);
+ }
+}
+
+1;
diff --git a/contrib/nvi/perl_scripts/make.pl b/contrib/nvi/perl_scripts/make.pl
new file mode 100644
index 0000000..118dd99
--- /dev/null
+++ b/contrib/nvi/perl_scripts/make.pl
@@ -0,0 +1,27 @@
+sub make {
+ open MAKE, "make 2>&1 1>/dev/null |";
+ while(<MAKE>) {
+ if (($file, $line, $msg) = /([^: ]*):(\d*):(.+)/) {
+ if ($file == $prevfile && $line == $prevline) {
+ $error[-1]->[2] .= "\n$msg";
+ } else {
+ push @error, [$file, $line, $msg];
+ ($prevline, $prevfile) = ($line, $file);
+ }
+ }
+ }
+ close MAKE;
+}
+
+sub nexterror {
+ if ($index <= $#error) {
+ my $error = $error[$index++];
+ $curscr->Edit($error->[0]);
+ $curscr->SetCursor($error->[1],0);
+ $curscr->Msg($error->[2]);
+ }
+}
+
+# preverror is left as an exercise
+
+1;
diff --git a/contrib/nvi/perl_scripts/tk.pl b/contrib/nvi/perl_scripts/tk.pl
new file mode 100644
index 0000000..f8d1bc0
--- /dev/null
+++ b/contrib/nvi/perl_scripts/tk.pl
@@ -0,0 +1,20 @@
+# make sure every subprocess has it's exit and that the main one
+# hasn't
+sub fun {
+ unless ($pid = fork) {
+ unless (fork) {
+ use Tk;
+ $MW = MainWindow->new;
+ $hello = $MW->Button(
+ -text => 'Hello, world',
+ -command => sub {exit;},
+ );
+ $hello->pack;
+ MainLoop;
+ }
+ exit 0;
+ }
+ waitpid($pid, 0);
+}
+
+1;
diff --git a/contrib/nvi/perl_scripts/wc.pl b/contrib/nvi/perl_scripts/wc.pl
new file mode 100644
index 0000000..0a50159
--- /dev/null
+++ b/contrib/nvi/perl_scripts/wc.pl
@@ -0,0 +1,11 @@
+sub wc {
+ my $words;
+ $i = $VI::StartLine;
+ while ($i <= $VI::StopLine) {
+ $_ = $curscr->GetLine($i++);
+ $words+=split;
+ }
+ $curscr->Msg("$words words");
+}
+
+1;
OpenPOWER on IntegriCloud