aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Feist <shabble@metavore.org>2010-11-04 18:23:40 +0000
committerTom Feist <shabble@metavore.org>2010-11-04 18:23:40 +0000
commit30cef22efe59552e3292e8efab24af3205a8df30 (patch)
treeb254e52398a594c18b8be2352d43b34ccb9bc145
parentmake hist_search attempt to load uberprompt if it isn't already. If that fails, (diff)
downloadirssi-scripts-30cef22efe59552e3292e8efab24af3205a8df30.tar.gz
irssi-scripts-30cef22efe59552e3292e8efab24af3205a8df30.zip
add support for 'prompt length request' signal, which responds with a standard
'prompt changed' signal
-rw-r--r--prompt_info/uberprompt.pl26
1 files changed, 22 insertions, 4 deletions
diff --git a/prompt_info/uberprompt.pl b/prompt_info/uberprompt.pl
index 4d95b06..23786ab 100644
--- a/prompt_info/uberprompt.pl
+++ b/prompt_info/uberprompt.pl
@@ -143,6 +143,8 @@ my $prompt_format = '';
# theme formats to be applied to the content.
my $use_replaces = 0;
+my $emit_request = 0;
+
pre_init();
sub pre_init {
@@ -222,12 +224,21 @@ sub init {
# this event to be notified when the prompt changes.
# arguments are new contents (string), new length (int)
Irssi::signal_register({'prompt changed' => [qw/string int/]});
+ Irssi::signal_register({'prompt length request' => []});
+
+ Irssi::signal_add('prompt length request', \&length_request_handler);
if (DEBUG) {
Irssi::signal_add 'prompt changed', \&debug_prompt_changed;
}
}
+sub length_request_handler {
+ $emit_request = 1;
+ uberprompt_render_prompt();
+ $emit_request = 0;
+}
+
sub reload_settings {
$use_replaces = Irssi::settings_get_bool('uberprompt_use_replaces');
@@ -281,8 +292,7 @@ sub _escape_prompt_special {
return $str;
}
-sub uberprompt_draw {
- my ($sb_item, $get_size_only) = @_;
+sub uberprompt_render_prompt {
my $window = Irssi::active_win;
my $prompt_arg = '';
@@ -331,10 +341,10 @@ sub uberprompt_draw {
}
}
- print "Redrawing with: $prompt, size-only: $get_size_only" if DEBUG;
+ #print "Redrawing with: $prompt, size-only: $get_size_only" if DEBUG;
- if ($prompt ne $prompt_last) {
+ if (($prompt ne $prompt_last) or $emit_request) {
# print "Emitting prompt changed signal" if DEBUG;
# my $exp = Irssi::current_theme()->format_expand($text, 0);
@@ -343,6 +353,14 @@ sub uberprompt_draw {
Irssi::signal_emit('prompt changed', $ps, length($ps));
$prompt_last = $prompt;
}
+ return $prompt;
+}
+
+sub uberprompt_draw {
+ my ($sb_item, $get_size_only) = @_;
+
+ my $prompt = uberprompt_render_prompt();
+
my $ret = $sb_item->default_handler($get_size_only, $prompt, '', 0);
return $ret;