Changes in perlwrap.pm [18fb3d4f:b0c8011]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
perlwrap.pm
r18fb3d4f rb0c8011 14 14 15 15 package BarnOwl; 16 17 =head1 NAME 18 19 BarnOwl 20 21 =head1 DESCRIPTION 22 23 The BarnOwl module contains the core of BarnOwl's perl 24 bindings. Source in this module is also run at startup to bootstrap 25 barnowl by defining things like the default style. 26 27 =for NOTE 28 These following functions are defined in perlglue.xs. Keep the 29 documentation here in sync with the user-visible commands defined 30 there! 31 32 =head2 command STRING 33 34 Executes a BarnOwl command in the same manner as if the user had 35 executed it at the BarnOwl command prompt. If the command returns a 36 value, return it as a string, otherwise return undef. 37 38 =head2 getcurmsg 39 40 Returns the current message as a C<BarnOwl::Message> subclass, or 41 undef if there is no message selected 42 43 =head2 getnumcols 44 45 Returns the width of the display window BarnOwl is currently using 46 47 =head2 getidletime 48 49 Returns the length of time since the user has pressed a key, in 50 seconds. 51 52 =head2 zephyr_getrealm 53 54 Returns the zephyr realm barnowl is running in 55 56 =head2 zephyr_getsender 57 58 Returns the fully-qualified name of the zephyr sender barnowl is 59 running as, e.g. C<nelhage@ATHENA.MIT.EDU> 60 61 =head2 zephyr_zwrite COMMAND MESSAGE 62 63 Sends a zephyr programmatically. C<COMMAND> should be a C<zwrite> 64 command line, and C<MESSAGE> is the zephyr body to send. 65 66 =head2 ztext_stylestrip STRING 67 68 Strips zephyr formatting from a string and returns the result 69 70 =head2 queue_message MESSAGE 71 72 Enqueue a message in the BarnOwl message list, logging it and 73 processing it appropriately. C<MESSAGE> should be an instance of 74 BarnOwl::Message or a subclass. 75 76 =head2 admin_message HEADER BODY 77 78 Display a BarnOwl B<Admin> message, with the given header and body. 79 80 =head2 start_question PROMPT CALLBACK 81 82 Displays C<PROMPT> on the screen and lets the user enter a line of 83 text, and calls C<CALLBACK>, which must be a perl subroutine 84 reference, with the text the user entered 85 86 =head2 start_password PROMPT CALLBACK 87 88 Like C<start_question>, but echoes the user's input as C<*>s when they 89 input. 90 91 =head2 start_editwin PROMPT CALLBACK 92 93 Like C<start_question>, but displays C<PROMPT> on a line of its own 94 and opens the editwin. If the user cancels the edit win, C<CALLBACK> 95 is not invoked. 96 97 =head2 get_data_dir 98 99 Returns the BarnOwl system data directory, where system libraries and 100 modules are stored 101 102 =head2 get_config_dir 103 104 Returns the BarnOwl user configuration directory, where user modules 105 and configuration are stored (by default, C<$HOME/.owl>) 106 107 =head2 popless_text TEXT 108 109 Show a popup window containing the given C<TEXT> 110 111 =head2 popless_ztext TEXT 112 113 Show a popup window containing the provided zephyr-formatted C<TEXT> 114 115 =head2 error STRING 116 117 Reports an error and log it in `show errors'. Note that in any 118 callback or hook called in perl code from BarnOwl, a C<die> will be 119 caught and passed to C<error>. 120 121 =head2 getnumcolors 122 123 Returns the number of colors this BarnOwl is capable of displaying 124 125 =cut 126 16 127 17 128 BEGIN { … … 46 157 return &BarnOwl::Hooks::_receive_msg($m); 47 158 } 159 160 =head2 AUTOLOAD 161 162 BarnOwl.pm has a C<AUTOLOAD> method that translates unused names in 163 the BarnOwl:: namespace to a call to BarnOwl::command() with that 164 command. Underscores are also translated to C<->s, so you can do 165 e.g. C<BarnOwl::start_command()> and it will be translated into 166 C<start-command>. 167 168 So, if you're looking for functionality that you can't find in the 169 perl interface, check C<:show commands> or C<commands.c> in the 170 BarnOwl source tree -- there's a good chance it exists as a BarnOwl 171 command. 172 173 =head3 BUGS 174 175 There are horrible quoting issues here. The AUTOLOAD simple joins your 176 commands with spaces and passes them unmodified to C<::command> 177 178 =cut 48 179 49 180 # make BarnOwl::<command>("foo") be aliases to BarnOwl::command("<command> foo"); … … 63 194 64 195 ARGS should be a hashref containing any or all of C<summary>, 65 C<usage>, or C<description> keys. 196 C<usage>, or C<description> keys: 197 198 =over 4 199 200 =item summary 201 202 A one-line summary of the purpose of the command 203 204 =item usage 205 206 A one-line usage synopsis, showing available options and syntax 207 208 =item description 209 210 A longer description of the syntax and semantics of the command, 211 explaining usage and options 212 213 =back 66 214 67 215 =cut … … 410 558 package BarnOwl::Hook; 411 559 560 =head1 BarnOwl::Hook 561 562 =head1 DESCRIPTION 563 564 A C<BarnOwl::Hook> represents a list of functions to be triggered on 565 some event. C<BarnOwl> exports a default set of these (see 566 C<BarnOwl::Hooks>), but can also be created and used by module code. 567 568 =head2 new 569 570 Creates a new Hook object 571 572 =cut 573 412 574 sub new { 413 575 my $class = shift; 414 576 return bless [], $class; 415 577 } 578 579 =head2 run [ARGS] 580 581 Calls each of the functions registered with this hook with the given 582 arguments. 583 584 =cut 416 585 417 586 sub run { … … 420 589 return map {$_->(@args)} @$self; 421 590 } 591 592 =head2 add SUBREF 593 594 Registers a given subroutine with this hook 595 596 =cut 422 597 423 598 sub add { … … 428 603 } 429 604 605 =head2 clear 606 607 Remove all functions registered with this hook. 608 609 =cut 610 430 611 sub clear { 431 612 my $self = shift; … … 434 615 435 616 package BarnOwl::Hooks; 617 618 =head1 BarnOwl::Hooks 619 620 =head1 DESCRIPTION 621 622 C<BarnOwl::Hooks> exports a set of C<BarnOwl::Hook> objects made 623 available by BarnOwl internally. 624 625 =head2 USAGE 626 627 Modules wishing to respond to events in BarnOwl should register 628 functions with these hooks. 629 630 =head2 EXPORTS 631 632 None by default. Either import the hooks you need explicitly, or refer 633 to them with fully-qualified names. Available hooks are: 634 635 =over 4 636 637 =item $startup 638 639 Called on BarnOwl startup, and whenever modules are 640 reloaded. Functions registered with the C<$startup> hook get a true 641 argument if this is a reload, and false if this is a true startup 642 643 =item $shutdown 644 645 Called before BarnOwl shutdown 646 647 =item $receiveMessage 648 649 Called with a C<BarnOwl::Message> object every time BarnOwl appends a 650 new message to its message list 651 652 =item $mainLoop 653 654 Called on B<every pass> through the C<BarnOwl> main loop. Any 655 functions with this hook should be very cheap, as they are very 656 frequently by the runtime. 657 658 =item $getBuddyList 659 660 Called to display buddy lists for all protocol handlers. The result 661 from every function registered with this hook will be appended and 662 displayed in a popup window, with zephyr formatting parsed. 663 664 =back 665 666 =cut 436 667 437 668 use Exporter; … … 468 699 } 469 700 } 701 702 # These are the internal hooks called by the barnowl C code, which 703 # take care of dispatching to the appropriate perl hooks, and deal 704 # with compatibility by calling the old, fixed-name hooks. 470 705 471 706 sub _startup {
Note: See TracChangeset
for help on using the changeset viewer.