Source

Kephra / lib / Kephra / App / Part / Editor.pm

Diff from to

lib/Kephra/App/Part/Editor.pm

 
 package Kephra::App::Part::Editor;
 our @ISA = 'Kephra::App::Panel';
-my ($active_bar, @passive_bar, $panel);
+my ($active_bar, @passive_bar, $panel, %splitter);
 use Scalar::Util qw(blessed);
 
 Kephra::API::Command::register({
  'docbar-prev' =>{sub=>'select_docbar_prev', label=>'Prev Docbar',  keys=>'alt+pageup'},
  'docbar-next' =>{sub=>'select_docbar_next', label=>'Next Docbar',  keys=>'alt+pagedown'},
+ 'docbar-del' =>{sub=>'select_docbar_del', label=>'Next Docbar',  keys=>'ctrl+alt+pageup'},
+ 'docbar-add' =>{sub=>'select_docbar_add', label=>'Prev Docbar',  keys=>'ctrl+alt+pagedown'},
 });
 
 
 sub docbar         { $active_bar }
 sub passive_docbars{ @passive_bar}
-sub all_docbars    { ($active_bar, @passive_bar) }
+sub all_docbars    { $active_bar, @passive_bar }
 
 sub new {
 	my( $class, $parent) = @_;
 	my $db  = Kephra::App::Bar::Document->new($self);
 	my $db2 = Kephra::App::Bar::Document->new($self);
 
-	my $splitter = Kephra::App::Splitter->new
+	my $splitter = $splitter{'main'} = Kephra::App::Splitter->new
 		({parent => $self, left => $db, right => $db2, dominant_child => 'left'});
 	$self->append( \$splitter );
 	$splitter->resize('equal');
 
 	$active_bar = $db;
 	@passive_bar = ($db2);
+say $active_bar;
 
 	$self;
 }
 
+sub select_docbar_del {
+	my $docbar_count = scalar @passive_bar + 1;
+	return if $docbar_count < 2;
+	if    ($docbar_count == 4){
+		
+	}
+	elsif ($docbar_count == 3){
+		
+	}
+	elsif ($docbar_count == 2){
+		$splitter{'main'}->set({dominant_child => $active_bar});
+		$splitter{'main'}->unsplit();
+	}
+	$passive_bar[-1]->Destroy();
+	delete $passive_bar[-1];
+}
+sub select_docbar_add {
+	my $docbar_count = scalar @passive_bar + 1;
+	return if $docbar_count > 3;
+	if    ($docbar_count == 3){
+		
+	}
+	elsif ($docbar_count == 2){
+		
+	}
+	elsif ($docbar_count == 1){
+		$passive_bar[0]->Show(1);
+		$splitter{'main'}->resplit();
+	}
+}
+
 sub select_docbar_next {
 	push @passive_bar, $active_bar;
 	$active_bar = shift @passive_bar;
 }
 
 
-sub switch_bar{
-	
-}
-
 sub refresh_doc_label {
 	my $doc = shift // Kephra::API::document();
+	return unless Kephra::API::Doc::is($doc);
 	my $unsaved_mark = '*';
 
 	my $title = $doc->title;