repo: rxvt-unicode-sixel action: commit revision: path_from: revision_from: 0cfa2c6177a81fe9cf35e07bd6cdbd11ff7e8786: path_to: revision_to:
commit 0cfa2c6177a81fe9cf35e07bd6cdbd11ff7e8786 Author: Emanuele GiaquintaDate: Fri Dec 2 09:13:50 2011 +0000 Reimplement keysym list parsing in a perl extension. diff --git a/MANIFEST b/MANIFEST
--- a/MANIFEST +++ b/MANIFEST @@ -153,6 +153,7 @@ src/perl/clipboard-osc src/perl/confirm-paste src/perl/digital-clock src/perl/example-refresh-hooks +src/perl/keysym-list src/perl/kuake src/perl/macosx-clipboard src/perl/macosx-clipboard-native diff --git a/doc/rxvt.1.pod b/doc/rxvt.1.pod
--- a/doc/rxvt.1.pod +++ b/doc/rxvt.1.pod @@ -1206,7 +1206,8 @@ performed in an exact manner; however, the closest match is assured. Imay contain escape values (C<\n>: newline, C<\000>: octal number), see RESOURCES in C for further details. -You can define a range of keysyms in one shot by providing a I +You can define a range of keysyms in one shot by +loading the C perl extension and providing a I with pattern B , where the delimiter `/' should be a character not used by the strings. diff --git a/src/keyboard.C b/src/keyboard.C
--- a/src/keyboard.C
+++ b/src/keyboard.C
@@ -114,35 +114,6 @@ keyboard_manager::register_user_translation (KeySym keysym, unsigned int state,
{
char *translation = rxvt_wcstoutf8 (ws);
- if (strncmp (translation, "list", 4) == 0 && translation [4]
- && strlen (translation) < STRING_MAX)
- {
- char *prefix = translation + 4;
- char *middle = strchr (prefix + 1, translation [4]);
- char *suffix = strrchr (prefix + 1, translation [4]);
-
- if (suffix && middle && suffix > middle + 1)
- {
- int range = suffix - middle - 1;
- int prefix_len = middle - prefix - 1;
- char buf[STRING_MAX];
-
- memcpy (buf, prefix + 1, prefix_len);
- strcpy (buf + prefix_len + 1, suffix + 1);
-
- for (int i = 0; i < range; i++)
- {
- buf [prefix_len] = middle [i + 1];
- register_translation (keysym + i, state, strdup (buf));
- }
-
- free (translation);
- return;
- }
- else
- rxvt_warn ("unable to parse list-type keysym '%s', processing as normal keysym.\n", translation);
- }
-
register_translation (keysym, state, translation);
}
diff --git a/src/perl/keysym-list b/src/perl/keysym-list
new file mode 100644
index 0000000000000000000000000000000000000000..3488a39526e31ca89e399f0cd0e0e9edf886ee4f
--- /dev/null
+++ b/src/perl/keysym-list
@@ -0,0 +1,21 @@
+#! perl
+
+sub on_register_command {
+ my ($self, $keysym, $state, $str) = @_;
+
+ if ($str =~ /^list(.)/) {
+ my @list = split /\Q$1/, $str;
+ if (@list == 4) {
+ for (0 .. (length $list[2]) - 1) {
+ my $middle = substr $list[2], $_, 1;
+ my $def = $list[1] . $middle . $list[3];
+ $self->register_command ($keysym + $_, $state, $def);
+ }
+ return 1;
+ }
+
+ warn "unable to parse keysym '$str' as list, processing as normal keysym\n";
+ }
+
+ ()
+}
-----END OF PAGE-----