[ee183be] | 1 | use strict; |
---|
| 2 | use warnings; |
---|
| 3 | |
---|
| 4 | package BarnOwl; |
---|
| 5 | |
---|
[2be605a] | 6 | use base qw(Exporter); |
---|
| 7 | our @EXPORT_OK = qw(command getcurmsg getnumcols getidletime |
---|
| 8 | zephyr_getsender zephyr_getrealm zephyr_zwrite |
---|
| 9 | zephyr_stylestrip zephyr_smartstrip_user zephyr_getsubs |
---|
| 10 | queue_message admin_message |
---|
| 11 | start_question start_password start_edit_win |
---|
| 12 | get_data_dir get_config_dir popless_text popless_ztext |
---|
[eede1bf] | 13 | error debug |
---|
[2be605a] | 14 | create_style getnumcolors wordwrap |
---|
[ffc4df6] | 15 | add_dispatch remove_dispatch |
---|
| 16 | add_io_dispatch remove_io_dispatch |
---|
[2be605a] | 17 | new_command |
---|
| 18 | new_variable_int new_variable_bool new_variable_string |
---|
[4df918b] | 19 | quote redisplay); |
---|
[2be605a] | 20 | our %EXPORT_TAGS = (all => \@EXPORT_OK); |
---|
| 21 | |
---|
[fd8dfe7] | 22 | BEGIN { |
---|
| 23 | # bootstrap in C bindings and glue |
---|
| 24 | *owl:: = \*BarnOwl::; |
---|
| 25 | bootstrap BarnOwl 1.2; |
---|
| 26 | }; |
---|
| 27 | |
---|
| 28 | use lib(get_data_dir() . "/lib"); |
---|
| 29 | use lib(get_config_dir() . "/lib"); |
---|
| 30 | |
---|
| 31 | use BarnOwl::Hook; |
---|
| 32 | use BarnOwl::Hooks; |
---|
| 33 | use BarnOwl::Message; |
---|
| 34 | use BarnOwl::Style; |
---|
[df569c5] | 35 | use BarnOwl::Zephyr; |
---|
[fd8dfe7] | 36 | use BarnOwl::Timer; |
---|
[cf26b72] | 37 | use BarnOwl::Editwin; |
---|
[8eac1a5] | 38 | use BarnOwl::Completion; |
---|
[fd8dfe7] | 39 | |
---|
[6700c605] | 40 | use List::Util qw(max); |
---|
| 41 | |
---|
[ee183be] | 42 | =head1 NAME |
---|
| 43 | |
---|
| 44 | BarnOwl |
---|
| 45 | |
---|
| 46 | =head1 DESCRIPTION |
---|
| 47 | |
---|
| 48 | The BarnOwl module contains the core of BarnOwl's perl |
---|
| 49 | bindings. Source in this module is also run at startup to bootstrap |
---|
| 50 | barnowl by defining things like the default style. |
---|
| 51 | |
---|
| 52 | =for NOTE |
---|
| 53 | These following functions are defined in perlglue.xs. Keep the |
---|
| 54 | documentation here in sync with the user-visible commands defined |
---|
| 55 | there! |
---|
| 56 | |
---|
| 57 | =head2 command STRING |
---|
| 58 | |
---|
| 59 | Executes a BarnOwl command in the same manner as if the user had |
---|
| 60 | executed it at the BarnOwl command prompt. If the command returns a |
---|
| 61 | value, return it as a string, otherwise return undef. |
---|
| 62 | |
---|
| 63 | =head2 getcurmsg |
---|
| 64 | |
---|
| 65 | Returns the current message as a C<BarnOwl::Message> subclass, or |
---|
| 66 | undef if there is no message selected |
---|
| 67 | =head2 getnumcols |
---|
| 68 | |
---|
| 69 | Returns the width of the display window BarnOwl is currently using |
---|
| 70 | |
---|
| 71 | =head2 getidletime |
---|
| 72 | |
---|
| 73 | Returns the length of time since the user has pressed a key, in |
---|
| 74 | seconds. |
---|
| 75 | |
---|
| 76 | =head2 zephyr_getrealm |
---|
| 77 | |
---|
| 78 | Returns the zephyr realm barnowl is running in |
---|
| 79 | |
---|
| 80 | =head2 zephyr_getsender |
---|
| 81 | |
---|
| 82 | Returns the fully-qualified name of the zephyr sender barnowl is |
---|
| 83 | running as, e.g. C<nelhage@ATHENA.MIT.EDU> |
---|
| 84 | |
---|
| 85 | =head2 zephyr_zwrite COMMAND MESSAGE |
---|
| 86 | |
---|
| 87 | Sends a zephyr programmatically. C<COMMAND> should be a C<zwrite> |
---|
| 88 | command line, and C<MESSAGE> is the zephyr body to send. |
---|
| 89 | |
---|
| 90 | =head2 ztext_stylestrip STRING |
---|
| 91 | |
---|
| 92 | Strips zephyr formatting from a string and returns the result |
---|
| 93 | |
---|
| 94 | =head2 zephyr_getsubs |
---|
| 95 | |
---|
| 96 | Returns the list of subscription triples <class,instance,recipient>, |
---|
| 97 | separated by newlines. |
---|
| 98 | |
---|
| 99 | =head2 queue_message MESSAGE |
---|
| 100 | |
---|
| 101 | Enqueue a message in the BarnOwl message list, logging it and |
---|
| 102 | processing it appropriately. C<MESSAGE> should be an instance of |
---|
| 103 | BarnOwl::Message or a subclass. |
---|
| 104 | |
---|
| 105 | =head2 admin_message HEADER BODY |
---|
| 106 | |
---|
| 107 | Display a BarnOwl B<Admin> message, with the given header and body. |
---|
| 108 | |
---|
| 109 | =head2 start_question PROMPT CALLBACK |
---|
| 110 | |
---|
| 111 | Displays C<PROMPT> on the screen and lets the user enter a line of |
---|
| 112 | text, and calls C<CALLBACK>, which must be a perl subroutine |
---|
| 113 | reference, with the text the user entered |
---|
| 114 | |
---|
| 115 | =head2 start_password PROMPT CALLBACK |
---|
| 116 | |
---|
| 117 | Like C<start_question>, but echoes the user's input as C<*>s when they |
---|
| 118 | input. |
---|
| 119 | |
---|
| 120 | =head2 start_edit_win PROMPT CALLBACK |
---|
| 121 | |
---|
| 122 | Like C<start_question>, but displays C<PROMPT> on a line of its own |
---|
| 123 | and opens the editwin. If the user cancels the edit win, C<CALLBACK> |
---|
| 124 | is not invoked. |
---|
| 125 | |
---|
| 126 | =head2 get_data_dir |
---|
| 127 | |
---|
| 128 | Returns the BarnOwl system data directory, where system libraries and |
---|
| 129 | modules are stored |
---|
| 130 | |
---|
| 131 | =head2 get_config_dir |
---|
| 132 | |
---|
| 133 | Returns the BarnOwl user configuration directory, where user modules |
---|
| 134 | and configuration are stored (by default, C<$HOME/.owl>) |
---|
| 135 | |
---|
| 136 | =head2 popless_text TEXT |
---|
| 137 | |
---|
| 138 | Show a popup window containing the given C<TEXT> |
---|
| 139 | |
---|
| 140 | =head2 popless_ztext TEXT |
---|
| 141 | |
---|
| 142 | Show a popup window containing the provided zephyr-formatted C<TEXT> |
---|
| 143 | |
---|
| 144 | =head2 error STRING |
---|
| 145 | |
---|
| 146 | Reports an error and log it in `show errors'. Note that in any |
---|
| 147 | callback or hook called in perl code from BarnOwl, a C<die> will be |
---|
| 148 | caught and passed to C<error>. |
---|
| 149 | |
---|
[eede1bf] | 150 | =head2 debug STRING |
---|
| 151 | |
---|
| 152 | Logs a debugging message to BarnOwl's debug log |
---|
| 153 | |
---|
[ee183be] | 154 | =head2 getnumcolors |
---|
| 155 | |
---|
| 156 | Returns the number of colors this BarnOwl is capable of displaying |
---|
| 157 | |
---|
| 158 | =head2 add_dispatch FD CALLBACK |
---|
| 159 | |
---|
| 160 | Adds a file descriptor to C<BarnOwl>'s internal C<select()> |
---|
| 161 | loop. C<CALLBACK> will be invoked whenever data is available to be |
---|
| 162 | read from C<FD>. |
---|
| 163 | |
---|
[ffc4df6] | 164 | C<add_dispatch> has been deprecated in favor of C<add_io_dispatch>, |
---|
| 165 | and is now a wrapper for it called with C<mode> set to C<'r'>. |
---|
| 166 | |
---|
| 167 | =cut |
---|
| 168 | |
---|
| 169 | sub add_dispatch { |
---|
| 170 | my $fd = shift; |
---|
| 171 | my $cb = shift; |
---|
| 172 | add_io_dispatch($fd, 'r', $cb); |
---|
| 173 | } |
---|
| 174 | |
---|
[ee183be] | 175 | =head2 remove_dispatch FD |
---|
| 176 | |
---|
| 177 | Remove a file descriptor previously registered via C<add_dispatch> |
---|
| 178 | |
---|
[ffc4df6] | 179 | C<remove_dispatch> has been deprecated in favor of |
---|
| 180 | C<remove_io_dispatch>. |
---|
| 181 | |
---|
| 182 | =cut |
---|
| 183 | |
---|
| 184 | *remove_dispatch = \&remove_io_dispatch; |
---|
| 185 | |
---|
| 186 | =head2 add_io_dispatch FD MODE CB |
---|
| 187 | |
---|
| 188 | Adds a file descriptor to C<BarnOwl>'s internal C<select()> |
---|
| 189 | loop. <MODE> can be 'r', 'w', or 'rw'. C<CALLBACK> will be invoked |
---|
| 190 | whenever C<FD> becomes ready, as specified by <MODE>. |
---|
| 191 | |
---|
| 192 | Only one callback can be registered per FD. If a new callback is |
---|
| 193 | registered, the old one is removed. |
---|
| 194 | |
---|
| 195 | =cut |
---|
| 196 | |
---|
| 197 | sub add_io_dispatch { |
---|
| 198 | my $fd = shift; |
---|
| 199 | my $modeStr = shift; |
---|
| 200 | my $cb = shift; |
---|
| 201 | my $mode = 0; |
---|
| 202 | |
---|
| 203 | $mode |= 0x1 if ($modeStr =~ /r/i); # Read |
---|
| 204 | $mode |= 0x2 if ($modeStr =~ /w/i); # Write |
---|
| 205 | if ($mode) { |
---|
| 206 | $mode |= 0x4; # Exceptional |
---|
| 207 | BarnOwl::Internal::add_io_dispatch($fd, $mode, $cb); |
---|
| 208 | } else { |
---|
| 209 | die("Invalid I/O Dispatch mode: $modeStr"); |
---|
| 210 | } |
---|
| 211 | } |
---|
| 212 | |
---|
| 213 | =head2 remove_io_dispatch FD |
---|
| 214 | |
---|
| 215 | Remove a file descriptor previously registered via C<add_io_dispatch> |
---|
| 216 | |
---|
[ee183be] | 217 | =head2 create_style NAME OBJECT |
---|
| 218 | |
---|
| 219 | Creates a new barnowl style with the given NAME defined by the given |
---|
| 220 | object. The object must have a C<description> method which returns a |
---|
| 221 | string description of the style, and a and C<format_message> method |
---|
| 222 | which accepts a C<BarnOwl::Message> object and returns a string that |
---|
| 223 | is the result of formatting the message for display. |
---|
| 224 | |
---|
[4df918b] | 225 | =head2 redisplay |
---|
| 226 | |
---|
| 227 | Redraw all of the messages on screen. This is useful if you've just |
---|
| 228 | changed how a style renders messages. |
---|
| 229 | |
---|
[ee183be] | 230 | =cut |
---|
| 231 | |
---|
| 232 | # perlconfig.c will set this to the value of the -c command-line |
---|
| 233 | # switch, if present. |
---|
| 234 | our $configfile; |
---|
| 235 | |
---|
[d7bcff8] | 236 | our @all_commands; |
---|
| 237 | |
---|
[ee183be] | 238 | if(!$configfile && -f $ENV{HOME} . "/.barnowlconf") { |
---|
| 239 | $configfile = $ENV{HOME} . "/.barnowlconf"; |
---|
| 240 | } |
---|
| 241 | $configfile ||= $ENV{HOME}."/.owlconf"; |
---|
| 242 | |
---|
| 243 | # populate global variable space for legacy owlconf files |
---|
| 244 | sub _receive_msg_legacy_wrap { |
---|
| 245 | my ($m) = @_; |
---|
| 246 | $m->legacy_populate_global(); |
---|
| 247 | return &BarnOwl::Hooks::_receive_msg($m); |
---|
| 248 | } |
---|
| 249 | |
---|
| 250 | =head2 new_command NAME FUNC [{ARGS}] |
---|
| 251 | |
---|
| 252 | Add a new owl command. When owl executes the command NAME, FUNC will |
---|
| 253 | be called with the arguments passed to the command, with NAME as the |
---|
| 254 | first argument. |
---|
| 255 | |
---|
| 256 | ARGS should be a hashref containing any or all of C<summary>, |
---|
| 257 | C<usage>, or C<description> keys: |
---|
| 258 | |
---|
| 259 | =over 4 |
---|
| 260 | |
---|
| 261 | =item summary |
---|
| 262 | |
---|
| 263 | A one-line summary of the purpose of the command |
---|
| 264 | |
---|
| 265 | =item usage |
---|
| 266 | |
---|
| 267 | A one-line usage synopsis, showing available options and syntax |
---|
| 268 | |
---|
| 269 | =item description |
---|
| 270 | |
---|
| 271 | A longer description of the syntax and semantics of the command, |
---|
| 272 | explaining usage and options |
---|
| 273 | |
---|
| 274 | =back |
---|
| 275 | |
---|
| 276 | =cut |
---|
| 277 | |
---|
| 278 | sub new_command { |
---|
| 279 | my $name = shift; |
---|
| 280 | my $func = shift; |
---|
| 281 | my $args = shift || {}; |
---|
| 282 | my %args = ( |
---|
| 283 | summary => "", |
---|
| 284 | usage => "", |
---|
| 285 | description => "", |
---|
| 286 | %{$args} |
---|
| 287 | ); |
---|
| 288 | |
---|
| 289 | BarnOwl::Internal::new_command($name, $func, $args{summary}, $args{usage}, $args{description}); |
---|
| 290 | } |
---|
| 291 | |
---|
| 292 | =head2 new_variable_int NAME [{ARGS}] |
---|
| 293 | |
---|
| 294 | =head2 new_variable_bool NAME [{ARGS}] |
---|
| 295 | |
---|
| 296 | =head2 new_variable_string NAME [{ARGS}] |
---|
| 297 | |
---|
| 298 | Add a new owl variable, either an int, a bool, or a string, with the |
---|
| 299 | specified name. |
---|
| 300 | |
---|
| 301 | ARGS can optionally contain the following keys: |
---|
| 302 | |
---|
| 303 | =over 4 |
---|
| 304 | |
---|
| 305 | =item default |
---|
| 306 | |
---|
| 307 | The default and initial value for the variable |
---|
| 308 | |
---|
| 309 | =item summary |
---|
| 310 | |
---|
| 311 | A one-line summary of the variable's purpose |
---|
| 312 | |
---|
| 313 | =item description |
---|
| 314 | |
---|
| 315 | A longer description of the function of the variable |
---|
| 316 | |
---|
| 317 | =back |
---|
| 318 | |
---|
| 319 | =cut |
---|
| 320 | |
---|
| 321 | sub new_variable_int { |
---|
| 322 | unshift @_, \&BarnOwl::Internal::new_variable_int, 0; |
---|
| 323 | goto \&_new_variable; |
---|
| 324 | } |
---|
| 325 | |
---|
| 326 | sub new_variable_bool { |
---|
| 327 | unshift @_, \&BarnOwl::Internal::new_variable_bool, 0; |
---|
| 328 | goto \&_new_variable; |
---|
| 329 | } |
---|
| 330 | |
---|
| 331 | sub new_variable_string { |
---|
| 332 | unshift @_, \&BarnOwl::Internal::new_variable_string, ""; |
---|
| 333 | goto \&_new_variable; |
---|
| 334 | } |
---|
| 335 | |
---|
| 336 | sub _new_variable { |
---|
| 337 | my $func = shift; |
---|
| 338 | my $default_default = shift; |
---|
| 339 | my $name = shift; |
---|
| 340 | my $args = shift || {}; |
---|
| 341 | my %args = ( |
---|
| 342 | summary => "", |
---|
| 343 | description => "", |
---|
| 344 | default => $default_default, |
---|
| 345 | %{$args}); |
---|
| 346 | $func->($name, $args{default}, $args{summary}, $args{description}); |
---|
| 347 | } |
---|
| 348 | |
---|
[fc92e6e2] | 349 | =head2 quote LIST |
---|
[ee183be] | 350 | |
---|
[fc92e6e2] | 351 | Quotes each of the strings in LIST and returns a string that will be |
---|
| 352 | correctly decoded to LIST by the BarnOwl command parser. For example: |
---|
| 353 | |
---|
| 354 | quote('zwrite', 'andersk', '-m', 'Hello, world!') |
---|
| 355 | # returns "zwrite andersk -m 'Hello, world!'" |
---|
[ee183be] | 356 | |
---|
| 357 | =cut |
---|
| 358 | |
---|
| 359 | sub quote { |
---|
[fc92e6e2] | 360 | my @quoted; |
---|
| 361 | for my $str (@_) { |
---|
| 362 | if ($str eq '') { |
---|
| 363 | push @quoted, "''"; |
---|
| 364 | } elsif ($str !~ /['" ]/) { |
---|
| 365 | push @quoted, "$str"; |
---|
| 366 | } elsif ($str !~ /'/) { |
---|
| 367 | push @quoted, "'$str'"; |
---|
| 368 | } else { |
---|
| 369 | (my $qstr = $str) =~ s/"/"'"'"/g; |
---|
| 370 | push @quoted, '"' . $qstr . '"'; |
---|
| 371 | } |
---|
[ee183be] | 372 | } |
---|
[fc92e6e2] | 373 | return join(' ', @quoted); |
---|
[ee183be] | 374 | } |
---|
| 375 | |
---|
[22b54a7] | 376 | =head2 Modify filters by appending text |
---|
| 377 | |
---|
| 378 | =cut |
---|
| 379 | |
---|
[cff58b4] | 380 | sub register_builtin_commands { |
---|
[0b2afba] | 381 | # Filter modification |
---|
[cff58b4] | 382 | BarnOwl::new_command("filterappend", |
---|
| 383 | sub { filter_append_helper('appending', '', @_); }, |
---|
| 384 | { |
---|
| 385 | summary => "append '<text>' to filter", |
---|
| 386 | usage => "filterappend <filter> <text>", |
---|
| 387 | }); |
---|
| 388 | |
---|
| 389 | BarnOwl::new_command("filterand", |
---|
| 390 | sub { filter_append_helper('and-ing', 'and', @_); }, |
---|
| 391 | { |
---|
| 392 | summary => "append 'and <text>' to filter", |
---|
| 393 | usage => "filterand <filter> <text>", |
---|
| 394 | }); |
---|
| 395 | |
---|
| 396 | BarnOwl::new_command("filteror", |
---|
| 397 | sub { filter_append_helper('or-ing', 'or', @_); }, |
---|
| 398 | { |
---|
| 399 | summary => "append 'or <text>' to filter", |
---|
| 400 | usage => "filteror <filter> <text>", |
---|
| 401 | }); |
---|
| 402 | |
---|
[0b2afba] | 403 | # Date formatting |
---|
| 404 | BarnOwl::new_command("showdate", |
---|
| 405 | sub { BarnOwl::time_format('showdate', '%Y-%m-%d %H:%M'); }, |
---|
| 406 | { |
---|
| 407 | summary => "Show date in timestamps for supporting styles.", |
---|
| 408 | usage => "showdate", |
---|
| 409 | }); |
---|
| 410 | |
---|
| 411 | BarnOwl::new_command("hidedate", |
---|
| 412 | sub { BarnOwl::time_format('hidedate', '%H:%M'); }, |
---|
| 413 | { |
---|
| 414 | summary => "Don't show date in timestamps for supporting styles.", |
---|
| 415 | usage => "hidedate", |
---|
| 416 | }); |
---|
| 417 | |
---|
| 418 | BarnOwl::new_command("timeformat", |
---|
| 419 | \&BarnOwl::time_format, |
---|
| 420 | { |
---|
| 421 | summary => "Set the format for timestamps and re-display messages", |
---|
| 422 | usage => "timeformat <format>", |
---|
| 423 | }); |
---|
| 424 | |
---|
[6700c605] | 425 | # Receive window scrolling |
---|
| 426 | BarnOwl::new_command("recv:shiftleft", |
---|
| 427 | \&BarnOwl::recv_shift_left, |
---|
| 428 | { |
---|
| 429 | summary => "scrolls receive window to the left", |
---|
| 430 | usage => "recv:shiftleft [<amount>]", |
---|
| 431 | description => <<END_DESCR |
---|
| 432 | By default, scroll left by 10 columns. Passing no arguments or 0 activates this default behavior. |
---|
| 433 | Otherwise, scroll by the number of columns specified as the argument. |
---|
| 434 | END_DESCR |
---|
| 435 | }); |
---|
| 436 | |
---|
| 437 | BarnOwl::new_command("recv:shiftright", |
---|
| 438 | \&BarnOwl::recv_shift_right, |
---|
| 439 | { |
---|
| 440 | summary => "scrolls receive window to the right", |
---|
| 441 | usage => "recv:shiftright [<amount>]", |
---|
| 442 | description => <<END_DESCR |
---|
| 443 | By default, scroll right by 10 columns. Passing no arguments or 0 activates this default behavior. |
---|
| 444 | Otherwise, scroll by the number of columns specified as the argument. |
---|
| 445 | END_DESCR |
---|
| 446 | }); |
---|
| 447 | |
---|
[cff58b4] | 448 | } |
---|
| 449 | |
---|
| 450 | $BarnOwl::Hooks::startup->add("BarnOwl::register_builtin_commands"); |
---|
[22b54a7] | 451 | |
---|
| 452 | =head3 filter_append_helper ACTION SEP FUNC FILTER APPEND_TEXT |
---|
| 453 | |
---|
| 454 | Helper to append to filters. |
---|
| 455 | |
---|
| 456 | =cut |
---|
| 457 | |
---|
| 458 | sub filter_append_helper |
---|
| 459 | { |
---|
| 460 | my $action = shift; |
---|
| 461 | my $sep = shift; |
---|
| 462 | my $func = shift; |
---|
| 463 | my $filter = shift; |
---|
| 464 | my @append = @_; |
---|
| 465 | my $oldfilter = BarnOwl::getfilter($filter); |
---|
| 466 | chomp $oldfilter; |
---|
[0b5168d] | 467 | my $newfilter = "$oldfilter $sep " . quote(@append); |
---|
| 468 | my $msgtext = "To filter " . quote($filter) . " $action\n" . quote(@append) . "\nto get\n$newfilter"; |
---|
[22b54a7] | 469 | if (BarnOwl::getvar('showfilterchange') eq 'on') { |
---|
| 470 | BarnOwl::admin_message("Filter", $msgtext); |
---|
| 471 | } |
---|
[1b9a163] | 472 | set_filter($filter, $newfilter); |
---|
[22b54a7] | 473 | return; |
---|
| 474 | } |
---|
| 475 | BarnOwl::new_variable_bool("showfilterchange", |
---|
| 476 | { default => 1, |
---|
| 477 | summary => 'Show modifications to filters by filterappend and friends.'}); |
---|
[ee183be] | 478 | |
---|
[1b9a163] | 479 | sub set_filter |
---|
| 480 | { |
---|
| 481 | my $filtername = shift; |
---|
| 482 | my $filtertext = shift; |
---|
| 483 | my $cmd = 'filter ' . BarnOwl::quote($filtername) . ' ' . $filtertext; |
---|
| 484 | BarnOwl::command($cmd); |
---|
| 485 | } |
---|
| 486 | |
---|
[0b2afba] | 487 | =head3 time_format FORMAT |
---|
| 488 | |
---|
| 489 | Set the format for displaying times (variable timeformat) and redisplay |
---|
| 490 | messages. |
---|
| 491 | |
---|
| 492 | =cut |
---|
| 493 | |
---|
[d694c55] | 494 | my $timeformat = '%H:%M'; |
---|
[0b2afba] | 495 | |
---|
| 496 | sub time_format |
---|
| 497 | { |
---|
| 498 | my $function = shift; |
---|
| 499 | my $format = shift; |
---|
| 500 | if(!$format) |
---|
| 501 | { |
---|
| 502 | return $timeformat; |
---|
| 503 | } |
---|
| 504 | if(shift) |
---|
| 505 | { |
---|
| 506 | return "Wrong number of arguments for command"; |
---|
| 507 | } |
---|
| 508 | $timeformat = $format; |
---|
| 509 | redisplay(); |
---|
| 510 | } |
---|
| 511 | |
---|
[6700c605] | 512 | =head3 Receive window scrolling |
---|
| 513 | |
---|
| 514 | Permit scrolling the receive window left or right by arbitrary |
---|
| 515 | amounts (with a default of 10 characters). |
---|
| 516 | |
---|
| 517 | =cut |
---|
| 518 | |
---|
| 519 | sub recv_shift_left |
---|
| 520 | { |
---|
| 521 | my $func = shift; |
---|
| 522 | my $delta = shift; |
---|
[65fca7a0] | 523 | $delta = 10 unless defined($delta) && int($delta) > 0; |
---|
[6700c605] | 524 | my $shift = BarnOwl::recv_getshift(); |
---|
| 525 | if($shift > 0) { |
---|
| 526 | BarnOwl::recv_setshift(max(0, $shift-$delta)); |
---|
| 527 | } else { |
---|
| 528 | return "Already full left"; |
---|
| 529 | } |
---|
| 530 | } |
---|
| 531 | |
---|
| 532 | sub recv_shift_right |
---|
| 533 | { |
---|
| 534 | my $func = shift; |
---|
| 535 | my $delta = shift; |
---|
| 536 | $delta = 10 unless int($delta) > 0; |
---|
| 537 | my $shift = BarnOwl::recv_getshift(); |
---|
| 538 | BarnOwl::recv_setshift($shift+$delta); |
---|
| 539 | } |
---|
| 540 | |
---|
[de3f641] | 541 | =head3 default_zephyr_signature |
---|
| 542 | |
---|
| 543 | Compute the default zephyr signature. |
---|
| 544 | |
---|
| 545 | =cut |
---|
| 546 | |
---|
| 547 | sub default_zephyr_signature |
---|
| 548 | { |
---|
[77c87b2] | 549 | my $zsig = getvar('zsig'); |
---|
[3c428d4] | 550 | if (!$zsig) { |
---|
| 551 | if (my $zsigproc = getvar('zsigproc')) { |
---|
| 552 | $zsig = `$zsigproc`; |
---|
| 553 | } elsif (!defined($zsig = get_zephyr_variable('zwrite-signature'))) { |
---|
| 554 | $zsig = ((getpwuid($<))[6]); |
---|
| 555 | $zsig =~ s/,.*//; |
---|
| 556 | } |
---|
[de3f641] | 557 | } |
---|
[77c87b2] | 558 | chomp($zsig); |
---|
| 559 | return $zsig; |
---|
[de3f641] | 560 | } |
---|
| 561 | |
---|
[7589f0a] | 562 | # Stub for owl::startup / BarnOwl::startup, so it isn't bound to the |
---|
| 563 | # startup command. This may be redefined in a user's configfile. |
---|
| 564 | sub startup |
---|
| 565 | { |
---|
| 566 | } |
---|
| 567 | |
---|
[ee183be] | 568 | 1; |
---|