From 0759c5aed971ad08b8838dd84d5baeb649deabbb Mon Sep 17 00:00:00 2001 From: Tom Feist Date: Mon, 11 Oct 2010 21:03:26 +0100 Subject: modified rl_history_search to use uberprompt, and added INSTALL section to header comments --- history-search/rl_history_search.pl | 42 ++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 15 deletions(-) (limited to 'history-search') diff --git a/history-search/rl_history_search.pl b/history-search/rl_history_search.pl index 83ff934..f63a6d7 100644 --- a/history-search/rl_history_search.pl +++ b/history-search/rl_history_search.pl @@ -1,29 +1,39 @@ # Search within your typed history as you type (like ctrl-R in bash) -# Usage: - +# +# INSTALL: +# +# This script requires that you have first installed and loaded 'uberprompt.pl' +# Uberprompt can be downloaded from: +# +# http://github.com/shabble/irssi-scripts/raw/master/prompt_info/uberprompt.pl +# +# and follow the instructions at the top of that file for installation. +# +# USAGE: +# # * Setup: /bind ^R /history_search_start - +# # * Then type ctrl-R and type what you're searching for - +# # * You can cycle through multiple matches with ^R (older matches), and # ^S (newer matches) - +# # NOTE: Ctrl-S may not work if you have software flow control configured for # your terminal. It may appear to freeze irssi entirely. If this happens, it can # be restored with Ctrl-Q, but you will be unable to use the Ctrl-S binding. # You can disable flow control by running the command `stty -ixon' in your # terminal, or setting `defflow off' in your ~/.screenrc if using GNU Screen. - +# # * Hitting enter selects a match and terminates search mode. - +# # * You can use ^G to exit search mode without selecting. - +# # * Any other ctrl- or meta- key binding will terminate search mode, leaving the # selected item in the input line. - +# # Original script Copyright 2007 Wouter Coekaerts # Heavy modifications by Shabble , 2010. - +# # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or @@ -53,7 +63,7 @@ $VERSION = '1.0'; description => 'Search within your typed history as you type' . ' (like ctrl-R in readline applications)', license => 'GPLv2 or later', - url => 'http://github.com/shabble/shab-irssi-scripts/tree/master/history-search/', + url => 'http://github.com/shabble/irssi-scripts/tree/master/history-search/', changed => '24/7/2010' ); @@ -67,7 +77,7 @@ my $match_index = 0; sub DEBUG () { 0 } -# check we have prompt_info loaded. +# check we have uberprompt loaded. sub script_is_loaded { my $name = shift; @@ -79,7 +89,7 @@ sub script_is_loaded { return $retval; } -unless (script_is_loaded('prompt_info')) { +unless (script_is_loaded('uberprompt')) { die "This script requires 'prompt_info' in order to work. " . "Please load it and try again"; } else { @@ -105,11 +115,13 @@ sub history_search { sub history_exit { $search_active = 0; - Irssi::signal_emit('change prompt', ''); + Irssi::signal_emit('change prompt', '', 'UP_INNER'); } sub update_history_prompt { - Irssi::signal_emit('change prompt', " reverse-i-search: \`$search_str'"); + Irssi::signal_emit('change prompt', + " reverse-i-search: \`$search_str'", + 'UP_INNER'); } sub update_history_matches { -- cgit v1.2.3 From 365fa468c5e2bd566e1f0be5945eb3c0c873ecf5 Mon Sep 17 00:00:00 2001 From: Tom Feist Date: Mon, 11 Oct 2010 21:11:06 +0100 Subject: history search now uses colour to indicate matches/no-matches --- history-search/rl_history_search.pl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'history-search') diff --git a/history-search/rl_history_search.pl b/history-search/rl_history_search.pl index f63a6d7..64f4f20 100644 --- a/history-search/rl_history_search.pl +++ b/history-search/rl_history_search.pl @@ -90,7 +90,7 @@ sub script_is_loaded { } unless (script_is_loaded('uberprompt')) { - die "This script requires 'prompt_info' in order to work. " + die "This script requires 'uberprompt.pl' in order to work. " . "Please load it and try again"; } else { history_init(); @@ -119,8 +119,10 @@ sub history_exit { } sub update_history_prompt { + my $col = scalar(@search_matches) ? '%g' : '%r'; Irssi::signal_emit('change prompt', - " reverse-i-search: \`$search_str'", + ' reverse-i-search: `' . $col . $search_str + . '%n' . "'", 'UP_INNER'); } -- cgit v1.2.3 From 9e2e49faf7730daf70b56b4fa35716eb6eefddb3 Mon Sep 17 00:00:00 2001 From: Tom Feist Date: Wed, 13 Oct 2010 02:09:42 +0100 Subject: updated history search to use a irssi setting 'histsearch_debug' to enable debugging output. --- history-search/rl_history_search.pl | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'history-search') diff --git a/history-search/rl_history_search.pl b/history-search/rl_history_search.pl index 64f4f20..32d42a3 100644 --- a/history-search/rl_history_search.pl +++ b/history-search/rl_history_search.pl @@ -75,7 +75,8 @@ my @search_matches = (); my $match_index = 0; -sub DEBUG () { 0 } +my $DEBUG_ENABLED = 0; +sub DEBUG () { $DEBUG_ENABLED } # check we have uberprompt loaded. @@ -97,11 +98,21 @@ unless (script_is_loaded('uberprompt')) { } sub history_init { + Irssi::settings_add_bool('history_search', 'histsearch_debug', 0); + Irssi::command_bind('history_search_start', \&history_search); - #Irssi::command_bind('history_search_exit', \&history_search_exit); + + Irssi::signal_add ('setup changed' => \&setup_changed); Irssi::signal_add_first('gui key pressed' => \&handle_keypress); + + setup_changed(); } +sub setup_changed { + $DEBUG_ENABLED = Irssi::settings_get_bool('histsearch_debug'); +} + + sub history_search { $search_active = 1; $search_str = ''; -- cgit v1.2.3 From 3eb58a871f1c6d9697d479a0237fd33d628eb414 Mon Sep 17 00:00:00 2001 From: Tom Feist Date: Wed, 13 Oct 2010 12:37:23 +0100 Subject: removed a defined-or which needs perl 5.10 --- history-search/rl_history_search.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'history-search') diff --git a/history-search/rl_history_search.pl b/history-search/rl_history_search.pl index 32d42a3..eebb6c7 100644 --- a/history-search/rl_history_search.pl +++ b/history-search/rl_history_search.pl @@ -139,7 +139,7 @@ sub update_history_prompt { sub update_history_matches { my ($match_str) = @_; - $match_str //= $search_str; + $match_str = $search_str unless defined $match_str; my %unique; my @matches = grep { m/\Q$match_str/i } @history_cache; -- cgit v1.2.3