cvs: embed /php-irssi/examples rotator.php

From: Date: Wed, 02 Apr 2003 10:50:06 +0000
Subject: cvs: embed /php-irssi/examples rotator.php
Groups: php.embed.cvs 
Request: Send a blank email to [email protected] to get a copy of this message
wez		Wed Apr  2 05:50:06 2003 EDT

  Modified files:              
    /embed/php-irssi/examples	rotator.php 
  Log:
  Howto use it :)
  
  
  
Index: embed/php-irssi/examples/rotator.php
diff -u embed/php-irssi/examples/rotator.php:1.1 embed/php-irssi/examples/rotator.php:1.2
--- embed/php-irssi/examples/rotator.php:1.1	Wed Apr  2 05:35:04 2003
+++ embed/php-irssi/examples/rotator.php	Wed Apr  2 05:50:06 2003
@@ -1,17 +1,23 @@
 <?php
-
-/* Rotator displays a small statusbar item to show that irssi is still running */
+/* $Id: rotator.php,v 1.2 2003/04/02 10:50:06 wez Exp $
+ * Rotator displays a small statusbar item to show that irssi is still running.
+ *
+ * Usage:
+ *   Load this script, then add the status bar item:
+ *   /statusbar window add -align right php_rotator
+ */
 
 namespace SampleRotator {
 
-	var $R = "foo";
-
 	class Rotator {
 		var $pos = 0;
 		var $display = '';
 		var $width = 10;
 		var $charset = 'hey there, this is a scrolling message';
 
+		/* milliseconds between scroll increments */
+		var $update_speed = 800;
+
 		function scroll()
 		{
 			$this->pos++;
@@ -27,13 +33,17 @@
 			$item->min_size = $this->width;
 			$item->default_handler($get_size_only, '{sb ' . $this->display . '}',
'', true);
 		}
+
+		function __construct()
+		{
+			irssi_statusbar_item_register('php_rotator', '$0', array($this,
'draw_bar'));
+			irssi_timeout_add($this->update_speed, array($this, 'scroll'));
+		}
 	}
 
 	function init()
 	{
-		SampleRotator::$R = new SampleRotator::Rotator;
-		irssi_statusbar_item_register('php_rotator', '$0', array(SampleRotator::$R,
'draw_bar'));
-		irssi_timeout_add(800, array(SampleRotator::$R, 'scroll'));
+		new SampleRotator::Rotator;
 	}
 }
 




Thread (1 message)

  • Wez Furlong
« previous php.embed.cvs (#75) next »