File: completion_helpers.pm

package info (click to toggle)
qpdf 12.3.2-1
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 72,660 kB
  • sloc: cpp: 59,054; perl: 12,189; ansic: 6,809; sh: 1,231; python: 1,041; xml: 43; makefile: 42
file content (36 lines) | stat: -rw-r--r-- 773 bytes parent folder | download | duplicates (3)
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
# This is also used by qpdf.test.

sub bash_completion
{
    my ($x, $line, $point) = @_;
    if (! defined $point)
    {
        $point = length($line);
    }
    my $before_point = substr($line, 0, $point);
    my $first = '';
    my $sep = '';
    my $cur = '';
    if ($before_point =~ m/^(.*)([ =])([^= ]*)$/)
    {
        ($first, $sep, $cur) = ($1, $2, $3);
    }
    my $prev = ($sep eq '=' ? $sep : $first);
    $prev =~ s/.* (\S+)$/$1/;
    my $this = $first;
    $this =~ s/(\S+)\s.*/$1/;
    ['env', "COMP_LINE=$line", "COMP_POINT=$point",
     $x, $this, $cur, $prev];
}

sub zsh_completion
{
    my ($x, $line, $point) = @_;
    if (! defined $point)
    {
        $point = length($line);
    }
    ['env', "COMP_LINE=$line", "COMP_POINT=$point", $x];
}

1;