Herbert Breunung avatar Herbert Breunung committed 958b020

closing commit

Comments (0)

Files changed (7)

lib/Kephra/API/Command.pm

-use v5.10;
+use strict;
 use warnings;
-use Kephra::Log;
 
-package Kephra::API::Command;                             # callable by the user (UI)
+package Kephra::API::Command;                             # callable by the user
+
 my %list;     # by ID
 #my %keyproxy;# by keycode
 my %switchvar; #switchvar vor cmd definitions
+my $done_init = 0;
 
 
 sub      _raw_list { \%list }
 	my $api = 'Kephra::API';
 	my $caller = calling_module();
 	return Kephra::Log::error("only callable by $api", 1) if $caller ne $api;
+	return Kephra::Log::error("has to be called before init", 1)
+		if $done_init and not keys %switchvar;
 	#return Kephra::Log::error("call me just once", 1) if keys %switchvar;
 	return Kephra::Log::error("need a hashref", 1) unless ref $var_def eq 'HASH';
 	for my $var (keys %$var_def){
 		delete $var_def->{$var} unless substr($var, 0, 1) eq '$';
 		delete $var_def->{$var} unless sub_exists( $api .'::'. $var_def->{$var}{'switch'} );
-		#delete $var_def->{$var} unless package_exists ( $var_def->{$var}{'class'} ); # class could be loaded later
+		delete $var_def->{$var} unless package_exists ( $var_def->{$var}{'class'} );
 	}
 	%switchvar = %$var_def;
-	compile( keys %list );
 }
 
 sub register {
 		#for (qw/sub options state event label help keys icon/){} filter input later
 		$list{$ID}           = $cmd->{$ID};
 		$list{$ID}{'source'} = $caller;
-		compile($ID) if %switchvar; #dont make sense without defined switch var
+		compile($ID) if $done_init;
 	}
 }
 
+sub init {
+	compile( keys %list );
+	$done_init = 1;
+}
 
 sub compile {
 	for my $cmd_ID (@_) {

lib/Kephra/App/Editor.pm

 
 package Kephra::App::Editor;
 our @ISA = 'Wx::StyledTextCtrl';
+#our @ISA = 'Wx::ScintillaTextCtrl';
 use Kephra::App::Util qw(create_color);
 
 
 		$event->Skip;
 		Kephra::App::Part::Editor::select_docbar( $ed->GetParent->GetParent );
 	});
-
 	#Wx::Event::EVT_DROP_FILES       ($ep, sub{});
 	#Wx::Event::EVT_STC_START_DRAG   ($ep, -1, sub {
 	#Wx::Event::EVT_STC_DRAG_OVER    ($ep, -1, sub { $droppos = $_[1]->GetPosition });
 	#Wx::Event::EVT_STC_UPDATEUI
 	Wx::Event::EVT_STC_SAVEPOINTREACHED($self, -1, sub { });
 	Wx::Event::EVT_STC_SAVEPOINTLEFT($self, -1, sub { });
+	Wx::Event::EVT_SET_FOCUS( $self, sub { });
 	#Wx::Event::EVT_DROP_FILES       ($ep, sub{});
 	#Wx::Event::EVT_STC_START_DRAG   ($ep, -1, sub {
 	#Wx::Event::EVT_STC_DRAG_OVER    ($ep, -1, sub { $droppos = $_[1]->GetPosition });

lib/Kephra/App/Focus.pm

 	my ($widget) = @_;
 	return unless defined $widget;
 	Kephra::Log::note("focus is on :". get()." and will be: $widget");
-	return Kephra::Log::warning( "got no proper widget but $widget", 1 )
-		unless is_widget($widget);
+	return Kephra::Log::warning( "got no proper widget but $widget", 1 ) unless is_widget($widget);
 	return if $widget eq get();
 	unshift @focus_stack, $widget;
 	pop @focus_stack while stack_size() > $max_stack_size;

lib/Kephra/App/Splitter.pm

 	} else { 
 		$self->SplitVertically( $self->{'child1'}, $self->{'child2'}, $self->{'position'} )
 	}
-	$self->UpdateSize;
 }
 
 sub unsplit {

lib/Kephra/File.pm

 		next unless $file and -e $file;
 
 		# raise tab if doc is alread open
-		Kephra::API::Docs::find($file)->raise, next if Kephra::API::Docs::file_loaded($file);
+		Kephra::App::Part::Editor::raise_document($file), next
+		  if Kephra::API::Doc::file_loaded($file);
 
 		my $db = Kephra::API::docbar();
 		my $doc = Kephra::API::document();
 	}
 	Kephra::API::main_window()->refresh_title();
 }
+
 sub reopen {
 	for my $doc (@_){
 		next unless ref $doc eq 'Kephra::Document';

lib/docbar.pl

-use v5.12;
-use warnings;
-
-package Kephra;
-BEGIN {
-	our $NAME = __PACKAGE__;
-	our $VERSION = 'sp1';
-}
-
-package Kephra::App;
-use Wx;
-use Kephra::API;
-use Kephra::App::Bar::Document;
-use Kephra::App::Dialog;
-use Kephra::App::Editor;
-use Kephra::App::Frame;
-use Kephra::File;
-use base qw(Wx::App);
-our $_ref;
-
-sub OnInit {
-	my $app  = $_ref = shift;
-	$Kephra::Log::test_mode = 1; 
-	my $win = Kephra::App::Frame->new( 'DBD - docbar demo' );
-	my $db = Kephra::App::Bar::Document->new($win);
-
-	Kephra::File::new();
-	Kephra::API::focus( Kephra::API::document()->panel );
-	my $doc = Kephra::API::document();
-
-	$win->Center();
-	$win->Show(1);
-	$app->SetTopWindow($win);
-	1;
-}
-
-
-package main;
-Kephra::App->new->MainLoop;
+use v5.12;
+use warnings;
+
+package Kephra;
+BEGIN {
+	our $NAME = __PACKAGE__;
+	our $VERSION = 'sp1';
+}
+
+package Kephra::App;
+use Wx;
+use Kephra::API;
+use Kephra::App::Bar::Document;
+use Kephra::App::Dialog;
+use Kephra::App::Editor;
+use Kephra::App::Frame;
+use Kephra::File;
+use base qw(Wx::App);
+our $_ref;
+
+sub OnInit {
+	my $app  = $_ref = shift;
+	$Kephra::Log::test_mode = 1; 
+	my $win = Kephra::App::Frame->new( 'DBD - docbar demo' );
+	my $db = Kephra::App::Bar::Document->new($win);
+
+	Kephra::File::new();
+	Kephra::API::focus( Kephra::API::document()->panel );
+	my $doc = Kephra::API::document();
+
+	$win->Center();
+	$win->Show(1);
+	$app->SetTopWindow($win);
+	1;
+}
+
+
+package main;
+Kephra::App->new->MainLoop;
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.