1. Herbert Breunung
  2. Kephra

Commits

Herbert Breunung  committed 53bc6e2

streamlined sed proto

  • Participants
  • Parent commits c3cb2cb
  • Branches sp2

Comments (0)

Files changed (6)

File README.txt

View file
  • Ignore whitespace
 
 
 sed           R       single file editor, read, writes files, utf safe, perl highlighting
-ded             I     doc editor, multi file, file_path is just one property of a doc,
+ded             I     doc editor, multi file, file_path is one of many doc properties,
                       docs stored in a stash, multi tab bar separated by moveable splitter
-                      so several views of same doc, focus management
+                      multi views of same doc, central API, focus management
 ked              N    keylog ed: all modules subscribe their UI functions using Command.pm
                       any key combo calls a command - no autoaction by scintilla, not even insert char
                       main menu and context menus, menus made out of command lists, stored inline
-ced              N    comfort editing, formating, converting, commenting for keyboard and mouse
+ced              N    comfort editing: navigating, selecting, moving with keyboard and mouse
+                      formating, converting, commenting, multi clipboards and context values
 led              N    local editor, store and retrieve all configs and user data from local files
 ted              N    tool lib extention, input & output extentions, more internal logging, notes
 fed              N    file sessions, closed file menu, file browser, project browser, project functions
 orgpad           N    minimal effective emacs orgmode clone
 emacs            N    emacs like keyboard usage
 acme             N    advanced mouse controls with click combos and context panels
-
+html
+latex
 
 see doc/Components.pod in sp3 for details

File lib/sed/Kephra/API.pm

  • Ignore whitespace
-use v5.12;
-use warnings;
-use Exporter;
-
-
-package Kephra::API;
-our $VERSION = 0.1002;
-our @ISA = qw(Exporter);
-our @EXPORT = qw(message warning error);
-our @EXPORT_OK = qw(message warning error output);  # symbols to export on request
-#%EXPORT_TAGS = (T => [qw()], 2 => [qw()]);
-
-our $ed;
-our $doc;
-our $tabbar;
-
-sub message  { Kephra::Log::message(@_) }
-sub warning  { Kephra::Log::warning(@_) }
-sub error    { Kephra::Log::error(@_)   }
-
-sub output {}
-
-
-'all you need should is there for you';

File lib/sed/Kephra/App/KeyMap.pm

View file
  • Ignore whitespace
+use v5.12;
+use warnings;
+use Wx;
+
+package Kephra::App::KeyMap;
+
+my %definition;
+my %code;
+my %mod_key_value = ( shift => 1000, ctrl => 2000, alt  => 4000, meta => 8000);
+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,
+	delete=> &Wx::WXK_DELETE,   insert => &Wx::WXK_INSERT,
+	back  => &Wx::WXK_BACK,        tab => &Wx::WXK_TAB,
+	esc   => &Wx::WXK_ESCAPE,    
+	enter => &Wx::WXK_RETURN,    space => &Wx::WXK_SPACE,
+	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, plus => 43,        minus => 45, sharp => 47,    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,
+);
+my %key_name;
+$key_name{ $key_value{$_} } = $_ for keys %key_value;
+
+my $main_map = 'editor';
+
+sub apply {}
+sub build {}
+sub copy {}
+sub overlay {}
+sub register_map {
+}
+
+sub register_keys {
+	my ($keys, $map) = @_;
+	#return Kephra::Log::warning("got no hashref") unless ref $keys eq ref {};
+	$map = $main_map unless defined $map;
+	for my $cmd (keys %$keys) {
+		$definition{$map}{ $cmd } = $keys->{$cmd};
+		my $code = keycode_from_definition( $keys->{$cmd} );
+		unless (exists $code{$map}{ $code }) { $code{$map}{ $code } = $cmd }
+		else {
+			#Kephra::Log::warning("$cmd tried to register the already taken keycode $code");
+		}
+	}
+}
+
+sub keycode_is_registered {
+	my ($code, $map) = @_;
+	#Kephra::Log::warning('got no key code') unless $code;
+	$map = $main_map unless defined $map;
+	return 1 if defined $code{$map}{$code} and $code{$map}{$code}
+}
+
+sub cmd_from_keycode {
+	my ($code, $map) = @_;
+	#Kephra::Log::warning('got no key code') unless $code;
+	$map = $main_map unless defined $map;
+	$code{$map}{$code};
+}
+
+sub keycode_from_definition {
+	my $def = shift;
+	$def =~ tr/ 	//d;
+	#Kephra::Log::warning('got no key definition') unless $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('don\'t know this key '.$key[-1]) unless $code;
+
+	$code += $mod_key_value{ shift(@key) } while @key > 1;
+	#Kephra::Log::warning("got unknown key definition $def") unless $code;
+	return $code;
+}
+
+sub keycode_from_event {
+	my $event = shift;
+	#Kephra::Log::warning ("got no event, but $event") unless ref $event and $event->isa('Wx::Event');
+	my $code = $event->GetUnicodeKey;
+	$code += $mod_key_value{'shift'} if $event->ShiftDown;
+	$code += $mod_key_value{'ctrl'} if $event->ControlDown;
+	$code += $mod_key_value{'alt'} if $event->AltDown;
+	return $code;
+}
+
+sub definition_from_event {
+	my $event = shift;
+	#Kephra::Log::warning ("got no event, but $event") unless ref $event and $event->isa('Wx::Event');
+	my $code = $event->GetUnicodeKey;
+	my $definition;
+	$definition .= 'shift+' if $event->ShiftDown;
+	$definition .= 'ctrl+' if $event->ControlDown;
+	$definition .= 'alt+' if $event->AltDown;
+	$definition .= $key_name{$code} ? $key_name{$code} : lc chr $code;
+	return $definition;
+}
+
+sub react_on_event {
+	my ($event, $map) = @_;
+	#Kephra::Log::warning ("got no event, but $event") unless ref $event and $event->isa('Wx::Event');
+	$map = $main_map unless defined $map;
+	my $key = keycode_from_event($event);
+	#Kephra::API::log("pressed key $key inside the ".(caller)[0]);
+	if (keycode_is_registered($key)){
+			my $cmd = cmd_from_code($key);
+			#Kephra::API::log("run command: $cmd");
+			#Kephra::API::Command::run( $cmd );
+	}
+	else {$event->Skip}
+}
+
+1;

