Commits

Herbert Breunung committed 2361649

remove doc when closing file

Comments (0)

Files changed (4)

lib/Kephra/App/Panel/Editor.pm

 		$doc = Kephra::Document->new();
 		$doc->assign_file( $file );
 		$doc->editor( Kephra::App::Editor->new( $win ) );
-		Kephra::DocumentStash::add( $doc );
+		Kephra::DocumentStash::add_and_activate( $doc );
 		$main_doc_bar->add_page( $doc->file_name, -1, 1, $doc);
 	}
 	$doc->editor->focus();
 	my $main_doc_bar = active_docbar();
 	if ($main_doc_bar->GetPageCount > 1) {
 		$main_doc_bar->remove_page( $main_doc_bar->GetPageIndex( $doc->editor ) );
+		Kephra::DocumentStash::del($doc);
 	} else {
 		$doc->editor->ClearAll;
 		$doc->assign_file('');

lib/Kephra/App/Panel/IOUnit.pm

     return $op;
 }
 
-sub set_focus { Wx::Window::SetFocus( $input ) }
+sub write_to_channel {
+    
+}
+
+sub focus { Wx::Window::SetFocus( $input ) }
+
+
 
 1;

lib/Kephra/Config/Default/MainMenu.pm

 [
 	{ ID => 'file'}
 	'file_new',
-	'file_open',
-	'file_save',
-	'file_close',
 	'',
-	'app_close_save',
 ],
 
-
 ---
 - ID: file
 - file_new
-- file_open
-- file_save
-- file_close
 - ''
-- app_close_save	

lib/Kephra/DocumentStash.pm

 	warn "Kephra::DocumentStash::set_active_doc: need a parameter!" unless $any;
 	my $new_doc = doc_by_anything( $any ) ;
 	return unless defined $new_doc;
+	_activate($new_doc);
+	return 1;
+}
+sub _activate {
 	$previous = $active;
-	$active = $new_doc;
+	$active = shift;
 }
-sub add_active {
+sub add_and_activate {
 	my $doc = shift;
 	add($doc);
-	set_active_doc($doc);
+	_activate($doc);
 }
 sub add {
 	my $doc = shift;
 	delete $document{$doc->editor};
 }
 
+
+sub doc_by_anything {
+	my $any = shift;
+	warn "Kephra::DocumentStash::get_by_anything: need a parameter!" unless $any;
+	return ref($any) eq ''                      ? doc_by_path ($any)
+			 : $any->isa('Wx::Panel')           ? doc_by_panel($any)
+			 : $any->isa('Kephra::App::Editor') ? doc_by_ed   ($any)
+			 : $any->isa('Kephra::Document')    ? $document{$any->editor} 
+			 :                                    undef;
+}
 sub doc_by_ed {
 	my $ed = shift;
 	warn "Kephra::DocumentStash::get_by_ed needs a Kephra::App::Editor, not $ed!"
 		return $document{$ed} if $document{$ed}->file_path eq $file_path;
 	}
 }
-sub doc_by_anything {
-	my $any = shift;
-	warn "Kephra::DocumentStash::get_by_anything: need a parameter!" unless $any;
-	return ref($any) eq ''                      ? doc_by_path ($any)
-			 : $any->isa('Wx::Panel')           ? doc_by_panel($any)
-			 : $any->isa('Kephra::App::Editor') ? doc_by_ed   ($any)
-			 : $any->isa('Kephra::Document')    ? $document{$any->editor} 
-			 :                                    undef;
-}
 sub all_doc { values %document }
 
+
 sub dump_all_ed { print "$_ + \n" for keys %document }
 
 sub file_loaded {