Changeset 470
- Timestamp:
- 10/26/08 02:14:21 (3 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 4 edited
-
MANIFEST (modified) (1 diff)
-
lib/Padre/Document.pm (modified) (1 diff)
-
lib/Padre/Documents.pm (added)
-
lib/Padre/Wx/MainWindow.pm (modified) (5 diffs)
-
lib/Padre/Wx/Menu.pm (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/MANIFEST
r452 r470 10 10 lib/Padre/DB.pm 11 11 lib/Padre/Document.pm 12 lib/Padre/Documents.pm 12 13 lib/Padre/PluginManager.pm 13 14 lib/Padre/Project.pm -
trunk/lib/Padre/Document.pm
r456 r470 147 147 our $DEFAULT_LEXER = wxSTC_LEX_AUTOMATIC; 148 148 149 ### DODGY HACK150 # This is a temporary method that can generate an "anonymous"151 # document for whatever is in the current buffer. The document152 # is not saved or cached anywhere.153 # This method may be changed to work properly later, but for now154 # feel free to use it wherever needed.155 sub from_selection {156 $_[0]->from_pageid( $_[0]->notebook->GetSelection );157 }158 159 sub from_pageid {160 my $class = shift;161 my $pageid = shift;162 163 # TODO maybe report some error?164 return if not defined $pageid or $pageid =~ /\D/;165 166 if ( $pageid == -1 ) {167 # No page selected168 return;169 }170 171 return if $pageid >= $class->notebook->GetPageCount;172 173 my $page = $class->notebook->GetPage( $pageid );174 175 return $page->{Document};176 }177 178 179 180 181 182 #####################################################################183 # Class Methods184 185 sub notebook {186 Padre->ide->wx->main_window->{notebook};187 }188 189 190 191 149 192 150 -
trunk/lib/Padre/Wx/MainWindow.pm
r469 r470 19 19 use Padre::Wx::ToolBar (); 20 20 use Padre::Wx::Output (); 21 use Padre::Documents (); 21 22 22 23 use base qw{Wx::Frame}; … … 341 342 342 343 sub selected_document { 343 Padre::Document ->from_selection;344 Padre::Documents->from_selection; 344 345 } 345 346 … … 850 851 # and it is unused, close it. 851 852 if ( $self->{notebook}->GetPageCount == 1 ) { 852 if ( Padre::Document ->from_selection->is_unused ) {853 if ( Padre::Documents->from_selection->is_unused ) { 853 854 $self->on_close; 854 855 } … … 935 936 my $self = shift; 936 937 foreach my $id ( $self->pageids ) { 937 my $doc = Padre::Document ->from_pageid($id);938 my $doc = Padre::Documents->from_pageid($id); 938 939 $self->on_save( $doc ) or return 0; 939 940 } … … 1244 1245 1245 1246 sub _DOCUMENT { 1246 return (defined $_[0]) ? Padre::Document ->from_pageid($_[0]) : Padre::Document->from_selection;1247 return (defined $_[0]) ? Padre::Documents->from_pageid($_[0]) : Padre::Documents->from_selection; 1247 1248 } 1248 1249 -
trunk/lib/Padre/Wx/Menu.pm
r469 r470 6 6 use Params::Util qw{_INSTANCE}; 7 7 8 use Padre::Wx (); 9 use Padre::Util (); 8 use Padre::Wx (); 9 use Padre::Util (); 10 use Padre::Documents (); 10 11 11 12 our $VERSION = '0.12'; … … 99 100 sub { 100 101 if ( $_[ 0 ]->{notebook}->GetPageCount == 1 ) { 101 if ( Padre::Document ->from_selection->is_unused ) {102 if ( Padre::Documents->from_selection->is_unused ) { 102 103 $_[0]->on_close; 103 104 } … … 138 139 $menu->{edit}->Append( Wx::wxID_UNDO, '' ), 139 140 sub { 140 my $page = Padre::Document ->from_selection->editor;141 my $page = Padre::Documents->from_selection->editor; 141 142 if ( $page->CanUndo ) { 142 143 $page->Undo; … … 148 149 $menu->{edit}->Append( Wx::wxID_REDO, '' ), 149 150 sub { 150 my $page = Padre::Document ->from_selection->editor;151 my $page = Padre::Documents->from_selection->editor; 151 152 if ( $page->CanRedo ) { 152 153 $page->Redo; … … 277 278 $menu->{perl_find_unmatched}, 278 279 sub { 279 my $doc = Padre::Document ->from_selection;280 my $doc = Padre::Documents->from_selection; 280 281 unless ( $doc and $doc->isa('Padre::Document::Perl') ) { 281 282 return; … … 437 438 sub { 438 439 $DB::single = 1; 439 my $document = Padre::Document ->from_selection;440 my $document = Padre::Documents->from_selection; 440 441 $_[0]->{menu}->refresh( $document ); 441 442 $_[0]->SetMenuBar( $_[0]->{menu}->{wx} ); … … 449 450 sub { 450 451 my $self = shift; 451 my $code = Padre::Document ->from_selection->text_get;452 my $code = Padre::Documents->from_selection->text_get; 452 453 eval $code; 453 454 if ($@) {
Note: See TracChangeset
for help on using the changeset viewer.
