1. Herbert Breunung
  2. Kephra

Commits

Herbert Breunung  committed e8de99d

move tab selection by keys

  • Participants
  • Parent commits cc75a42
  • Branches default

Comments (0)

Files changed (4)

File lib/Kephra.pm

View file
 our $VERSION  = '0.5.0.5';
 
 sub start {
-    #TODO:  start_worker_thread();
-    load_libs();
-    #configdir();
-    Kephra::App->new()->MainLoop();
+	#TODO:  start_worker_thread();
+	load_libs();
+	#configdir();
+	Kephra::App->new()->MainLoop();
 }
 
 our @external_dependencies = (
-    qw/Benchmark Encode Encode::Guess Cwd/,
-    qw/File::Find File::Spec File::UserConfig Config::General YAML/,
-    qw/PPI Moo/,
-    qw/Wx Wx::STC Wx::Perl::ProcessStream/, # Wx::Scintilla
+	qw/Benchmark Encode Encode::Guess Cwd/,
+	qw/File::Find File::Spec File::UserConfig Config::General YAML/,
+	qw/PPI Moo/,
+	qw/Wx Wx::STC Wx::Perl::ProcessStream/, # Wx::Scintilla
 );
 our @used_wx_modules = qw/Wx::AUI Wx::DND Wx::RichText/; # Wx::STC
 
 #our @command_modules;
 
 sub load_libs {
-    eval "require $_" for @external_dependencies, @used_wx_modules;
-    eval "require Kephra::$_" for @needed_at_first;
+	eval "require $_" for @external_dependencies, @used_wx_modules;
+	eval "require Kephra::$_" for @needed_at_first;
 }
 
 
 }
 
 sub configdir {
-    $_[0] and $_[0] eq $NAME and shift;
-    print File::UserConfig->configdir(@_);
+	$_[0] and $_[0] eq $NAME and shift;
+	print File::UserConfig->configdir(@_);
 }
 
 sub debug {
-    #Wx->import( ':everything' );
+	#Wx->import( ':everything' );
 }
 
 1;
 
 You can find documentation for this module with the perldoc command.
 
-    perldoc Kephra
+	perldoc Kephra
 
 You can also look for information at:
 

File lib/Kephra/App/Bar/Document.pm

View file
 our @ISA = 'Wx::AuiNotebook';
 
 my $put_on_panel = Kephra::App::Util::get('put_on_panel');
-my @tab_nr;
 
 sub new {
 	my( $class, $parent) = @_;
 		&Wx::wxAUI_NB_SCROLL_BUTTONS | &Wx::wxAUI_NB_CLOSE_ON_ACTIVE_TAB
 	);
 
+	$self->{'tab_nr'} = [];
+
 	my $dragged_tab_nr;
 	Wx::Event::EVT_AUINOTEBOOK_BEGIN_DRAG( $self, -1, sub {
 		my ($nb, $event ) = @_;
+print $event->GetSelection," drag \n";
 	});
 	Wx::Event::EVT_AUINOTEBOOK_END_DRAG($self, -1, sub {
 		my ($nb, $event ) = @_;
+print $event->GetSelection," drag \n";
 	});
 	Wx::Event::EVT_AUINOTEBOOK_PAGE_CHANGED( $self, -1, sub {
 		my ($nb, $event ) = @_;
 		$event->Veto;
 		Kephra::File::close_active();
 	});
-
 	return $self;
 }
 
 	$label = '<untitled>' unless $label;
 	$self->SetPageText( $nr, $label );
 }
-#AdvanceSelection
 
+sub select_left  { 
+	my ($self) = @_;
+	my ($pos, $max) = ($self->GetSelection, $self->GetPageCount - 1);
+	$self->SetSelection( $pos == 0 ? $max : $pos-1 );
+}
+sub select_right { 
+	my ($self) = @_;
+	my ($pos, $max) = ($self->GetSelection, $self->GetPageCount - 1);
+	$self->SetSelection( $pos == $max ? 0 : $pos+1 );
+}
 
 1;

File lib/Kephra/App/Editor.pm

View file
 			( $event->ShiftDown
 			+ $event->ControlDown * 2 
 			+ $event->AltDown     * 4);
-		if      ($key ==  &Wx::WXK_UP + 2000) {
-			if ($event->ShiftDown) {$self->CmdKeyExecute(&Wx::wxSTC_CMD_PARAUPEXTEND)} 
-			else                   {$self->CmdKeyExecute(&Wx::wxSTC_CMD_PARAUP)}
-		} elsif ($key ==  &Wx::WXK_DOWN + 2000){
-			if ($event->ShiftDown) {$self->CmdKeyExecute(&Wx::wxSTC_CMD_PARADOWNEXTEND)} 
-			else                   {$self->CmdKeyExecute(&Wx::wxSTC_CMD_PARADOWN)}
-		}
-		elsif ($key ==  &Wx::WXK_ESCAPE){ Kephra::App::Panel::FileBrowser::focus() } 
-		elsif ($key ==  ord('Q') + 2000) { Kephra::File::close_active() }
+		if    ($key ==  &Wx::WXK_UP + 2000)  {$self->CmdKeyExecute(&Wx::wxSTC_CMD_PARAUP)}
+		elsif ($key ==  &Wx::WXK_UP + 3000)  {$self->CmdKeyExecute(&Wx::wxSTC_CMD_PARAUPEXTEND)}
+		elsif ($key ==  &Wx::WXK_DOWN + 2000){$self->CmdKeyExecute(&Wx::wxSTC_CMD_PARADOWN)}
+		elsif ($key ==  &Wx::WXK_DOWN + 3000){$self->CmdKeyExecute(&Wx::wxSTC_CMD_PARADOWNEXTEND)}
+		elsif ($key ==  &Wx::WXK_PAGEUP + 2000){Kephra::App::Panel::Editor::select_tab_left()}
+		elsif ($key ==  &Wx::WXK_PAGEUP + 3000){Kephra::App::Panel::Editor::move_tab_left()  }
+		elsif ($key ==  &Wx::WXK_PAGEDOWN+2000){Kephra::App::Panel::Editor::select_tab_right()}
+		elsif ($key ==  &Wx::WXK_PAGEDOWN+3000){Kephra::App::Panel::Editor::move_tab_right()}
+		elsif ($key ==  &Wx::WXK_ESCAPE)       {Kephra::App::Panel::FileBrowser::focus() } 
+		elsif ($key ==  ord('Q') + 2000)       {Kephra::File::close_active() }
 		else {$event->Skip}
-
 		#print " $key- \n";
 	});
 	#Wx::Event::EVT_STC_STYLENEEDED(id, sub{}) 

File lib/Kephra/App/Panel/Editor.pm

View file
 	return $doc;
 }
 
-sub raise_file {
-	my $file = shift;
-	_active_docbar()->raise_panel( 
-		Kephra::DocumentStash::get_by_path($file)->{editor}
-	);
-}
-
-sub active_title {
-	my $nb = _active_docbar();
-	$nb->GetPageText( $nb->GetSelection );
-}
-
 sub remove_document {
 	my $doc = shift;
 	return unless ref $doc and $doc->isa('Kephra::Document');
 	}
 }
 
-1;
+sub raise_file {
+	my $file = shift;
+	_active_docbar()->raise_panel( 
+		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 active_title {
+	my $nb = _active_docbar();
+	$nb->GetPageText( $nb->GetSelection );
+}
+
+1;