Commits

Herbert Breunung committed 3ae9935

runnning on mac now but not fully (1 docbar no editor getter/setter)

  • Participants
  • Parent commits f2c5730
  • Branches sp3

Comments (0)

Files changed (6)

lib/Kephra/API.pm

 #sub passive_docbars     { Kephra::App::Part::Editor::passive_docbars() }
 sub document            { Kephra::API::DocumentStash::active_doc() }
 sub all_documents       { Kephra::API::DocumentStash::all_docs() }
-#sub do_with_all_editors {&Kephra::API::Doc::do_with_all_editors }
-#sub editor              { Kephra::API::Doc::active_editor() }
+#sub do_with_all_editors {&Kephra::API::DocumentStash::do_with_all_editors }
+sub editor              { Kephra::API::DocumentStash::active_editor() }
 
 sub focus           { Kephra::App::Focus::set(@_) }
 sub focus_back      { Kephra::App::Focus::set_back(@_) }
 
+sub env_obj  { }
+
 # IO-unit
 #sub input  {main_window()->{'part'}{'iounit'}->get_line() if ref main_window() and exists main_window()->{'part'}{'iounit'} }
 #sub output {main_window()->{'part'}{'iounit'}->output(@_) if ref main_window() and exists main_window()->{'part'}{'iounit'} }

lib/Kephra/API/DocumentStash.pm

 
 package Kephra::API::DocumentStash;
 my %document = ('ID'=>{});             # keys of subhashes: ID editor panel file
-my $active;
+my $active_doc;
 my $lowest_free_ID = 1;
 my $lowest_free_anon_NR = 1;
 
 use Scalar::Util qw(blessed looks_like_number);
 
 
-sub active_doc    { $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 active_doc    { $active_doc || '' }
+sub active_editor { $active_doc->editor->{Kephra::API::docbar()} if $active_doc }
+sub active_panel  { $active_doc->panel->{Kephra::API::docbar()} if $active_doc }
+sub set_active    {
 	my $doc = find( shift );
-	$active = $doc if $doc;
+	$active_doc = $doc if $doc;
 }
 sub previous      { App::Kephra::Focus::last( DOC_CLASS ) }
 sub all_docs      { values %{$document{'ID'}} }
 
-sub is { return 1 if blessed($_[0]) and $_[0]->isa( DOC_CLASS ); return 0 }
+sub is_doc { return 1 if blessed($_[0]) and $_[0]->isa( DOC_CLASS ); return 0 }
 
 
 sub add_doc {
 	my $doc = shift;
-	Kephra::Log::warning('need a ' . DOC_CLASS . " thats in stash, not $doc!", 1)
-		unless is($doc);
-	$document{'ID'}  {$lowest_free_ID} = $doc;
-	add_doc_instance($doc, $_) for keys $doc->editor;
+	Kephra::Log::warning('only accepting ' . DOC_CLASS . " objects, not $doc!", 1) unless is_doc($doc);
+	$document{'ID'}{$lowest_free_ID} = $doc;
+	if (ref $doc->editor eq 'HASH') {
+		#add_doc_instance($doc, $_) for keys $doc->editor;
+	}
 	if ($doc->file_path) {
 		$document{'file'}{$doc->file_path} = $doc;
 	} else {
 sub rename_file {
 	my $doc = find( shift );
 	Kephra::Log::warning('need a ' . DOC_CLASS . " thats in stash, not $doc!", 1)
-		unless is($doc);
+		unless is_doc($doc);
 	my $file = $doc->prev_file_path;
 	delete $document{'file'}{$file} if $file and $document{'file'}{$file};
 	if ($doc->file_path){
 	my $doc = shift;
 #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);
+		unless is_doc($doc);
 	delete $document{'ID'}{$doc->ID} if $doc->ID;
 	#remove_doc_instance($doc, $_) for values $doc->panel;
 	delete $document{'file'}{$doc->file_path} if $doc->file_path;
 sub add_doc_instance {
 	my ($doc, $bar) = @_;
 	return Kephra::Log::warning('need as first parameter a'.DOC_CLASS.' thats in stash, not $doc!', 1)
-		unless is($doc);
+		unless is_doc($doc);
 	#return Kephra::Log::warning("need a Kephra::App::Bar::Document instance as second parameter, not $bar")
 	#	unless blessed($bar) eq 'Kephra::App::Bar::Document';
 	$document{'panel'} { $doc->panel->{$bar}  } = $doc;
 sub remove_doc_instance {
 	my ($doc, $bar) = @_;
 	return Kephra::Log::warning('need as first parameter a'.DOC_CLASS.' thats in stash, not $doc!', 1)
-		unless is($doc);
+		unless is_doc($doc);
 	return Kephra::Log::warning("need a Kephra::App::Bar::Document instance as second parameter, not $bar")
 		unless blessed($bar) eq 'Kephra::App::Bar::Document';
 	delete $document{'panel'}{ $doc->panel->{$bar} };

lib/Kephra/App.pm

 use base qw(Wx::App);
 use Kephra::API;
 use Kephra::App::Window;
+#use Kephra::File;
+
 
 our $_ref;
 

lib/Kephra/App/Bar/Document.pm

 		Kephra::File::close_active();
 	});
 	# keep focus on editor even when klicking on tab bar
-	Wx::Event::EVT_LEFT_DOWN( $self, sub { Kephra::API::active_editor()->focus; }); #print "--down";
+	Wx::Event::EVT_LEFT_DOWN( $self, sub { Kephra::API::focus(Kephra::API::editor); }); #print "--down";
 	$self->Connect( -1, -1, &Wx::wxEVT_SET_FOCUS, sub {  } ); #print "--";
 	Wx::Event::EVT_SET_FOCUS( $self, sub { my ($bar, $event ) = @_; $event->Skip; }); # say "--bar";
 

lib/Kephra/App/Window.pm

 	#my $ed = Kephra::App::Editor->new($self);
 	my $ed = Kephra::App::Bar::Document->new($self);
 
-	Wx::Window::SetFocus( $ed );
 	Kephra::API::focus($ed);
-
 	return $self;
 }
 

lib/Kephra/Document.pm

 	return Kephra::Log::warning("need an existing Kephra::App::Bar::Document instance")
 		unless blessed($bar) eq 'Kephra::App::Bar::Document';
 
-	my @editor = values $self->editor;
+# say "==" unless ref $self;
+	#my @editor = values $self->editor;
 	my $panel = $self->panel->{$bar} = Kephra::App::Panel->new( $bar );
 	my $ed = $self->editor->{$bar} = Kephra::App::Editor->new( $panel );
 	$panel->append( \$ed );
-	$ed->SetDocPointer( $editor[0]->GetDocPointer() ) if @editor;
+	#$ed->SetDocPointer( $editor[0]->GetDocPointer() ) if @editor;
 	Kephra::API::DocumentStash::add_doc_instance($self, $bar);
 }