aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Feist <shabble@metavore.org>2011-03-31 21:03:34 +0000
committerTom Feist <shabble@metavore.org>2011-03-31 21:03:34 +0000
commitd431098109187fdfbf68f7d63864c94442dc3354 (patch)
tree681f912fe56d5c150f0b910384fbb1e3c5e55b1c
parentpatch to fix irssi bug #795, although useless because it's already fixed in (diff)
downloadirssi-scripts-d431098109187fdfbf68f7d63864c94442dc3354.tar.gz
irssi-scripts-d431098109187fdfbf68f7d63864c94442dc3354.zip
uberprompt: add script developer notes and stealable code loading snippet to
documentation at the top of the script.
Diffstat (limited to '')
-rw-r--r--prompt_info/uberprompt.pl56
1 files changed, 56 insertions, 0 deletions
diff --git a/prompt_info/uberprompt.pl b/prompt_info/uberprompt.pl
index 70d083d..3ef220e 100644
--- a/prompt_info/uberprompt.pl
+++ b/prompt_info/uberprompt.pl
@@ -83,6 +83,62 @@
#
# signal_add 'prompt changed', sub { my ($text, $len) = @_; ... do something ... };
#
+#
+# NOTES FOR SCRIPT WRITERS:
+#
+# The following code snippet can be used within your own script as a preamble
+# to ensure that uberprompt is loaded before your script to avoid
+# any issues with load order. It first checks if uberprompt is loaded, and
+# if not, attempts to load it. If the load fails, the script will die
+# with an error message, otherwise it will call your app_init() function.
+#
+# ---- start of snippet ----
+
+# my $DEBUG_ENABLED = 0;
+# sub DEBUG () { $DEBUG_ENABLED }
+#
+# # check we have uberprompt loaded.
+#
+# sub script_is_loaded {
+# my $name = shift;
+# print "Checking if $name is loaded" if DEBUG;
+# no strict 'refs';
+# my $retval = defined %{ "Irssi::Script::${name}::" };
+# use strict 'refs';
+#
+# return $retval;
+# }
+#
+# if (not script_is_loaded('uberprompt')) {
+#
+# print "This script requires 'uberprompt.pl' in order to work. "
+# . "Attempting to load it now...";
+#
+# Irssi::signal_add('script error', 'load_uberprompt_failed');
+# Irssi::command("script load uberprompt.pl");
+#
+# unless(script_is_loaded('uberprompt')) {
+# load_uberprompt_failed("File does not exist");
+# }
+# app_init();
+# } else {
+# app_init();
+# }
+#
+# sub load_uberprompt_failed {
+# Irssi::signal_remove('script error', 'load_prompt_failed');
+#
+# print "Script could not be loaded. Script cannot continue. "
+# . "Check you have uberprompt.pl installed in your path and "
+# . "try again.";
+#
+# die "Script Load Failed: " . join(" ", @_);
+# }
+#
+# ---- end of snippet ----
+#
+#
+#
# Bugs:
#
# * Resizing the terminal rapidly whilst using this script in debug mode