aboutsummaryrefslogtreecommitdiffstats
path: root/feature-tests/subtest.pl
diff options
context:
space:
mode:
authorTom Feist <shabble@cowu.be>2010-07-24 17:23:13 +0000
committerTom Feist <shabble@cowu.be>2010-07-24 17:23:13 +0000
commit91f126ae4c9ea90336bdeb24001fadca79439edc (patch)
treed21b72a82b67b0979aadfa3f6efbbc2586d962b1 /feature-tests/subtest.pl
parentupdated script info to add my url and to change contact details to me (diff)
downloadirssi-scripts-91f126ae4c9ea90336bdeb24001fadca79439edc.tar.gz
irssi-scripts-91f126ae4c9ea90336bdeb24001fadca79439edc.zip
moved most tests to feature-tests/
Diffstat (limited to 'feature-tests/subtest.pl')
-rw-r--r--feature-tests/subtest.pl76
1 files changed, 76 insertions, 0 deletions
diff --git a/feature-tests/subtest.pl b/feature-tests/subtest.pl
new file mode 100644
index 0000000..fd5a9cc
--- /dev/null
+++ b/feature-tests/subtest.pl
@@ -0,0 +1,76 @@
+use strict;
+use Irssi;
+use Irssi::TextUI;
+use Data::Dumper;
+
+use vars qw($VERSION %IRSSI);
+$VERSION = '1.0';
+%IRSSI = (
+ authors => 'Wouter Coekaerts',
+ contact => 'coekie@irssi.org',
+ name => 'history_search',
+ description => 'Search within your typed history as you type (like ctrl-R in bash)',
+ license => 'GPLv2 or later',
+ url => 'http://wouter.coekaerts.be/irssi/',
+ changed => '04/08/07'
+);
+
+
+Irssi::command_bind("foo bar", \&subcmd_bar);
+Irssi::command_bind("foo", \&subcmd_handler);
+
+sub subcmd_handler {
+ my ($data, $server, $item) = @_;
+ $data =~ s/\s+$//g;
+ Irssi::command_runsub('foo', $data, $server, $item);
+}
+
+sub subcmd_bar {
+ my ($args) = @_;
+ print "subcommand called with: $args";
+}
+
+# my $prev_typed;
+# my $prev_startpos;
+# my $enabled = 0;
+
+# Irssi::command_bind('history_search', sub {
+# $enabled = ! $enabled;
+# if ($enabled) {
+# $prev_typed = '';
+# $prev_startpos = 0;
+# }
+# });
+
+# Irssi::signal_add_last 'gui key pressed' => sub {
+# my ($key) = @_;
+
+# if ($key == 10) { # enter
+# $enabled = 0;
+# }
+
+# return unless $enabled;
+
+# my $prompt = Irssi::parse_special('$L');
+# my $pos = Irssi::gui_input_get_pos();
+
+# if ($pos < $prev_startpos) {
+# $enabled = 0;
+# return;
+# }
+
+# my $typed = substr($prompt, $prev_startpos, ($pos-$prev_startpos));
+
+# my $history = ($typed eq '') ? '' : Irssi::parse_special('$!' . $typed . '!');
+# if ($history eq '') {
+# $history = $typed;
+# }
+
+# my $startpos = index(lc($history), lc($typed));
+
+# Irssi::gui_input_set($history);
+# Irssi::gui_input_set_pos($startpos + length($typed));
+
+# $prev_typed = $typed;
+# $prev_startpos = $startpos;
+# };