aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/w3mhelp.cgi.in
blob: 2045224b352b682bcb7890da3450cd5d4579c131 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
#!@PERL@
# $Id: w3mhelp.cgi.in,v 1.4 2001/12/21 18:33:41 ukai Exp $

$helpdir = "@HELP_DIR@";
unshift(@INC, $helpdir);
@docdirs = split(" ", "@DOCDIRS@");

require "w3mhelp-funcname.pl";
require "w3mhelp-funcdesc.en.pl";
$lang = 'en';

%htmlesc = (
    '<', '&lt;',
    '>', '&gt;',
    '&', '&amp;'
);

$keymap = "$ENV{'HOME'}/.w3m/keymap";
$version = '*unknown*';
if (defined($ENV{'QUERY_STRING'})) {
    print "QUERY_STRING=$ENV{'QUERY_STRING'}\n";
    if ($ENV{'QUERY_STRING'} =~ /(^|&)version=([^&]*)/) {
	$version = $2;
	$version =~ s/\+|%([0-9A-Fa-f][0-9A-Fa-f])/$& eq '+' ? ' ' : pack('C', hex($1))/ge;
	$version =~ s/w3m\///;
    }
    if ($ENV{'QUERY_STRING'} =~ /(^|&)lang=([^&]*)/) {
	local($tlang) = $2;
	$tlang =~ s/\+|%([0-9A-Fa-f][0-9A-Fa-f])/$& eq '+' ? ' ' : pack('C', hex($1))/ge;
	$tlang =~ tr/A-Z/a-z/;
	print "tlang=$tlang\n";
	eval {require "w3mhelp-funcdesc.$tlang.pl";};
	if (defined(%funcdesc)) {
	    $lang = $tlang;
	}
    }
}

if (-f $keymap) {
    open(KEYMAP, "< $keymap") || die "cannot open keymap: $keymap, $!";
    &load_keymap(*KEYMAP, $func);
    close(KEYMAP);
}

local (%funckeydesc, $key, $fname, $desc);

%funcname = (%funcname, %buf_funcname, %lineedit_funcname);

%funcdesc = (%funcdesc, %buf_funcdesc, %lineedit_funcdesc);
while (($fname, $desc) = each %funcdesc) {
    $funckeydesc{$funcname{$fname}} = "$desc\n";
}

while (($key, $fname) = each %keyfunc) {
    $funckeydesc{$funcname{$fname}} .= "$key,";
}
while (($key, $fname) = each %buf_keyfunc) {
    $funckeydesc{$funcname{$fname}} .= "$key,";
}
while (($key, $fname) = each %lineedit_keyfunc) {
    $funckeydesc{$funcname{$fname}} .= "$key,";
}

print <<HEADING;
Content-Type: text/html

<HTML>
<HEAD>
<TITLE>w3m help page</TITLE>
</HEAD>
<BODY>
<CENTER>
******* 
<A HREF="http://w3m.sourceforge.net/">w3m</A>
 (WWW-wo-Miru)  Version $version by 
<A HREF="mailto:aito\@fw.ipsj.or.jp">A.ITO</A> ********<BR>
             ***** Key assign table *****
</CENTER>

HEADING

$q_version = $version;
$q_version =~ s/[^A-Za-z0-9_\$\.\-]/sprintf('%%%02X', ord($&))/ge;
$script = "<A HREF=\"$ENV{'SCRIPT_NAME'}?version=$q_version&amp;lang=";

# doc:en_English doc-jp:ja_Japanese
for $otherlang (@docdirs) {
    local(@d) = split(/[:_]/, $otherlang);
    
    if ($d[1] ne $lang) {
	$d[1] =~ s/[^A-Za-z0-9_\$\.\-]/sprintf('%%%02X', ord($&))/ge;
	print $script, $d[1], "\">$d[2] version</A><BR>\n";
    }
}

&show_keymap("Page/Cursor motion", 
	     split(" ", "pgFore pgBack movR movL movD movU lup1 ldown1 
		goLineF goLineL movRW movLW shiftl shiftr
		col1R col1L goLine ctrCsrH ctrCsrV
		topA lastA nextA prevA
		nextL nextLU nextR nextRD nextD nextU"));

&show_keymap("Hyperlink operation",
	     split(" ", "followA svA peekURL peekIMG followI svI
		chkURL chkNMID curURL pginfo curlno ldHist
		rFrame extbrz linkbrz"));

&show_keymap("File/Stream operation",
	     split(" ", "goURL ldfile readsh pipesh"));

&show_keymap("Buffer operation",
	     split(" ", "backBf vwSrc selMn editBf rdrwSc reload 
		svBuf svSrc editScr"));

&show_keymap("Buffer selection mode",
	     split(" ", "buffer_prev buffer_next buffer_delete buffer_go"));

&show_keymap("Bookmark operation",
	     split(" ", "ldBmark adBmark"));

&show_keymap("Search",
	     split(" ", "srchfor srchbak srchnxt srchprv"));

&show_keymap("Dictionary look-up",
	     split(" ", "dictword dictwordat"));

&show_keymap("Mark operation",
	     split(" ", "_mark prevMk nextMk reMark"));

&show_keymap("Miscellany",
	     split(" ",
		"setAlarm execsh ldhelp ldOpt cooLst susp qquitfm quitfm"));

&show_keymap("Line-edit mode",
	     split(" ", "lineedit_forward lineedit_back lineedit_backspace 
		lineedit_delete lineedit_kill_after lineedit_kill_before
		lineedit_top lineedit_bottom lineedit_prev lineedit_next
		lineedit_complete lineedit_accept"));

print <<PAGE;
<HR>
</BODY>
</HTML>
PAGE

exit 0;

sub load_keymap {
    local(*FH) = shift;
    local($func) = @_;

    while (<FH>) {
	next if /^#/;
	next if /^\s*$/;
	($keymap, $key, $fname) = split;
	next unless $keymap =~ /keymap/;
	$fname =~ tr/a-z/A-Z/;
	next unless (defined($funcdesc{$fname}));
	$key =~ s/^\\//;
	$keyfunc{$key} = $fname;
    }
}

sub show_keymap {
    local($head, @list) = @_;
    local($fid);
    local($attr) = " WIDTH=140";

    if (defined($title{$head})) {
	$head = $title{$head};
	$head =~ s/[<>&]/$htmlesc{$&}/ge;
    }

    print <<PAGE;
<H2>$head</H2>
<table cellpadding=0>
PAGE
    foreach $fid (@list) {
	local ($desc, $keys) = split("\n", $funckeydesc{$fid}, 2);
	$keys =~ s/,$//;
	$keys = '<NOT ASSIGNED>' if ($keys eq '');
	$keys =~ s/[<>&]/$htmlesc{$&}/ge;
	$desc =~ s/[<>&]/$htmlesc{$&}/ge;
	print <<PAGE;
<TR><TD$attr>$keys</TD><TD>$desc</TD></TR>
PAGE
	$attr = "";
    }
    print "</table>\n";
}