summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/checkkeys.pl91
-rwxr-xr-xscripts/checkopts.pl71
-rwxr-xr-xscripts/lskeys.pl20
-rwxr-xr-xscripts/lsopts.pl32
-rwxr-xr-xscripts/update-todo.sh4
5 files changed, 218 insertions, 0 deletions
diff --git a/scripts/checkkeys.pl b/scripts/checkkeys.pl
new file mode 100755
index 0000000..ecf01e0
--- /dev/null
+++ b/scripts/checkkeys.pl
@@ -0,0 +1,91 @@
+#!/usr/bin/env perl
+## Copyright © 2011 by Birte Kristina Friesel <derf@finalrewind.org>
+## License: WTFPL:
+## 0. You just DO WHAT THE FUCK YOU WANT TO.
+use strict;
+use warnings;
+use 5.010;
+
+use autodie;
+
+my $fh;
+my $keys;
+
+my $re_struct = qr{
+ struct \s __fehkey \s (?<action> [^;]+ ) ;
+}x;
+
+my $re_set = qr{
+ feh_set_kb \( \& keys \. (?<action> [^ ,]+ ) \s* ,
+ \s* (?<mod1> \d+ ) ,
+ \s* (?<key1> [^ ,]+ ) \s* ,
+ \s* (?<mod2> \d+ ) ,
+ \s* (?<key2> [^ ,]+ ) \s* ,
+ \s* (?<mod3> \d+ ) ,
+ \s* (?<key3> [^ ,]+ ) \s* \) ;
+}x;
+
+my $re_parse_action = qr{
+ if \s \( \! strcmp \( action , \s " (?<action> [^"]+ ) " \) \)
+}x;
+
+my $re_parse_conf = qr{
+ cur_kb \s = \s \& keys \. (?<str> [^;]+ ) ;
+}x;
+
+my $re_man = qr{
+ ^ \. It \s (?<keys> .+ ) \s Bq \s (?<action> .+ ) $
+}x;
+
+my $re_skip = qr{
+ ^ ( action | orient ) _
+}x;
+
+open($fh, '<', 'src/options.h');
+while (my $line = <$fh>) {
+ if ($line =~ $re_struct) {
+ $keys->{ $+{action} }->{struct} = 1;
+ }
+}
+close($fh);
+
+open($fh, '<', 'src/keyevents.c');
+while (my $line = <$fh>) {
+ if ($line =~ $re_set) {
+ $keys->{ $+{action} }->{default}
+ = [@+{'mod1', 'key1', 'mod2', 'key2', 'mod3', 'key3'}];
+ }
+ elsif ($line =~ $re_parse_action) {
+ $keys->{ $+{action} }->{parse} = 1;
+ }
+}
+close($fh);
+
+open($fh, '<', 'man/feh.pre');
+while (my $line = <$fh>) {
+ if ($line =~ $re_man) {
+ $keys->{ $+{action} }->{man} = 1;
+ }
+}
+close($fh);
+
+for my $action (sort keys %{$keys}) {
+ my $k = $keys->{$action};
+
+ if ($action =~ $re_skip) {
+ next;
+ }
+
+ if (not defined $k->{struct}) {
+ say "$action missing in struct";
+ }
+ if (not defined $k->{default}) {
+ say "$action missing in defaults";
+ }
+ if (not defined $k->{parse}) {
+ say "$action missing in parser";
+ }
+ if (not defined $k->{man}) {
+ say "$action missing in manual";
+ }
+}
diff --git a/scripts/checkopts.pl b/scripts/checkopts.pl
new file mode 100755
index 0000000..e5779ca
--- /dev/null
+++ b/scripts/checkopts.pl
@@ -0,0 +1,71 @@
+#!/usr/bin/env perl
+## Copyright © 2010 by Birte Kristina Friesel <derf@finalrewind.org>
+## License: WTFPL <http://sam.zoy.org/wtfpl>
+use strict;
+use warnings;
+
+my $options;
+
+open(my $c_fh, '<', 'src/options.c') or die("Can't read options.c: $!");
+while (my $line = <$c_fh>) {
+
+ if ($line =~ /\{"(?<long>[\w-]+)"\s*,.*,\s*(?:'(?<short>.)'|(?<short>\d+))\}/o) {
+ push(@{$options->{$+{long}}}, ['source', $+{short}]);
+ }
+}
+close($c_fh);
+
+open(my $h_fh, '<', 'src/help.raw') or die("Can't read help.raw: $!");
+while (my $line = <$h_fh>) {
+
+ if ($line =~ /^ (?:\-(?<short>.), |\s*)--(?<long>[\w-]+) /) {
+ push(@{$options->{$+{long}}}, ['help', $+{short}]);
+ }
+}
+close($h_fh);
+
+open(my $man_fh, '<', 'man/feh.1') or die("Can't read feh.1: $!");
+while (my $line = <$man_fh>) {
+
+ if ($line =~ /^\.It Cm (?:-(?<short>.) , )?--(?<long>[\w-]+)/) {
+ push(@{$options->{$+{long}}}, ['manual', $+{short}]);
+ }
+
+}
+close($man_fh);
+
+foreach my $option (keys %{$options}) {
+ my $last;
+ my $count = 0;
+
+ if ($option =~ / ^ action\d | help /x) {
+ next;
+ }
+
+ foreach my $source (@{$options->{$option}}) {
+ my $name = $source->[0];
+ my $short = $source->[1] // '';
+ $short = '' if ($short =~ /^\d+$/);
+
+ if (not defined $last) {
+ $last = $short;
+ }
+
+ if ($last ne $short) {
+ last;
+ }
+
+ $last = $short;
+ $count++;
+ }
+
+ if ($count == 3) {
+ next;
+ }
+
+ foreach my $source (@{$options->{$option}}) {
+ my $name = $source->[0];
+ my $short = $source->[1] // '';
+ print "$option: $name ($short)\n";
+ }
+}
diff --git a/scripts/lskeys.pl b/scripts/lskeys.pl
new file mode 100755
index 0000000..530e38d
--- /dev/null
+++ b/scripts/lskeys.pl
@@ -0,0 +1,20 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use 5.010;
+
+use autodie;
+
+my @keys;
+
+open(my $fh, '<', 'src/keyevents.c');
+while (my $line = <$fh>) {
+ chomp($line);
+ if ($line =~ qr{
+ if \s \( \! strcmp \( action , \s " (?<key> [^"]+ ) " \)\) }x) {
+ push(@keys, $+{key});
+ }
+}
+close($fh);
+
+say join("\n", sort @keys);
diff --git a/scripts/lsopts.pl b/scripts/lsopts.pl
new file mode 100755
index 0000000..1ea8aaf
--- /dev/null
+++ b/scripts/lsopts.pl
@@ -0,0 +1,32 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use 5.010;
+
+my %opts;
+
+for my $chr ('a' .. 'z', 'A' .. 'Z') {
+ $opts{$chr} = q{};
+}
+
+open(my $fh, '<', 'src/options.c') or die("Can't open options.c: $!");
+while (my $line = <$fh>) {
+ chomp($line);
+ if ($line =~ /\{"(?<long>[^"]+)"\s*,.+,.+, (?<short>...)/) {
+ if (substr($+{'short'}, 0, 1) eq '\'') {
+ $opts{substr($+{'short'}, 1, 1)} = $+{'long'};
+ }
+ else {
+ $opts{$+{'short'}} = $+{'long'};
+ }
+ }
+}
+close($fh);
+
+foreach my $short (sort keys %opts) {
+ printf(
+ "%s\t%s\n",
+ $short,
+ $opts{$short},
+ );
+}
diff --git a/scripts/update-todo.sh b/scripts/update-todo.sh
new file mode 100755
index 0000000..962ad70
--- /dev/null
+++ b/scripts/update-todo.sh
@@ -0,0 +1,4 @@
+#!/bin/sh -e
+
+ghi --repo=derf/feh --verbose list > TODO
+git commit -m 'Update TODO (via github)' TODO