Commits

Herbert Breunung  committed 6f0870a

little cleanup

  • Participants
  • Parent commits dba447d

Comments (0)

Files changed (5)

File lib/Kephra/API.pm

 sub all_documents   { Kephra::DocumentStash::all_doc() }
 sub do_with_all_documents { }
 
-sub focus           { $Kephra::App::Window::_ref->set_focus(@_) }
-sub focus_back      { $Kephra::App::Window::_ref->set_focus_back(@_) }
+sub focus           { main_window()->set_focus(@_) }
+sub focus_back      { main_window()->set_focus_back(@_) }
 
 # IO-unit
-sub input           { $Kephra::App::Part::IOUnit::_ref->get_line() }
-sub output          { $Kephra::App::Part::IOUnit::_ref->output(@_) }
-sub log             { $Kephra::App::Part::IOUnit::_ref->output('log', @_) }
+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'}
+}
+sub log             { 
+	main_window()->{'part'}{'iounit'}->output('log', @_)
+		if ref main_window() and exists main_window()->{'part'}{'iounit'}
+}
 
 sub configs  { }
 
-# event table
-sub add_event_callback { }
-sub del_event_callback { }
-sub trigger_event      { }
-sub freeze_event       { }
-sub thaw_event         { }
-
-
 # command list
 sub add_command { }
 sub del_command { }
 # cmd line lang
 sub run_sandrum_commands {}
 
+# event table
+sub add_event_callback { }
+sub del_event_callback { }
+sub trigger_event      { }
+sub freeze_event       { }
+sub thaw_event         { }
+
 # plugin API
 sub register_plugin {}
 sub get_plugin_status {}

File lib/Kephra/App/Window.pm

 	$self->{'focus_stack'} = [$self];
 
 	# container var for all panel, sizer and splitter
-	my (%panel, %sizer, %splitter);
+	my (%panel, %sizer, %splitter, %gui_part);
 	$splitter{'left'}  = Wx::SplitterWindow->new( $self,             -1 );
 	$splitter{'right'} = Wx::SplitterWindow->new( $splitter{'left'}, -1 );
 	$splitter{'below'} = Wx::SplitterWindow->new( $splitter{'right'},-1 );
 															   or $name eq 'below';
 		$panel{ $name }->SetSizer( $sizer{ $name } );
 	}
-	my $editorpanel = Kephra::App::Part::Editor     ->new( $panel{'edit'} );
-	my $searchbar   = Kephra::App::Bar::Search      ->new( $panel{'above'} );
-	my $iounit      = Kephra::App::Part::IOUnit     ->new( $panel{'below'} );
-	my $filebrowser = Kephra::App::Part::FileBrowser->new( $panel{'left'} );
-	#my $projectman  = Kephra::App::Part::ProjectManarger->new( $panel{'left'} );
-	my $treelib     = Kephra::App::Part::TreeLib    ->new( $panel{'right'} );
-	#my $orgpad      = Kephra::App::Part::OrgPad     ->new( $panel{'right'} );
-	#my $scratchsheet= Kephra::App::Part::ScratchSheet->new( $panel{'right'} );
-	my $statusbar   = Kephra::App::Bar::Status       ->new( $self );
+	$self->{'part'} = \%gui_part;
+	$gui_part{'editor'}      = Kephra::App::Part::Editor   ->new( $panel{'edit'} );
+	$gui_part{'searchbar'}   = Kephra::App::Bar::Search    ->new( $panel{'above'} );
+	$gui_part{'iounit'}      = Kephra::App::Part::IOUnit   ->new( $panel{'below'} );
+	$gui_part{'filebrowser'} = Kephra::App::Part::FileBrowser->new($panel{'left'} );
+	#my $projectman      = Kephra::App::Part::ProjectManarger->new( $panel{'left'} );
+	$gui_part{'treelib'}     = Kephra::App::Part::TreeLib  ->new( $panel{'right'} );
+	#my $orgpad          = Kephra::App::Part::OrgPad     ->new( $panel{'right'} );
+	#my $scratchsheet    = Kephra::App::Part::ScratchSheet->new( $panel{'right'} );
+	$gui_part{'statusbar'}   = Kephra::App::Bar::Status    ->new( $self );
 
 	$splitter{'left'}->SplitVertically( $panel{'left'}, $splitter{'right'}, 200);
 	$splitter{'left'}->SetSashGravity(0);
 	$splitter{'below'}->SetMinimumPaneSize(100);
 	$splitter{'edit'}->Initialize( $panel{'edit'} );
 
