Changeset 880311d


Ignore:
Timestamp:
Dec 28, 2009, 12:03:28 AM (15 years ago)
Author:
Nelson Elhage <nelhage@mit.edu>
Branches:
master, release-1.10, release-1.6, release-1.7, release-1.8, release-1.9
Children:
e6cec01
Parents:
4815492
git-author:
Nelson Elhage <nelhage@mit.edu> (12/24/09 16:45:08)
git-committer:
Nelson Elhage <nelhage@mit.edu> (12/28/09 00:03:28)
Message:
Completion: Allow completers to provide partial completion.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • perl/lib/BarnOwl/Completion.pm

    r4815492 r880311d  
    3434
    3535    if($prefix) {
    36         insert_completion($ctx, $prefix, scalar @words == 1);
     36        insert_completion($ctx, $prefix,
     37                          scalar @words == 1 && completion_done($words[0]));
    3738    }
    3839
     
    5556An arrayref completion consists of
    5657
    57     [$display_text, $replacement_value].
     58    [$display_text, $replacement_value[, $completion_done] ].
    5859
    5960$display_text will be printed in the case of ambiguous completions,
    60 $replacement_value will be used to substitute the value in.
     61$replacement_value will be used to substitute the value in. If there
     62is only a single completion for a given word, a space will be appended
     63after the completion iff $completion_done is true (or missing).
    6164
    6265=cut
     
    7477}
    7578
     79sub completion_done {
     80    my $c = shift;
     81    return 1 if ref($c) ne 'ARRAY' or @$c < 3;
     82    return $c->[2];
     83}
     84
    7685sub insert_completion {
    7786    my $ctx = shift;
    7887    my $completion = BarnOwl::quote(completion_value(shift));
    79     my $unique = shift;
     88    my $done = shift;
    8089
    81     if($unique) {
     90    if($done) {
    8291        $completion .= " ";
    8392    }
Note: See TracChangeset for help on using the changeset viewer.