Commits

Herbert Breunung  committed b15e934

open file works now in parallel too

  • Participants
  • Parent commits 0785c3f
  • Branches sp1

Comments (0)

Files changed (5)

File lib/Kephra/API/Docs.pm

 	Kephra::Log::warning('need a ' . DOC_CLASS . " thats in stash, not $doc!", 1)
 		unless ref $doc and $doc->isa( DOC_CLASS );
 	$document{'ID'}  {$lowest_free_ID} = $doc;
-	for my $docbar (keys $doc->panel){
-		$document{'panel'} {$doc->panel->{$docbar} } = $doc if $doc->panel->{$docbar};
-		$document{'editor'}{$doc->editor->{$docbar}} = $doc if $doc->editor->{$docbar};
-	}
+	$document{'panel'}{$_} = $doc for values $doc->panel;
+	$document{'editor'}{$_} = $doc for values $doc->editor;
 	$document{'file'}{$doc->file_path} = $doc if $doc->file_path;
 	$lowest_free_ID++;
 }
 	Kephra::Log::warning('need a ' . DOC_CLASS . ' thats in stash, not $doc!', 1)
 		unless ref $doc and $doc->isa( DOC_CLASS );
 	delete $document{'ID'}{$doc->ID};
-	delete $document{'panel'}{$doc->panel}    if $doc->panel;
-	delete $document{'editor'}{$doc->editor}  if $doc->editor;
+#	delete $document{'panel'}{$_}    for values $doc->panel;
+#	delete $document{'editor'}{$_}   for values $doc->editor;
 	delete $document{'file'}{$doc->file_path} if $doc->file_path;
 #say "removed $doc ", scalar keys %{$document{'ID'}}, ' ',scalar keys %{$document{'file'}}; 
-
 }
 
-
 sub find {
 	my $any = shift;
 	Kephra::Log::warning("need a parameter!", 1) unless defined $any and $any;

File lib/Kephra/App/Frame.pm

-use strict;
+use v5.10;
 use warnings;
 use Wx;
 use Kephra::API;
 sub refresh_title {
 	my $self = shift;
 	my $doc = Kephra::API::document();
-
-#print "refresh ",$doc->file_name;
-
 	my $title = (ref $doc and $doc->file_name)
 		? $doc->file_name.' ('.$doc->file_path.')'
 		: Kephra::API::docbar()->active_title();

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

 
 package Kephra::App::Part::Editor;
 our @ISA = 'Kephra::App::Panel';
-
-my $active;
-my @passive;
-my $panel;
+my ($active, @passive, $panel);
 
 sub docbar         { $active }
 sub passive_docbars{ @passive}

File lib/Kephra/File.pm

 	my $docbar = Kephra::API::docbar();
 	$_->add_page( $doc->panel->{$_},'rightmost','',1 ) for Kephra::API::all_docbars();
 	my $content_ref = $doc->editor->{$docbar}->GetDocPointer();
-	$doc->editor->{$_}->SetDocPointer( $content_ref ) for Kephra::API::passive_docbars()
+	$doc->editor->{$_}->SetDocPointer( $content_ref ) for Kephra::API::passive_docbars();
 }
 sub open {
 	# open dialog if no file was given
 
 		my $db = Kephra::API::docbar();
 		my $doc = Kephra::API::document();
-		my $ed = $doc->editor;
+		my $ed = Kephra::API::editor();
 		if ($ed->GetLength) {
-			#say "will     BUILD";
 			$doc = Kephra::Document->new($file);
-			$db->add_page( $doc->panel, 'right', $doc->file_name, 1);
+			$_->add_page( $doc->panel->{$_},'right', $doc->file_name, 1) for Kephra::API::all_docbars();
+			my $content_ref = $doc->editor->{$db}->GetDocPointer();
+			$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->set_page_title( $doc->file_name, $doc->panel->{$db} );
 		}
 		Kephra::API::app()->Yield;
 		#$ed->unmount_events();
 		Kephra::File::Local::read( $doc, $file );
-		Kephra::API::app()->Yield;
 		$ed->EmptyUndoBuffer;
 		#$ed->mount_events();
 	}

File lib/Kephra/File/Local.pm

 	my $file = Kephra::File::normalize_path( shift ) || $doc->file_path;
 	return Kephra::Log::warning("can't load nonexising file") unless $file and -e $file;
 	return Kephra::Log::warning("can't read $file") unless -r $file;
-	my $ed = $doc->editor;
+	my $ed = $doc->editor->{ Kephra::API::docbar() };
 	CORE::open my $FH, '<', $file;
 	binmode($FH);
 	my $content = do { local $/; <$FH> };
 			$doc->encoding( $suggest_encodings[0] );
 		} else { $doc->encoding( 'utf-8' ) }
 		$content = Encode::decode( $doc->encoding,  $content );
-		say $doc->encoding; 
+		#say $doc->encoding; 
 
 		$ed->SetText( $content );
 		$ed->SetSavePoint;
 	return Kephra::Log::warning("need a file path") unless $file;
 	return Kephra::Log::warning("can't overwrite $file") if -e $file and not -w $file;
 	$doc->file_path($file) unless defined $doc->file_path and $doc->file_path eq $file;
-	my $ed = $doc->editor;
+	my $ed = $doc->editor->{ Kephra::API::docbar() };
 	CORE::open my $FH, '> :raw :encoding('.$doc->encoding.')', $file;
 	print $FH $ed->GetText;
 	$ed->SetSavePoint;