w3m

Unnamed repository; edit this file to name it for gitweb.
git clone https://logand.com/git/w3m.git/
Log | Files | Refs | README

w3mhelp.cgi.in (7943B)


      1 #!@PERL@
      2 # $Id$
      3 
      4 if ( $^O =~ /^(ms)?(dos|win(32|nt)?)/i ) {
      5   $CYGPATH = 1;
      6 }
      7 
      8 $prefix = "@prefix@";
      9 $datarootdir = "@datarootdir@";
     10 $helpdir = "@HELP_DIR@";
     11 if ($CYGPATH) {
     12   $helpdir = &cygwin_pathconv($helpdir);
     13 }
     14 unshift(@INC, $helpdir);
     15 @docdirs = split(" ", "@DOCDIRS@");
     16 
     17 require "w3mhelp-funcname.pl";
     18 require "w3mhelp-funcdesc.en.pl";
     19 $lang = 'en';
     20 $charset = 'US-ASCII';
     21 
     22 %htmlesc = (
     23     '<', '&lt;',
     24     '>', '&gt;',
     25     '&', '&amp;'
     26 );
     27 
     28 $RC_DIR = '@RC_DIR@';
     29 $RC_DIR =~ s/^~/$ENV{'HOME'}/;
     30 if ($CYGPATH) {
     31   $RC_DIR = &cygwin_pathconv("$RC_DIR");
     32 }
     33 $keymap = "$RC_DIR/keymap";
     34 $version = '*unknown*';
     35 if (defined($ENV{'QUERY_STRING'})) {
     36     print "QUERY_STRING=$ENV{'QUERY_STRING'}\n";
     37     if ($ENV{'QUERY_STRING'} =~ /(^|&)version=([^&]*)/) {
     38 	$version = $2;
     39 	$version =~ s/\+|%([0-9A-Fa-f][0-9A-Fa-f])/$& eq '+' ? ' ' : pack('C', hex($1))/ge;
     40 	$version =~ s/w3m\///;
     41     }
     42     if ($ENV{'QUERY_STRING'} =~ /(^|&)lang=([^&]*)/) {
     43 	local($tlang) = $2;
     44 	$tlang =~ s/\+|%([0-9A-Fa-f][0-9A-Fa-f])/$& eq '+' ? ' ' : pack('C', hex($1))/ge;
     45 	$tlang =~ tr/A-Z/a-z/;
     46 	if ($tlang !~ /^[a-z][a-z]$/) {
     47 	    $tlang = 'en';
     48 	}
     49 	# print "tlang=$tlang\n";
     50 	eval {require "w3mhelp-funcdesc.$tlang.pl";};
     51 	if (defined(%funcdesc)) {
     52 	    $lang = $tlang;
     53 	}
     54     }
     55 }
     56 
     57 %f = %keyfunc;
     58 %keyfunc = ();
     59 while (($key, $fname) = each %f) {
     60 	$key = &norm_key($key);
     61 	$keyfunc{$key} = $fname;
     62 }
     63 
     64 if (-f $keymap) {
     65     open(KEYMAP, "< $keymap") || die "cannot open keymap: $keymap, $!";
     66     &load_keymap(*KEYMAP, $func);
     67     close(KEYMAP);
     68 }
     69 
     70 local (%funckeydesc, $key, $fname, $desc);
     71 
     72 %funcname = (%funcname, %buf_funcname, %lineedit_funcname, %menu_funcname);
     73 
     74 %funcdesc = (%funcdesc, %buf_funcdesc, %lineedit_funcdesc, %menu_funcdesc);
     75 while (($fname, $desc) = each %funcdesc) {
     76     $funckeydesc{$funcname{$fname}} = "$fname\n$desc\n";
     77 }
     78 
     79 while (($key, $fname) = each %keyfunc) {
     80     $keydata{$key} && next;
     81     $funckeydesc{$funcname{$fname}} .= "$key,";
     82 }
     83 while (($key, $fname) = each %buf_keyfunc) {
     84     $funckeydesc{$funcname{$fname}} .= "$key,";
     85 }
     86 while (($key, $fname) = each %lineedit_keyfunc) {
     87     $funckeydesc{$funcname{$fname}} .= "$key,";
     88 }
     89 while (($key, $fname) = each %menu_keyfunc) {
     90     $funckeydesc{$funcname{$fname}} .= "$key,";
     91 }
     92 
     93 print <<HEADING;
     94 Content-Type: text/html; charset=$charset
     95 
     96 <HTML>
     97 <HEAD>
     98 <TITLE>w3m help page</TITLE>
     99 </HEAD>
    100 <BODY>
    101 <CENTER>
    102 ******* 
    103 <A HREF="http://w3m.sourceforge.net/">w3m</A>
    104  (WWW-wo-Miru)  Version $version by 
    105 <A HREF="mailto:aito\@fw.ipsj.or.jp">A.ITO</A> ********<BR>
    106              ***** Key assign table *****
    107 </CENTER>
    108 
    109 HEADING
    110 
    111 $q_version = $version;
    112 $q_version =~ s/[^A-Za-z0-9_\$\.\-]/sprintf('%%%02X', ord($&))/ge;
    113 $script = "<A HREF=\"$ENV{'SCRIPT_NAME'}?version=$q_version&amp;lang=";
    114 
    115 # doc:en_English doc-jp:ja_Japanese
    116 for $otherlang (@docdirs) {
    117     local(@d) = split(/[:_]/, $otherlang);
    118     
    119     if ($d[1] ne $lang) {
    120 	$d[1] =~ s/[^A-Za-z0-9_\$\.\-]/sprintf('%%%02X', ord($&))/ge;
    121 	print $script, $d[1], "\">$d[2] version</A>\n";
    122     }
    123 }
    124 
    125 $keymap =~ s/[<>&]/$htmlesc{$&}/ge;
    126 $head = "Show keymap file";
    127 if (defined($title{$head})) {
    128 	$head = $title{$head};
    129 	$head =~ s/[<>&]/$htmlesc{$&}/ge;
    130 }
    131 print "<P><A HREF=\"$keymap\">$head</A>\n";
    132 
    133 &show_keymap("Page/Cursor motion", 
    134 	     split(" ", "pgFore pgBack movR movL movD movU
    135 		movR1 movL1 movD1 movU1 ldown1 lup1
    136 		shiftl shiftr col1L col1R linbeg linend ctrCsrH ctrCsrV
    137 		goLine goLineF goLineL movRW movLW
    138 		topA lastA nextA prevA movlistMn
    139 		nextR nextL nextD nextU nextRD nextLU
    140 		undoPos redoPos"));
    141 
    142 &show_keymap("Hyperlink operation",
    143 	     split(" ", "followA tabA svA followI svI submitForm
    144 		curURL peekURL peekIMG pginfo curlno chkURL chkWORD chkNMID
    145 		rFrame extbrz linkbrz linkLst listMn linkMn accessKey"));
    146 
    147 &show_keymap("File/Stream operation",
    148 	     split(" ", "goURL gorURL tabURL tabrURL ldfile readsh pipesh
    149 		pipeBuf"));
    150 
    151 &show_keymap("Buffer operation",
    152 	     split(" ", "backBf nextBf prevBf selMn selBuf vwSrc svSrc svBuf
    153 		editBf editScr reload reshape rdrwSc dispI stopI"));
    154 
    155 &show_keymap("Tab operation",
    156 	     split(" ", "newT closeT nextT prevT tabMn tabR tabL"));
    157 
    158 &show_keymap("Bookmark operation",
    159 	     split(" ", "ldBmark adBmark"));
    160 
    161 &show_keymap("Search",
    162 	     split(" ", "srchfor srchbak srchnxt srchprv isrchfor isrchbak"));
    163 
    164 &show_keymap("Dictionary look-up",
    165 	     split(" ", "dictword dictwordat"));
    166 
    167 &show_keymap("Mark operation",
    168 	     split(" ", "_mark nextMk prevMk reMark"));
    169 
    170 &show_keymap("Miscellany",
    171 	     split(" ", "mainMn ldhelp ldOpt dispVer cooLst ldHist ldDL
    172 		docCSet defCSet
    173 		msgs msToggle wrapToggle execCmd setAlarm setOpt setEnv defKey
    174 		reinit execsh susp qquitfm quitfm"));
    175 
    176 &show_keymap_data("User defined keymaps");
    177 
    178 print "<BR>\n<HR WIDTH=80%>\n";
    179 
    180 &show_keymap("Buffer selection mode",
    181 	     split(" ", "buffer_next buffer_prev buffer_delete buffer_go"));
    182 
    183 print "<BR>\n<HR WIDTH=80%>\n";
    184 
    185 &show_keymap("Line-edit mode",
    186 	     split(" ", "lineedit_forward lineedit_back lineedit_backspace 
    187 		lineedit_delete lineedit_kill_after lineedit_kill_before
    188 		lineedit_top lineedit_bottom lineedit_prev lineedit_next
    189 		lineedit_editor lineedit_complete lineedit_accept"));
    190 
    191 print "<BR>\n<HR WIDTH=80%>\n";
    192 
    193 &show_keymap("Popup menu",
    194 	     split(" ", "menu_select menu_close menu_cancel menu_down menu_up
    195 		menu_line_up menu_line_down menu_top menu_last menu_next
    196 		menu_prev menu_search_fore menu_search_back menu_search_next
    197 		menu_search_prev menu_suspend"));
    198 
    199 print <<PAGE;
    200 <HR>
    201 </BODY>
    202 </HTML>
    203 PAGE
    204 
    205 exit 0;
    206 
    207 sub load_keymap {
    208     local(*FH) = shift;
    209     local($func) = @_;
    210 
    211     while (<FH>) {
    212 	/^#/ && next;
    213 	s/^\s*keymap\s+// || next;
    214 	s/^(\"(\\\"|[^\"])+\"|\'(\\\'|[^\'])+\'|\S+)\s+(\S+)\s*// || next;
    215 	($key, $fname) = ($1, $4);
    216 	$data = $_;
    217 	$fname =~ tr/a-z/A-Z/;
    218 	defined($funcdesc{$fname}) || next;
    219 	$key =~ s/^["'](.*)["']$/$1/;
    220 	$key = &norm_key($key);
    221 	$keyfunc{$key} = $fname;
    222 	if ($data) {
    223 		$keydata{$key} = $data;
    224 	} else {
    225 		delete $keydata{$key};
    226 	}
    227     }
    228 }
    229 
    230 sub norm_key {
    231     local($_) = @_;
    232 
    233     s/(ESC|SPC|TAB|DEL|UP|DOWN|RIGHT|LEFT)/\U$1/i;
    234     s/\\(.)/$1/g;
    235     s/(^|\s+|-)\^(.)/${1}C-$2/g;
    236     s/(^|\s+|-)(C-\[|M-)/${1}ESC-/g;
    237     if (/^ESC-\[/) {
    238 	/^ESC-\[A$/ && return "UP";
    239 	/^ESC-\[B$/ && return "DOWN";
    240 	/^ESC-\[C$/ && return "RIGHT";
    241 	/^ESC-\[D$/ && return "LEFT";
    242     }
    243     s/(^|\s+|-)ESC-\[/$1\^\[\[/g;
    244     s/(^|\s+|-)ESC-\^(.)/${1}ESC-C-$2/g;
    245     s/(^|\s+|-)(ESC-)?C-[iI]/$1${2}TAB/g;
    246     s/(^|\s+|-)(ESC-)?C-\?/$1${2}DEL/g;
    247     return $_;
    248 }
    249 
    250 sub show_keymap {
    251     local($head, @list) = @_;
    252     local($fid);
    253     local($attr) = " WIDTH=140";
    254 
    255     if (defined($title{$head})) {
    256 	$head = $title{$head};
    257 	$head =~ s/[<>&]/$htmlesc{$&}/ge;
    258     }
    259 
    260     print <<PAGE;
    261 <H2>$head</H2>
    262 <table cellpadding=0>
    263 PAGE
    264     foreach $fid (@list) {
    265 	local ($name, $desc, $keys) = split("\n", $funckeydesc{$fid}, 3);
    266 	$keys =~ s/,$//;
    267 	$keys = '<NOT ASSIGNED>' if ($keys eq '');
    268 	$keys =~ s/[<>&]/$htmlesc{$&}/ge;
    269 	if ($name =~ /:/) {
    270 		$name = "";
    271 	} else {
    272 		$name =~ s/[<>&]/$htmlesc{$&}/ge;
    273 		$name = " (<b>$name</b>)";
    274 	}
    275 	$desc =~ s/[<>&]/$htmlesc{$&}/ge;
    276 	print <<PAGE;
    277 <TR><TD$attr>$keys<TD><NOBR>$desc$name</NOBR>
    278 PAGE
    279 	$attr = "";
    280     }
    281     print "</table>\n";
    282 }
    283 
    284 sub show_keymap_data {
    285     local($head, @list) = @_;
    286     local($fid);
    287     local($attr) = " WIDTH=140";
    288 
    289     if (defined($title{$head})) {
    290 	$head = $title{$head};
    291 	$head =~ s/[<>&]/$htmlesc{$&}/ge;
    292     }
    293 
    294     print <<PAGE;
    295 <H2>$head</H2>
    296 <table cellpadding=0>
    297 PAGE
    298     foreach $keys (sort keys %keydata) {
    299 	$keys =~ s/[<>&]/$htmlesc{$&}/ge;
    300 	$name = $keyfunc{$keys};
    301 	$data = $keydata{$keys};
    302 	$name =~ s/[<>&]/$htmlesc{$&}/ge;
    303 	$data =~ s/[<>&]/$htmlesc{$&}/ge;
    304 	print <<PAGE;
    305 <TR><TD$attr>$keys<TD>$name<TD><NOBR>$data</NOBR>
    306 PAGE
    307 	$attr = "";
    308     }
    309     print "</table>\n";
    310 }
    311 
    312 
    313 sub cygwin_pathconv {
    314   local($_) = @_;
    315   local(*CYGPATH);
    316 
    317   open(CYGPATH, '-|') || exec('cygpath', '-w', $_);
    318   $_ = <CYGPATH>;
    319   close(CYGPATH);
    320   s/\r?\n$//;
    321   s!\\!/!g;
    322   s!/$!!;
    323   return $_;
    324 }