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