Commits

Herbert Breunung committed ac839f5

base file menu functions operational with split docbar

  • Participants
  • Parent commits 408cdc8
  • Branches sp1

Comments (0)

Files changed (7)

File lib/Kephra/App/Bar/Document.pm

-use v5.10;
-use strict;
+use v5.12;
 use warnings;
 use Wx;
 use Wx::AUI;
 
 sub set_page_title {
 	my ($self, $label, $page) = @_;
-	return if blessed($page) and $page->isa('Kephra::App::Panel');
-	my $position = $page ? $self->GetPageIndex($page) : $self->GetSelection;
-	return unless $self->valid_page_pos($position);
+	$page = $self->GetSelection unless defined $page;
+	return Kephra::Log::warning("need a Kephra::App::Panel or valid position number") 
+		unless (looks_like_number($page) and $self->valid_page_pos($page))
+		or (blessed($page) and $page->isa('Kephra::App::Panel'));
+	my $found = $self->GetPageIndex($page);
+	my $position = $found eq &Wx::wxNOT_FOUND ? $page : $found;
 	$self->SetPageText( $position, $label );
 }
 

File lib/Kephra/App/Editor.pm

-use v5.10;
-use strict;
+use v5.12;
 use warnings;
 use Wx;
 use Wx::STC;

File lib/Kephra/App/Frame.pm

-use v5.10;
+use v5.12;
 use warnings;
 use Wx;
 use Kephra::API;
 sub refresh_title {
 	my $self = shift;
 	my $doc = Kephra::API::document();
-	my $title = (ref $doc and $doc->file_name)
-		? $doc->file_name.' ('.$doc->file_path.')'
-		: Kephra::API::document()->title();
+	my $title;
+	$title .= $doc->title if $doc->title;
+	$title .= ' ('.$doc->file_path.')' if $doc->file_path;
 	$self->set_title( $title . " - $title_end" );
 }
 

File lib/Kephra/App/Part/Editor.pm

 }
 sub select_docbar {
 	my $bar = shift;
-	return Kephra::Log::warning("need a Kephra::App::Bar::Document instance") 
+	return Kephra::Log::warning("need a Kephra::App::Bar::Document instance")
 		unless ref $bar eq 'Kephra::App::Bar::Document';
 	return if $active_bar eq $bar;
 	my $i;

File lib/Kephra/Document.pm

 		} else {
 			$self->_set_title('<untitled '.$self->anon_NR.'>');
 		}
+
 		$self->_set_old_file_path( $self->file_path );
+		$_->set_page_title( $self->title, $self->panel->{$_} )
+			for Kephra::API::all_docbars();
 	});
 has file_dir     => ( is => 'rwp', );
 has file_name    => ( is => 'rwp', );
 	$self->_set_ID( Kephra::API::Docs::add($self) );
 	$self->_set_title('<untitled '.$self->anon_NR.'>') unless $self->file_path;
 }
-sub DEMOLISH { Kephra::API::Docs::remove($_[0]); say "demolish $_[0]"; 
+sub DEMOLISH { Kephra::API::Docs::remove($_[0]); #say "demolish $_[0]"; 
 }
 
 sub raise { Kephra::API::focus( shift->panel ) }

File lib/Kephra/File.pm

 			$doc->editor->{$_}->SetDocPointer( $content_ref ) for Kephra::API::passive_docbars()
 		}
 		# reuse it if current doc is empty
-		else { 
-			$doc->file_path($file);
-			$db->set_page_title( $doc->file_name, $doc->panel->{$db} );
+		else {
+			$doc->file_path($file) 
 		}
 		Kephra::API::app()->Yield;
 		Kephra::File::Local::read( $doc, $file );
 		$ed->EmptyUndoBuffer;
 		#$ed->mount_events();
 	}
+	Kephra::API::main_window()->refresh_title();
 }
 sub reopen {
 	for my $doc (@_){
 	return unless $file;
 	Kephra::File::Local::write($doc, $file);
 	$doc->file_path($file);
-	$_->set_page_title( $doc->title, $doc->panel->{$_} ) for Kephra::API::all_docbars();
 	Kephra::API::main_window()->refresh_title();
 }
 sub rename {
 			$ed->SetSavePoint;
 			$ed->EmptyUndoBuffer;
 			$doc->file_path('');
-			#$active_bar->set_page_title($doc->title;);
 		}
 	}
 	Kephra::API::main_window()->refresh_title();

File lib/docbar.pl

 
 
 package main;
-Kephra::App->new->MainLoop;
+Kephra::App->