Commits

Herbert Breunung committed 3a54b2a

added naming rules

Comments (0)

Files changed (3)

lib/Kephra/App/Bar/Document.pm

 		&Wx::wxAUI_NB_SCROLL_BUTTONS | &Wx::wxAUI_NB_CLOSE_ON_ACTIVE_TAB
 	);
 
-	$self->{'tab_nr'} = [];
+	$self->{'visual_panel_order'} = [];
+	$self->{'internal_panel_order'} = [];
 
 	my $dragged_tab_nr;
 	Wx::Event::EVT_AUINOTEBOOK_BEGIN_DRAG( $self, -1, sub {
 		my ($nb, $event ) = @_;
-print $event->GetSelection," drag \n";
+		$self->{'moving_panel_nr'} = $event->GetSelection;
 	});
 	Wx::Event::EVT_AUINOTEBOOK_END_DRAG($self, -1, sub {
 		my ($nb, $event ) = @_;
-print $event->GetSelection," drag \n";
+		return unless defined $self->{'moving_panel_nr'};
+		my $panel_nr = $self->{'moving_panel_nr'};
+		$nb->move_panel($panel_nr, $event->GetSelection);
+		$self->{'moving_panel_nr'} = undef;
 	});
 	Wx::Event::EVT_AUINOTEBOOK_PAGE_CHANGED( $self, -1, sub {
 		my ($nb, $event ) = @_;
-		my $new_nr = $event->GetSelection;
-		Kephra::DocumentStash::set_active_doc( $nb->GetPage($new_nr) );
+		my $new_ed = $nb->GetPage( $event->GetSelection );
+		Kephra::DocumentStash::set_active_doc( $new_ed );
 		Kephra::API::widget('win')->refresh_title();
+		$new_ed->focus;
 		$event->Skip;
 	});
 	Wx::Event::EVT_AUINOTEBOOK_PAGE_CLOSE( $self, -1, sub {
 		$event->Veto;
 		Kephra::File::close_active();
 	});
+	# keep focus on editor even when klicking on tab bar
+	Wx::Event::EVT_LEFT_DOWN($self, sub { Kephra::API::active_editor()->focus; print "--"; });
 	return $self;
 }
 
 	$self->SetPageText( $nr, $label );
 }
 
-sub select_left  { 
+sub select_panel_left  { 
 	my ($self) = @_;
 	my ($pos, $max) = ($self->GetSelection, $self->GetPageCount - 1);
 	$self->SetSelection( $pos == 0 ? $max : $pos-1 );
 }
-sub select_right { 
+sub select_panel_right { 
 	my ($self) = @_;
 	my ($pos, $max) = ($self->GetSelection, $self->GetPageCount - 1);
 	$self->SetSelection( $pos == $max ? 0 : $pos+1 );
 }
+sub move_panel_left  { 
+	my ($self) = @_;
+	my ($pos, $max) = ($self->GetSelection, $self->GetPageCount - 1);
+	my $next = $pos == 0 ? $max : $pos-1;
+	$self->move_panel( $pos, $next );
+}
+sub move_panel_right { 
+	my ($self) = @_;
+	my ($pos, $max) = ($self->GetSelection, $self->GetPageCount - 1);
+	my $next = $pos == $max ? 0 : $pos+1;
+	$self->move_panel( $pos, $next );
+}
+
+sub move_panel { 
+	my ($self, $from, $to ) = @_;
+}
+sub refresh_internal_panel_order {
+	my ($self) = @_;
+	my $visual = $self->{'visual_panel_order'};
+	return unless ref $visual eq ref [];
+	my $internal;
+	$internal->[] for 0 .. @$visual-1;
+	$self->{'internal_panel_order'} = $internal;
+}
 
 1;

lib/Kephra/App/Panel/Editor.pm

 	if ($doc and $doc->editor->is_empty and $file) {
 		$doc->assign_file($file);
 		$main_doc_bar->SetPageText( $main_doc_bar->GetSelection , $doc->file_name );
-		$doc->editor->focus();
 	# make new editor
 	} else {
 		my $ed = Kephra::App::Editor->new( $main_doc_bar );
 		Kephra::DocumentStash::add( $doc );
 		$main_doc_bar->add_page( $doc->file_name, -1, 1, $ed) ;
 	}
+	$doc->editor->focus();
 	Kephra::API::widget('win')->refresh_title();
 	return $doc;
 }
 		Kephra::DocumentStash::get_by_path($file)->{editor}
 	);
 }
-sub select_tab_left  {_active_docbar()->select_left }
-sub select_tab_right {_active_docbar()->select_right }
-sub move_tab_left    {_active_docbar() }
-sub move_tab_right   {_active_docbar() }
+sub select_tab_left  {_active_docbar()->select_panel_left }
+sub select_tab_right {_active_docbar()->select_panel_right }
+sub move_tab_left    {_active_docbar()->move_panel_left }
+sub move_tab_right   {_active_docbar()->move_panel_right }
 
 sub active_title {
 	my $nb = _active_docbar();

lib/StyleGuide.pod

 
 =head2 Variable Names
 
+lowercase words separated by _ ~~ like_this
+
 $self  reference of the class itself
 
 $ed    in most cases the active editor pane
        (was renamed from $ep to prevent simple copy and paste of old code)
 
-$file  full file path, unless oyur specific like file_name, file_path etc.
+$file  full file path, unless oyur specific like file_name, file_path etc.
+
+
+
+=head2 sub/method Names
+
+lowercase words separated by _ ~~ like_this
+
+=head2 module/class Names
+
+titlecase / camelcase       ~~ LikeThis