Herbert Breunung avatar Herbert Breunung committed b4fa086

renamed to docbar::raise_document, played with moo oop on doc class , no result for good constructor so far

Comments (0)

Files changed (4)

 
 package Kephra;
 our $NAME     = __PACKAGE__;    # name of entire application
-our $VERSION  = '0.5.0.5';
+our $VERSION  = '0.5.0.6';      # version of ..
 
 our @external_dependencies = (
 	qw/Benchmark Encode Encode::Guess Cwd/,
 	qw/PPI Moo/,
 	qw/Wx Wx::Scintilla Wx::Perl::ProcessStream/, # Wx::Scintilla Wx::STC
 );
-our @used_wx_modules = qw/Wx::AUI Wx::DND Wx::RichText/; # Wx::STC
+our @used_wx_modules = qw/Wx::AUI Wx::DND Wx::RichText/; # Wx::STC Wx::HTML
 
 our @needed_at_first = qw/App API/;
-our @starttime_modules = qw/
+our @starttime_loaded_modules = qw/
 	App App::Util API Config Config::Default Config::File
 	Document DocumentStash CommandList Edit EventTable 
 	File PluginRegistrar SandrumInterpreter Works/;
-our @runtime_namespaces = qw/App::Dialog Config::Default/;
+our @runtime_loaded_namespaces =
+	qw/App::Dialog Config::Default/;
+
 our @command_modules = 
 	qw/App App::Panel::Editor App::Panel::FileBrowser App::Panel::IOUnit
 	App::Panel::OrgPad App::Panel::ProjectManager App::Panel::SratchSheet
 	App::Panel::TextLab App::Panel::TreeLib
 	CommandList Config 
 	Edit File EventTable PluginRegistrar SandrumInterpreter/;
-our @oop_interfaces = qw/App::Editor App::Panel App::Bar::Document Document/;
+our @oop_interfaces = 
+	qw/App::Editor App::Panel App::Splitter App::Bar::Document Document/;
 
 sub start {
 	start_worker_thread();

lib/Kephra/App/Panel/Editor.pm

 		$doc->assign_file($file);
 		$main_doc_bar->SetPageText( $main_doc_bar->GetSelection , $doc->file_name );
 	} else {                                         # make new editor
-		$doc = Kephra::Document->new();
+		$doc = Kephra::Document->new({ file => $file });
 		$doc->assign_file( $file );
 		$doc->editor( Kephra::App::Editor->new( $win ) );
 		Kephra::DocumentStash::add( $doc );
 	}
 }
 
-sub raise_file {
-	my $file = shift;
-	active_docbar()->raise_page( 
-		Kephra::DocumentStash::doc_by_path($file)->{panel}
-	);
+sub raise_document {
+	my $doc = Kephra::DocumentStash::doc_by_anything(shift);
+	active_docbar()->raise_page( $doc->{panel} ) if $doc;
 }
 sub select_tab_leftmost {active_docbar()->select_page_leftmost }
 sub select_tab_rightmost{active_docbar()->select_page_rightmost }

lib/Kephra/Document.pm

 use Kephra::File;
 use File::Spec;
 
+
 has editor => (
 	is  => 'rw',
 	isa => sub {die "$_[0] is no editor" unless ref $_[0] eq 'Kephra::App::Editor'},
 has folded_lines => ( is  => 'rw', );
 has marked_lines => ( is  => 'rw', );
 
+around BUILDARGS => sub {
+   my $orig = shift;
+   my ( $class, @args ) = @_;
+   #print $args[0]{'file'}, " $orig\n";
+   #$class->assign_file( $args[0]{'file'} ) if defined $args[0]{'file'};
+   return $class->$orig( @args );
+ };
+
+ 
 sub assign_file {
 	my ($self, $file_path) = @_;
 	return unless $file_path;
-	$file_path = Kephra::File::_normalize_name($file_path);
+	$file_path = Kephra::File::normalize_name($file_path);
 	$self->file_path($file_path);
 	my @path_parts = File::Spec->splitpath( $_[0]->file_path );
 	$self->file_dir( $path_parts[1] );

lib/Kephra/File.pm

 
 package Kephra::File;
 
-sub _normalize_name {
+sub normalize_name {
 	my $file = shift;
 	return unless $file;
 
 
 sub new  { Kephra::App::Panel::Editor::create_document() }
 sub open {
-	my $file = _normalize_name( shift );
+	my $file = normalize_name( shift );
 	return unless $file and -e $file;
 
 	# doc is alread open
-	return Kephra::App::Panel::Editor::raise_file( $file)
+	return Kephra::App::Panel::Editor::raise_document($file)
 		if Kephra::DocumentStash::file_loaded($file);
 
 	my $doc = Kephra::App::Panel::Editor::create_document($file);
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.