1. Herbert Breunung
  2. Kephra

Source

Kephra / lib / Kephra / App / Editor.pm

Diff from to

File lib/Kephra/App/Editor.pm

  • Ignore whitespace
 package Kephra::App::Editor;
 our @ISA = 'Wx::StyledTextCtrl';
 #our @ISA = 'Wx::ScintillaTextCtrl';
-
-my $color = Kephra::App::Util::get('create_color');
+use Kephra::App::Util qw(create_color);
 
 sub new {
 	my( $class, $parent, $style) = @_;
 	my ($self, @which) = @_;
 	$self->DragAcceptFiles(1) if $^O eq 'MSWin32'; # enable drop files on win
 	$self->SetDropTarget( Kephra::App::Editor::TextDropTarget->new($self) );
+
 	Wx::Event::EVT_STC_CHANGE       ($self, -1, sub {
 		my ($ed, $event) = @_;
 		$ed->{'change_pos'} = $ed->GetCurrentPos;
 		$event->Skip;
 	} );
+
 	Wx::Event::EVT_KEY_DOWN ($self, sub {
 		my ($ed, $event) = @_;
 		my $key = Kephra::API::KeyMap::keycode_from_event($event);
 	#Wx::Event::EVT_RIGHT_DOWN
 	#Wx::Event::EVT_STC_UPDATEUI
 	Wx::Event::EVT_STC_SAVEPOINTREACHED
-		($self, -1, sub { Kephra::API::docbar()->refresh_page_title() });
+		($self, -1, sub { Kephra::App::Part::Editor::refresh_doc_label() });
 	Wx::Event::EVT_STC_SAVEPOINTLEFT
-		($self, -1, sub { Kephra::API::docbar()->refresh_page_title() });
+		($self, -1, sub { Kephra::App::Part::Editor::refresh_doc_label() });
+	Wx::Event::EVT_SET_FOCUS( $self, sub {
+		my ($ed, $event ) = @_;
+		$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_DO_DROP   
-
 }
 
 sub set_margin {
 		$self->SetMarginSensitive( 0, 1 );
 		$self->SetMarginSensitive( 1, 1 );
 		$self->SetMarginSensitive( 2, 1 );
-		$self->StyleSetForeground(&Wx::wxSTC_STYLE_LINENUMBER, $color->(123,123,137));
-		$self->StyleSetBackground(&Wx::wxSTC_STYLE_LINENUMBER, $color->(226,226,222));
+		$self->StyleSetForeground(&Wx::wxSTC_STYLE_LINENUMBER, create_color(123,123,137));
+		$self->StyleSetBackground(&Wx::wxSTC_STYLE_LINENUMBER, create_color(226,226,222));
 		$self->SetMarginWidth(0,  0);
 		$self->SetMarginWidth(1, 31);
 		$self->SetMarginWidth(2,  0);
 
 	# extra margin left and right inside the white text area
 	$self->SetMargins(2, 2);
+	$self;
 }
 
 sub insert_text {
 
 sub set_colors {
 	my $self = shift;
-	$self->SetCaretLineBack( $color->(250,245,185) );
+	$self->SetCaretLineBack( create_color(250,245,185) );
 	#$self->SetCaretPeriod( 500 );
 	#$self->SetCaretWidth( 2 );
-	$self->SetCaretForeground( $color->(0,0,255) );
+	$self->SetCaretForeground( create_color(0,0,255) );
 	$self->SetCaretLineVisible(1);
-	$self->SetSelForeground( 1, $color->(243,243,243) );
-	$self->SetSelBackground( 1, $color->(0, 17, 119) );
-	$self->SetWhitespaceForeground( 1, $color->(204, 204, 153) );
+	$self->SetSelForeground( 1, create_color(243,243,243) );
+	$self->SetSelBackground( 1, create_color(0, 17, 119) );
+	$self->SetWhitespaceForeground( 1, create_color(204, 204, 153) );
 	$self->SetViewWhiteSpace(1);
 
-	$self->SetEdgeColour( $color->(200,200,255) );
+	$self->SetEdgeColour( create_color(200,200,255) );
 	$self->SetEdgeColumn( 80 );
 	$self->SetEdgeMode( &Wx::wxSTC_EDGE_LINE );
 }