common keyboard javascript include
[sheet.git] / vim.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.2';
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>vi 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 <script type="text/javascript" src="/keys.js"></script>
47
48 <body id="vim">
49
50 <h1>vi/vim cheat sheet</h1>
51
52 <h2>normal mode (default)</h2>
53
54 <ul id="rows">
55
56 <li class="row">
57         <ul class="keys omni">
58         <li class="mo" onclick="setmode()"><b>Esc</b> normal mode
59                 <!-- not as static anymore, but never bothered; just see ^[ -->
60         </ul>
61 </li>
62
63 <:
64 our %sign = (
65         arg    => $ascii ? '.' : '·',  # described as 'dot'
66         motion => $ascii ? '|' : '↕',
67         alias  => $ascii ? 'see: ' : '»',
68         up     => $ascii ? 'up'    : '▲',
69         right  => $ascii ? 'right' : '▶',
70         down   => $ascii ? 'down'  : '▼',
71         left   => $ascii ? 'left'  : '◀',
72         sep    => $ascii ? '*'     : '•',
73         _      => exists $get{ascii} && !$ascii ? "\x{200b}" : '<wbr>',
74                 # use the correct ZWNJ only when unicode is forced on
75                 # default to use unofficial html for best support
76 );
77
78 use Shiar_Sheet::Keyboard;
79 my $keys = Shiar_Sheet::Keyboard->new({do 'vim.inc.pl'});
80 $keys->map($get{map}) or undef $get{map};
81 $keys->print_rows($get{static});
82 :>
83 </ul>
84
85 <hr>
86
87 <div class="help">
88         <div class="left">
89                 <dl class="legend legend-types">
90                 <dt class="ci">info
91                         <dd>Info command: shows/does something without altering anything.
92                 <dt class="pm">motion
93                         <dd>Moves the cursor, or defines the range for an operator (<:= $sign{motion} :>).
94                 <dt class="po">positioning
95                         <dd>Other movement (jumps, window (re)positioning).
96                 <dt class="co">command
97                         <dd>Direct action command.
98                 <dt class="mi">ins mode
99                         <dd>Enters Insert or Replace mode.
100                 <dt class="mo">mode
101                         <dd>Enters a different mode.
102                 <dt class="mv">vis mode
103                         <dd>Enters Visual or Select mode.
104                 <dt class="me">key cmd
105                         <dd>Additional key commands (click for overview).
106                 </dl>
107         </div>
108
109         <div class="right">
110                 <dl class="legend legend-options">
111                 <dt>key<:= $sign{arg} :>
112                         <dd>Commands with a dot need a char argument afterwards.
113                 <dt>key<:= $sign{motion} :>
114                         <dd>Requires a motion afterwards, operates between cursor and destination.
115                 <dt class="vim">vim
116                         <dd>Not in original Vi (assessment incomplete).
117                 <dt class="vim7">vim7
118                         <dd>New in vim version 7.x.
119                 </dl>
120
121                 <ul class="legend legend-set">
122                 <li>keyboard <strong>map</strong> is
123                         <:= $get{map} ? 'set to ' : '' :><em><:= $keys->{map} :></em>
124                 <li><strong>ascii</strong> mode is
125                         <:= exists $get{ascii} && 'forced ' :><em><:=
126                                 $ascii ? 'on' : 'off' :></em>
127                 <li><strong>keys</strong> are
128                         <em><:= $showkeys ? 'always shown' : 'hidden if unassigned' :></em><:=
129                                 !exists $get{keys} && ' by default' :>
130                 <li>default <strong>style</strong> is
131                         <:= defined $get{style} && 'set to ' :><em><:= $style :></em>
132                 </ul>
133         </div>
134 </div>
135
136 <p class="footer">
137         <a href="http://sheet.shiar.nl/vim">sheet.shiar.nl<strong>/vim</strong></a>
138         <a href="git://dev.shiar.nl/sheet"><:= "v$VERSION" :></a>
139         created by Shiar <:= $sign{sep} :>
140         <a title="Licensed under the GNU Affero General Public License, version 3"
141            href="http://www.fsf.org/licensing/licenses/agpl-3.0.html">AGPLv3</a> <:= $sign{sep} :>
142         last update <:
143                 use Time::Format qw(time_format);
144                 print time_format('yyyy-mm-dd', (stat 'vim.inc.pl')[9]);
145         :>
146 </p>
147
148 </html>