Herbert Breunung avatar Herbert Breunung committed a5ab5ce

reset style befor defining new

Comments (0)

Files changed (4)

lib/Kephra/API.pm

 );
 
 # gui parts of main window
-sub _app   { $Kephra::App::_ref }
 sub widget { # widget names are same as in the config
 	my $name = shift;
 	croak "requested widget withou name from Kephra::API::widget " unless $name;

lib/Kephra/App/Bar/Document.pm

     $active = 1              unless defined $active;
 
     my $panel = Wx::Panel->new( $tb );
-    my $ep = Kephra::App::Editor->new($panel);
-    my $doc = Kephra::Document->new(editor => $ep);
+    my $ed = Kephra::App::Editor->new($panel);
+    my $doc = Kephra::Document->new(editor => $ed);
     Kephra::DocumentStash::add( $doc );
 
 
     #  sane frame for the editor widget to fit into surrounding structure
     my $sizer = Wx::BoxSizer->new( &Wx::wxVERTICAL );
-    $sizer->Add( $ep, 1, &Wx::wxGROW );
+    $sizer->Add( $ed, 1, &Wx::wxGROW );
     $panel->SetSizer( $sizer );
 
     $tb->InsertPage( $pos, $panel, '<untitled>', $active );
-    $ep->set_focus() if $active;
+    $ed->set_focus() if $active;
 
     return $tb;
 }

