Permalink
Browse files

Call BarnOwl::start_question directly in the editwin callback

As of BarnOwl 1.6 this is possible. This gets rid of the awkward 1s
delay, prevents problems if another editwin is started before the
mainLoop hook runs, and avoids using deprecated API.

Reported-by: Geoffrey Thomas <geofft@mit.edu>
  • Loading branch information...
1 parent 6dc27f5 commit 97e52d2b928f26d7ad62f8bb434614b14701e8c2 @davidben davidben committed Jul 18, 2011
Showing with 3 additions and 20 deletions.
  1. +3 −20 lib/BarnOwl/Module/ZStatus.pm
@@ -15,8 +15,6 @@ package BarnOwl::Module::ZStatus;
our $VERSION = 0.1;
-my $next = undef;
-
sub cmd_zstatus {
my $cmd = shift;
my $args = join(" ", @_);
@@ -53,23 +51,17 @@ sub got_data {
sub got_sleep {
my @pass = @_;
- $next = sub {
- BarnOwl::start_question('Angst [0-10]? ', sub {got_angst(@pass, @_)});
- };
+ BarnOwl::start_question('Angst [0-10]? ', sub {got_angst(@pass, @_)});
}
sub got_angst {
my @pass = @_;
- $next = sub {
- BarnOwl::start_question('Stress [0-10]? ', sub {got_stress(@pass, @_)});
- }
+ BarnOwl::start_question('Stress [0-10]? ', sub {got_stress(@pass, @_)});
}
sub got_stress {
my @pass = @_;
- $next = sub {
- BarnOwl::start_question('Hosage [0-10]? ', sub {got_hosage(@pass, @_)});
- }
+ BarnOwl::start_question('Hosage [0-10]? ', sub {got_hosage(@pass, @_)});
}
sub got_hosage {
@@ -117,13 +109,4 @@ BarnOwl::new_command(zbars => \&cmd_zbars, {
usage => "zbars [zephyr command-line]",
});
-sub main_loop {
- if($next) {
- $next->();
- undef $next;
- }
-}
-
-$BarnOwl::Hooks::mainLoop->add(\&main_loop);
-
1;

0 comments on commit 97e52d2

Please sign in to comment.