Herbert Breunung avatar Herbert Breunung committed f4a7a7b

all works again almost

Comments (0)

Files changed (6)

lib/Kephra/API/Doc.pm

 use Kephra::Document;
 
 package Kephra::API::Doc;
-my %document;                           # keys of subhashes: ID editor panel file
+my %document = ('ID'=>{});             # keys of subhashes: ID editor panel file
 my $active;
 my $lowest_free_ID = 1;
 my $lowest_free_anon_NR = 1;
 sub active        { $active || '' }
 sub active_editor { $active->editor->{Kephra::API::docbar()} if $active }
 sub active_panel  { $active->panel->{Kephra::API::docbar()} if $active }
-sub set_active{
+sub set_active {
 	my $doc = find( shift );
 	$active = $doc if $doc;
 }
 #say "remove $doc ", scalar keys %{$document{'ID'}}, ' ',scalar keys %{$document{'file'}}; 
 	Kephra::Log::warning('need a ' . DOC_CLASS . ' thats in stash, not $doc!', 1)
 		unless is($doc);
-	delete $document{'ID'}{$doc->ID};
+	delete $document{'ID'}{$doc->ID} if $doc->ID;
 	#remove_instance($doc, $_) for values $doc->panel;
 	delete $document{'file'}{$doc->file_path} if $doc->file_path;
 #say "removed $doc ", scalar keys %{$document{'ID'}}, ' ',scalar keys %{$document{'file'}}; 

lib/Kephra/App/Bar/Document.pm

 	$self->SetSelection( $position ) unless $position == $self->GetSelection;
 	my $page = $self->GetPage($position);
 	my $doc = Kephra::API::Doc::find($page);
+	Kephra::API::Doc::set_active( $doc );
 	Kephra::API::focus ( defined $doc ? $doc->editor->{$self} : $page );
 }
 

lib/Kephra/App/Part/Editor.pm

 
 	$active_bar = $db;
 	@passive_bar = ($db2);
-say $active_bar;
 
 	$self;
 }
 	}
 	$passive_bar[-1]->Destroy();
 	delete $passive_bar[-1];
+	Kephra::API::focus($active_bar->GetSelection);
+	#Kephra::API::focus( Kephra::API::document()->panel->{$active_bar} );
+	#Kephra::API::focus( $splitter{'main'} );
 }
 sub select_docbar_add {
 	my $docbar_count = scalar @passive_bar + 1;
 	push @passive_bar, $active_bar;
 	$active_bar = shift @passive_bar;
 	$active_bar->raise_page( $active_bar->GetSelection );
+	Kephra::API::main_window()->refresh_title();
 }
 sub select_docbar_prev {
 	unshift @passive_bar, $active_bar;
 	$active_bar = pop @passive_bar;
 	$active_bar->raise_page( $active_bar->GetSelection );
+	Kephra::API::main_window()->refresh_title();
 }
 sub select_docbar {
 	my $bar = shift;

lib/Kephra/Document.pm

 
 has ID     => ( is  => 'rwp' );                             # API::Doc ID
 has title  => ( is  => 'rwp' );                             # shown as tab label
-has editor => ( is  => 'ro' );
-has panel  => ( is  => 'ro' );
+has editor => ( is  => 'rwp', default => sub { {} } );
+has panel  => ( is  => 'rwp', default => sub { {} } );
 has anon_NR=> ( is  => 'rw' );
 has file_path=>( 
 	is      => 'rw',
 	my ( $self, @args ) = @_;
 	unshift @args, "file_path" if @args % 2 == 1;
 	my %args = @args;
-
-	my (%panel, %editor);
-	for my $docbar (Kephra::API::all_docbars()){
-		$panel{$docbar} = Kephra::App::Panel->new( $docbar );
-		$editor{$docbar} = Kephra::App::Editor->new( $panel{$docbar} );
-		$panel{$docbar}->append( \$editor{$docbar} );
-	}
-
-	$args{'panel'} = \%panel;
-	$args{'editor'} = \%editor;
 	$args{'encoding'} = 'utf-8';
 
-	return \ %args;
-};
+	return \%args;
+}
 
 sub BUILD    {
 	my $self = shift;
+	$self->add_instance($_) for Kephra::API::all_docbars();
 	$self->_set_ID( Kephra::API::Doc::add($self) );
 	$self->_set_title('<untitled '.$self->anon_NR.'>') unless $self->file_path;
 }
-sub DEMOLISH { Kephra::API::Doc::remove($_[0]); #say "demolish $_[0]"; 
+
+sub DEMOLISH { Kephra::API::Doc::remove($_[0]);# say "demolish $_[0]"; 
 }
 
 sub add_instance {

lib/Kephra/File.pm

 sub new  {
 	my $doc = Kephra::Document->new();
 	my $docbar = Kephra::API::docbar();
-	$_->add_page( $doc->panel->{$_}, 'rightmost', $doc->title, 0 )
-		for Kephra::API::all_docbars();
-	my $content_ref = $doc->editor->{$docbar}->GetDocPointer();
-	$doc->editor->{$_}->SetDocPointer( $content_ref ) for Kephra::API::passive_docbars();
+	$_->add_page( $doc->panel->{$_}, 'rightmost', $doc->title, 0 ) for Kephra::API::all_docbars();;
+	Kephra::API::focus( $doc->editor->{$docbar} );
 }
 sub open {
 	# open dialog if no file was given
 	$Kephra::Log::test_mode = 1; 
 	my $win = Kephra::App::Frame->new( 'DDD - double docbar demo' );
 	my $ep = Kephra::App::Part::Editor->new($win);
-
 	Kephra::File::new();
-	Kephra::API::focus( Kephra::API::editor() );
-say Kephra::API::editor();
-#say Kephra::API::editor()->GetParent->GetParent;
 
 	$win->Center();
 	$win->Show(1);
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.