~ubuntu-branches/debian/sid/padre/sid

« back to all changes in this revision

Viewing changes to lib/Padre/Document.pm

  • Committer: Bazaar Package Importer
  • Author(s): Damyan Ivanov, gregor herrmann, Damyan Ivanov
  • Date: 2009-11-18 17:48:27 UTC
  • mfrom: (1.1.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20091118174827-srz62scl23gdl88v
Tags: 0.50.ds1-1
[ gregor herrmann ]
* debian/control: change dependency on "libclass-xsaccessor-array-perl
  (>= 1.02)" to "libclass-xsaccessor-perl (>= 1.05-2) |
  libclass-xsaccessor-array-perl (>= 1.02)".

[ Damyan Ivanov ]
* New upstream release
  + copyright: add a new translator
    - describe share/doc/perlopref copyright and licensing
  + update patches:
    - refresh disable-tcp-server.patch
    - drop fix-man-whatis.patch and fix-pod.patch (merged upstream)
    - drop fix-helpprovider-with-no-perlopref.patch: no longer necessary
* repack.sh: in 0.49 padre.exe moved from script/ to bin/
  + perlopref is now properly licensed
* add perl (>= 5.10.1) as a preferred alternative to versioned (build)
  dependencies on libtest-simple-perl and libpod-simple-perl
* update debian/not-real-manual.list for 0.50 (one file added, two files
  changed in size)
* rules: remove cruft from padre.deb
  + license etc from perlopref directory (already present in d/copyright)
  + remove .po files from the .deb (there are .mo files installed)

Show diffs side-by-side

added added

removed removed

Lines of Context:
135
135
use Padre::MimeTypes ();
136
136
use Padre::File      ();
137
137
 
138
 
our $VERSION = '0.48';
 
138
our $VERSION = '0.50';
139
139
 
140
140
 
141
141
 
557
557
        return "\n";
558
558
}
559
559
 
 
560
=pod
 
561
 
 
562
=head2 autocomplete_matching_char
 
563
 
 
564
The first argument needs to be a reference to the editor this method should
 
565
work on.
 
566
 
 
567
The second argument is expected to be a event reference to the event object
 
568
which is the reason why the method was launched.
 
569
 
 
570
This method expects a hash as the third argument. If the last key typed by the
 
571
user is a key in this hash, the value is automatically added and the cursor is
 
572
set between key and value. Both key and value are expected to be ASCII codes.
 
573
 
 
574
Usually used for brackets and text signs like:
 
575
 
 
576
        $self->autocomplete_matching_char(
 
577
                        $editor,
 
578
                        $event,
 
579
                        39  => 39,  # ' '
 
580
                        40  => 41,  # ( )
 
581
                );
 
582
 
 
583
Returns 1 if something was added or 0 otherwise (if anybody cares about this).
 
584
 
 
585
=cut
 
586
 
 
587
sub autocomplete_matching_char {
 
588
        my $self   = shift;
 
589
        my $editor = shift;
 
590
        my $event  = shift;
 
591
        my %table  = @_;
 
592
 
 
593
        my $config = Padre->ide->config;
 
594
        my $main   = Padre->ide->wx->main;
 
595
 
 
596
        my $selection_exists = 0;
 
597
        my $text             = $editor->GetSelectedText;
 
598
        if ( defined($text) && length($text) > 0 ) {
 
599
                $selection_exists = 1;
 
600
        }
 
601
 
 
602
        my $key = $event->GetUnicodeKey;
 
603
 
 
604
        my $pos   = $editor->GetCurrentPos;
 
605
        my $line  = $editor->LineFromPosition($pos);
 
606
        my $first = $editor->PositionFromLine($line);
 
607
        my $last  = $editor->PositionFromLine( $line + 1 ) - 1;
 
608
 
 
609
        if ( $config->autocomplete_brackets ) {
 
610
                if ( $table{$key} ) {
 
611
                        if ($selection_exists) {
 
612
                                my $start = $editor->GetSelectionStart;
 
613
                                my $end   = $editor->GetSelectionEnd;
 
614
                                $editor->GotoPos($end);
 
615
                                $editor->AddText( chr( $table{$key} ) );
 
616
                                $editor->GotoPos($start);
 
617
                        } else {
 
618
                                my $nextChar;
 
619
                                if ( $editor->GetTextLength > $pos ) {
 
620
                                        $nextChar = $editor->GetTextRange( $pos, $pos + 1 );
 
621
                                }
 
622
                                unless ( defined($nextChar) && ord($nextChar) == $table{$key}
 
623
                                        and ( !$config->autocomplete_multiclosebracket ) )
 
624
                                {
 
625
                                        $editor->AddText( chr( $table{$key} ) );
 
626
                                        $editor->CharLeft;
 
627
                                }
 
628
                        }
 
629
                        return 1;
 
630
                }
 
631
        }
 
632
 
 
633
        return 0;
 
634
 
 
635
}
 
636
 
 
637
 
 
638
 
560
639
sub _set_filename {
561
640
        my $self     = shift;
562
641
        my $filename = shift;
575
654
        $self->{filename} = $self->{file}->{filename};
576
655
}
577
656
 
 
657
# Only a dummy for documents which don't support this
 
658
sub autoclean {
 
659
        my $self = shift;
 
660
 
 
661
        return 1;
 
662
}
 
663
 
 
664
 
 
665
 
578
666
sub save_file {
579
667
        my ($self) = @_;
580
668
        $self->set_errstr('');
581
669
 
 
670
        my $config = Padre->ide->config;
 
671
 
 
672
        $self->autoclean if $config->save_autoclean;
 
673
 
582
674
        my $content = $self->text_get;
583
675
        my $file    = $self->file;
584
676
        if ( !defined($file) ) {