Commits

Herbert Breunung  committed 2655cce

add save as and file rename and get the first work

  • Participants
  • Parent commits 614851e

Comments (0)

Files changed (6)

File lib/Kephra/App/Bar/Document.pm

 	$panel_candidate->panel( $new_panel ) if $panel_candidate->isa('Kephra::Document');# and ($position == 0 or $label);
 
 	$self->InsertPage( $position, $new_panel, '', $set_active );# if $position == 0 or $label;
-	$self->set_page_title( $position, $label);
+	$self->set_page_title( $label, $new_panel);
 	Wx::Window::SetFocus( $new_panel ) if $set_active;
 
 	# inserting new index to position translators
 }
 
 sub set_page_title {
-	my ($self, $position, $label) = @_;
-	return unless $position >= 0 and $position < $self->GetPageCount;
+	my ($self, $label, $page) = @_;
+	return if ref $page and $page ne ref $page and $page->isa(' Wx::Window');
+	my $position = $page ? $self->GetPageIndex($page) : $self->GetSelection;
+	return unless $position >= 0;
 	$label = '<untitled>' unless $label;
 	my $max_width = 15;
 	if ( length($label) > $max_width and $max_width > 7 ) {

File lib/Kephra/App/Dialog.pm

                           sub=>'Kephra::App::Util::lounch_browser',   parameter => 'http://kephra.sourceforge.net/site/en/home_news.shtml',},
  'help-bugreport'      =>{                     label=>'Send a Wish',  keys=> '',
                           sub=>'Kephra::App::Util::lounch_browser',   parameter => 'http://sourceforge.net/tracker/?func=add&group_id=169747&atid=851593',},
+ 'help-forum'          =>{                     label=>'Perl Forum',   keys=> '',
+                          sub=>'Kephra::App::Util::lounch_browser',   parameter => 'http://www.perl-community.de/bat/poard/latest/24h',},
 });
 
 
 #}
 #
 sub get_file_open {
-	my $title  = shift // 'Open File';
+	my $title  = shift // 'Open File ...';
 	my $dir    = shift // '.';
 	my $filter = shift // '(*)|*';
 	my $parent = _parent($_[0]);
 	Wx::FileSelector( $title, $dir, '', '', $filter, &Wx::wxFD_OPEN, $parent);
 }
-#
-#sub get_files_open {
-	#my $dialog = Wx::FileDialog->new(
-		#_win(),  @_[0,1], '', $_[2], &Wx::wxFD_OPEN | &Wx::wxFD_MULTIPLE, [-1,-1]
-	#);
-	#if ($dialog->ShowModal != &Wx::wxID_CANCEL) {
-		#my @files = $dialog->GetPaths;
-		#return \@files;
-	#}
-#}
-#
-#sub get_file_save { 
-	#Wx::FileSelector( @_[0,1], '', '', $_[2], &Wx::wxFD_SAVE, _win())
-#}
+
+sub get_file_save { 
+	my $title  = shift // 'Save File As ...';
+	my $dir    = shift // '.';
+	my $filter = shift // '(*)|*';
+	my $parent = _parent($_[0]);
+	Wx::FileSelector( $title, $dir, '', '', $filter, &Wx::wxFD_SAVE, $parent);
+}
 #
 #sub get_dir  {  Wx::DirSelector      ( @_[0,1] ,0, [-1,-1], _win()) }
 #sub get_font {  Wx::GetFontFromUser  ( _win(), $_[0]) }

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

 	my $main_doc_bar = active_docbar();
 
 	if ($doc and $doc->editor->is_empty and $file) { # overwrite empty doc
-		$doc->assign_file($file);
-		$main_doc_bar->SetPageText( $main_doc_bar->GetSelection , $doc->file_name );
+		$doc->assign_file_name($file);
+		$main_doc_bar->set_page_title( $doc->file_name );
 	} else {                                         # make new editor
 		$doc = Kephra::Document->new();
-		$doc->assign_file( $file );
+		$doc->assign_file_name( $file );
 		$doc->editor( Kephra::App::Editor->new( $win ) );
 		Kephra::DocumentStash::add_and_activate( $doc );
 		$main_doc_bar->add_page( $doc->file_name, -1, 1, $doc);
 		Kephra::DocumentStash::del($doc);
 	} else {
 		$doc->editor->ClearAll;
-		$doc->assign_file('');
-		$main_doc_bar->set_page_title(0, '');
+		$doc->assign_file_name('');
+		$main_doc_bar->set_page_title('');
 	}
 	Kephra::API::main_window()->refresh_title();
 }

File lib/Kephra/Config/Default/Menu.pm

 		'+-documentation',
 		'+-homepage',
 		'+-bugreport',
+		'+-forum',
 		'',
 		'+-about',
 	],

File lib/Kephra/Document.pm

 );
 has panel => (
 	is  => 'rw',
-	isa => sub {#Kephra::Log::error("$_[0] is no panel")
-				#unless ref $_[0] eq 'Wx::Panel' or ref $_[0] eq 'Kephra::App::Panel' 
-				},
+	isa => sub {Kephra::Log::error("$_[0] is no panel")
+				unless ref $_[0] eq 'Wx::Panel' or ref $_[0] eq 'Kephra::App::Panel'},
 );
 has file_path    => ( is  => 'rw', );
 has file_dir     => ( is  => 'rw', );
 has folded_lines => ( is  => 'rw', );
 has marked_lines => ( is  => 'rw', );
 
-sub assign_file {
+sub assign_file_name {
 	my ($self, $file_path) = @_;
 	return unless defined $file_path and -e $file_path;
 	if ($file_path){

File lib/Kephra/File.pm

 sub save_active { save( Kephra::API::document() ) }
 sub save_all    { save( Kephra::API::all_documents()   ) }
 
+sub save_as {
+	my $doc = Kephra::API::document();
+	my $file = Kephra::App::Dialog::get_file_save();
+	return unless $file;
+	CORE::open my $FH, '>', $file;
+	print $FH $doc->editor->GetText;
+	$doc->assign_file_name($file);
+	Kephra::API::docbar()->set_page_title( $doc->file_name);
+	Kephra::API::main_window()->refresh_title();
+}
+
+sub rename {
+	my $old_file = Kephra::API::document()->file_name;
+	save_as();
+	unlink $old_file;
+}
+
 
 sub close_active {
 	my $doc = Kephra::API::document();