Commits

Herbert Breunung  committed 27ecb16

open file without flicker

  • Participants
  • Parent commits 524faf8

Comments (0)

Files changed (3)

File lib/Kephra/API/Doc.pm

-use v5.10; #
+use v5.10;
 use strict;
 use warnings;
 use Wx;

File lib/Kephra/App/Editor.pm

 
 sub is_empty { not shift->GetTextLength }
 
+sub unmount_events {
+	my ($self, @which) = @_;
+	Wx::Event::EVT_STC_CHANGE          ($self, -1, sub {} );
+	Wx::Event::EVT_KEY_DOWN            ($self,     sub {} );
+	Wx::Event::EVT_STC_SAVEPOINTREACHED($self, -1, sub {} );
+	Wx::Event::EVT_STC_SAVEPOINTLEFT   ($self, -1, sub {} );
+	Wx::Event::EVT_SET_FOCUS           ($self,     sub {} );
+}
+
 sub mount_events {
 	my ($self, @which) = @_;
 	$self->DragAcceptFiles(1) if $^O eq 'MSWin32'; # enable drop files on win

File lib/Kephra/File.pm

 sub new  {
 	my $docbar = Kephra::API::docbar();
 	my $doc = Kephra::Document->new();
-	$_->add_page( $doc->panel->{$_}, 'rightmost', $doc->title, 0 ) for Kephra::API::all_docbars();;
+	$_->add_page( $doc->panel->{$_}, 'rightmost', $doc->title, 0 ) for Kephra::API::all_docbars();
 	Kephra::API::focus( $doc->editor->{$docbar} );
 	Kephra::API::main_window()->refresh_title();
 }
 		my $ed = Kephra::API::editor();
 		if ($ed->GetLength) {
 			$doc = Kephra::Document->new($file);
+			$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->editor->{$_}->SetDocPointer( $content_ref ) for Kephra::API::passive_docbars()
+			$doc->editor->{$_}->SetDocPointer( $content_ref ) for Kephra::API::passive_docbars();
 		}
 		# reuse it if current doc is empty
 		else {
 		Kephra::File::Local::read( $doc, $file );
 		$ed = Kephra::API::editor();
 		$ed->EmptyUndoBuffer;
-		#$ed->mount_events();
+		$doc->editor->{$_}->mount_events() for Kephra::API::all_docbars();
 		Kephra::API::main_window()->refresh_title();
 	}
 }