File lib/sed/Kephra/KeyMap.pm

  • Ignore whitespace
-use v5.12;
-use warnings;
-use Wx;
-
-package Kephra::API::KeyMap;
-use Kephra::API qw(warning);
-
-my %definition;
-my %code;
-my %mod_key_value = ( shift => 1000, ctrl => 2000, alt  => 4000, meta => 8000);
-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,
-	delete=> &Wx::WXK_DELETE,   insert => &Wx::WXK_INSERT,
-	back  => &Wx::WXK_BACK,        tab => &Wx::WXK_TAB,
-	esc   => &Wx::WXK_ESCAPE,    
-	enter => &Wx::WXK_RETURN,    space => &Wx::WXK_SPACE,
-	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, plus => 43,        minus => 45, sharp => 47,    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,
-);
-my %key_name;
-$key_name{ $key_value{$_} } = $_ for keys %key_value;
-
-my $main_map = 'editor';
-
-sub apply {}
-sub build {}
-sub copy {}
-sub overlay {}
-sub register_map {
-}
-
-sub register_keys {
-	my ($keys, $map) = @_;
-	#return Kephra::Log::warning("got no hashref") unless ref $keys eq ref {};
-	$map = $main_map unless defined $map;
-	for my $cmd (keys %$keys) {
-		$definition{$map}{ $cmd } = $keys->{$cmd};
-		my $code = keycode_from_definition( $keys->{$cmd} );
-		unless (exists $code{$map}{ $code }) { $code{$map}{ $code } = $cmd }
-		else {
-			#Kephra::Log::warning("$cmd tried to register the already taken keycode $code");
-		}
-	}
-}
-
-sub keycode_is_registered {
-	my ($code, $map) = @_;
-	#Kephra::Log::warning('got no key code') unless $code;
-	$map = $main_map unless defined $map;
-	return 1 if defined $code{$map}{$code} and $code{$map}{$code}
-}
-
-sub cmd_from_keycode {
-	my ($code, $map) = @_;
-	#Kephra::Log::warning('got no key code') unless $code;
-	$map = $main_map unless defined $map;
-	$code{$map}{$code};
-}
-
-sub keycode_from_definition {
-	my $def = shift;
-	$def =~ tr/ 	//d;
-	#Kephra::Log::warning('got no key definition') unless $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('don\'t know this key '.$key[-1]) unless $code;
-
-	$code += $mod_key_value{ shift(@key) } while @key > 1;
-	#Kephra::Log::warning("got unknown key definition $def") unless $code;
-	return $code;
-}
-
-sub keycode_from_event {
-	my $event = shift;
-	#Kephra::Log::warning ("got no event, but $event") unless ref $event and $event->isa('Wx::Event');
-	my $code = $event->GetUnicodeKey;
-	$code += $mod_key_value{'shift'} if $event->ShiftDown;
-	$code += $mod_key_value{'ctrl'} if $event->ControlDown;
-	$code += $mod_key_value{'alt'} if $event->AltDown;
-	return $code;
-}
-
-sub definition_from_event {
-	my $event = shift;
-	#Kephra::Log::warning ("got no event, but $event") unless ref $event and $event->isa('Wx::Event');
-	my $code = $event->GetUnicodeKey;
-	my $definition;
-	$definition .= 'shift+' if $event->ShiftDown;
-	$definition .= 'ctrl+' if $event->ControlDown;
-	$definition .= 'alt+' if $event->AltDown;
-	$definition .= $key_name{$code} ? $key_name{$code} : lc chr $code;
-	return $definition;
-}
-
-sub react_on_event {
-	my ($event, $map) = @_;
-	#Kephra::Log::warning ("got no event, but $event") unless ref $event and $event->isa('Wx::Event');
-	$map = $main_map unless defined $map;
-	my $key = keycode_from_event($event);
-	#Kephra::API::log("pressed key $key inside the ".(caller)[0]);
-	if (keycode_is_registered($key)){
-			my $cmd = cmd_from_code($key);
-			#Kephra::API::log("run command: $cmd");
-			#Kephra::API::Command::run( $cmd );
-	}
-	else {$event->Skip}
-}
-
-1;

