| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Kephra::App; |
|
2
|
|
|
|
|
|
|
our $VERSION = '0.12'; |
|
3
|
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
887
|
use strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
27
|
|
|
5
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
1053
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our @ISA = 'Wx::App'; # $NAME is a wx application |
|
8
|
|
|
|
|
|
|
my $obj; |
|
9
|
0
|
0
|
|
0
|
|
|
sub _ref { $obj = ref $_[0] eq __PACKAGE__ ? $_[0] : $obj } |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# main layout, main frame |
|
12
|
0
|
|
|
0
|
0
|
|
sub warn { Kephra::Dialog::warning_box(Kephra::App::Window::_ref(), @_, 'Warning') } |
|
13
|
|
|
|
|
|
|
sub splashscreen { |
|
14
|
0
|
|
|
0
|
0
|
|
my $img_file = shift; |
|
15
|
0
|
|
|
|
|
|
$img_file = Kephra::Config::filepath( $img_file ); |
|
16
|
0
|
|
|
|
|
|
Wx::InitAllImageHandlers(); |
|
17
|
0
|
0
|
0
|
|
|
|
my $sc = Wx::SplashScreen->new( |
|
18
|
|
|
|
|
|
|
Wx::Bitmap->new( $img_file, &Wx::wxBITMAP_TYPE_ANY ), |
|
19
|
|
|
|
|
|
|
&Wx::wxSPLASH_CENTRE_ON_SCREEN | &Wx::wxSPLASH_NO_TIMEOUT, 0, undef, -1, |
|
20
|
|
|
|
|
|
|
&Wx::wxDefaultPosition, &Wx::wxDefaultSize, |
|
21
|
|
|
|
|
|
|
&Wx::wxSIMPLE_BORDER | &Wx::wxFRAME_NO_TASKBAR | &Wx::wxSTAY_ON_TOP |
|
22
|
|
|
|
|
|
|
) if $img_file and -e $img_file; |
|
23
|
0
|
|
|
|
|
|
return $sc; |
|
24
|
|
|
|
|
|
|
} |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub assemble_layout { |
|
27
|
0
|
|
|
0
|
0
|
|
my $win = Kephra::App::Window::_ref(); |
|
28
|
0
|
|
|
|
|
|
my $tg = &Wx::wxTOP | &Wx::wxGROW; |
|
29
|
0
|
|
|
|
|
|
Kephra::EventTable::freeze |
|
30
|
|
|
|
|
|
|
( qw(app.splitter.right.changed app.splitter.bottom.changed) ); |
|
31
|
|
|
|
|
|
|
|
|
32
|
0
|
0
|
|
|
|
|
$Kephra::app{splitter}{right} = Wx::SplitterWindow->new |
|
33
|
|
|
|
|
|
|
($win, -1, [-1,-1], [-1,-1], &Wx::wxSP_PERMIT_UNSPLIT) |
|
34
|
|
|
|
|
|
|
unless exists $Kephra::app{splitter}{right}; |
|
35
|
0
|
|
|
|
|
|
my $right_splitter = $Kephra::app{splitter}{right}; |
|
36
|
|
|
|
|
|
|
Wx::Event::EVT_SPLITTER_SASH_POS_CHANGED( $right_splitter, $right_splitter, sub { |
|
37
|
0
|
|
|
0
|
|
|
Kephra::EventTable::trigger( 'app.splitter.right.changed' ); |
|
38
|
0
|
|
|
|
|
|
} ); |
|
39
|
|
|
|
|
|
|
Wx::Event::EVT_SPLITTER_DOUBLECLICKED($right_splitter, $right_splitter, sub { |
|
40
|
0
|
|
|
0
|
|
|
Kephra::App::Panel::Notepad::show(0); |
|
41
|
0
|
|
|
|
|
|
}); |
|
42
|
0
|
|
|
|
|
|
$right_splitter->SetSashGravity(1); |
|
43
|
0
|
|
|
|
|
|
$right_splitter->SetMinimumPaneSize(10); |
|
44
|
|
|
|
|
|
|
|
|
45
|
0
|
0
|
|
|
|
|
$Kephra::app{panel}{main} = Wx::Panel->new($right_splitter) |
|
46
|
|
|
|
|
|
|
unless exists $Kephra::app{panel}{main}; |
|
47
|
0
|
|
|
|
|
|
my $column_panel = $Kephra::app{panel}{main}; |
|
48
|
0
|
|
|
|
|
|
$column_panel->Reparent($right_splitter); |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# setting up output splitter |
|
51
|
0
|
0
|
|
|
|
|
$Kephra::app{splitter}{bottom} = Wx::SplitterWindow->new |
|
52
|
|
|
|
|
|
|
($column_panel, -1, [-1,-1], [-1,-1], &Wx::wxSP_PERMIT_UNSPLIT) |
|
53
|
|
|
|
|
|
|
unless exists $Kephra::app{splitter}{bottom}; |
|
54
|
0
|
|
|
|
|
|
my $bottom_splitter = $Kephra::app{splitter}{bottom}; |
|
55
|
|
|
|
|
|
|
Wx::Event::EVT_SPLITTER_SASH_POS_CHANGED( $bottom_splitter, $bottom_splitter, sub { |
|
56
|
0
|
|
|
0
|
|
|
Kephra::EventTable::trigger( 'app.splitter.bottom.changed' ); |
|
57
|
0
|
|
|
|
|
|
} ); |
|
58
|
|
|
|
|
|
|
Wx::Event::EVT_SPLITTER_DOUBLECLICKED($bottom_splitter, $bottom_splitter, sub { |
|
59
|
0
|
|
|
0
|
|
|
Kephra::App::Panel::Output::show(0); |
|
60
|
0
|
|
|
|
|
|
}); |
|
61
|
0
|
|
|
|
|
|
$bottom_splitter->SetSashGravity(1); |
|
62
|
0
|
|
|
|
|
|
$bottom_splitter->SetMinimumPaneSize(10); |
|
63
|
|
|
|
|
|
|
|
|
64
|
0
|
0
|
|
|
|
|
$Kephra::app{panel}{center} = Wx::Panel->new($bottom_splitter) |
|
65
|
|
|
|
|
|
|
unless exists $Kephra::app{panel}{center}; |
|
66
|
0
|
|
|
|
|
|
my $center_panel = $Kephra::app{panel}{center}; |
|
67
|
0
|
|
|
|
|
|
$center_panel->Reparent($bottom_splitter); |
|
68
|
|
|
|
|
|
|
|
|
69
|
0
|
|
|
|
|
|
my $tab_bar = Kephra::App::TabBar::_ref(); |
|
70
|
0
|
|
|
|
|
|
my $search_bar = Kephra::App::SearchBar::_ref(); |
|
71
|
0
|
|
|
|
|
|
my $search_pos = Kephra::App::SearchBar::position(); |
|
72
|
0
|
|
|
|
|
|
my $notepad_panel = Kephra::App::Panel::Notepad::_ref(); |
|
73
|
0
|
|
|
|
|
|
my $output_panel = Kephra::App::Panel::Output::_ref(); |
|
74
|
0
|
|
|
|
|
|
$tab_bar->Reparent($center_panel); |
|
75
|
0
|
|
|
|
|
|
$search_bar->Reparent($center_panel); |
|
76
|
0
|
0
|
|
|
|
|
$search_bar->Reparent($column_panel) if $search_pos eq 'bottom'; |
|
77
|
0
|
|
|
|
|
|
$notepad_panel->Reparent($right_splitter); |
|
78
|
0
|
|
|
|
|
|
$output_panel->Reparent($bottom_splitter); |
|
79
|
|
|
|
|
|
|
|
|
80
|
0
|
|
|
|
|
|
my $center_sizer = Wx::BoxSizer->new(&Wx::wxVERTICAL); |
|
81
|
0
|
0
|
|
|
|
|
$center_sizer->Add( $search_bar, 0, $tg, 0) if $search_pos eq 'above'; |
|
82
|
0
|
|
|
|
|
|
$center_sizer->Add( $tab_bar, 1, $tg, 0 ); |
|
83
|
0
|
0
|
|
|
|
|
$center_sizer->Add( $search_bar, 0, $tg, 0 ) if $search_pos eq 'below'; |
|
84
|
0
|
|
|
|
|
|
$center_panel->SetSizer($center_sizer); |
|
85
|
0
|
|
|
|
|
|
$center_panel->SetAutoLayout(1); |
|
86
|
|
|
|
|
|
|
|
|
87
|
0
|
|
|
|
|
|
my $column_sizer = Wx::BoxSizer->new(&Wx::wxVERTICAL); |
|
88
|
0
|
|
|
|
|
|
$column_sizer->Add( $bottom_splitter, 1, $tg, 0); |
|
89
|
0
|
0
|
|
|
|
|
$column_sizer->Add( $search_bar, 0, $tg, 0) if $search_pos eq 'bottom'; |
|
90
|
0
|
|
|
|
|
|
$column_panel->SetSizer($column_sizer); |
|
91
|
0
|
|
|
|
|
|
$column_panel->SetAutoLayout(1); |
|
92
|
|
|
|
|
|
|
|
|
93
|
0
|
|
|
|
|
|
my $win_sizer = Wx::BoxSizer->new(&Wx::wxVERTICAL); |
|
94
|
0
|
|
|
|
|
|
$win_sizer->Add( $right_splitter, 1, $tg, 0 ); |
|
95
|
0
|
|
|
|
|
|
$win->SetSizer($win_sizer); |
|
96
|
0
|
|
|
|
|
|
$win->SetAutoLayout(1); |
|
97
|
0
|
|
|
|
|
|
$column_panel->Layout(); |
|
98
|
0
|
|
|
|
|
|
$center_panel->Layout(); |
|
99
|
|
|
|
|
|
|
#$win->SetBackgroundColour($tab_bar->GetBackgroundColour); |
|
100
|
|
|
|
|
|
|
|
|
101
|
0
|
|
|
|
|
|
Kephra::EventTable::thaw |
|
102
|
|
|
|
|
|
|
( qw(app.splitter.right.changed app.splitter.bottom.changed) ); |
|
103
|
0
|
|
|
|
|
|
Kephra::App::SearchBar::show(); |
|
104
|
0
|
|
|
|
|
|
Kephra::App::Panel::Notepad::show(); |
|
105
|
0
|
|
|
|
|
|
Kephra::App::Panel::Output::show(); |
|
106
|
|
|
|
|
|
|
} |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub OnInit { |
|
109
|
1
|
|
|
1
|
|
1021
|
use Benchmark (); |
|
|
1
|
|
|
|
|
178867
|
|
|
|
1
|
|
|
|
|
1089
|
|
|
110
|
0
|
0
|
|
0
|
0
|
|
my $t0 = new Benchmark if $Kephra::BENCHMARK; |
|
111
|
0
|
|
|
|
|
|
my $app = shift; |
|
112
|
0
|
|
|
|
|
|
_ref($app); |
|
113
|
|
|
|
|
|
|
#setup_logging(); |
|
114
|
0
|
|
|
|
|
|
Wx::InitAllImageHandlers(); |
|
115
|
|
|
|
|
|
|
# 2'nd splashscreen can close when app is ready, now called from Kephra.pm |
|
116
|
0
|
|
|
|
|
|
my $splashscreen = splashscreen('interface/icon/splash/start_kephra.jpg'); |
|
117
|
0
|
|
|
|
|
|
my $frame = Kephra::App::Window::create(); |
|
118
|
0
|
|
|
|
|
|
Kephra::Document::Data::create_slot(0); |
|
119
|
0
|
|
|
|
|
|
Kephra::App::TabBar::create(); |
|
120
|
0
|
|
|
|
|
|
my $ep = Kephra::App::TabBar::add_edit_tab(0); |
|
121
|
0
|
|
|
|
|
|
Kephra::Document::Data::set_current_nr(0); |
|
122
|
0
|
|
|
|
|
|
Kephra::Document::Data::set_previous_nr(0); |
|
123
|
0
|
|
|
|
|
|
Kephra::Document::Data::set_value('buffer',1); |
|
124
|
0
|
|
|
|
|
|
Kephra::Document::Data::set_value('modified', 0); |
|
125
|
0
|
|
|
|
|
|
Kephra::Document::Data::set_value('loaded', 0); |
|
126
|
|
|
|
|
|
|
#Kephra::Plugin::load_all(); |
|
127
|
|
|
|
|
|
|
#$main::logger->debug("init app pntr"); |
|
128
|
0
|
0
|
|
|
|
|
print " init app:", |
|
129
|
|
|
|
|
|
|
Benchmark::timestr( Benchmark::timediff( new Benchmark, $t0 ) ), "\n" |
|
130
|
|
|
|
|
|
|
if $Kephra::BENCHMARK; |
|
131
|
0
|
|
|
|
|
|
my $t1 = new Benchmark; |
|
132
|
|
|
|
|
|
|
#$main::logger->debug("glob cfg load"); |
|
133
|
0
|
0
|
|
|
|
|
print " glob cfg load:", |
|
134
|
|
|
|
|
|
|
Benchmark::timestr( Benchmark::timediff( new Benchmark, $t1 ) ), "\n" |
|
135
|
|
|
|
|
|
|
if $Kephra::BENCHMARK; |
|
136
|
0
|
|
|
|
|
|
my $t2 = new Benchmark; |
|
137
|
|
|
|
|
|
|
|
|
138
|
0
|
0
|
|
|
|
|
if (Kephra::Config::Global::autoload()) { |
|
139
|
0
|
|
|
|
|
|
Kephra::App::EditPanel::apply_settings_here($ep); |
|
140
|
0
|
|
|
|
|
|
Kephra::EventTable::freeze_all(); |
|
141
|
0
|
0
|
|
|
|
|
print " configs eval:", |
|
142
|
|
|
|
|
|
|
Benchmark::timestr( Benchmark::timediff( new Benchmark, $t2 ) ), "\n" |
|
143
|
|
|
|
|
|
|
if $Kephra::BENCHMARK; |
|
144
|
0
|
|
|
|
|
|
my $t3 = new Benchmark; |
|
145
|
0
|
|
|
|
|
|
Kephra::File::Session::autoload(); |
|
146
|
0
|
|
|
|
|
|
Kephra::EventTable::thaw_all(); |
|
147
|
0
|
|
|
|
|
|
Kephra::Edit::Search::load_search_data(); |
|
148
|
0
|
|
|
|
|
|
Kephra::Document::add($_) for @ARGV; |
|
149
|
0
|
0
|
|
|
|
|
print " file session:", |
|
150
|
|
|
|
|
|
|
Benchmark::timestr( Benchmark::timediff( new Benchmark, $t3 ) ), "\n" |
|
151
|
|
|
|
|
|
|
if $Kephra::BENCHMARK; |
|
152
|
0
|
|
|
|
|
|
my $t4 = new Benchmark; |
|
153
|
0
|
0
|
|
|
|
|
print " event table:", |
|
154
|
|
|
|
|
|
|
Benchmark::timestr( Benchmark::timediff( new Benchmark, $t4 ) ), "\n" |
|
155
|
|
|
|
|
|
|
if $Kephra::BENCHMARK; |
|
156
|
0
|
|
|
|
|
|
Kephra::App::EditPanel::gets_focus(); |
|
157
|
0
|
|
|
|
|
|
Kephra::Edit::_let_caret_visible(); |
|
158
|
|
|
|
|
|
|
|
|
159
|
0
|
|
|
|
|
|
$frame->Show(1); |
|
160
|
0
|
|
|
|
|
|
$splashscreen->Destroy(); |
|
161
|
0
|
0
|
|
|
|
|
print "app startet:", |
|
162
|
|
|
|
|
|
|
Benchmark::timestr( Benchmark::timediff( new Benchmark, $t0 ) ), "\n" |
|
163
|
|
|
|
|
|
|
if $Kephra::BENCHMARK; |
|
164
|
0
|
|
|
|
|
|
1; # everything is good |
|
165
|
|
|
|
|
|
|
} else { |
|
166
|
0
|
|
|
|
|
|
$app->ExitMainLoop(1); |
|
167
|
|
|
|
|
|
|
} |
|
168
|
|
|
|
|
|
|
} |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
sub exit { |
|
171
|
0
|
|
|
0
|
0
|
|
Kephra::EventTable::stop_timer(); |
|
172
|
0
|
0
|
|
|
|
|
if (Kephra::Dialog::save_on_exit() eq 'cancel') { |
|
173
|
0
|
|
|
|
|
|
Kephra::EventTable::start_timer(); |
|
174
|
0
|
|
|
|
|
|
return; |
|
175
|
|
|
|
|
|
|
} |
|
176
|
0
|
|
|
|
|
|
exit_unsaved(); |
|
177
|
|
|
|
|
|
|
} |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
sub exit_unsaved { |
|
180
|
0
|
|
|
0
|
0
|
|
my $t0 = new Benchmark; |
|
181
|
0
|
|
|
|
|
|
Kephra::EventTable::stop_timer(); |
|
182
|
0
|
|
|
|
|
|
Kephra::File::Session::autosave(); |
|
183
|
0
|
|
|
|
|
|
Kephra::File::History::save(); |
|
184
|
0
|
|
|
|
|
|
Kephra::Config::Global::autosave(); |
|
185
|
0
|
|
|
|
|
|
Kephra::Config::set_xp_style(); # |
|
186
|
0
|
|
|
|
|
|
Kephra::App::Window::_ref()->Show(0); |
|
187
|
0
|
|
|
|
|
|
Kephra::App::Window::destroy(); # close window |
|
188
|
0
|
|
|
|
|
|
Wx::wxTheClipboard->Flush; # set copied text free to the global Clipboard |
|
189
|
0
|
0
|
|
|
|
|
print "shut down in:", |
|
190
|
|
|
|
|
|
|
Benchmark::timestr( Benchmark::timediff( new Benchmark, $t0 ) ), "\n" |
|
191
|
|
|
|
|
|
|
if $Kephra::BENCHMARK; |
|
192
|
|
|
|
|
|
|
} |
|
193
|
|
|
|
|
|
|
|
|
194
|
0
|
|
|
0
|
0
|
|
sub raw_exit { Wx::Window::Destroy(shift) } |
|
195
|
|
|
|
|
|
|
#sub new_instance { system("kephra.exe") } |
|
196
|
|
|
|
|
|
|
# wxNullAcceleratorTable |
|
197
|
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
1; |
|
199
|
|
|
|
|
|
|
|