fe30db555d0261635c08bfeada8cf55ceaeb004d
[sheet.git] / vimperator.plp
1 <:
2 use utf8;
3 use strict;
4 use warnings;
5 no  warnings 'qw';  # you know what you doing
6 no  warnings 'uninitialized';  # save some useless checks for more legible code
7
8 our $VERSION = '1.0';
9
10 our $ascii = 0;
11 if (exists $get{ascii}) {
12         $ascii = $get{ascii} ne '0';  # manual override
13 } elsif (defined $ENV{HTTP_ACCEPT_CHARSET}) {
14         $ascii = 1;
15         for (split q{,}, $ENV{HTTP_ACCEPT_CHARSET}) {
16                 $ascii = 0, last if $_ eq '*' or m{utf-?8}i;
17         }
18 }
19
20 my $charset = $ascii ? 'us-ascii' : 'utf-8';
21 my $ctype = "text/html; charset=$charset";
22 $header{content_type} = $ctype;
23
24 :><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
25  "http://www.w3.org/TR/html4/loose.dtd">
26 <html>
27
28 <head>
29 <title>vimperator cheat sheet</title>
30 <meta http-equiv="content-type" content="<:= $ctype :>">
31 <link rel="stylesheet" type="text/css" media="all" href="base.css">
32 <!--[if lte IE 6]><style> .help dl.legend dt {margin:0 0 1px} </style><![endif]-->
33 <!--[if lte IE 7]><style> .help dl.legend dd {float:none} </style><![endif]--><:
34         my %styles = map {$_ => $_} qw(dark circus mono red terse);
35         our $style = exists $get{style} && $styles{$get{style}} || 'light';
36         printf(qq{\n<link rel="%s" type="text/css" media="all" href="%s" title="%s">},
37                 $_ eq $style ? 'stylesheet' : 'alternate stylesheet', "$_.css", $_
38         ) for keys %styles;
39
40         our $showkeys = exists $get{keys} && $get{keys} ne '0';
41         print "\n<style> .no {visibility:hidden} </style>" unless $showkeys;
42         print "\n<style> .no, .alias {opacity:.5} </style>"
43                 if $showkeys and $get{keys} eq 'ghost';
44 :>
45 <link rel="vcs" type="git" href="git://dev.shiar.nl/sheet">
46
47 <script><!--
48 function setmode(classname) {
49         // set style for each #rows>li>ul>li to display:none unless it matches classname
50         var showclass = classname ? ' '+classname+'(?!\\w)' : '^$';
51         var parentskip = /^keys/;
52         var row = document.getElementById('rows').firstChild;
53         do {
54                 if (row.tagName == 'LI' && row.firstChild.tagName == 'UL'
55                 && !row.firstChild.className.match(parentskip)) {
56                         var el = row.firstChild.firstChild;
57                         if (el) do {
58                                 if (el.tagName == 'LI') {
59                                         el.style.display = el.className.match(showclass) ? 'block' : 'none';
60                                 }
61                         } while (el = el.nextSibling);
62                 }
63         } while (row = row.nextSibling);
64
65         // update H2 to reflect the first part of a currently active (but hidden) H3
66         var h3s = document.getElementsByTagName('H3');
67         for (var i = 0; i < h3s.length; i++) {
68                 if (h3s[i].parentNode.style.display != 'block') continue;
69                 document.getElementsByTagName('H2')[0].innerHTML = h3s[i].firstChild.data;
70         }
71 } // setmode
72 //--></script>
73
74 <body id="vimperator">
75
76 <h1>Vimperator cheat sheet</h1>
77
78 <h2>normal mode (default)</h2>
79
80 <ul id="rows">
81
82 <li class="row">
83         <ul class="keys omni">
84         <li class="mv" onclick="setmode()"><b>Esc</b> normal mode
85                 <!-- not as static anymore, but never bothered; just see ^[ -->
86         </ul>
87 </li>
88
89 <:
90 our %sign = (
91         arg    => $ascii ? '.' : '·',  # described as 'dot'
92         args   => $ascii ? ':' : '⁚',  # described as 'two dots'
93         alias  => $ascii ? 'see: ' : '»',
94         up     => $ascii ? 'up'    : '▲',
95         right  => $ascii ? 'right' : '▶',
96         down   => $ascii ? 'down'  : '▼',
97         left   => $ascii ? 'left'  : '◀',
98         sep    => $ascii ? '*'     : '•',
99         _      => exists $get{ascii} && !$ascii ? "\x{200b}" : '<wbr>',
100                 # use the correct ZWNJ only when unicode is forced on
101                 # default to use unofficial html for best support
102 );
103
104 use Shiar_Sheet::Keyboard;
105 my $keys = Shiar_Sheet::Keyboard->new({do 'vimperator.inc.pl'});
106 $keys->map($get{map}) or undef $get{map};
107 $keys->print_rows($get{static});
108 :>
109 </ul>
110
111 <hr>
112
113 <div class="help">
114         <div class="left">
115                 <dl class="legend legend-types">
116                 <dt class="ci">info
117                         <dd>Displays something without any permanent consequences.
118                 <dt class="pm">motion
119                         <dd>Move cursor, scroll window, focus buffer element.
120                 <dt class="po">tab
121                         <dd>Tab or window navigation/selection.
122                 <dt class="co">buffer
123                         <dd>Page interaction.
124                 <dt class="cp">open
125                         <dd>Browse to a location in the current tab.
126                 <dt class="mi">tab open
127                         <dd>Browse somewhere in a new tab.
128                 <dt class="mo">browser
129                         <dd>Other browser action.
130                 <dt class="mv">mode
131                         <dd>Enter a different mode.
132                 <dt class="me">key cmd
133                         <dd>Additional key commands (click for overview).
134                 </dl>
135         </div>
136
137         <div class="right">
138                 <dl class="legend legend-options">
139                 <dt>key<:= $sign{arg} :>
140                         <dd>Commands with a dot need a char argument afterwards.
141                 <dt>key<:= $sign{args} :>
142                         <dd>Commands with two dots require variable arguments afterwards.
143                 </dl>
144
145                 <ul class="legend legend-set">
146                 <li>keyboard <strong>map</strong> is
147                         <:= $get{map} ? 'set to ' : '' :><em><:= $keys->{map} :></em>
148                 <li><strong>ascii</strong> mode is
149                         <:= exists $get{ascii} && 'forced ' :><em><:=
150                                 $ascii ? 'on' : 'off' :></em>
151                 <li><strong>keys</strong> are
152                         <em><:= $showkeys ? 'always shown' : 'hidden if unassigned' :></em><:=
153                                 !exists $get{keys} && ' by default' :>
154                 <li>default <strong>style</strong> is
155                         <:= defined $get{style} && 'set to ' :><em><:= $style :></em>
156                 </ul>
157         </div>
158 </div>
159
160 <p class="footer">
161         <a href="http://sheet.shiar.nl/vimperator">sheet.shiar.nl<strong>/vimperator</strong></a>
162         <a href="git://dev.shiar.nl/sheet"><:= "v$VERSION" :></a>
163         created by Shiar <:= $sign{sep} :>
164         <a title="Licensed under the GNU Affero General Public License, version 3"
165            href="http://www.fsf.org/licensing/licenses/agpl-3.0.html">AGPLv3</a> <:= $sign{sep} :>
166         last update <:
167                 use Time::Format qw(time_format);
168                 print time_format('yyyy-mm-dd', (stat 'vimperator.inc.pl')[9]);
169         :>
170 </p>
171
172 </html>