File lib/sed/Kephra/Log.pm

  • Ignore whitespace
-use v5.12;
-use warnings;
-
-package Kephra::API::Log;
-
-use Kephra::API qw(output);
-
-our $level;
-our @output;
-our %switch = (global => 1, cli => 1, gui => 0); # logging is on per default
-
-sub mode {
-	my $mode = shift;
-	return unless defined $mode;
-	return unless $mode eq 'on' or $mode eq 'off'
-		or $mode eq 'gui' or $mode eq 'text' or $mode eq 'all';
-	$switch{'global'} = $mode eq 'off' ? 0 : 1;
-	if ($mode eq 'text'){ $switch{'gui'} = 0; $switch{'cli'} = 1 }
-	if ($mode eq 'gui') { $switch{'gui'} = 1; $switch{'cli'} = 0 }
-	if ($mode eq 'all') { $switch{'gui'} = 1; $switch{'cli'} = 1 }
-}
-
-
-sub message {
-	return unless $switch{'global'};
-	my $msg = msg_text( @_ );
-	say message( @_ ) if $switch{'cli'};
-}
-
-sub warning {
-	return unless $switch{'global'};
-	my $msg = msg_text( @_ );
-	warn $msg if $switch{'cli'};
-	#Kephra::API::output('warn', $msg) if $switch{'gui'};
-}
-
-sub error {
-	return unless $switch{'global'};
-	my $msg = msg_text( @_ );
-	die $msg if $switch{'cli'};
-	#Kephra::API::output('warn', 'ERROR: '.$msg) if $switch{'gui'};
-}
-
-sub msg_text{ 
-	my ($text, $name_parent) = @_;
-	my $msg = timestamp() . ' ' . calling_sub(3) . ': "'. $text.'"';
-	$msg .= ', when called by '. calling_sub(3 + $name_parent) if $name_parent;
-	return $msg;
-}
-
-sub timestamp   { sprintf("[%02u:%02u:%02u]", (localtime)[2,1,0]) }
-sub calling_sub { ( caller($_[0]) )[3] } 
-
-1;

File lib/sed/sed.pl

View file
  • Ignore whitespace
 
 package Kephra::App::Window;
 use base qw(Wx::Frame);
-use Kephra::API qw(warning);
 use Kephra::App::Dialog;
 use Kephra::App::Editor;
+use Kephra::App::KeyMap;
 use Kephra::IO::LocalFile;
-use Kephra::KeyMap;
-use Kephra::Log;
 
 our ($file, $encoding, $content, $ed);
 
 
 	Wx::Event::EVT_KEY_DOWN($ed , sub {
 		my ($ed, $event) = @_;
-		given (Kephra::API::KeyMap::definition_from_event($event)){
+		given (Kephra::App::KeyMap::definition_from_event($event)){
 			when('ctrl+o'){ open_file( Kephra::App::Dialog::get_file_open() ) }
 			when('ctrl+q'){ $self->Close }
 			when('ctrl+s'){
 		}
 	});
 	Wx::Event::EVT_STC_UPDATEUI($ed, -1, sub {
-		$self->SetStatusText( $ed->GetCurrentPos, 0);	
+		$self->SetStatusText( $ed->GetCurrentPos, 0);
 	});
 	
 	open_file(__FILE__);
 
 sub set_title {
 	my ($self, $status) = @_;
-	my $title = 'Single Edit - Kephra sp2 testbed step 1 - ' . $file;
+	my $title = 'Single Edit - KephraXP sp2 step 1 - ' . $file;
 	$title .= ' *' if $status;
 	$self->SetTitle($title);
 }