lib/Kephra/App/Editor.pm

 
 sub new {
     my( $class, $parent, $style) = @_;
-    my $ep = $class->SUPER::new($parent, -1);
-    $ep->load_font();
-    $ep->set_margin();
-    $ep->set_colors();
-    $ep->set_perlhighlight();
-    $ep->mount_events();
+    my $ed = $class->SUPER::new($parent, -1);
+    $ed->load_font();
+    $ed->set_margin();
+    $ed->set_colors();
+    $ed->set_perlhighlight();
+    $ed->mount_events();
 
-    return $ep;
+    return $ed;
 }
 
 sub mount_events {
-    my ($ep, @which) = @_;
-    $ep->SetAcceleratorTable(
+    my ($ed, @which) = @_;
+    $ed->SetAcceleratorTable(
         Wx::AcceleratorTable->new(
             #[&Wx::wxACCEL_CTRL, ord 'n', 1000],
     ));
-    #$ep->SetAcceleratorTable( Wx::AcceleratorTable->new() );
-    #Wx::Event::EVT_MENU( $ep, 1000, sub { $_[1]->Skip; } );
-    #Wx::Event::EVT_STC_SAVEPOINTREACHED($ep, -1, \&Kephra::File::savepoint_reached);
-    #Wx::Event::EVT_STC_SAVEPOINTLEFT($ep, -1, \&Kephra::File::savepoint_left);
-    #Wx::Event::EVT_STC_CHANGE       ($ep, -1, sub {&$trigger('document.text.change')} );
+    #$ed->SetAcceleratorTable( Wx::AcceleratorTable->new() );
+    #Wx::Event::EVT_MENU( $ed, 1000, sub { $_[1]->Skip; } );
+    #Wx::Event::EVT_STC_SAVEPOINTREACHED($ed, -1, \&Kephra::File::savepoint_reached);
+    #Wx::Event::EVT_STC_SAVEPOINTLEFT($ed, -1, \&Kephra::File::savepoint_left);
+    #Wx::Event::EVT_STC_CHANGE       ($ed, -1, sub {&$trigger('document.text.change')} );
     #Wx::Event::EVT_KEY_DOWN ($win, sub {
     #EVT_STC_STYLENEEDED(id, fn) 
     #EVT_STC_CHARADDED(id, fn) 
 sub set_focus {  Wx::Window::SetFocus( $_[0] ) }
 
 sub set_margin {
-    my ($ep, $style) = @_;
+    my ($ed, $style) = @_;
     $style = '' unless defined $style;
 
-    $ep->SetMarginType( 0, &Wx::wxSTC_MARGIN_SYMBOL );
-    $ep->SetMarginType( 1, &Wx::wxSTC_MARGIN_NUMBER );
-    $ep->SetMarginType( 2, &Wx::wxSTC_MARGIN_SYMBOL );
-    $ep->SetMarginMask( 0, 0x01FFFFFF );
-    $ep->SetMarginMask( 1, 0 );
-    $ep->SetMarginMask( 2, &Wx::wxSTC_MASK_FOLDERS );
-    $ep->SetMarginSensitive( 0, 1 );
-    $ep->SetMarginSensitive( 1, 1 );
-    $ep->SetMarginSensitive( 2, 1 );
-    if ($style eq 'no') { $ep->SetMarginWidth($_, 0) for 0..2 }
+    $ed->SetMarginType( 0, &Wx::wxSTC_MARGIN_SYMBOL );
+    $ed->SetMarginType( 1, &Wx::wxSTC_MARGIN_NUMBER );
+    $ed->SetMarginType( 2, &Wx::wxSTC_MARGIN_SYMBOL );
+    $ed->SetMarginMask( 0, 0x01FFFFFF );
+    $ed->SetMarginMask( 1, 0 );
+    $ed->SetMarginMask( 2, &Wx::wxSTC_MASK_FOLDERS );
+    $ed->SetMarginSensitive( 0, 1 );
+    $ed->SetMarginSensitive( 1, 1 );
+    $ed->SetMarginSensitive( 2, 1 );
+    if ($style eq 'no') { $ed->SetMarginWidth($_, 0) for 0..2 }
     else {
-        $ep->StyleSetForeground(&Wx::wxSTC_STYLE_LINENUMBER, $mk_color->(123,123,137));
-        $ep->StyleSetBackground(&Wx::wxSTC_STYLE_LINENUMBER, $mk_color->(226,226,222));
-        $ep->SetMarginWidth(0,  0);
-        $ep->SetMarginWidth(1, 31);
-        $ep->SetMarginWidth(2,  0);
+        $ed->StyleSetForeground(&Wx::wxSTC_STYLE_LINENUMBER, $mk_color->(123,123,137));
+        $ed->StyleSetBackground(&Wx::wxSTC_STYLE_LINENUMBER, $mk_color->(226,226,222));
+        $ed->SetMarginWidth(0,  0);
+        $ed->SetMarginWidth(1, 31);
+        $ed->SetMarginWidth(2,  0);
     }
-    $ep->SetMargins(2, 2 );
-    $ep->SetScrollWidth(200);
+    $ed->SetMargins(2, 2 );
+    $ed->SetScrollWidth(200);
 }
 
 sub set_colors {
-    my $ep = shift;
+    my $ed = shift;
     my $color = Kephra::App::Helper::get('make_color');
-    $ep->SetCaretLineBack( $mk_color->(245,245,161) );
-    $ep->SetCaretPeriod( 500 );
-    $ep->SetCaretWidth( 2 );
-    $ep->SetCaretForeground( $mk_color->(0,0,255) );
-    $ep->SetCaretLineVisible(1);
-    $ep->SetSelForeground( 1, $mk_color->(255,246,194) );
-    $ep->SetSelBackground( 1, $mk_color->(0, 17, 119) );
-    $ep->SetWhitespaceForeground( 1, $mk_color->(204, 204, 153) );
+    $ed->SetCaretLineBack( $mk_color->(245,245,161) );
+    $ed->SetCaretPeriod( 500 );
+    $ed->SetCaretWidth( 2 );
+    $ed->SetCaretForeground( $mk_color->(0,0,255) );
+    $ed->SetCaretLineVisible(1);
+    $ed->SetSelForeground( 1, $mk_color->(255,246,194) );
+    $ed->SetSelBackground( 1, $mk_color->(0, 17, 119) );
+    $ed->SetWhitespaceForeground( 1, $mk_color->(204, 204, 153) );
 }
 
 sub load_font {
-    my ($ep, $font) = @_;
+    my ($ed, $font) = @_;
     my ( $fontweight, $fontstyle ) = ( &Wx::wxNORMAL, &Wx::wxNORMAL );
     $font = {
         #family => 'Courier New', # old default
     my $wx_font = Wx::Font->new( 
         $font->{size}, &Wx::wxDEFAULT, $fontstyle, $fontweight, 0, $font->{family}
     );
-    $ep->StyleSetFont( &Wx::wxSTC_STYLE_DEFAULT, $wx_font ) if $wx_font->Ok > 0;
+    $ed->StyleSetFont( &Wx::wxSTC_STYLE_DEFAULT, $wx_font ) if $wx_font->Ok > 0;
 }
 
 sub set_perlhighlight {
-    #my ($ep) = @_;
-        $_[0]->SetLexer( &Wx::wxSTC_LEX_PERL );         # Set Lexers to use
-    $_[0]->SetKeyWords(0, 'NULL 
+    my ($ed) = @_;
+    $ed->StyleClearAll;
+    $ed->SetLexer( &Wx::wxSTC_LEX_PERL );         # Set Lexers to use
+    $ed->SetKeyWords(0, 'NULL 
 __FILE__ __LINE__ __PACKAGE__ __DATA__ __END__ __WARN__ __DIE__
 AUTOLOAD BEGIN CHECK CORE DESTROY END EQ GE GT INIT LE LT NE UNITCHECK 
 abs accept alarm and atan2 bind binmode bless break
 # Add new keyword.
 # $_[0]->StyleSetSpec( &Wx::wxSTC_H_TAG, "fore:#000055" ); # Apply tag style for selected lexer (blue)
 
-     $_[0]->StyleSetSpec(1,"fore:#ff0000");                                     # Error
-     $_[0]->StyleSetSpec(2,"fore:#aaaaaa");                                     # Comment
-     $_[0]->StyleSetSpec(3,"fore:#004000,back:#E0FFE0,$(font.text),eolfilled"); # POD: = at beginning of line
-     $_[0]->StyleSetSpec(4,"fore:#007f7f");                                     # Number
-     $_[0]->StyleSetSpec(5,"fore:#000077,bold");                                # Keywords
-     $_[0]->StyleSetSpec(6,"fore:#ee7b00,back:#fff8f8");                        # Doublequoted string
-     $_[0]->StyleSetSpec(7,"fore:#f36600,back:#fffcff");                        # Single quoted string
-     $_[0]->StyleSetSpec(8,"fore:#555555");                                     # Symbols / Punctuation. Currently not used by LexPerl.
-     $_[0]->StyleSetSpec(9,"");                                                 # Preprocessor. Currently not used by LexPerl.
-     $_[0]->StyleSetSpec(10,"fore:#002200");                                    # Operators
-     $_[0]->StyleSetSpec(11,"fore:#3355bb");                                    # Identifiers (functions, etc.)
-     $_[0]->StyleSetSpec(12,"fore:#228822");                                    # Scalars: $var
-     $_[0]->StyleSetSpec(13,"fore:#339933");                                    # Array: @var
-     $_[0]->StyleSetSpec(14,"fore:#44aa44");                                    # Hash: %var
-     $_[0]->StyleSetSpec(15,"fore:#55bb55");                                    # Symbol table: *var
-     $_[0]->StyleSetSpec(17,"fore:#000000,back:#A0FFA0");                       # Regex: /re/ or m{re}
-     $_[0]->StyleSetSpec(18,"fore:#000000,back:#F0E080");                       # Substitution: s/re/ore/
-     $_[0]->StyleSetSpec(19,"fore:#000000,back:#8080A0");                       # Long Quote (qq, qr, qw, qx) -- obsolete: replaced by qq, qx, qr, qw
-     $_[0]->StyleSetSpec(20,"fore:#ff7700,back:#f9f9d7");                       # Back Ticks
-     $_[0]->StyleSetSpec(21,"fore:#600000,back:#FFF0D8,eolfilled");             # Data Section: __DATA__ or __END__ at beginning of line
-     $_[0]->StyleSetSpec(22,"fore:#000000,back:#DDD0DD");                       # Here-doc (delimiter)
-     $_[0]->StyleSetSpec(23,"fore:#7F007F,back:#DDD0DD,eolfilled,notbold");     # Here-doc (single quoted, q)
-     $_[0]->StyleSetSpec(24,"fore:#7F007F,back:#DDD0DD,eolfilled,bold");        # Here-doc (double quoted, qq)
-     $_[0]->StyleSetSpec(25,"fore:#7F007F,back:#DDD0DD,eolfilled,italics");     # Here-doc (back ticks, qx)
-     $_[0]->StyleSetSpec(26,"fore:#7F007F,$(font.monospace),notbold");          # Single quoted string, generic 
-     $_[0]->StyleSetSpec(27,"fore:#ee7b00,back:#fff8f8");                       # qq = Double quoted string
-     $_[0]->StyleSetSpec(28,"fore:#ff7700,back:#f9f9d7");                                # qx = Back ticks
-     $_[0]->StyleSetSpec(29,"fore:#000000,back:#A0FFA0");                                # qr = Regex
-     $_[0]->StyleSetSpec(30,"fore:#f36600,back:#fff8f8");                       # qw = Array
+     $ed->StyleSetSpec(1,"fore:#ff0000");                                     # Error
+     $ed->StyleSetSpec(2,"fore:#aaaaaa");                                     # Comment
+     $ed->StyleSetSpec(3,"fore:#004000,back:#E0FFE0,$(font.text),eolfilled"); # POD: = at beginning of line
+     $ed->StyleSetSpec(4,"fore:#007f7f");                                     # Number
+     $ed->StyleSetSpec(5,"fore:#000077,bold");                                # Keywords
+     $ed->StyleSetSpec(6,"fore:#ee7b00,back:#fff8f8");                        # Doublequoted string
+     $ed->StyleSetSpec(7,"fore:#f36600,back:#fffcff");                        # Single quoted string
+     $ed->StyleSetSpec(8,"fore:#555555");                                     # Symbols / Punctuation. Currently not used by LexPerl.
+     $ed->StyleSetSpec(9,"");                                                 # Preprocessor. Currently not used by LexPerl.
+     $ed->StyleSetSpec(10,"fore:#002200");                                    # Operators
+     $ed->StyleSetSpec(11,"fore:#3355bb");                                    # Identifiers (functions, etc.)
+     $ed->StyleSetSpec(12,"fore:#228822");                                    # Scalars: $var
+     $ed->StyleSetSpec(13,"fore:#339933");                                    # Array: @var
+     $ed->StyleSetSpec(14,"fore:#44aa44");                                    # Hash: %var
+     $ed->StyleSetSpec(15,"fore:#55bb55");                                    # Symbol table: *var
+     $ed->StyleSetSpec(17,"fore:#000000,back:#A0FFA0");                       # Regex: /re/ or m{re}
+     $ed->StyleSetSpec(18,"fore:#000000,back:#F0E080");                       # Substitution: s/re/ore/
+     $ed->StyleSetSpec(19,"fore:#000000,back:#8080A0");                       # Long Quote (qq, qr, qw, qx) -- obsolete: replaced by qq, qx, qr, qw
+     $ed->StyleSetSpec(20,"fore:#ff7700,back:#f9f9d7");                       # Back Ticks
+     $ed->StyleSetSpec(21,"fore:#600000,back:#FFF0D8,eolfilled");             # Data Section: __DATA__ or __END__ at beginning of line
+     $ed->StyleSetSpec(22,"fore:#000000,back:#DDD0DD");                       # Here-doc (delimiter)
+     $ed->StyleSetSpec(23,"fore:#7F007F,back:#DDD0DD,eolfilled,notbold");     # Here-doc (single quoted, q)
+     $ed->StyleSetSpec(24,"fore:#7F007F,back:#DDD0DD,eolfilled,bold");        # Here-doc (double quoted, qq)
+     $ed->StyleSetSpec(25,"fore:#7F007F,back:#DDD0DD,eolfilled,italics");     # Here-doc (back ticks, qx)
+     $ed->StyleSetSpec(26,"fore:#7F007F,$(font.monospace),notbold");          # Single quoted string, generic 
+     $ed->StyleSetSpec(27,"fore:#ee7b00,back:#fff8f8");                       # qq = Double quoted string
+     $ed->StyleSetSpec(28,"fore:#ff7700,back:#f9f9d7");                                # qx = Back ticks
+     $ed->StyleSetSpec(29,"fore:#000000,back:#A0FFA0");                                # qr = Regex
+     $ed->StyleSetSpec(30,"fore:#f36600,back:#fff8f8");                       # qw = Array
 }
 
 1;

lib/Kephra/DocumentStash.pm

 sub active        { $active }
 sub active_editor { $active->editor }
 sub add {
-	my $ep = shift;
-	#warn "$ep is not a  document"
-	$document{$ep->editor} = $active = $ep;
+	my $ed = shift;
+	#warn "$ed is not a  document"
+	$document{$ed->editor} = $active = $ed;
 }
 sub del {
-	my $ep = shift;
+	my $ed = shift;
 }
 
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.