Skip to content

Instantly share code, notes, and snippets.

@mwgamera
Created August 1, 2013 13:00
Show Gist options
  • Save mwgamera/6131099 to your computer and use it in GitHub Desktop.
Save mwgamera/6131099 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
use strict;
use Tk;
my $E = MainWindow->new->Entry->pack;
$E->bind('<Key-Return>', sub {
my $e = shift;
my $v = $e->get;
$e->delete(0, length $v);
printf "<%s>\n", $v;
});
$E->bind('<Alt-Key-f>', sub {
my $e = shift;
my $i = $e->index('insert');
$e->icursor($i + length shift [
substr($e->get, $i) =~ /^(\w*+\W*+)/, '']);
});
$E->bind('<Alt-Key-b>', sub {
my $e = shift;
my $i = $e->index('insert');
$e->icursor($i - length shift [
reverse(substr $e->get, 0, $i) =~ /^(\W*+\w*+)/, '']);
});
$E->bind('<Alt-Key-d>', sub {
my $e = shift;
my $i = $e->index('insert');
$e->delete($i, $i + length shift [
substr($e->get, $i) =~ /^(\W*+\w*+)/, '']);
});
$E->bind('<Control-Key-w>', sub {
my $e = shift;
my $i = $e->index('insert');
$e->delete($i - length shift [
reverse(substr $e->get, 0, $i) =~ /^(\W*+\w*+)/], $i);
});
MainLoop;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment