Commits

Herbert Breunung committed 2f30bed

forewarding some core editing function, put replace on strg+v and switched back to STC (filed wx::scintilla bug)

Comments (0)

Files changed (8)

 	qw/Benchmark Encode Encode::Guess Cwd/,
 	qw/File::Find File::Spec File::UserConfig Config::General YAML/,
 	qw/PPI Moo/,
-	qw/Wx Wx::Scintilla Wx::Perl::ProcessStream/, # Wx::Scintilla Wx::STC
+	qw/Wx Wx::STC Wx::Perl::ProcessStream/, # Wx::Scintilla Wx::STC
 );
 our @used_wx_modules = qw/Wx::AUI Wx::DND Wx::RichText/; # Wx::STC Wx::HTML
 

lib/Kephra/App/Editor.pm

 
 use Wx;
 #use Wx::DND;
-#use Wx::STC;
-use Wx::Scintilla;
+use Wx::STC;
+#use Wx::Scintilla;
 
 use Kephra::API;
 use Kephra::App::Editor::TextDropTarget;

lib/Kephra/Edit.pm

 use strict;
 use warnings;
 
+use Wx;
 use Kephra::Config;
 use Kephra::CommandList;
 
 package Kephra::App::Editor;
 Kephra::CommandList::register_cmd_namespace('edit');
 Kephra::CommandList::register_cmd({
-	'-undo'=>{
-		sub => '$ed->undo',    label => 'Undo', keys => 'ctrl+z', 
+	'undo' => {
+		sub => '$ed->Undo',    label => 'Undo',    keys => 'ctrl+z',
 		help => ''},
-	'-redo'=>{
-		sub => '$ed->redo',    label => 'Redo', keys => 'ctrl+shift+z', 
+	'redo' => {
+		sub => '$ed->Redo',    label => 'Redo',    keys => 'ctrl+shift+z',
+		help => ''} ,
+	'copy' => {
+		sub => '$ed->Copy',    label => 'Copy',    keys => 'ctrl+c',
 		help => ''},
-	'-select-form'=>{
-		sub => '$ed->select_form', label => 'Form', keys => 'ctrl+y', 
+	'copy-line'=> {
+		sub => '$ed->LineCopy',label =>'Copy Line',keys => 'ctrl+shift+c',
 		help => ''},
-	'-select-content'=>{
-		sub => '$ed->select_content',label => 'Content',keys => 'ctrl+shift+y', 
+	'cut' => {
+		sub => '$ed->Cut',     label => 'Cut',     keys => 'ctrl+x',
+		help => ''},
+	'delete'  => {
+		sub =>'$ed->Clear',    label=>'Delete',    keys => 'delete',
+		help => ''},
+	'delete-back'  => {
+		sub =>'$ed->DeleteBack',label=>'Del Back', keys => 'back',
+		help => ''},
+	'delete-line'=> {
+		sub =>'$ed->LineDelete',label=>'Del Line', keys => 'ctrl+shift+delete', 
+		help => ''},
+	'insert'  => {
+		sub => '$ed->Paste',    label => 'Insert', keys => 'ctrl+v',
+		help => ''},
+	'replace' => {
+		sub => '$ed->replace',  label => 'Replace', keys => 'ctrl+shift+v', 
+		help => ''},
+	'double'  => {
+		sub => '$ed->SelectionDuplicate',label=> 'Double',keys => 'ctrl+d', 
+		help => ''},
+	'select-form' =>{
+		sub =>'$ed->select_form',  label => 'Form', keys => 'ctrl+y', 
+		help => ''},
+	'select-content'=>{
+		sub =>'$ed->select_content', label =>'Content',keys => 'ctrl+shift+y',
 		help => ''},
 });
 
+sub get_clipboard_text {
+	my $text;
+	my $cboard = &Wx::wxTheClipboard;
+	$cboard->Open;
+	if ( $cboard->IsSupported( &Wx::wxDF_TEXT ) ) {
+		my $data = Wx::TextDataObject->new;
+		my $ok = $cboard->GetData( $data );
+		if ( $ok ) { $text = $data->GetText; }
+		else { # todo: error handling
+		}
+	}
+	$cboard->Close;
+	$text = '' unless defined $text and $text;
+}
 
-sub undo { $_[0]->Undo }
-sub redo { $_[0]->Redo }
+sub copy_line {
+}
 
+sub replace {
+	my ($self) = @_;
+	return unless $self->CanPaste;
+	my ($begin, $end_a) = $self->GetSelection();
+	$self->BeginUndoAction;
+	$self->SetSelection($begin, $begin);
+	$self->Paste();
+	my $end_b = $self->GetCurrentPos();
+	$self->SetSelection($end_b, $end_b + $end_a - $begin);
+	$self->Cut();
+	$self->SetSelection($begin, $begin + $end_b - $begin);
+	$self->EndUndoAction;
+}
 
-sub select_form {}
-sub select_content {}
+sub select_form {
+	my ($self) = @_;
+
+}
+
+sub select_content {
+	my ($self) = @_;
+
+}
 
 1;

lib/Kephra/Edit/Comment.pm

 package Kephra::App::Editor;
 
 Kephra::CommandList::register_cmd({
-	'edit-comment-toggle'=>{
+	'comment-toggle'=>{
 		sub => '$ed->toggle_comment', label => 'Toggle Comment', keys => 'alt+#', 
 		help => ''},
 });

lib/Kephra/Edit/Format.pm

 package Kephra::App::Editor;
 
 Kephra::CommandList::register_cmd({
-	'-indent-level' => { sub => '$ed->indent_level', label => 'Indent Level',keys => 'alt+right', 
-			help => ''},
-	'-dedent-level' => { sub => '$ed->dedent_level', label => 'Dedent Level',keys => 'alt+left', 
-			help => ''},
-	'-move-line-up' => { sub=> '$ed->move_sel_or_line_up',label => 'Line Up',keys => 'alt+up', 
-			help => ''},
-	'-move-line-down'=>{ sub=>'$ed->move_sel_or_line_down',label=>'Line Down',keys=>'alt+down', 
-			help => ''},
-	'-goto-block-up' =>{ sub => '$ed->ParaUp',       label => 'Block Up',    keys => 'ctrl+up', 
-			help => ''},
-	'-goto-block-down'=>{sub => '$ed->ParaDown',     label => 'Block Down',  keys => 'ctrl+down', 
-			help => ''},
-	'-select-block-up'=>{sub => '$ed->ParaUpExtend', label => 'Block Up',    keys => 'ctrl+shift+up', 
-			help => ''},
-	'-select-block-down'=>{sub => '$ed->ParaDownExtend',label=> 'Block Down',keys => 'ctrl+shift+down', 
-			help => ''},
+	'indent-level' => {
+		sub => '$ed->indent_level', label => 'Indent Level', keys => 'alt+right',
+		help => ''},
+	'dedent-level' => { sub => '$ed->dedent_level', label => 'Dedent Level',keys => 'alt+left', 
+		help => ''},
+	'move-line-up' => { sub=> '$ed->move_sel_or_line_up',label => 'Line Up',keys => 'alt+up', 
+		help => ''},
+	'move-line-down'=>{ sub=>'$ed->move_sel_or_line_down',label=>'Line Down',keys=>'alt+down', 
+		help => ''},
+	'goto-block-up' =>{ sub => '$ed->ParaUp',       label => 'Block Up',    keys => 'ctrl+up', 
+		help => ''},
+	'goto-block-down'=>{sub => '$ed->ParaDown',     label => 'Block Down',  keys => 'ctrl+down', 
+		help => ''},
+	'select-block-up'=>{sub => '$ed->ParaUpExtend', label => 'Block Up',    keys => 'ctrl+shift+up', 
+		help => ''},
+	'select-block-down'=>{
+		sub => '$ed->ParaDownExtend',label=> 'Block Down',keys => 'ctrl+shift+down', 
+		help => ''},
 });
 
 

lib/Kephra/Edit/Search.pm

 package Kephra::App::Editor;
 
 Kephra::CommandList::register_cmd({
-	'-goto-last-edit'=>{
+	'goto-last-change'=>{
 		sub => '$ed->goto_last_change', label => 'Last Change', keys => 'ctrl+shift+g', 
 		help => ''},
-	'-find-next-comment'=>{
+	'find-next-comment'=>{
 		sub => '$ed->next_comment', label => 'Next Comment', keys => 'ctrl+#', 
 		help => ''},
-	'-find-prev-comment'=>{
+	'find-prev-comment'=>{
 		sub => '$ed->prev_comment', label => 'Previous Comment', keys => 'ctrl+shift+#', 
 		help => ''},
 });

lib/Kephra/Keymap.pm

 my %code;
 my %mod_key_value = ( shift => 1000, ctrl => 2000, alt  => 4000);
 my %key_value = (
-	left => &Wx::WXK_LEFT,     right => &Wx::WXK_RIGHT,
-	up => &Wx::WXK_UP,         down => &Wx::WXK_DOWN,
-	pageup => &Wx::WXK_PAGEUP, pagedown => &Wx::WXK_PAGEDOWN,
-	home => &Wx::WXK_HOME,     end => &Wx::WXK_END,
-	back => &Wx::WXK_BACK,     tab => &Wx::WXK_TAB,
-	esc => &Wx::WXK_ESCAPE,    
-	enter => &Wx::WXK_RETURN,  space => &Wx::WXK_SPACE,
-	del => &Wx::WXK_DELETE,    insert => &Wx::WXK_INSERT,
+	left  => &Wx::WXK_LEFT,      right => &Wx::WXK_RIGHT,
+	up    => &Wx::WXK_UP,         down => &Wx::WXK_DOWN,
+	pageup=> &Wx::WXK_PAGEUP, pagedown => &Wx::WXK_PAGEDOWN,
+	home  => &Wx::WXK_HOME,        end => &Wx::WXK_END,
+	back  => &Wx::WXK_BACK,        tab => &Wx::WXK_TAB,
+	esc   => &Wx::WXK_ESCAPE,    
+	enter => &Wx::WXK_RETURN,    space => &Wx::WXK_SPACE,
+	delete => &Wx::WXK_DELETE,  insert => &Wx::WXK_INSERT,
 	F1 => &Wx::WXK_F1, F2 => &Wx::WXK_F2,  F3 => &Wx::WXK_F3,  F4 => &Wx::WXK_F4,
 	F5 => &Wx::WXK_F5, F6 => &Wx::WXK_F6,  F7 => &Wx::WXK_F7,  F8 => &Wx::WXK_F8,
 	F9 => &Wx::WXK_F9,F10 => &Wx::WXK_F10,F11 => &Wx::WXK_F11,F12 => &Wx::WXK_F12,
 	pound => 35, tilde => 92,
-	num_left => &Wx::WXK_NUMPAD_LEFT,   num_right=> &Wx::WXK_NUMPAD_RIGHT,
-	num_up => &Wx::WXK_NUMPAD_UP,       num_down => &Wx::WXK_NUMPAD_DOWN,
-	num_space => &Wx::WXK_NUMPAD_SPACE, num_tab => &Wx::WXK_NUMPAD_TAB,
-	num_enter => &Wx::WXK_NUMPAD_ENTER, num_F1  => &Wx::WXK_NUMPAD_F1,
+	num_left  => &Wx::WXK_NUMPAD_LEFT,  num_right=> &Wx::WXK_NUMPAD_RIGHT,
+	num_up    => &Wx::WXK_NUMPAD_UP,    num_down => &Wx::WXK_NUMPAD_DOWN,
+	num_space => &Wx::WXK_NUMPAD_SPACE, num_tab  => &Wx::WXK_NUMPAD_TAB,
+	num_enter => &Wx::WXK_NUMPAD_ENTER, num_F1   => &Wx::WXK_NUMPAD_F1,
 );
 my $main_map = 'editor';
 
 	$def =~ tr/ 	//d;
 	Kephra::Log::warning ("code_from_definition: got no key definition") unless $def;
 
-	my @key = split /[+-]/, $def;
+	my @key = split '\+', $def;           # only + can combine key in definition
 	my $code = length($key[-1]) == 1 ? ord uc $key[-1] : $key_value{ $key[-1] };
 	Kephra::Log::warning ("code_from_definition: don't know this key ".$key[-1]) unless $code;
 

lib/StyleGuide.pod

 =head3 Event Names
 
 words separated by .
+
+=head3 Key Definitions
+
+keys separated by +