line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Kephra::Document::SyntaxMode;
|
2
|
|
|
|
|
|
|
our $VERSION = '0.06';
|
3
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
1585
|
use strict;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
44
|
|
5
|
1
|
|
|
1
|
|
7
|
use warnings;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
992
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
my $current;
|
8
|
0
|
0
|
|
0
|
|
|
sub _ID { $current = defined $_[0] ? $_[0] : $current }
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# syntaxstyles
|
11
|
|
|
|
|
|
|
|
12
|
0
|
|
|
0
|
|
|
sub _get_auto{ &_get_by_fileending }
|
13
|
|
|
|
|
|
|
sub _get_by_fileending {
|
14
|
0
|
|
|
0
|
|
|
my $file_ending = Kephra::Document::Data::get_attribute('ending', shift );
|
15
|
0
|
0
|
0
|
|
|
|
chop $file_ending if $file_ending and (substr ($file_ending, -1) eq '~');
|
16
|
0
|
|
|
|
|
|
my $language_id;
|
17
|
0
|
0
|
|
|
|
|
if ($file_ending) {
|
18
|
0
|
|
|
|
|
|
$language_id = $Kephra::temp{file}{end2langmap}
|
19
|
|
|
|
|
|
|
{ Kephra::Config::_lc_utf($file_ending) };
|
20
|
0
|
|
|
|
|
|
} else { return "none" }
|
21
|
0
|
0
|
0
|
|
|
|
if ( !$language_id or $language_id eq '') { return "none" }
|
|
0
|
0
|
|
|
|
|
|
22
|
0
|
|
|
|
|
|
elsif ( $language_id eq 'text' ) { return "none" }
|
23
|
0
|
|
|
|
|
|
return $language_id;
|
24
|
|
|
|
|
|
|
}
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub switch_auto {
|
27
|
0
|
|
|
0
|
0
|
|
my $auto_style = _get_auto();
|
28
|
0
|
0
|
|
|
|
|
if (_ID() ne $auto_style) { set($auto_style) }
|
|
0
|
|
|
|
|
|
|
29
|
0
|
|
|
|
|
|
else { set('none') }
|
30
|
|
|
|
|
|
|
}
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub reload {
|
33
|
0
|
|
|
0
|
0
|
|
my $nr = Kephra::Document::Data::valid_or_current_doc_nr(shift);
|
34
|
0
|
|
|
|
|
|
set( Kephra::Document::Data::get_attribute('syntaxmode', $nr), $nr );
|
35
|
|
|
|
|
|
|
}
|
36
|
0
|
|
|
0
|
0
|
|
sub update { _ID(Kephra::Document::Data::attr('syntaxmode')) }
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub set {
|
39
|
0
|
|
|
0
|
0
|
|
my $style = shift;
|
40
|
0
|
|
|
|
|
|
my $doc_nr = Kephra::Document::Data::valid_or_current_doc_nr(shift);
|
41
|
0
|
0
|
|
|
|
|
return if $doc_nr == -1;
|
42
|
0
|
|
|
|
|
|
my $ep = Kephra::Document::Data::_ep($doc_nr);
|
43
|
0
|
|
|
|
|
|
my $color = \&Kephra::Config::color;
|
44
|
0
|
0
|
|
|
|
|
$style = _get_by_fileending() if $style eq 'auto';
|
45
|
0
|
0
|
|
|
|
|
$style = 'none' unless $style;
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# do nothing when syntaxmode of next doc is the same
|
48
|
|
|
|
|
|
|
#return if _ID() eq $style;
|
49
|
|
|
|
|
|
|
# prevent clash between big lexer & indicator
|
50
|
0
|
0
|
|
|
|
|
if ( $style =~ /asp|html|php|xml/ ) { $ep->SetStyleBits(7) }
|
|
0
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
else { $ep->SetStyleBits(5) }
|
52
|
|
|
|
|
|
|
# clear style infos
|
53
|
0
|
|
|
|
|
|
$ep->StyleResetDefault;
|
54
|
0
|
|
|
|
|
|
Kephra::App::EditPanel::load_font($ep);
|
55
|
0
|
|
|
|
|
|
$ep->StyleClearAll;
|
56
|
0
|
|
|
|
|
|
$ep->SetKeyWords( $_, '' ) for 0 .. 1;
|
57
|
|
|
|
|
|
|
# load syntax style
|
58
|
0
|
0
|
|
|
|
|
if ( $style eq 'none' ) {
|
59
|
0
|
|
|
|
|
|
$ep->SetLexer(&Wx::wxSTC_LEX_NULL);
|
60
|
|
|
|
|
|
|
} else {
|
61
|
0
|
|
|
|
|
|
eval("require syntaxhighlighter::$style");
|
62
|
0
|
|
|
|
|
|
eval("syntaxhighlighter::$style" . '::load($ep)');
|
63
|
|
|
|
|
|
|
}
|
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
# restore bracelight, bracebadlight indentguide colors
|
66
|
0
|
|
|
|
|
|
my $indicator = Kephra::App::EditPanel::_config()->{indicator};
|
67
|
0
|
|
|
|
|
|
my $bracelight = $indicator->{bracelight};
|
68
|
0
|
0
|
|
|
|
|
if ( $bracelight->{visible} ) {
|
69
|
0
|
|
|
|
|
|
$ep->StyleSetBold( &Wx::wxSTC_STYLE_BRACELIGHT, 1 );
|
70
|
0
|
|
|
|
|
|
$ep->StyleSetBold( &Wx::wxSTC_STYLE_BRACEBAD, 1 );
|
71
|
0
|
|
|
|
|
|
$ep->StyleSetForeground
|
72
|
|
|
|
|
|
|
( &Wx::wxSTC_STYLE_BRACELIGHT, &$color( $bracelight->{good_color} ) );
|
73
|
0
|
|
|
|
|
|
$ep->StyleSetBackground
|
74
|
|
|
|
|
|
|
( &Wx::wxSTC_STYLE_BRACELIGHT, &$color( $bracelight->{back_color} ) );
|
75
|
0
|
|
|
|
|
|
$ep->StyleSetForeground
|
76
|
|
|
|
|
|
|
( &Wx::wxSTC_STYLE_BRACEBAD, &$color( $bracelight->{bad_color} ) );
|
77
|
0
|
|
|
|
|
|
$ep->StyleSetBackground
|
78
|
|
|
|
|
|
|
( &Wx::wxSTC_STYLE_BRACEBAD, &$color( $bracelight->{back_color} ) );
|
79
|
0
|
|
|
|
|
|
$ep->StyleSetForeground
|
80
|
|
|
|
|
|
|
(&Wx::wxSTC_STYLE_INDENTGUIDE,&$color($indicator->{indent_guide}{color}));
|
81
|
|
|
|
|
|
|
}
|
82
|
|
|
|
|
|
|
|
83
|
0
|
|
|
|
|
|
Kephra::Document::Data::set_attribute( 'syntaxmode', $style, $doc_nr);
|
84
|
0
|
|
|
|
|
|
_ID($style);
|
85
|
|
|
|
|
|
|
|
86
|
0
|
|
|
|
|
|
Kephra::EventTable::freeze('document.text.change');
|
87
|
0
|
|
|
|
|
|
$ep->Colourise( 0, $ep->GetTextLength ); # refresh editpanel painting, not needed normally
|
88
|
0
|
|
|
|
|
|
Kephra::EventTable::thaw('document.text.change');
|
89
|
|
|
|
|
|
|
# cleanup
|
90
|
0
|
|
|
|
|
|
Kephra::App::EditPanel::Margin::refresh_changeable_settings($ep);
|
91
|
0
|
|
|
|
|
|
Kephra::App::StatusBar::style_info($style);
|
92
|
0
|
|
|
|
|
|
return $style;
|
93
|
|
|
|
|
|
|
}
|
94
|
|
|
|
|
|
|
|
95
|
0
|
|
|
0
|
0
|
|
sub compile {}
|
96
|
0
|
|
|
0
|
0
|
|
sub apply_color {}
|
97
|
|
|
|
|
|
|
|
98
|
0
|
|
|
0
|
0
|
|
sub open_file { Kephra::Config::open_file( 'syntaxhighlighter', "$_[0].pm") }
|
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
1;
|
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head1 NAME
|
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Kephra::Document::SyntaxMode - content language specific settings of a doc
|
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head1 DESCRIPTION
|
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=cut |