Leser: 4
![]() |
|< 1 ... 50 51 52 53 54 55 56 ... 64 >| | ![]() |
631 Einträge, 64 Seiten |
1 2 3 4
sub templates{ require Kephra::Dialog::Template; &Kephra::Dialog::Template::main; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
package Kephra::Dialog::Template; $VERSION = '0.17'; use strict; use Wx qw( wxVERTICAL wxHORIZONTAL wxLEFT wxTOP wxBOTTOM wxGROW wxEXPAND wxALIGN_CENTRE wxSYSTEM_MENU wxCAPTION wxSTAY_ON_TOP wxNO_FULL_REPAINT_ON_RESIZE wxSIMPLE_BORDER wxRAISED_BORDER wxCLOSE_BOX wxMINIMIZE_BOX wxFRAME_NO_TASKBAR wxBITMAP_TYPE_XPM wxWHITE wxTR_NO_BUTTONS wxTR_HIDE_ROOT wxTR_SINGLE ); use Wx::Event qw(EVT_KEY_DOWN EVT_TEXT EVT_BUTTON EVT_CHECKBOX EVT_RADIOBUTTON EVT_CLOSE); my $template_path = './templates/'; sub _get { $Kephra::app{dialog}{template} } sub _set { $Kephra::app{dialog}{template} = $_[0] if ref $_[0] eq 'Wx::Frame' } sub main { if ( !$Kephra::temp{dialog}{template}{active} or $Kephra::temp{dialog}{template}{active} == 0 ) { # init search and replace dialog $Kephra::temp{dialog}{template}{active} = 1; my $frame = Kephra::App::Window::_get(); my $config = $Kephra::config{dialog}{template}; my $d_l10n = $Kephra::localisation{dialog}{template}; my $g_l10n = $Kephra::localisation{dialog}{general}; #my $m_l10n = $Kephra::localisation{app}{menu}; #my $cl_l10n= $Kephra::localisation{commandlist}{label}; my $d_style= wxNO_FULL_REPAINT_ON_RESIZE | wxSYSTEM_MENU | wxCAPTION | wxMINIMIZE_BOX | wxCLOSE_BOX | wxSTAY_ON_TOP; $d_style |= wxSTAY_ON_TOP if $Kephra::config{app}{window}{stay_on_top}; # making window & main design my $dialog = Wx::Frame->new( $frame, -1, ' '.$d_l10n->{title}, [ $config->{position_x}, $config->{position_y} ], [ 120, 80 ], $d_style); Kephra::App::Window::load_icon ($dialog,Kephra::Config::dirpath($Kephra::config{app}{window}{icon})); _set($dialog); # main panel my $mpanel = Wx::Panel->new( $dialog, -1, [0, 0], [120, 160] ); # construction left main menu my $input = Wx::TextCtrl->new( $mpanel, -1, '', [10, 4], [80, 20], wxSIMPLE_BORDER | wxRAISED_BORDER ); # release $dialog->Show(1); Wx::Window::SetFocus( $input ); EVT_CLOSE( $dialog, \&quit_template_dialog ); EVT_KEY_DOWN($input, \&in_template ); #EVT_TEXT_ENTER($input, \&in_template ); } else { my $dialog = _get(); $dialog->Iconize(0); $dialog->Raise; } } sub in_template{ my ( $input, $event ) = @_; my $key_code = $event->GetKeyCode; if( $key_code == 13 ){ my $statement = $input->GetValue; my @codes = split / /, $statement; if( @codes and $codes[0] eq 'i' ){ shift @codes; my $ep = Kephra::App::EditPanel::_get(); for my $tmpl ( @codes ){ my $file = $template_path . $tmpl; my $text = Kephra::File::IO::open_buffer( $file ); $ep->InsertText( $ep->GetCurrentPos, $text ); } } elsif( @codes ){ my $file = $template_path . $codes[0]; if( -e $file ){ Kephra::File::new_from_template( $file ); } } $input->GetParent->GetParent->Close; } elsif( $key_code == 27 ){ $input->GetParent->GetParent->Close; } $event->Skip; } sub quit_template_dialog { my ( $win, $event ) = @_; my $config = $Kephra::config{dialog}{template}; if ( $config->{save_position} == 1 ) { ($config->{position_x}, $config->{position_y}) = $win->GetPositionXY; } $Kephra::temp{dialog}{template}{active} = 0; $win->Destroy; } 1;
1
2
3
4
5
6
7
8
9
...
new-template2 = Kephra::Dialog::templates()
...
<key>
<file>
new = ctrl+n
new-template2 = ctrl+y
...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
sub new_from_template { my $template = shift; my $doc_nr = Kephra::Document::Internal::new_if_allowed('new'); Kephra::Document::Internal::reset(); return unless -e $template; my $panel = Kephra::App::EditPanel::_get(); my $src = Kephra::File::IO::open_buffer($template); $panel->SetText($src); my $doc_attr = $Kephra::document{open}[$doc_nr]; $doc_attr->{syntaxmode} = 'perl'; Kephra::Document::_set_current_nr( $doc_nr ); }
![]() |
|< 1 ... 50 51 52 53 54 55 56 ... 64 >| | ![]() |
631 Einträge, 64 Seiten |