Commits

Herbert Breunung committed 9381678

create doc with new file is lame and safe and works now fully without flicker

  • Participants
  • Parent commits 27ecb16

Comments (0)

Files changed (3)

lib/Kephra/App/Editor.pm

 			my $cmd = Kephra::API::KeyMap::cmd_from_keycode($key);
 			Kephra::API::log("run command: $cmd");
 			Kephra::API::Command::run( $cmd );
+			#say scalar Kephra::API::all_docbars();
+			#say Kephra::API::all_docbars();
+			#say "----------";
 			#$ed->GetStyleAt($ed->GetCurrentPos);
 		}
 		else {$event->Skip}

lib/Kephra/Document.pm

 use Moo;
 use Scalar::Util qw(blessed);
 
-my $max_title_width = 15;
-
-# export SUB_QUOTE_DEBUG=1
-
+my $max_title_width = 15;                               # export SUB_QUOTE_DEBUG=1
 
 has ID     => ( is  => 'rwp' );                             # API::Doc ID
 has title  => ( is  => 'rwp' );                             # shown as tab label
 		}
 
 		$self->_set_old_file_path( $self->file_path );
-		#$_->set_page_title( $self->title, $self->panel->{$_} )
-			#for Kephra::API::all_docbars();
+		$_->set_page_title( $self->title, $self->panel->{$_} ) for Kephra::API::all_docbars();
 	});
 has file_dir     => ( is => 'rwp', );
 has file_name    => ( is => 'rwp', );
 has folded_lines => ( is => 'rw', );
 has marked_lines => ( is => 'rw', );
 
+
 sub BUILDARGS {
 	my ( $self, @args ) = @_;
-	unshift @args, "file_path" if @args % 2 == 1;
-	my %args = @args;
+	#unshift @args, "file_path" if @args % 2 == 1;
+	my %args;
+	%args = @args unless scalar @args % 2;
 	$args{'encoding'} = 'utf-8';
 
 	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]) }
 
-sub DEMOLISH { Kephra::API::Doc::remove($_[0]);# say "demolish $_[0]"; 
-}
 
 sub add_instance {
 	my ($self, $bar) = @_;

lib/Kephra/File.pm

 		my $doc = Kephra::API::document();
 		my $ed = Kephra::API::editor();
 		if ($ed->GetLength) {
-			$doc = Kephra::Document->new($file);
+			$doc = Kephra::Document->new();
 			$doc->editor->{$_}->unmount_events() for Kephra::API::all_docbars();
 			$_->add_page( $doc->panel->{$_},'right', $doc->file_name, 1) for Kephra::API::all_docbars();
 			my $content_ref = $doc->editor->{$db}->GetDocPointer();
+			$doc->file_path($file);
 			$doc->editor->{$_}->SetDocPointer( $content_ref ) for Kephra::API::passive_docbars();
 		}
 		# reuse it if current doc is empty
 		else {
+			$doc->editor->{$_}->unmount_events() for Kephra::API::all_docbars();
 			$doc->file_path($file) 
 		}
 		Kephra::API::app()->Yield;
 		$ed = Kephra::API::editor();
 		$ed->EmptyUndoBuffer;
 		$doc->editor->{$_}->mount_events() for Kephra::API::all_docbars();
+		$_->mount_events() for Kephra::API::all_docbars();
 		Kephra::API::main_window()->refresh_title();
 	}
 }