~ubuntu-branches/ubuntu/natty/perl-tk/natty

« back to all changes in this revision

Viewing changes to Tk/TextUndo.pm

  • Committer: Bazaar Package Importer
  • Author(s): Stephen Zander
  • Date: 2004-03-14 13:54:44 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20040314135444-prc09u2or4dbr3to
Tags: 1:800.025-2
Add xlibs-dev to Build-Depends:,
Closes: #237942

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (c) 1995-1999 Nick Ing-Simmons.
 
1
# Copyright (c) 1995-2003 Nick Ing-Simmons.
2
2
# Copyright (c) 1999 Greg London.
3
3
# All rights reserved.
4
4
# This program is free software; you can redistribute it and/or
6
6
package Tk::TextUndo;
7
7
 
8
8
use vars qw($VERSION $DoDebug);
9
 
$VERSION = '3.050'; # $Id: //depot/Tk8/Tk/TextUndo.pm#50 $
 
9
$VERSION = '3.054'; # $Id: //depot/Tk8/Tk/TextUndo.pm#54 $
10
10
$DoDebug = 0;
11
11
 
12
12
use Tk qw (Ev);
571
571
 $w->addGlobStart;
572
572
 $w->SUPER::Insert($char);
573
573
 $w->addGlobEnd;
 
574
 $w->see('insert');
574
575
}
575
576
 
576
577
 
709
710
   my $count=0;
710
711
   my $index = '1.0';
711
712
   my $progress;
712
 
   my ($lines) = $w->index('end') =~ /^(\d+)\./;
 
713
   my ($lines) = $w->index('end - 1 chars') =~ /^(\d+)\./;
713
714
   while ($w->compare($index,'<','end'))
714
715
    {
715
716
#    my $end = $w->index("$index + 1024 chars");
910
911
sub RestoreSelectionsMarkedSaved
911
912
{
912
913
 my ($w)=@_;
913
 
 my $i = 0;
 
914
 my $i = 1;
914
915
 my %mark_hash;
915
916
 foreach my $mark ($w->markNames)
916
917
  {
932
933
 
933
934
####################################################################
934
935
# selected lines may be discontinous sequence.
935
 
sub SelectedLineNumbers
 
936
sub GetMarkedSelectedLineNumbers
936
937
{
937
938
 my ($w) = @_;
938
 
 my @ranges = $w->tagRanges('sel');
 
939
 
 
940
 my $i = 1;
 
941
 my %mark_hash;
 
942
 my @ranges;
 
943
 foreach my $mark ($w->markNames)
 
944
  {
 
945
   $mark_hash{$mark}=1;
 
946
  }
 
947
 
 
948
 while(1)
 
949
  {
 
950
   my $markstart = 'MarkSelectionsSavePositions_'.$i++;
 
951
   last unless(exists($mark_hash{$markstart}));
 
952
   my $indexstart = $w->index($markstart);
 
953
   my $markend = 'MarkSelectionsSavePositions_'.$i++;
 
954
   last unless(exists($mark_hash{$markend}));
 
955
   my $indexend = $w->index($markend);
 
956
 
 
957
   push(@ranges, $indexstart, $indexend);
 
958
  }
 
959
 
939
960
 my @selection_list;
940
961
 while (@ranges)
941
962
  {
959
980
 my ($w,$insert_string)=@_;
960
981
 $w->addGlobStart;
961
982
 $w->MarkSelectionsSavePositions;
962
 
 foreach my $line ($w->SelectedLineNumbers)
 
983
 foreach my $line ($w->GetMarkedSelectedLineNumbers)
963
984
  {
964
985
   $w->insert($line.'.0', $insert_string);
965
986
  }
973
994
 $w->addGlobStart;
974
995
 $w->MarkSelectionsSavePositions;
975
996
 my $length = length($insert_string);
976
 
 foreach my $line ($w->SelectedLineNumbers)
 
997
 foreach my $line ($w->GetMarkedSelectedLineNumbers)
977
998
  {
978
999
   my $start = $line.'.0';
979
1000
   my $end   = $line.'.'.$length;