From 6fd8460df07ddb82f0de33439db88177d2dc53c2 Mon Sep 17 00:00:00 2001 From: Tom Feist Date: Mon, 18 Jul 2011 04:19:40 +0100 Subject: changed format reset to format delete for chansetup_footer, to properly restore it if unset to begin with --- feature-tests/getchan.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'feature-tests') diff --git a/feature-tests/getchan.pl b/feature-tests/getchan.pl index 7d4ee55..acb1748 100644 --- a/feature-tests/getchan.pl +++ b/feature-tests/getchan.pl @@ -104,7 +104,7 @@ sub restore_formats { Irssi::command("^FORMAT chansetup_line $line_format"); Irssi::command("^FORMAT chansetup_header $head_format"); if ($foot_format =~ m/^\s*$/) { - Irssi::command("^FORMAT -reset chansetup_footer"); + Irssi::command("^FORMAT -delete chansetup_footer"); } else { Irssi::command("^FORMAT chansetup_footer $foot_format"); } -- cgit v1.2.3 From 82b9876de12f14b04e8926b7f8b66b01b79da5c2 Mon Sep 17 00:00:00 2001 From: shabble Date: Mon, 15 Aug 2011 13:41:24 +0100 Subject: added simple demo of input masking for password entry. --- feature-tests/hide_password.pl | 125 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 125 insertions(+) create mode 100644 feature-tests/hide_password.pl (limited to 'feature-tests') diff --git a/feature-tests/hide_password.pl b/feature-tests/hide_password.pl new file mode 100644 index 0000000..2fe01fc --- /dev/null +++ b/feature-tests/hide_password.pl @@ -0,0 +1,125 @@ +=pod + +=head1 NAME + +hide_password.pl + +=head1 DESCRIPTION + +A minimalist template useful for basing actual scripts on. + +=head1 INSTALLATION + +Copy into your F<~/.irssi/scripts/> directory and load with +C>. + +=head1 USAGE + +None, since it doesn't actually do anything. + +=head1 AUTHORS + +Copyright E 2011 Tom Feist Cshabble+irssi@metavore.orgE> + +=head1 LICENCE + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +=head1 BUGS + +=head1 TODO + +Use this template to make an actual script. + +=cut + +use strict; +use warnings; + +use Irssi; +use Irssi::Irc; +use Irssi::TextUI; + +use Data::Dumper; + +our $VERSION = '0.1'; +our %IRSSI = ( + authors => 'shabble', + contact => 'shabble+irssi@metavore.org', + name => '', + description => '', + license => 'MIT', + updated => '$DATE' + ); + + +my $password_active; +my $password_buffer; + +sub PASSWORD_CHAR () { ord('#') } + +sub init { + Irssi::command_bind('password', \&cmd_password); + $password_active = 0; + $password_buffer = ''; + +} + +sub cmd_password { + # Hmm, broken. + #Irssi::gui_input_set('Password: '); + begin_entry_redirect(); +} + +sub begin_entry_redirect { + $password_active = 1; + $password_buffer = ''; + + Irssi::signal_add_first('gui key pressed', 'sig_key_pressed'); + +} + +sub end_entry_redirect { + Irssi::signal_remove('gui key pressed', 'sig_key_pressed'); + $password_active = 0; +} + +sub password_complete { + Irssi::active_win->command("/echo Your password is: $password_buffer"); + Irssi::gui_input_set(''); +} + +sub sig_key_pressed { + my ($key) = @_; + + return unless $password_active; + + my $char = chr $key; + if ($char =~ m/\r|\n/) { + end_entry_redirect(); + password_complete(); + Irssi::signal_stop; + } else { + # TODO: Test if the char is printable, and abort otherwise? + $password_buffer .= $char; + Irssi::signal_continue(PASSWORD_CHAR); + } +} + +init(); -- cgit v1.2.3 From f3f4d3bd4fb76aea0bb60247dfa8b8efff06d52c Mon Sep 17 00:00:00 2001 From: shabble Date: Mon, 15 Aug 2011 13:47:48 +0100 Subject: added a delay to the /password function to make the input change show up. --- feature-tests/hide_password.pl | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'feature-tests') diff --git a/feature-tests/hide_password.pl b/feature-tests/hide_password.pl index 2fe01fc..695a985 100644 --- a/feature-tests/hide_password.pl +++ b/feature-tests/hide_password.pl @@ -82,9 +82,13 @@ sub init { } sub cmd_password { - # Hmm, broken. - #Irssi::gui_input_set('Password: '); - begin_entry_redirect(); + + # not sure why this delay is needed, but otherwise + # setting the input (" Password: ") doesn't work. + Irssi::timeout_add_once(10, sub { + Irssi::gui_input_set('Password: '); + begin_entry_redirect(); + }, 0); } sub begin_entry_redirect { -- cgit v1.2.3