File: plugins.pl

package info (click to toggle)
vile 9.8za-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 10,644 kB
  • sloc: ansic: 120,894; lex: 14,981; sh: 4,478; perl: 3,511; cpp: 3,180; makefile: 1,425; awk: 271
file content (66 lines) | stat: -rw-r--r-- 1,315 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# $Id: plugins.pl,v 1.8 2014/01/28 21:37:40 tom Exp $
# (see dir.doc)
package plugins;

use strict;

our $RPM_Provides = 'plugins.pl perl(plugins.pl)';

sub gzip {
    my ($file) = @_;
    my ( $cb, $line );

    open( GZIP, "gunzip -c $file |" ) || do { print "$!\n"; return 0; };

    foreach $cb ( Vile::buffers() ) {
        if ( $cb->buffername eq "<gzip-viewer>" ) {
            Vile->current_buffer($cb);
            $cb->setregion( 1, '$$' )->attribute("normal")->delete;
            last;
        }
    }
    $cb = $Vile::current_buffer;
    if ( $cb->buffername ne "<gzip-viewer>" ) {
        $cb = new Vile::Buffer;
        $cb->buffername("<gzip-viewer>");
        Vile->current_buffer($cb);
        $cb->set( "view",     1 );
        $cb->set( "readonly", 1 );
        $cb->set( "cfilname", $file );
        $cb->unmark->dot('$$');
    }

    while ( $line = <GZIP> ) { print $cb $line; }

    close(GZIP);

    $cb->unmark()->dot( 1, 0 );
    Vile::update();
    return 1;
}

1;

__DATA__

=head1 NAME

plugins - additional perl module for vile

=head1 SYNOPSIS

    use plugins;
    plugins::gzip("filename");

=head1 DESCRIPTION

The B<plugins> module is used by the B<mime> module to display a file according
to this MIME-type in vile:

    x-vile-flags=plugin

=head1 AUTHOR

Kuntal Daftary

=cut