release-1.10release-1.4release-1.5release-1.6release-1.7release-1.8release-1.9
Last change
on this file since 01846ce was
9300fe5,
checked in by Nelson Elhage <nelhage@mit.edu>, 15 years ago
|
Zephyr completion: Convert fields to lowercase for completing.
Classes, instances, and username are case-insensitive, so canonicalize
on lower-case for storing completions.
|
-
Property mode set to
100644
|
File size:
1.7 KB
|
Rev | Line | |
---|
[8f16dcd] | 1 | use strict; |
---|
| 2 | use warnings; |
---|
| 3 | |
---|
| 4 | package BarnOwl::Complete::Zephyr; |
---|
| 5 | |
---|
| 6 | use BarnOwl::Completion::Util qw(complete_flags); |
---|
| 7 | |
---|
[fdc0c47] | 8 | our %classes = (); |
---|
| 9 | our %realms = map {$_ => 1} qw(ATHENA.MIT.EDU ANDREW.CMU.EDU ZONE.MIT.EDU); |
---|
| 10 | our %users = (); |
---|
[8f16dcd] | 11 | |
---|
| 12 | sub complete_class { keys %classes } |
---|
| 13 | sub complete_instance { } |
---|
| 14 | sub complete_realm { keys %realms } |
---|
| 15 | sub complete_opcode { } |
---|
| 16 | sub complete_user { keys %users; } |
---|
| 17 | |
---|
| 18 | sub complete_zwrite { |
---|
| 19 | my $ctx = shift; |
---|
| 20 | return complete_flags($ctx, |
---|
| 21 | [qw(-n -C -m)], |
---|
| 22 | { |
---|
| 23 | "-c" => \&complete_class, |
---|
| 24 | "-i" => \&complete_instance, |
---|
| 25 | "-r" => \&complete_realm, |
---|
| 26 | "-O" => \&complete_opcode, |
---|
| 27 | }, |
---|
| 28 | \&complete_user |
---|
| 29 | ); |
---|
| 30 | } |
---|
| 31 | |
---|
[ea7cfa8] | 32 | sub complete_viewclass { |
---|
| 33 | my $ctx = shift; |
---|
| 34 | return unless $ctx->word == 1; |
---|
| 35 | return complete_class(); |
---|
| 36 | } |
---|
| 37 | |
---|
| 38 | sub complete_viewuser { |
---|
| 39 | my $ctx = shift; |
---|
| 40 | return unless $ctx->word == 1; |
---|
| 41 | return complete_user(); |
---|
| 42 | } |
---|
| 43 | |
---|
[8f16dcd] | 44 | sub on_message { |
---|
| 45 | my $m = shift; |
---|
| 46 | return unless $m->type eq 'zephyr'; |
---|
[9300fe5] | 47 | $classes{lc $m->class} = 1; |
---|
| 48 | $realms{lc $m->realm} = 1; |
---|
| 49 | $users{lc BarnOwl::Message::Zephyr::strip_realm($m->sender)} = 1; |
---|
[8f16dcd] | 50 | } |
---|
| 51 | |
---|
| 52 | BarnOwl::Completion::register_completer(zwrite => \&complete_zwrite); |
---|
| 53 | BarnOwl::Completion::register_completer(zcrypt => \&complete_zwrite); |
---|
| 54 | |
---|
[ea7cfa8] | 55 | # Aliases should really be taken care of by the core completion code. |
---|
| 56 | BarnOwl::Completion::register_completer(viewclass => \&complete_viewclass); |
---|
| 57 | BarnOwl::Completion::register_completer(vc => \&complete_viewclass); |
---|
| 58 | BarnOwl::Completion::register_completer(viewuser => \&complete_viewuser); |
---|
| 59 | BarnOwl::Completion::register_completer(vu => \&complete_viewuser); |
---|
| 60 | |
---|
[8f16dcd] | 61 | $BarnOwl::Hooks::newMessage->add("BarnOwl::Complete::Zephyr::on_message"); |
---|
| 62 | |
---|
| 63 | 1; |
---|
Note: See
TracBrowser
for help on using the repository browser.