mirror of
https://github.com/irssi/irssi.git
synced 2026-08-10 12:23:37 +02:00
Update scripts to most recent version from scripts.irssi.org
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@3931 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
parent
74b4c07223
commit
fa6d77429a
3 changed files with 408 additions and 129 deletions
108
scripts/buf.pl
108
scripts/buf.pl
|
|
@ -1,28 +1,28 @@
|
|||
# Highly experimental. use it at your own risk.
|
||||
|
||||
use strict;
|
||||
use vars qw($VERSION %IRSSI);
|
||||
|
||||
use Irssi 20020120; # 21/01/2002, 18:00 cvs commit
|
||||
# at http://juerd.nl/irssi/temporary.deb for debian sid
|
||||
$VERSION = "2.06";
|
||||
use Irssi qw(command signal_add signal_add_first active_win
|
||||
settings_get_str settings_get_bool channels windows
|
||||
settings_add_str settings_add_bool get_irssi_dir
|
||||
window_find_refnum signal_stop);
|
||||
$VERSION = '2.13';
|
||||
%IRSSI = (
|
||||
authors => "Juerd",
|
||||
contact => "juerd\@juerd.nl",
|
||||
name => "Scroll buffer thingy",
|
||||
description => "Saves the buffer for /upgrade",
|
||||
license => "Public Domain",
|
||||
url => "http://juerd.nl/irssi/",
|
||||
changed => "Tue Feb 28 16:22 CET 2002",
|
||||
changes => "+logging workaround (untested, suggested by darix)"
|
||||
authors => 'Juerd',
|
||||
contact => 'juerd@juerd.nl',
|
||||
name => 'Scroll buffer restorer',
|
||||
description => 'Saves the buffer for /upgrade, so that no information is lost',
|
||||
license => 'Public Domain',
|
||||
url => 'http://juerd.nl/irssi/',
|
||||
changed => 'Mon May 13 19:41 CET 2002',
|
||||
changes => 'Severe formatting bug removed * oops, I ' .
|
||||
'exposed Irssi to ircII foolishness * sorry ' .
|
||||
'** removed logging stuff (this is a fix)',
|
||||
note1 => 'This script HAS TO BE in your scripts/autorun!',
|
||||
note2 => 'Perl support must be static or in startup',
|
||||
);
|
||||
|
||||
# Saves the Irssi scrollbuffer and displays it after /UPGADEing.
|
||||
# Additionaly saves your settings and layout.
|
||||
# HAS TO BE in $irssidir/scripts/autorun (don't forget to load the
|
||||
# perl module if you have to... put /load perl in $irssidir/startup)
|
||||
|
||||
# Q: How can I get a very smooth and clean upgrade?
|
||||
#
|
||||
# A: /set -clear upgrade_separator
|
||||
# /set upgrade_suppress_join ON (default)
|
||||
# /set channel_sync OFF
|
||||
|
|
@ -31,6 +31,7 @@ $VERSION = "2.06";
|
|||
# Q: Is it possible to save my command history?
|
||||
# Q: Can I prevent the screen from blinking?
|
||||
# Q: Can you make it faster?
|
||||
#
|
||||
# A: Probably not, but if you can do it, tell me how.
|
||||
|
||||
use Irssi::TextUI;
|
||||
|
|
@ -39,94 +40,83 @@ use Data::Dumper;
|
|||
my %suppress;
|
||||
|
||||
sub upgrade {
|
||||
open (BUF, sprintf('>%s/scrollbuffer', Irssi::get_irssi_dir()));
|
||||
my $logging = Irssi::settings_get_bool('autolog') || 0;
|
||||
print BUF join("\0", map $_->{server}->{address} . $_->{name}, Irssi::channels()), "\n";
|
||||
print BUF "$logging\n";
|
||||
for my $window (Irssi::windows()){
|
||||
open BUF, sprintf('>%s/scrollbuffer', get_irssi_dir) or die $!;
|
||||
print BUF join("\0", map $_->{server}->{address} . $_->{name}, channels), "\n";
|
||||
for my $window (windows) {
|
||||
next unless defined $window;
|
||||
next if $window->{name} eq 'status';
|
||||
my $view = $window->view();
|
||||
my $line = $view->get_lines();
|
||||
my $view = $window->view;
|
||||
my $line = $view->get_lines;
|
||||
my $lines = 0;
|
||||
my $buf = '';
|
||||
if (defined $line){
|
||||
{
|
||||
$buf .= $line->get_text(1) . "\n";
|
||||
$line = $line->next();
|
||||
$line = $line->next;
|
||||
$lines++;
|
||||
redo if defined $line;
|
||||
}
|
||||
}
|
||||
printf BUF ("%s:%s\n%s", $window->{refnum}, $lines, $buf);
|
||||
printf BUF "%s:%s\n%s", $window->{refnum}, $lines, $buf;
|
||||
}
|
||||
close BUF;
|
||||
unlink sprintf("%s/sessionconfig", Irssi::get_irssi_dir());
|
||||
Irssi::command('/layout save');
|
||||
Irssi::command('/set autolog off') if $logging;
|
||||
Irssi::command('/save');
|
||||
unlink sprintf("%s/sessionconfig", get_irssi_dir);
|
||||
command 'layout save';
|
||||
command 'save';
|
||||
}
|
||||
|
||||
sub restore {
|
||||
open (BUF, sprintf('<%s/scrollbuffer', Irssi::get_irssi_dir()));
|
||||
open BUF, sprintf('<%s/scrollbuffer', get_irssi_dir) or die $!;
|
||||
my @suppress = split /\0/, <BUF>;
|
||||
my $logging = <BUF>;
|
||||
chomp $logging;
|
||||
if (Irssi::settings_get_bool('upgrade_suppress_join')) {
|
||||
if (settings_get_bool 'upgrade_suppress_join') {
|
||||
chomp $suppress[-1];
|
||||
@suppress{@suppress} = (2) x @suppress;
|
||||
}
|
||||
Irssi::active_win()->command('/^window scroll off');
|
||||
active_win->command('^window scroll off');
|
||||
while (my $bla = <BUF>){
|
||||
chomp $bla;
|
||||
my ($refnum, $lines) = split /:/, $bla;
|
||||
next unless $lines;
|
||||
my $window = Irssi::window_find_refnum($refnum);
|
||||
my $window = window_find_refnum $refnum;
|
||||
unless (defined $window){
|
||||
<BUF> for 1..$lines;
|
||||
Irssi::print("no $refnum?");
|
||||
next;
|
||||
}
|
||||
my $view = $window->view();
|
||||
my $view = $window->view;
|
||||
$view->remove_all_lines();
|
||||
$view->redraw();
|
||||
my $buf = '';
|
||||
$buf .= <BUF> for 1..$lines;
|
||||
my $sep = Irssi::settings_get_str('upgrade_separator');
|
||||
my $sep = settings_get_str 'upgrade_separator';
|
||||
$sep .= "\n" if $sep ne '';
|
||||
$window->gui_printtext_after(undef, MSGLEVEL_CLIENTNOTICE, "$buf\cO$sep");
|
||||
$view->redraw();
|
||||
}
|
||||
Irssi::active_win()->command('/^window scroll on');
|
||||
Irssi::active_win()->command('/^scrollback end');
|
||||
Irssi::command('/set autolog on') if $logging;
|
||||
active_win->command('^window scroll on');
|
||||
active_win->command('^scrollback end');
|
||||
}
|
||||
|
||||
sub suppress {
|
||||
my ($first, $second) = @_;
|
||||
return unless scalar keys %suppress
|
||||
and Irssi::settings_get_bool('upgrade_suppress_join');
|
||||
return
|
||||
unless scalar keys %suppress
|
||||
and settings_get_bool 'upgrade_suppress_join';
|
||||
my $key = $first->{address} .
|
||||
(grep { (s/^://, /^[#!+&]/) } split ' ', $second)[0];
|
||||
(grep { (s/^://, /^[#!+&]/) } split ' ', $second)[0];
|
||||
if (exists $suppress{$key} and $suppress{$key}--) {
|
||||
Irssi::signal_stop();
|
||||
signal_stop();
|
||||
delete $suppress{$key} unless $suppress{$key};
|
||||
}
|
||||
}
|
||||
|
||||
# Don't use these :P they're for testing
|
||||
#Irssi::command_bind('emulate_upgrade', 'upgrade');
|
||||
#Irssi::command_bind('emulate_restore', 'restore');
|
||||
settings_add_str 'buffer', 'upgrade_separator' => '=Upgrade=';
|
||||
settings_add_bool 'buffer', 'upgrade_suppress_join' => 1;
|
||||
|
||||
Irssi::settings_add_str('buffer', 'upgrade_separator', '=Upgrade=');
|
||||
Irssi::settings_add_bool('buffer', 'upgrade_suppress_join', 1);
|
||||
signal_add_first 'session save' => 'upgrade';
|
||||
signal_add_first 'session restore' => 'restore';
|
||||
signal_add 'event 366' => 'suppress';
|
||||
signal_add 'event join' => 'suppress';
|
||||
|
||||
Irssi::signal_add_first('session save', 'upgrade');
|
||||
Irssi::signal_add_first('session restore', 'restore');
|
||||
Irssi::signal_add('event 366', 'suppress');
|
||||
Irssi::signal_add('event join', 'suppress');
|
||||
|
||||
unless (-f sprintf('%s/scripts/autorun/buf.pl', Irssi::get_irssi_dir())) {
|
||||
unless (-f sprintf('%s/scripts/autorun/buf.pl', get_irssi_dir)) {
|
||||
Irssi::print('PUT THIS SCRIPT IN ~/.irssi/scripts/autorun/ BEFORE /UPGRADING!!');
|
||||
Irssi::print('And don\'t forget to /load perl using ~/.irssi/autostart');
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue