aboutsummaryrefslogtreecommitdiffstats
path: root/prompt_info
diff options
context:
space:
mode:
authorTom Feist <shabble@metavore.org>2011-04-18 17:59:36 +0000
committerTom Feist <shabble@metavore.org>2011-04-18 17:59:36 +0000
commit2ea2db3f227383be4ce7ffc6fdc1c358debadd46 (patch)
treef9d297e62f3d3acb284b2a6024d924b852bf4d4b /prompt_info
parentvim-mode/vim_mode: added '$vim_cmd_mode' expando that contains the same info as (diff)
downloadirssi-scripts-2ea2db3f227383be4ce7ffc6fdc1c358debadd46.tar.gz
irssi-scripts-2ea2db3f227383be4ce7ffc6fdc1c358debadd46.zip
uberprompt: added uberprompt_load_hook and uberprompt_unload_hook settings which
run user-specified commands during uberprompt startup and shutdown.
Diffstat (limited to 'prompt_info')
-rw-r--r--prompt_info/uberprompt.pl33
1 files changed, 33 insertions, 0 deletions
diff --git a/prompt_info/uberprompt.pl b/prompt_info/uberprompt.pl
index 9d97b0c..71638a5 100644
--- a/prompt_info/uberprompt.pl
+++ b/prompt_info/uberprompt.pl
@@ -255,6 +255,8 @@ my $emit_request = 0;
my $expando_refresh_timer;
my $expando_vars = {};
+my $init_callbacks = {load => '', unload => ''};
+
pre_init();
sub pre_init {
@@ -345,6 +347,10 @@ sub init {
Irssi::expando_create('rbrace', \&exp_rbrace, {});
Irssi::settings_add_str ('uberprompt', 'uberprompt_format', '[$*$uber] ');
+
+ Irssi::settings_add_str ('uberprompt', 'uberprompt_load_hook', '');
+ Irssi::settings_add_str ('uberprompt', 'uberprompt_unload_hook', '');
+
Irssi::settings_add_bool('uberprompt', 'uberprompt_debug', 0);
Irssi::settings_add_bool('uberprompt', 'uberprompt_autostart', 1);
Irssi::settings_add_bool('uberprompt', 'uberprompt_use_replaces', 0);
@@ -455,6 +461,11 @@ sub reload_settings {
$use_replaces = Irssi::settings_get_bool('uberprompt_use_replaces');
$DEBUG_ENABLED = Irssi::settings_get_bool('uberprompt_debug');
+ $init_callbacks = {
+ load => Irssi::settings_get_str('uberprompt_load_hook'),
+ unload => Irssi::settings_get_str('uberprompt_unload_hook'),
+ };
+
if (DEBUG) {
Irssi::signal_add 'prompt changed', 'debug_prompt_changed';
} else {
@@ -613,6 +624,17 @@ sub replace_prompt_items {
qw/-alignment left -before input -priority '-1'/);
_sbar_command('prompt', 'position', '100');
+
+ my $load_hook = $init_callbacks->{load};
+ if (defined $load_hook and length $load_hook) {
+ eval {
+ Irssi::command($load_hook);
+ };
+ if ($@) {
+ _error("Uberprompt user load-hook command ($load_hook) failed: $@");
+ }
+ }
+
}
sub restore_prompt_items {
@@ -622,6 +644,17 @@ sub restore_prompt_items {
_debug_print("Restoring original prompt");
_sbar_command('prompt', 'reset');
+
+ my $unload_hook = $init_callbacks->{unload};
+
+ if (defined $unload_hook and length $unload_hook) {
+ eval {
+ Irssi::command($unload_hook);
+ };
+ if ($@) {
+ _error("Uberprompt user unload-hook command ($unload_hook) failed: $@");
+ }
+ }
}
sub _sbar_command {