I'm considering using PCE as my new primary text editor, but it really lacks configurable hotkeys. So this is my first try at hacking them in.
As this is a five minute hack, it really lacks extensibility. In the long run, this will need to be replaced by a hash-lookup on the keycode, so it is easily extensible by just plugging in the keycodes you want and one doesn't need to patch the code all the time. Oh well. So many projects, so little time.
# This needs to go into /src/pce/app/events.pm # Re-Implement key_down_filter via a hash lookup sub key_down_filter { my ($sci_frame, $event) = @_; my $key = $event->GetKeyCode; if ($key == 13){ my $newline; if ($pce::config{'editpanel'}{'blockindent'}){ my $pos = $sci_frame->GetCurrentPos-1; #$pos-- while ($sci_frame->GetCharAt($pos) == 32); my $char = $sci_frame->GetCharAt($pos); if ($char == 123) {pce::edit::format::blockindent_open( +$pos); $newline++} elsif ($char == 125) {pce::edit::format::blockindent_close +($pos); $newline++} } unless ($newline) { if ($pce::config{'editpanel'}{'autoindent'}) {pce::edit::f +ormat::autoindent();} else {$sci_frame->CmdKeyExecute(wxSTC_CMD_NEWLINE)} } return; } elsif ($key == 351){ # F10 use Data::Dumper; #pce::dialog::msg_box(undef,Dumper $pce::internal{'file'}{'cur +rent'},""); # Get "current" filename my $current_dir = $pce::internal{'file'} ->{'current'} ->{'open'} ->[pce::document::get_current_nr()] ->{'directory'}; $current_dir =~ tr!/!\\!; # Win32 fix # Spawn a console there use Cwd; my $old_dir = getcwd; chdir $current_dir; system(qq{start cmd.exe /k g:\\systeme\\tools\\path.cmd}); chdir $old_dir; #elsif ($key == 350){ # use pce::ext::Perl::Syntax; # pce::ext::Perl::Syntax::check(); # return; #}; #pce::app::visual::status_msg(); #SCI_SETSELECTIONMODE #elsif ($event->AltDown){ #if ($key == 49){pce::document::change_current(0);} #if ($key == 50){pce::document::change_current(1);} #if ($key == 51){pce::document::change_current(2);} #if ($key == 52){pce::document::change_current(3);} #if ($key == 53){pce::document::change_current(4);} #if ($key == 54){pce::document::change_current(5);} #if ($key == 55){pce::document::change_current(6);} #if ($key == 56){pce::document::change_current(7);} #if ($key == 57){pce::document::change_current(8);} #if ($key == 48){pce::document::change_current(9);} #pce::dialog::msg_box(undef,$key,""); # $event->Skip; } else { #pce::dialog::msg_box(undef,$key,""); $event->Skip; } }
A small hint - you should not edit your editor with itself unless you rarely make syntax errors :-)
Updated: BrowserUK spotted the missing http:// in front of the external link.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Extend PCE with your own hotkeys
by sir_lichtkind (Friar) on Oct 24, 2005 at 13:57 UTC | |
by Corion (Patriarch) on Oct 24, 2005 at 14:09 UTC |