diff options
Diffstat (limited to 'contrib/nvi/perl_scripts')
-rw-r--r-- | contrib/nvi/perl_scripts/forall.pl | 10 | ||||
-rw-r--r-- | contrib/nvi/perl_scripts/make.pl | 27 | ||||
-rw-r--r-- | contrib/nvi/perl_scripts/tk.pl | 20 | ||||
-rw-r--r-- | contrib/nvi/perl_scripts/wc.pl | 11 |
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; |