-	$sizer{'edit'} ->Add( $editorpanel,     1, &Wx::wxGROW );
-	$sizer{'above'}->Add( $splitter{'edit'},1, &Wx::wxGROW );
-	$sizer{'above'}->Add( $searchbar,       0, &Wx::wxGROW );
-
-	$sizer{'below'}->Add( $iounit,          1, &Wx::wxGROW );
-	$sizer{'right'}->Add( $treelib,         1, &Wx::wxGROW );
-	$sizer{'left'} ->Add( $filebrowser,     1, &Wx::wxGROW );
+	$sizer{'edit'} ->Add( $gui_part{'editor'},     1, &Wx::wxGROW );
+	$sizer{'above'}->Add( $splitter{'edit'},       1, &Wx::wxGROW );
+	$sizer{'above'}->Add( $gui_part{'searchbar'},  0, &Wx::wxGROW );
+	$sizer{'below'}->Add( $gui_part{'iounit'},     1, &Wx::wxGROW );
+	$sizer{'right'}->Add( $gui_part{'treelib'},    1, &Wx::wxGROW );
+	$sizer{'left'} ->Add( $gui_part{'filebrowser'},1, &Wx::wxGROW );
 
 	$sizer{'main'} = Wx::BoxSizer->new( &Wx::wxVERTICAL );
-	$sizer{'main'}->Add( $splitter{'left'}, 1, &Wx::wxGROW);
-	$sizer{'main'}->Add( $statusbar,        0, &Wx::wxGROW);
+	$sizer{'main'}->Add( $splitter{'left'},       1, &Wx::wxGROW);
+	$sizer{'main'}->Add( $gui_part{'statusbar'},  0, &Wx::wxGROW);
 	$self->SetSizer( $sizer{'main'} );
 
 	$self->SetMenuBar( Kephra::App::Bar::Menu::get() );
 sub get_focus { $_[0]->{'focus_stack'}[0] }
 sub set_focus {
 	my ($self, $widget) = @_;
-	Kephra::Log::warning( "got no proper widget ($widget) from ", (caller)[0] )
+	Kephra::Log::warning( "got no proper widget ($widget) from ". (caller)[0] )
 		unless Kephra::App::Util::is_widget($widget);
 	unshift @{$self->{'focus_stack'}}, $widget;
 	pop @{$self->{'focus_stack'}} if @{$self->{'focus_stack'}} > 12;
 sub refocus { Wx::Window::SetFocus( $_[0]->{'focus_stack'}[0]) }
 
 1;
-
-__END__
-
-sub get_fullscreen_mode { _config()->{fullscreen} }
-sub switch_fullscreen_mode {
-	_config()->{fullscreen} ^= 1;
-	eval_fullscreen_flag();
-}
-
-sub eval_fullscreen_flag {
-	_ref->ShowFullScreen( 
-		get_fullscreen_mode(), 
-		&Wx::wxFULLSCREEN_NOCAPTION | &Wx::wxFULLSCREEN_NOBORDER
-);

File lib/Kephra/File.pm

 sub save_all    { save( Kephra::API::all_documents() ) }
 sub save_as {
 	my $doc = shift || Kephra::API::document();
-	my $file = Kephra::App::Dialog::get_file_save();
+	my $file = normalize_name( Kephra::App::Dialog::get_file_save() );
 	return unless $file;
 	_store_under_filename($doc, $file);
 	$doc->assign_file_name($file);

File lib/Kephra/Internals.pod

 
 =head2 Kephra::CommandList
 
+Also sort of API but more complex. Contains every call the user is able to make.
+Needed to protocol each call for monitoring, macros and other introspection
+based functions. Also helps to make simple menu and toolbar definitions.
+They just need to be a list of CommandIDs.
+
 =head2 Kephra::KeyMap
 
 =head2 Kephra::EventTable

File t/KTestHelper.pm

+# functions most test scripts need
+
+package KTestHelper;
+
+# making local lib favoured
+#BEGIN { unshift @INC, -d 't' ? 'lib' : '../lib' }
+#
+#use Test::More;
+#use Test::NoWarnings;
+#use File::Find;
+#use Kephra;
+#
+#diag( "Testing Kephra $Kephra::VERSION, Perl $], $^X" );
+#
+#my @modules = (
+    #@Kephra::external_dependencies, 
+    #@Kephra::used_wx_modules, 
+    #@{get_submodules()}, 
+#);
+#plan tests => 1 + @modules;
+#
+#use_ok($_) for @modules;
+#
+#sub get_submodules {
+    #my @kephra_modules = ();
+    #chdir '..' if -d '../t';
+    #find( sub {
+        #return if not -f $_ or $_ !~ /\.pm$/;
+        #my $module = $File::Find::name;
+        #$module =~ s|lib/||;
+        #$module =~ s|\.pm||;
+        #$module =~ s|/|::|g;
+        #push @kephra_modules, $module;
+    #}, 'lib'); # print "@modules"; #use Data::Dumper; # diag Dumper \@modules;
+    #return \@kephra_modules;
+#}
+#
+#exit(0);
+#
+
+1;