1#!/usr/local/bin/perl 2# 3# Created by Stefan "tommie" Tomanek [stefan@kann-nix.org] 4# to free the world from the evil inverted I 5# 6# 23.02.2002 7# *First release 8# 9# 01.03.200 10# *Changed to GPL 11 12use strict; 13use vars qw($VERSION %IRSSI); 14use Irssi; 15 16$VERSION = "2002123102"; 17%IRSSI = ( 18 authors => "Stefan 'tommie' Tomanek", 19 contact => "stefan\@pico.ruhr.de", 20 name => "tab_stop", 21 description => "This script replaces the evil inverted 'I' with a configurable number of whitespaces ", 22 license => "GPLv2", 23 changed => "$VERSION", 24); 25 26sub event_server_incoming { 27 my ($server, $data) = @_; 28 my $newdata; 29 if (has_tab($data)) { 30 $newdata = replace_tabs($data); 31 Irssi::signal_continue($server, $newdata); 32 } 33} 34 35# FIXME Experimental! 36sub sig_gui_print_text { 37 my ($win, $fg, $bg, $flags, $text, $dest) = @_; 38 return unless $text =~ /\t/; 39 my $newtext = replace_tabs($text); 40 Irssi::signal_continue($win, $fg, $bg, $flags, $newtext, $dest); 41} 42 43sub has_tab { 44 my ($text) = @_; 45 return $text =~ /\t/; 46} 47 48sub replace_tabs { 49 my ($text) = @_; 50 my $replacement = Irssi::settings_get_str('tabstop_replacement'); 51 $text =~ s/\t/$replacement/g; 52 return($text); 53} 54 55#Irssi::signal_add('gui print text', \&sig_gui_print_text); 56Irssi::signal_add_first('server incoming', \&event_server_incoming); 57 58Irssi::settings_add_str('misc', 'tabstop_replacement', " "); 59 60