Commits

Herbert Breunung committed 6cf84e1

prepare API dummies

Comments (0)

Files changed (16)

lib/Kephra/API.pm

 use Kephra::API::Command;
 use Kephra::API::DocumentStash;
 use Kephra::API::Event;
+use Kephra::API::GuiBuilder;
 use Kephra::API::KeyMap;
 #use Kephra::API::Macro;
 #use Kephra::API::Plugin;
 #use Kephra::API::Sandrum;
-use Kephra::App::Focus;
-use Kephra::Log;
 
 
 package Kephra::API;
 my $VERSION = 0.5;
 
-#Kephra::API::Command::switch_variables({
+Kephra::API::Command::switch_variables({
  #'$app'    => { switch => 'app',         class => 'Kephra::App' },
  #'$win'    => { switch => 'main_window', class => 'Kephra::App::Window' },
  #'$tabbar' => { switch => 'tabbar',      class => 'Kephra::App::Bar::Tab' },
  #'$doc'    => { switch => 'document',    class => 'Kephra::Document' },
  #'$ed'     => { switch => 'editor',      class => 'Kephra::App::Editor' },
-#});
+});
 
 sub app                 { $Kephra::App::_ref }
 sub main_window         { $Kephra::App::Window::_ref }
-sub tabbar              { $Kephra::App::Bar::Tab::_ref #Kephra::App::Part::Main::tabbar() 
+sub tabbar              { $Kephra::App::TabBar::_ref #Kephra::App::Part::Main::tabbar() 
 }
-sub all_tabbars         { $Kephra::App::Bar::Tab::_ref #Kephra::App::Part::Main::all_tabbars()
+sub all_tabbars         { $Kephra::App::TabBar::_ref #Kephra::App::Part::Main::all_tabbars()
 }
 #sub passive_tabbars     { Kephra::App::Part::Editor::passive_tabbars() }
 sub document            { Kephra::API::DocumentStash::active_doc() }

lib/Kephra/API/Event.pm

-use strict;
+use v5.12;
 use warnings;
-use Kephra::API;
 
 package Kephra::API::Event;
 

lib/Kephra/API/GuiBuilder.pm

+use v5.12;
+use warnings;
+
+package Kephra::API::GuiBuilder;
+
+1;

lib/Kephra/API/Macro.pm

Empty file removed.

lib/Kephra/API/MacroRecorder.pm

+use v5.12;
+use warnings;
+
+package Kephra::API::MacroRecorder;
+
+1;

lib/Kephra/API/Plugin.pm

+use v5.12;
+use warnings;
+
+package Kephra::API::Plugin;
+
+1;

lib/Kephra/API/Sandrum.pm

+use v5.12;
+use warnings;
+
+package Kephra::API::Sandrum;
+
+1;

lib/Kephra/App.pm

 use base qw(Wx::App);
 use Kephra::API;
 use Kephra::App::Dialog;
+use Kephra::App::Focus;
 use Kephra::App::Window;
 use Kephra::File;
+use Kephra::Log;
 
 
 our $_ref;
 sub OnInit {
 	my $app   = $_ref = shift;
 	my $win = Kephra::App::Window->new($Kephra::NAME.' SP3 '.$Kephra::VERSION);
-	Kephra::File::new();
+	#Kephra::File::new();
 
 	$win->Center();
 	$win->Refresh();   # remove visual clutter on start

lib/Kephra/App/Bar/MainTool.pm

-use strict;
-use warnings;
-
-package Kephra::App::Bar::MainTool;
-
-
-1;

lib/Kephra/App/Bar/Tab.pm

-use v5.12;
-use warnings;
-use Wx;
-use Wx::AUI;
-
-package Kephra::App::Bar::Tab;
-our @ISA = 'Wx::AuiNotebook';
-our $_ref;
-
-use Scalar::Util qw(blessed looks_like_number);
-
-
-#Kephra::API::Command::register({
- #'tabbar-select-left'     =>{sub=>'$tabbar->select_page_left',     label=>'Previous Tab',  keys=>'ctrl+pageup'},
- #'tabbar-select-right'    =>{sub=>'$tabbar->select_page_right',    label=>'Next Tab',      keys=>'ctrl+pagedown'},
- #'tabbar-select-leftmost' =>{sub=>'$tabbar->select_page_leftmost', label=>'First Tab',     keys=>'ctrl+shift+pageup'},
- #'tabbar-select-rightmost'=>{sub=>'$tabbar->select_page_rightmost',label=>'Last Tab',      keys=>'ctrl+shift+pagedown'},
- #'tabbar-move-left'       =>{sub=>'$tabbar->move_page_left',       label=>'Move Left',     keys=>'ctrl+shift+pageup'},
- #'tabbar-move-right'      =>{sub=>'$tabbar->move_page_right',      label=>'Move Right',    keys=>'ctrl+shift+pagedown'},
- #'tabbar-move-leftmost'   =>{sub=>'$tabbar->move_page_leftmost',   label=>'Move Leftmost', keys=>'alt+shift+pageup'},
- #'tabbar-move-rightmost'  =>{sub=>'$tabbar->move_page_rightmost',  label=>'Move Rightmost',keys=>'alt+shift+pagedown'},
-#});
-
-
-sub new {
-	my( $class, $parent) = @_;
-	my $self = $_ref = $class->SUPER::new( $parent, -1, [-1,-1], [-1,-1],
-		&Wx::wxAUI_NB_TOP | &Wx::wxAUI_NB_TAB_MOVE | &Wx::wxAUI_NB_WINDOWLIST_BUTTON |
-		&Wx::wxAUI_NB_SCROLL_BUTTONS | &Wx::wxAUI_NB_CLOSE_ON_ACTIVE_TAB
-	);
-
-	$self->{'visual_page_order'} = [];   # visual order of internal pos : vis -> int
-	$self->{'internal_page_order'} = []; # internal order of visual pos : int -> vis
-
-	$_->add_instance($self) for Kephra::API::all_documents();
-	$self->mount_events();
-
-	$self;
-}
-
-sub Destroy {
-	my ($self) = @_;
-	$_->del_instance($self) for Kephra::API::all_documents();
-	$self->SUPER::Destroy( );
-	1;
-}
-
-sub mount_events {
-	my ($self) = @_;
-	Wx::Event::EVT_SET_FOCUS ($self,  sub { print "focus--\n";$_[1]->Skip });
-	Wx::Event::EVT_AUINOTEBOOK_BEGIN_DRAG( $self, -1, sub {
-		my ($bar, $event ) = @_;
-		$bar->{'DND_page_nr'} = $event->GetSelection;
-	});
-	Wx::Event::EVT_AUINOTEBOOK_END_DRAG($self, -1, sub {
-		my ($bar, $event ) = @_;
-		return unless defined $bar->{'DND_page_nr'};
-		$bar->move_page_position_visually($bar->{'DND_page_nr'}, $event->GetSelection);
-		$bar->{'DND_page_nr'} = undef;
-		Kephra::App::Focus::stay();
-	});
-	Wx::Event::EVT_AUINOTEBOOK_PAGE_CHANGED( $self, -1, sub {
-		my ($bar, $event ) = @_;
-		my $new_page = $bar->GetPage( $event->GetSelection );
-		Kephra::API::DocumentStash::set_active( $new_page );
-		Kephra::API::main_window()->refresh_title();
-		Kephra::API::focus( $new_page );
-		$event->Skip;
-	});
-	Wx::Event::EVT_AUINOTEBOOK_PAGE_CLOSE( $self, -1, sub {
-		my ($bar, $event ) = @_; 
-		$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::focus(Kephra::API::editor); }); #print "--down";
-	$self->Connect( -1, -1, &Wx::wxEVT_SET_FOCUS, sub {  } ); #print "--";
-	Wx::Event::EVT_SET_FOCUS( $self, sub { my ($bar, $event ) = @_; $event->Skip; }); # say "--bar";
-
-	$self;
-}
-
-sub unmount_events {
-	my ($self) = @_;
-	Wx::Event::EVT_AUINOTEBOOK_BEGIN_DRAG( $self, -1, sub {});
-	Wx::Event::EVT_AUINOTEBOOK_END_DRAG  ( $self, -1, sub {});
-	Wx::Event::EVT_AUINOTEBOOK_PAGE_CHANGED( $self, -1, sub {});
-	Wx::Event::EVT_AUINOTEBOOK_PAGE_CLOSE  ( $self, -1, sub {});
-}
-
-
-sub add_page {
-	my ($self, $new_page, $position, $title, $set_active) = @_;
-	return Kephra::Log::warning( "got no panel", 1 ) until Kephra::App::Util::is_panel($new_page);
-	my $active_pos = $self->GetSelection;
-
-	$title    = ''                           unless defined $title;
-	$position = 'right'                      if $position eq 'default' or $position eq -1;
-	$position = $self->rightmost_page_pos+1  if $position eq 'rightmost';
-	$position = $active_pos + 1              if $position eq 'right';
-	$position = $active_pos                  if $position eq 'left';
-	$position = $self->leftmost_page_pos     if $position eq 'leftmost';
-	$set_active = 0                          unless defined $set_active;
-
-	$new_page->Reparent($self);
-	$self->InsertPage( $position, $new_page, $title, $set_active);
-	$self->set_page_title( $title, $new_page );
-	Kephra::API::focus($new_page) if $set_active;
-
-	# inserting new index to position translators
-	for   (@{$self->{'visual_page_order'}}){ $_++ if $_ >= $position }
-	splice @{$self->{'visual_page_order'}},  $position, 0, $position;
-	$self->refresh_internal_page_order();
-
-	$self;
-}
-
-sub remove_page {
-	my ($self, $page) = @_;
-	my $internal_position = $self->GetPageIndex( $page );
-
-	$self->RemovePage( $internal_position );
-	my $visual_position = $self->{'internal_page_order'}[$internal_position];
-	my $visual = $self->{'visual_page_order'};
-	splice @$visual, $visual_position, 1;
-	for (@$visual) {$_-- if $_ >= $internal_position}
-	$self->{'visual_page_order'} = $visual;
-	$self->refresh_internal_page_order;
-}
-
-
-sub refresh_internal_page_order {       # sync visual_page_order index with internal_page_order after each change
-	my ($self) = @_;
-	my $visual = $self->{'visual_page_order'};
-	return unless ref $visual eq ref [];
-	my $internal;
-	$internal->[ $visual->[$_] ] = $_ for 0 .. @$visual-1;
-	$self->{'internal_page_order'} = $internal;
-}
-
-sub move_page_position_visually {          # for dnd only
-	my ($self, $from, $to ) = @_;
-	return unless $from >= 0 and $from < $self->GetPageCount;
-	return unless $to >= 0 and $to < $self->GetPageCount;
-	my $position = splice @{$self->{'visual_page_order'}}, $from, 1;
-	splice @{$self->{'visual_page_order'}}, $to, 0, $position;
-	$self->refresh_internal_page_order();
-}
-
-sub move_page_visually  {               # for movements by keyboard
-	my ($self, $from, $to ) = @_;
-	my $max = $self->GetPageCount - 1;
-	return if $from < 0 or $from > $max;
-	return if $to < 0 or $to > $max;
-	return if $from == $to;
-
-	my $pos = $self->{'visual_page_order'}[ $from ];
-	my $page = $self->GetPage( $pos );
-	my $label = $self->GetPageText( $pos );
-	my $visual = $self->{'visual_page_order'};
-
-	$self->unmount_events();
-	$self->RemovePage( $pos );
-	$self->InsertPage( $to, $page, $label);
-	my $removed = splice @$visual, $from, 1;
-	if ($from < $to) { for (@$visual) {$_-- if $_ > $removed and $_ <= $to} }
-	else             { for (@$visual) {$_++ if $_ < $removed and $_ >= $to} }
-	splice @$visual, $to, 0, $to;
-	$self->{'visual_page_order'} = $visual;
-	$self->refresh_internal_page_order();
-	$self->SetSelection( $self->{'visual_page_order'}[$to] );
-	$self->mount_events();
-}
-
-sub move_page_left      {
-	my ($self) = @_;
-	$self->move_page_visually ( 
-		$self->active_visual_pos, $self->next_page_pos_rot_left( $self->GetSelection )
-	);
-}
-sub move_page_right     {
-	my ($self) = @_;
-	$self->move_page_visually( 
-		$self->active_visual_pos, $self->next_page_pos_rot_right( $self->GetSelection )
-	);
-}
-sub move_page_leftmost  { 
-	my ($self) = @_;
-	$self->move_page_visually( $self->active_visual_pos, $self->leftmost_page_pos );
-}
-sub move_page_rightmost { 
-	my ($self) = @_;
-	$self->move_page_visually( $self->active_visual_pos, $self->rightmost_page_pos );
-}
-
-sub select_page_left    { 
-	my ($self) = @_;
-	$self->raise_page( $self->next_page_pos_rot_left( $self->GetSelection ) );
-}
-sub select_page_right   { 
-	my ($self) = @_;
-	$self->raise_page( $self->next_page_pos_rot_right( $self->GetSelection ) );
-}
-sub select_page_leftmost  { $_[0]->raise_page( $_[0]->leftmost_page_pos ) }
-sub select_page_rightmost { $_[0]->raise_page( $_[0]->rightmost_page_pos ) }
-
-sub active_visual_pos     { $_[0]->{'internal_page_order'}[ $_[0]->GetSelection ] }
-sub leftmost_page_pos     { 0 }
-sub rightmost_page_pos    { $_[0]->GetPageCount-1 }
-sub valid_page_pos        { 
-	1 if $_[1] >= $_[0]->leftmost_page_pos and $_[1]<= $_[0]->rightmost_page_pos
-}
-sub next_page_pos_rot_left{
-	my ($self) = @_; # take in position of internal order
-	my $pos = $self->{'internal_page_order'}[ $_[1] ];
-	$self->{'visual_page_order'}[$pos == 0 ? $self->rightmost_page_pos : $pos-1]
-}
-sub next_page_pos_rot_right{
-	my ($self) = @_; # take in position of internal order
-	my $pos = $self->{'internal_page_order'}[ $_[1] ];
-	$self->{'visual_page_order'}[$pos == $self->rightmost_page_pos ? 0 : $pos+1]
-}
-
-
-sub raise_page    {
-	my ($self, $pop) = @_; # can be Position Or Page (panel reference)
-	my $position = int $pop eq $pop ? $pop : $self->GetPageIndex($pop);
-	return unless $self->valid_page_pos( $position );
-	# if just selecting the currrent, only tab drives focus nuts
-	$self->SetSelection( $position ) unless $position == $self->GetSelection;
-	my $page = $self->GetPage($position);
-	my $doc = Kephra::API::DocumentStash::find($page);
-	Kephra::API::DocumentStash::set_active( $doc );
-	Kephra::API::focus ( defined $doc ? $doc->editor->{$self} : $page );
-	Kephra::API::main_window()->refresh_title();
-
-}
-
-
-sub active_title { $_[0]->GetPageText( $_[0]->GetSelection ) }
-
-sub set_page_title {
-	my ($self, $label, $page) = @_;
-	$page = $self->GetSelection unless defined $page;
-	return Kephra::Log::warning("need a Kephra::App::Panel or valid position number") 
-		unless (looks_like_number($page) and $self->valid_page_pos($page))
-		or (blessed($page) and $page->isa('Kephra::App::Panel'));
-	my $found = $self->GetPageIndex($page);
-	my $position = $found eq &Wx::wxNOT_FOUND ? $page : $found;
-	$self->SetPageText( $position, $label );
-}
-
-
-1;

lib/Kephra/App/Part/Main.pm

 use Cwd;
 use File::Find;
 use File::Spec;
-use Kephra::App::Bar::Tab;
 use Kephra::App::Panel;
 use Kephra::App::Splitter;
+use Kephra::App::TabBar;
 
 package Kephra::App::Part::Main;
 our @ISA = 'Kephra::App::Panel';
 	my( $class, $parent) = @_;
 	my $self = $panel = $class->SUPER::new($parent);
 
-	$active_bar = Kephra::App::Bar::Tab->new($self);
-	@passive_bar = Kephra::App::Bar::Tab->new($self);
+	$active_bar = Kephra::App::TabBar->new($self);
+	@passive_bar = Kephra::App::TabBar->new($self);
 
 	my $splitter = $splitter{'main'} = Kephra::App::Splitter->new({ parent => $self,
 		left => $active_bar, right => $passive_bar[-1], dominant_child => 'left' });

lib/Kephra/App/TabBar.pm

+use v5.12;
+use warnings;
+use Wx::AUI;
+
+package Kephra::App::TabBar;
+our @ISA = 'Wx::AuiNotebook';
+our $_ref;
+
+use Scalar::Util qw(blessed looks_like_number);
+
+
+Kephra::API::Command::register({
+ #'tabbar-select-left'     =>{sub=>'$tabbar->select_page_left',     label=>'Previous Tab',  keys=>'ctrl+pageup'},
+ #'tabbar-select-right'    =>{sub=>'$tabbar->select_page_right',    label=>'Next Tab',      keys=>'ctrl+pagedown'},
+ #'tabbar-select-leftmost' =>{sub=>'$tabbar->select_page_leftmost', label=>'First Tab',     keys=>'ctrl+shift+pageup'},
+ #'tabbar-select-rightmost'=>{sub=>'$tabbar->select_page_rightmost',label=>'Last Tab',      keys=>'ctrl+shift+pagedown'},
+ #'tabbar-move-left'       =>{sub=>'$tabbar->move_page_left',       label=>'Move Left',     keys=>'ctrl+shift+pageup'},
+ #'tabbar-move-right'      =>{sub=>'$tabbar->move_page_right',      label=>'Move Right',    keys=>'ctrl+shift+pagedown'},
+ #'tabbar-move-leftmost'   =>{sub=>'$tabbar->move_page_leftmost',   label=>'Move Leftmost', keys=>'alt+shift+pageup'},
+ #'tabbar-move-rightmost'  =>{sub=>'$tabbar->move_page_rightmost',  label=>'Move Rightmost',keys=>'alt+shift+pagedown'},
+});
+
+
+sub new {
+	my( $class, $parent) = @_;
+	my $self = $_ref = $class->SUPER::new( $parent, -1, [-1,-1], [-1,-1],
+		&Wx::wxAUI_NB_TOP | &Wx::wxAUI_NB_TAB_MOVE | &Wx::wxAUI_NB_WINDOWLIST_BUTTON |
+		&Wx::wxAUI_NB_SCROLL_BUTTONS | &Wx::wxAUI_NB_CLOSE_ON_ACTIVE_TAB
+	);
+
+	$self->{'visual_page_order'} = [];   # visual order of internal pos : vis -> int
+	$self->{'internal_page_order'} = []; # internal order of visual pos : int -> vis
+
+	$_->add_instance($self) for Kephra::API::all_documents();
+	$self->mount_events();
+
+	$self;
+}
+
+sub Destroy {
+	my ($self) = @_;
+	$_->del_instance($self) for Kephra::API::all_documents();
+	$self->SUPER::Destroy( );
+	1;
+}
+
+sub mount_events {
+	my ($self) = @_;
+	Wx::Event::EVT_SET_FOCUS ($self,  sub { print "focus--\n";$_[1]->Skip });
+	Wx::Event::EVT_AUINOTEBOOK_BEGIN_DRAG( $self, -1, sub {
+		my ($bar, $event ) = @_;
+		$bar->{'DND_page_nr'} = $event->GetSelection;
+	});
+	Wx::Event::EVT_AUINOTEBOOK_END_DRAG($self, -1, sub {
+		my ($bar, $event ) = @_;
+		return unless defined $bar->{'DND_page_nr'};
+		$bar->move_page_position_visually($bar->{'DND_page_nr'}, $event->GetSelection);
+		$bar->{'DND_page_nr'} = undef;
+		Kephra::App::Focus::stay();
+	});
+	Wx::Event::EVT_AUINOTEBOOK_PAGE_CHANGED( $self, -1, sub {
+		my ($bar, $event ) = @_;
+		my $new_page = $bar->GetPage( $event->GetSelection );
+		Kephra::API::DocumentStash::set_active( $new_page );
+		Kephra::API::main_window()->refresh_title();
+		Kephra::API::focus( $new_page );
+		$event->Skip;
+	});
+	Wx::Event::EVT_AUINOTEBOOK_PAGE_CLOSE( $self, -1, sub {
+		my ($bar, $event ) = @_; 
+		$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::focus(Kephra::API::editor); }); #print "--down";
+	$self->Connect( -1, -1, &Wx::wxEVT_SET_FOCUS, sub {  } ); #print "--";
+	Wx::Event::EVT_SET_FOCUS( $self, sub { my ($bar, $event ) = @_; $event->Skip; }); # say "--bar";
+
+	$self;
+}
+
+sub unmount_events {
+	my ($self) = @_;
+	Wx::Event::EVT_AUINOTEBOOK_BEGIN_DRAG( $self, -1, sub {});
+	Wx::Event::EVT_AUINOTEBOOK_END_DRAG  ( $self, -1, sub {});
+	Wx::Event::EVT_AUINOTEBOOK_PAGE_CHANGED( $self, -1, sub {});
+	Wx::Event::EVT_AUINOTEBOOK_PAGE_CLOSE  ( $self, -1, sub {});
+}
+
+
+sub add_page {
+	my ($self, $new_page, $position, $title, $set_active) = @_;
+	return Kephra::Log::warning( "got no panel", 1 ) until Kephra::App::Util::is_panel($new_page);
+	my $active_pos = $self->GetSelection;
+
+	$title    = ''                           unless defined $title;
+	$position = 'right'                      if $position eq 'default' or $position eq -1;
+	$position = $self->rightmost_page_pos+1  if $position eq 'rightmost';
+	$position = $active_pos + 1              if $position eq 'right';
+	$position = $active_pos                  if $position eq 'left';
+	$position = $self->leftmost_page_pos     if $position eq 'leftmost';
+	$set_active = 0                          unless defined $set_active;
+
+	$new_page->Reparent($self);
+	$self->InsertPage( $position, $new_page, $title, $set_active);
+	$self->set_page_title( $title, $new_page );
+	Kephra::API::focus($new_page) if $set_active;
+
+	# inserting new index to position translators
+	for   (@{$self->{'visual_page_order'}}){ $_++ if $_ >= $position }
+	splice @{$self->{'visual_page_order'}},  $position, 0, $position;
+	$self->refresh_internal_page_order();
+
+	$self;
+}
+
+sub remove_page {
+	my ($self, $page) = @_;
+	my $internal_position = $self->GetPageIndex( $page );
+
+	$self->RemovePage( $internal_position );
+	my $visual_position = $self->{'internal_page_order'}[$internal_position];
+	my $visual = $self->{'visual_page_order'};
+	splice @$visual, $visual_position, 1;
+	for (@$visual) {$_-- if $_ >= $internal_position}
+	$self->{'visual_page_order'} = $visual;
+	$self->refresh_internal_page_order;
+}
+
+
+sub refresh_internal_page_order {       # sync visual_page_order index with internal_page_order after each change
+	my ($self) = @_;
+	my $visual = $self->{'visual_page_order'};
+	return unless ref $visual eq ref [];
+	my $internal;
+	$internal->[ $visual->[$_] ] = $_ for 0 .. @$visual-1;
+	$self->{'internal_page_order'} = $internal;
+}
+
+sub move_page_position_visually {          # for dnd only
+	my ($self, $from, $to ) = @_;
+	return unless $from >= 0 and $from < $self->GetPageCount;
+	return unless $to >= 0 and $to < $self->GetPageCount;
+	my $position = splice @{$self->{'visual_page_order'}}, $from, 1;
+	splice @{$self->{'visual_page_order'}}, $to, 0, $position;
+	$self->refresh_internal_page_order();
+}
+
+sub move_page_visually  {               # for movements by keyboard
+	my ($self, $from, $to ) = @_;
+	my $max = $self->GetPageCount - 1;
+	return if $from < 0 or $from > $max;
+	return if $to < 0 or $to > $max;
+	return if $from == $to;
+
+	my $pos = $self->{'visual_page_order'}[ $from ];
+	my $page = $self->GetPage( $pos );
+	my $label = $self->GetPageText( $pos );
+	my $visual = $self->{'visual_page_order'};
+
+	$self->unmount_events();
+	$self->RemovePage( $pos );
+	$self->InsertPage( $to, $page, $label);
+	my $removed = splice @$visual, $from, 1;
+	if ($from < $to) { for (@$visual) {$_-- if $_ > $removed and $_ <= $to} }
+	else             { for (@$visual) {$_++ if $_ < $removed and $_ >= $to} }
+	splice @$visual, $to, 0, $to;
+	$self->{'visual_page_order'} = $visual;
+	$self->refresh_internal_page_order();
+	$self->SetSelection( $self->{'visual_page_order'}[$to] );
+	$self->mount_events();
+}
+
+sub move_page_left      {
+	my ($self) = @_;
+	$self->move_page_visually ( 
+		$self->active_visual_pos, $self->next_page_pos_rot_left( $self->GetSelection )
+	);
+}
+sub move_page_right     {
+	my ($self) = @_;
+	$self->move_page_visually( 
+		$self->active_visual_pos, $self->next_page_pos_rot_right( $self->GetSelection )
+	);
+}
+sub move_page_leftmost  { 
+	my ($self) = @_;
+	$self->move_page_visually( $self->active_visual_pos, $self->leftmost_page_pos );
+}
+sub move_page_rightmost { 
+	my ($self) = @_;
+	$self->move_page_visually( $self->active_visual_pos, $self->rightmost_page_pos );
+}
+
+sub select_page_left    { 
+	my ($self) = @_;
+	$self->raise_page( $self->next_page_pos_rot_left( $self->GetSelection ) );
+}
+sub select_page_right   { 
+	my ($self) = @_;
+	$self->raise_page( $self->next_page_pos_rot_right( $self->GetSelection ) );
+}
+sub select_page_leftmost  { $_[0]->raise_page( $_[0]->leftmost_page_pos ) }
+sub select_page_rightmost { $_[0]->raise_page( $_[0]->rightmost_page_pos ) }
+
+sub active_visual_pos     { $_[0]->{'internal_page_order'}[ $_[0]->GetSelection ] }
+sub leftmost_page_pos     { 0 }
+sub rightmost_page_pos    { $_[0]->GetPageCount-1 }
+sub valid_page_pos        { 
+	1 if $_[1] >= $_[0]->leftmost_page_pos and $_[1]<= $_[0]->rightmost_page_pos
+}
+sub next_page_pos_rot_left{
+	my ($self) = @_; # take in position of internal order
+	my $pos = $self->{'internal_page_order'}[ $_[1] ];
+	$self->{'visual_page_order'}[$pos == 0 ? $self->rightmost_page_pos : $pos-1]
+}
+sub next_page_pos_rot_right{
+	my ($self) = @_; # take in position of internal order
+	my $pos = $self->{'internal_page_order'}[ $_[1] ];
+	$self->{'visual_page_order'}[$pos == $self->rightmost_page_pos ? 0 : $pos+1]
+}
+
+
+sub raise_page    {
+	my ($self, $pop) = @_; # can be Position Or Page (panel reference)
+	my $position = int $pop eq $pop ? $pop : $self->GetPageIndex($pop);
+	return unless $self->valid_page_pos( $position );
+	# if just selecting the currrent, only tab drives focus nuts
+	$self->SetSelection( $position ) unless $position == $self->GetSelection;
+	my $page = $self->GetPage($position);
+	my $doc = Kephra::API::DocumentStash::find($page);
+	Kephra::API::DocumentStash::set_active( $doc );
+	Kephra::API::focus ( defined $doc ? $doc->editor->{$self} : $page );
+	Kephra::API::main_window()->refresh_title();
+
+}
+
+
+sub active_title { $_[0]->GetPageText( $_[0]->GetSelection ) }
+
+sub set_page_title {
+	my ($self, $label, $page) = @_;
+	$page = $self->GetSelection unless defined $page;
+	return Kephra::Log::warning("need a Kephra::App::Panel or valid position number") 
+		unless (looks_like_number($page) and $self->valid_page_pos($page))
+		or (blessed($page) and $page->isa('Kephra::App::Panel'));
+	my $found = $self->GetPageIndex($page);
+	my $position = $found eq &Wx::wxNOT_FOUND ? $page : $found;
+	$self->SetPageText( $position, $label );
+}
+
+
+1;

lib/Kephra/App/Window.pm

 
 package Kephra::App::Window;
 use base qw(Wx::Frame);
-use Kephra::App::Bar::Tab;
+use Kephra::App::TabBar;
 use Kephra::App::Part::Main;
 #use Kephra::App::Editor;
 our $_ref;
 	my( $self ) = $_ref = $class->SUPER::new (  undef, -1, $title, [-1,-1], [800,600] );
 	$self->SetIcon( Wx::GetWxPerlIcon() );
 	#my $ed = Kephra::App::Editor->new($self);
-	my $ed = Kephra::App::Bar::Tab->new($self);
+	my $ed = Kephra::App::TabBar->new($self);
+	#my $ed = Kephra::App::Part::Main->new($self);
 
 	Kephra::API::focus($ed);
 	return $self;

lib/Kephra/Document.pm

 
 sub add_instance {
 	my ($self, $bar) = @_;
-	return Kephra::Log::warning("need an existing Kephra::App::Bar::Tab instance")
-		unless blessed($bar) eq 'Kephra::App::Bar::Tab';
+	return Kephra::Log::warning('need an existing Kephra::App::TabBar instance')
+		unless $bar and blessed($bar) eq 'Kephra::App::TabBar';
 
 # say "==" unless ref $self;
 	#my @editor = values $self->editor;
 
 sub del_instance {
 	my ($self, $bar) = @_;
-	return Kephra::Log::warning("need an existing Kephra::App::Bar::Tab instance")
-		unless blessed($bar) eq 'Kephra::App::Bar::Tab'
+	return Kephra::Log::warning('need an existing Kephra::App::TabBar instance')
+		unless blessed($bar) eq 'Kephra::App::TabBar'
 		and exists $self->panel->{$bar};
 	Kephra::API::DocumentStash::remove_doc_instance($self, $bar);
 	$bar->remove_page( $self->panel->{$bar} );

lib/Kephra/StyleGuide.pod

-=head1 Kephra Coding Style
-
-=head2 Technical Details
-
-    bracketing     = K & R
-    indention size = 4
-    use of tabs    = yes
-    line with      = 80 (not strict)
-    utf            = only in strings
-    perl version   = 5.12
-    pragmas        = warnings
-
-
-
-=head2  What Part Of Perl We Use Or Avoid
-
-
-
-
-=head2 Organisation
-
-1 module - 1 name - 1 namespace
-
-
-
-=head2 Naming
-
-We try to reuse same names for same (seldom similar) purpose,
-throughout all modules,
-or the same data part through different structures.
-
-We also try to lean toward natural Perl names (eg 'sub' 'coderef', 'push').
-
-
-=head3 module/class Names
-
-camelcase                      ~~ LikeThis
-
-
-=head3 sub/method Names
-
-lowercase words separated by _ ~~ like_this
-
-routines only to be called inside a module start with one _
-avoid to call these from outside by all means
-
-create not make when we generate something
-
-
-=head3 Variable Names
-
-lowercase words separated by _ ~~ like_this
-We say active, no more current or recent.
-
-$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)
-
-$doc    active document
-
-$tabbar active tab bar
-
-$file   full file path, unless oyur specific like file_name, file_path etc.
-
-$win    main window
-
-
-=head3 Command Names
-
-words separated by -
-
-
-=head3 Event Names
-
-words separated by .
-
-=head3 Key Definitions
-
-keys separated by +

lib/Kephra/StyleGuide.pod.pm

+
+
+=head1 Kephra Coding Style
+
+
+=head2 Perl Defaults
+
+    use v5.12;
+    use warnings;
+
+
+=head2 Technical Details
+
+    bracketing     = K & R
+    indention size = 4
+    use of tabs    = yes
+    line with      = 80 (not strict)
+    utf            = only in strings
+    perl version   = 5.12
+    pragmas        = warnings
+
+
+=head2  What Part Of Perl We Use Or Avoid
+
+
+
+
+=head2 Organisation
+
+1 module - 1 name - 1 namespace
+
+
+
+=head2 Naming
+
+We try to reuse same names for same (seldom similar) purpose,
+throughout all modules,
+or the same data part through different structures.
+
+We also try to lean toward natural Perl names (eg 'sub' 'coderef', 'push').
+
+
+=head3 module/class Names
+
+camelcase                      ~~ LikeThis
+
+
+=head3 sub/method Names
+
+lowercase words separated by _ ~~ like_this
+
+routines only to be called inside a module start with one _
+avoid to call these from outside by all means
+
+create not make when we generate something
+
+
+=head3 Variable Names
+
+lowercase words separated by _ ~~ like_this
+We say active, no more current or recent.
+
+$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)
+
+$doc    active document
+
+$tabbar active tab bar
+
+$file   full file path, unless oyur specific like file_name, file_path etc.
+
+$win    main window
+
+
+=head3 Command Names
+
+words separated by -
+
+
+=head3 Event Names
+
+words separated by .
+
+=head3 Key Definitions
+
+keys separated by +