trick/bin/pm/edit.pm
2015-02-26 09:02:31 -06:00

35 lines
848 B
Perl
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package edit ;
# $Id: edit.pm 2014 2011-10-31 18:33:09Z lin $
use Exporter ();
@ISA = qw(Exporter);
@EXPORT = qw(edit_only edit_and_exit);
use strict ;
use gte ;
sub edit_only {
my ($program, $f, $line_num) = @_ ;
my $editor ;
$editor = gte("TRICK_EDITOR") ;
chomp $editor ;
# Edit the offending file with the user's editor of choice. Use vi as default
if ($editor eq "emacs") { system "emacs +$line_num $f &" ; }
elsif ($editor eq "nedit") { system "nedit +$line_num $f &" ; }
elsif ($editor eq "vi" or $editor eq "vim" ) { system "xterm -geometry 80x50 -e $editor +$line_num $f &" ; }
elsif ($editor ne "none" and $editor ne "") { system "$editor $f &" ; }
}
sub edit_and_exit {
my ($program, $f, $line_num) = @_ ;
edit_only(@_) ;
print "\n\n$program aborted\n\n" ;
exit(1) ;
}
1;