From 629aa2beaad21c319b5010e6f705a28f45487866 Mon Sep 17 00:00:00 2001 From: Tom Feist Date: Fri, 15 Oct 2010 20:22:01 +0100 Subject: uberprompt: fix to allow { and } characters in input. % still pending - ideally te job of the sender to deal with it, or colour features can't be used. --- prompt_info/uberprompt.pl | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'prompt_info') diff --git a/prompt_info/uberprompt.pl b/prompt_info/uberprompt.pl index 7b3e022..ded45cf 100644 --- a/prompt_info/uberprompt.pl +++ b/prompt_info/uberprompt.pl @@ -153,14 +153,25 @@ sub prompt_subcmd_handler { } sub UNLOAD { + deinit(); +} + +sub exp_lbrace { '{' } +sub exp_rbrace { '}' } + +sub deinit { + Irssi::expando_destroy('brace'); # remove uberprompt and return the original ones. print "Removing uberprompt and restoring original"; restore_prompt_items(); } - sub init { Irssi::statusbar_item_register('uberprompt', 0, 'uberprompt_draw'); + # TODO: flags to prevent these from being recomputed? + Irssi::expando_create('lbrace', \&exp_lbrace, {}); + Irssi::expando_create('rbrace', \&exp_rbrace, {}); + Irssi::settings_add_str('uberprompt', 'uberprompt_format', '[$*$uber] '); Irssi::settings_add_bool('uberprompt', 'uberprompt_debug', 0); Irssi::settings_add_bool('uberprompt', 'uberprompt_autostart', 1); @@ -255,6 +266,10 @@ sub _escape_prompt_special { my $str = shift; $str =~ s/\$/\$\$/g; $str =~ s/\\/\\\\/g; + #$str =~ s/%/%%/g; + $str =~ s/{/\$lbrace/g; + $str =~ s/}/\$rbrace/g; + return $str; } @@ -292,6 +307,7 @@ sub uberprompt_draw { $prompt = $pdata_copy; } elsif ($prompt_data_pos eq 'UP_INNER' && defined $prompt_data) { + my $esc = _escape_prompt_special($prompt_data); $prompt =~ s/\$\$uber/$esc/; -- cgit v1.2.3