summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTrevor Slocum2014-08-01 15:27:47 -0700
committerTrevor Slocum2014-08-01 15:27:47 -0700
commit2c0b34ffefaf18f2aa746f58c789ea01bfe337fd (patch)
tree692b5f8a2021adfdb05fae5ca81d13fae6484086
parenta81da41a8cfd9b6617b2ec0d664597d2eaeb7af2 (diff)
downloadscripts.irssi.org-2c0b34ffefaf18f2aa746f58c789ea01bfe337fd.tar.bz2
Add scripts autoclearinput and winnum
-rw-r--r--_data/scripts.yaml20
-rw-r--r--scripts/autoclearinput.pl77
-rw-r--r--scripts/winnum.pl41
3 files changed, 138 insertions, 0 deletions
diff --git a/_data/scripts.yaml b/_data/scripts.yaml
index a9bc2cf..45d9119 100644
--- a/_data/scripts.yaml
+++ b/_data/scripts.yaml
@@ -280,6 +280,16 @@
url: "http://ninja.no/irssi/autochannel.pl"
version: "1.2"
+- authors: "Trevor Slocum"
+ contact: "tslocum@gmail.com"
+ description: "Automatically clears pending input when you are away"
+ filename: "autoclearinput.pl"
+ modified: "2014-05-13 10:35:00"
+ license: "GPLv3"
+ name: "autoclearinput"
+ url: "https://github.com/tslocum/irssi-scripts"
+ version: "1.0.1"
+
- authors: "Marcin Rozycki"
changed: "Fri Jan 3 23:20:06 CET 2003"
contact: "derwan@irssi.pl"
@@ -4372,6 +4382,16 @@
url: "http://wouter.coekaerts.be/irssi/"
version: "1.0"
+- authors: "Trevor Slocum"
+ contact: "tslocum@gmail.com"
+ description: "Goto a window by its reference number with /##"
+ filename: "winnum.pl"
+ modified: "2014-05-01 16:04:00"
+ license: "GPLv3"
+ name: "winnum"
+ url: "https://github.com/tslocum/irssi-scripts"
+ version: "1.0.0"
+
- authors: "Antti Ruokomäki"
changed: "Wed Apr 12 22:46:00 2006"
contact: "antti.ruokomaki@mbnet.fi"
diff --git a/scripts/autoclearinput.pl b/scripts/autoclearinput.pl
new file mode 100644
index 0000000..f01df5d
--- /dev/null
+++ b/scripts/autoclearinput.pl
@@ -0,0 +1,77 @@
+#
+# autoclearinput.pl
+# Automatically clears pending input when you are away.
+#
+#
+# Settings:
+# /SET autoclear_sec <seconds> (0 to disable, 30 by default)
+#
+# Commands:
+# /AUTOCLEARED, /CLEARED Retrieve the last cleared line of input
+#
+
+use strict;
+use vars qw($VERSION %IRSSI);
+
+$VERSION = '1.0.1';
+%IRSSI = (
+ authors => 'Trevor "tee" Slocum',
+ contact => 'tslocum@gmail.com',
+ name => 'AutoClearInput',
+ description => 'Automatically clears pending input when you are away.',
+ license => 'GPLv3',
+ url => 'https://github.com/tslocum/irssi-scripts',
+ changed => '2014-05-13'
+);
+
+my ($autoclear_tag, $autoclear_last_input);
+
+sub autoclear_key_pressed {
+ return if (Irssi::settings_get_int("autoclear_sec") <= 0);
+
+ if (defined($autoclear_tag)) {
+ Irssi::timeout_remove($autoclear_tag);
+ }
+
+ $autoclear_tag = Irssi::timeout_add_once(Irssi::settings_get_int("autoclear_sec") * 1000, "autoclear_timeout", "");
+}
+
+sub autoclear_timeout {
+ return if (Irssi::settings_get_int("autoclear_sec") <= 0);
+
+ my $autoclear_current_input = Irssi::parse_special('$L');
+ $autoclear_current_input =~ s/^\s+//;
+ $autoclear_current_input =~ s/\s+$//;
+ if ($autoclear_current_input ne "") {
+ $autoclear_last_input = Irssi::parse_special('$L');
+ }
+
+ Irssi::gui_input_set("");
+}
+
+sub autoclear_retrieve {
+ if (defined($autoclear_last_input)) {
+ Irssi::timeout_add_once(50, "autoclear_retrieve_workaround", "");
+ } else {
+ Irssi::print($IRSSI{name} . ': No input has been cleared yet.');
+ }
+}
+
+sub autoclear_retrieve_workaround {
+ return if (!defined($autoclear_last_input));
+
+ Irssi::gui_input_set($autoclear_last_input);
+ Irssi::gui_input_set_pos(length($autoclear_last_input));
+}
+
+Irssi::settings_add_int("misc", "autoclear_sec", 30);
+Irssi::signal_add_last("gui key pressed", "autoclear_key_pressed");
+Irssi::command_bind("autocleared", "autoclear_retrieve");
+Irssi::command_bind("cleared", "autoclear_retrieve");
+
+print $IRSSI{name} . ': v' . $VERSION . ' loaded. Pending input ' .
+ (Irssi::settings_get_int("autoclear_sec") > 0
+ ? ('will be cleared after %9' . Irssi::settings_get_int("autoclear_sec") . ' seconds%9 of idling.')
+ : 'clearing is currently %9disabled%9.');
+print $IRSSI{name} . ': Configure this delay with: /SET autoclear_sec <seconds> [0 to disable]';
+print $IRSSI{name} . ': Retrieve the last cleared line of input with: /CLEARED';
diff --git a/scripts/winnum.pl b/scripts/winnum.pl
new file mode 100644
index 0000000..e9ed0bc
--- /dev/null
+++ b/scripts/winnum.pl
@@ -0,0 +1,41 @@
+#
+# winnum.pl
+# Goto a window by its reference number with /##
+#
+#
+# Commands:
+# /<window #> Go to window
+#
+
+use strict;
+use vars qw($VERSION %IRSSI);
+
+$VERSION = '1.0.0';
+%IRSSI = (
+ authors => 'Trevor "tee" Slocum',
+ contact => 'tslocum@gmail.com',
+ name => 'WinNum',
+ description => 'Goto a window by its reference number with /##',
+ license => 'GPLv3',
+ url => 'https://github.com/tslocum/irssi-scripts',
+ changed => '2014-05-01'
+);
+
+sub winnum_default_command {
+ my ($command, $server) = @_;
+
+ $command =~ s/^\s+//;
+ $command =~ s/\s+$//;
+ my $winnum = ($command =~ /(\w+)/)[0];
+
+ if ($winnum =~ /^\d+$/) {
+ my $window = Irssi::window_find_refnum($winnum);
+ $window->set_active if $window;
+
+ Irssi::signal_stop();
+ }
+}
+
+Irssi::signal_add_first("default command", "winnum_default_command");
+
+print $IRSSI{name} . ': v' . $VERSION . ' loaded. Enter %9/<window #>%9 to goto a window.';