annotate runtime/tutor/tutor.vim @ 3386:cb2ae92ce106 v7.3.459

updated for version 7.3.459 Problem: Win32: Warnings for type conversion. Solution: Add type casts. (Mike Williams)
author Bram Moolenaar <bram@vim.org>
date Wed, 29 Feb 2012 13:58:47 +0100
parents f4f8014d516e
children 04592728474a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1 " Vim tutor support file
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2 " Author: Eduardo F. Amatria <eferna1@platea.pntic.mec.es>
1698
f4f8014d516e updated for version 7.2c-000
vimboss
parents: 1621
diff changeset
3 " Maintainer: Bram Moolenaar
f4f8014d516e updated for version 7.2c-000
vimboss
parents: 1621
diff changeset
4 " Last Change: 2008 Jul 21
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5
1698
f4f8014d516e updated for version 7.2c-000
vimboss
parents: 1621
diff changeset
6 " This Vim script is used for detecting if a translation of the
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7 " tutor file exist, i.e., a tutor.xx file, where xx is the language.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8 " If the translation does not exist, or no extension is given,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9 " it defaults to the english version.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11 " It is invoked by the vimtutor shell script.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13 " 1. Build the extension of the file, if any:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 let s:ext = ""
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15 if strlen($xx) > 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16 let s:ext = "." . $xx
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 let s:lang = ""
782
d20041a02ee5 updated for version 7.0228
vimboss
parents: 557
diff changeset
19 " Check that a potential value has at least two letters.
d20041a02ee5 updated for version 7.0228
vimboss
parents: 557
diff changeset
20 " Ignore "1043" and "C".
d20041a02ee5 updated for version 7.0228
vimboss
parents: 557
diff changeset
21 if exists("v:lang") && v:lang =~ '\a\a'
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 let s:lang = v:lang
782
d20041a02ee5 updated for version 7.0228
vimboss
parents: 557
diff changeset
23 elseif $LC_ALL =~ '\a\a'
205
d292c40ca788 updated for version 7.0060
vimboss
parents: 24
diff changeset
24 let s:lang = $LC_ALL
782
d20041a02ee5 updated for version 7.0228
vimboss
parents: 557
diff changeset
25 elseif $LANG =~ '\a\a'
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26 let s:lang = $LANG
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28 if s:lang != ""
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29 " Remove "@euro" (ignoring case), it may be at the end
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 let s:lang = substitute(s:lang, '\c@euro', '', '')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 " On MS-Windows it may be German_Germany.1252 or Polish_Poland.1250. How
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32 " about other languages?
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 if s:lang =~ "German"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34 let s:ext = ".de"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35 elseif s:lang =~ "Polish"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36 let s:ext = ".pl"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37 elseif s:lang =~ "Slovak"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38 let s:ext = ".sk"
1154
f23b876b21ff updated for version 7.1a
vimboss
parents: 969
diff changeset
39 elseif s:lang =~ "Czech"
f23b876b21ff updated for version 7.1a
vimboss
parents: 969
diff changeset
40 let s:ext = ".cs"
782
d20041a02ee5 updated for version 7.0228
vimboss
parents: 557
diff changeset
41 elseif s:lang =~ "Dutch"
d20041a02ee5 updated for version 7.0228
vimboss
parents: 557
diff changeset
42 let s:ext = ".nl"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44 let s:ext = "." . strpart(s:lang, 0, 2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48
1621
82b5078be2dd updated for version 7.2a
vimboss
parents: 1154
diff changeset
49 " Somehow ".ge" (Germany) is sometimes used for ".de" (Deutsch).
82b5078be2dd updated for version 7.2a
vimboss
parents: 1154
diff changeset
50 if s:ext =~? '\.ge'
82b5078be2dd updated for version 7.2a
vimboss
parents: 1154
diff changeset
51 let s:ext = ".de"
82b5078be2dd updated for version 7.2a
vimboss
parents: 1154
diff changeset
52 endif
82b5078be2dd updated for version 7.2a
vimboss
parents: 1154
diff changeset
53
82b5078be2dd updated for version 7.2a
vimboss
parents: 1154
diff changeset
54 if s:ext =~? '\.en'
82b5078be2dd updated for version 7.2a
vimboss
parents: 1154
diff changeset
55 let s:ext = ""
82b5078be2dd updated for version 7.2a
vimboss
parents: 1154
diff changeset
56 endif
82b5078be2dd updated for version 7.2a
vimboss
parents: 1154
diff changeset
57
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
58 " The japanese tutor is available in two encodings, guess which one to use
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
59 " The "sjis" one is actually "cp932", it doesn't matter for this text.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60 if s:ext =~? '\.ja'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
61 if &enc =~ "euc"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
62 let s:ext = ".ja.euc"
1621
82b5078be2dd updated for version 7.2a
vimboss
parents: 1154
diff changeset
63 elseif &enc != "utf-8"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64 let s:ext = ".ja.sjis"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
65 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
66 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
67
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68 " The korean tutor is available in two encodings, guess which one to use
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
69 if s:ext =~? '\.ko'
1621
82b5078be2dd updated for version 7.2a
vimboss
parents: 1154
diff changeset
70 if &enc != "utf-8"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
71 let s:ext = ".ko.euc"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
72 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
73 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
74
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
75 " The Chinese tutor is available in two encodings, guess which one to use
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76 " This segment is from the above lines and modified by
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
77 " Mendel L Chan <beos@turbolinux.com.cn> for Chinese vim tutorial
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
78 if s:ext =~? '\.zh'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
79 if &enc =~ 'big5\|cp950'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80 let s:ext = ".zh.big5"
1621
82b5078be2dd updated for version 7.2a
vimboss
parents: 1154
diff changeset
81 elseif &enc != 'utf-8'
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
82 let s:ext = ".zh.euc"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
83 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
84 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
85
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
86 " The Polish tutor is available in two encodings, guess which one to use.
24
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
87 if s:ext =~? '\.pl'
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
88 if &enc =~ 1250
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
89 let s:ext = ".pl.cp1250"
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 7
diff changeset
90 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
91 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
92
557
862863033fdd updated for version 7.0158
vimboss
parents: 205
diff changeset
93 " The Turkish tutor is available in two encodings, guess which one to use
862863033fdd updated for version 7.0158
vimboss
parents: 205
diff changeset
94 if s:ext =~? '\.tr'
1621
82b5078be2dd updated for version 7.2a
vimboss
parents: 1154
diff changeset
95 if &enc == "iso-8859-9"
557
862863033fdd updated for version 7.0158
vimboss
parents: 205
diff changeset
96 let s:ext = ".tr.iso9"
862863033fdd updated for version 7.0158
vimboss
parents: 205
diff changeset
97 endif
862863033fdd updated for version 7.0158
vimboss
parents: 205
diff changeset
98 endif
862863033fdd updated for version 7.0158
vimboss
parents: 205
diff changeset
99
969
cf4d73a8924e updated for version 7.0-095
vimboss
parents: 953
diff changeset
100 " The Greek tutor is available in three encodings, guess what to use.
cf4d73a8924e updated for version 7.0-095
vimboss
parents: 953
diff changeset
101 " We used ".gr" (Greece) instead of ".el" (Greek); accept both.
cf4d73a8924e updated for version 7.0-095
vimboss
parents: 953
diff changeset
102 if s:ext =~? '\.gr\|\.el'
cf4d73a8924e updated for version 7.0-095
vimboss
parents: 953
diff changeset
103 if &enc == "iso-8859-7"
1621
82b5078be2dd updated for version 7.2a
vimboss
parents: 1154
diff changeset
104 let s:ext = ".el"
969
cf4d73a8924e updated for version 7.0-095
vimboss
parents: 953
diff changeset
105 elseif &enc == "utf-8"
1621
82b5078be2dd updated for version 7.2a
vimboss
parents: 1154
diff changeset
106 let s:ext = ".el.utf-8"
969
cf4d73a8924e updated for version 7.0-095
vimboss
parents: 953
diff changeset
107 elseif &enc =~ 737
1621
82b5078be2dd updated for version 7.2a
vimboss
parents: 1154
diff changeset
108 let s:ext = ".el.cp737"
969
cf4d73a8924e updated for version 7.0-095
vimboss
parents: 953
diff changeset
109 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
110 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
111
1154
f23b876b21ff updated for version 7.1a
vimboss
parents: 969
diff changeset
112 " The Slovak tutor is available in three encodings, guess which one to use
f23b876b21ff updated for version 7.1a
vimboss
parents: 969
diff changeset
113 if s:ext =~? '\.sk'
1621
82b5078be2dd updated for version 7.2a
vimboss
parents: 1154
diff changeset
114 if &enc =~ 1250
1154
f23b876b21ff updated for version 7.1a
vimboss
parents: 969
diff changeset
115 let s:ext = ".sk.cp1250"
f23b876b21ff updated for version 7.1a
vimboss
parents: 969
diff changeset
116 endif
f23b876b21ff updated for version 7.1a
vimboss
parents: 969
diff changeset
117 endif
f23b876b21ff updated for version 7.1a
vimboss
parents: 969
diff changeset
118
f23b876b21ff updated for version 7.1a
vimboss
parents: 969
diff changeset
119 " The Czech tutor is available in three encodings, guess which one to use
f23b876b21ff updated for version 7.1a
vimboss
parents: 969
diff changeset
120 if s:ext =~? '\.cs'
1621
82b5078be2dd updated for version 7.2a
vimboss
parents: 1154
diff changeset
121 if &enc =~ 1250
1154
f23b876b21ff updated for version 7.1a
vimboss
parents: 969
diff changeset
122 let s:ext = ".cs.cp1250"
f23b876b21ff updated for version 7.1a
vimboss
parents: 969
diff changeset
123 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
124 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
125
953
2fb204616c9b updated for version 7.0-079
vimboss
parents: 782
diff changeset
126 " The Russian tutor is available in three encodings, guess which one to use.
2fb204616c9b updated for version 7.0-079
vimboss
parents: 782
diff changeset
127 if s:ext =~? '\.ru'
1621
82b5078be2dd updated for version 7.2a
vimboss
parents: 1154
diff changeset
128 if &enc =~ '1251'
953
2fb204616c9b updated for version 7.0-079
vimboss
parents: 782
diff changeset
129 let s:ext = '.ru.cp1251'
2fb204616c9b updated for version 7.0-079
vimboss
parents: 782
diff changeset
130 elseif &enc =~ 'koi8'
2fb204616c9b updated for version 7.0-079
vimboss
parents: 782
diff changeset
131 let s:ext = '.ru'
2fb204616c9b updated for version 7.0-079
vimboss
parents: 782
diff changeset
132 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
133 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
134
1621
82b5078be2dd updated for version 7.2a
vimboss
parents: 1154
diff changeset
135 " The Hungarian tutor is available in three encodings, guess which one to use.
1154
f23b876b21ff updated for version 7.1a
vimboss
parents: 969
diff changeset
136 if s:ext =~? '\.hu'
1621
82b5078be2dd updated for version 7.2a
vimboss
parents: 1154
diff changeset
137 if &enc =~ 1250
82b5078be2dd updated for version 7.2a
vimboss
parents: 1154
diff changeset
138 let s:ext = ".hu.cp1250"
1154
f23b876b21ff updated for version 7.1a
vimboss
parents: 969
diff changeset
139 elseif &enc =~ 'iso-8859-2'
f23b876b21ff updated for version 7.1a
vimboss
parents: 969
diff changeset
140 let s:ext = '.hu'
f23b876b21ff updated for version 7.1a
vimboss
parents: 969
diff changeset
141 endif
f23b876b21ff updated for version 7.1a
vimboss
parents: 969
diff changeset
142 endif
f23b876b21ff updated for version 7.1a
vimboss
parents: 969
diff changeset
143
1621
82b5078be2dd updated for version 7.2a
vimboss
parents: 1154
diff changeset
144 " The Croatian tutor is available in three encodings, guess which one to use.
82b5078be2dd updated for version 7.2a
vimboss
parents: 1154
diff changeset
145 if s:ext =~? '\.hr'
82b5078be2dd updated for version 7.2a
vimboss
parents: 1154
diff changeset
146 if &enc =~ 1250
82b5078be2dd updated for version 7.2a
vimboss
parents: 1154
diff changeset
147 let s:ext = ".hr.cp1250"
82b5078be2dd updated for version 7.2a
vimboss
parents: 1154
diff changeset
148 elseif &enc =~ 'iso-8859-2'
82b5078be2dd updated for version 7.2a
vimboss
parents: 1154
diff changeset
149 let s:ext = '.hr'
82b5078be2dd updated for version 7.2a
vimboss
parents: 1154
diff changeset
150 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
151 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
152
1621
82b5078be2dd updated for version 7.2a
vimboss
parents: 1154
diff changeset
153 " Esperanto is only available in utf-8
82b5078be2dd updated for version 7.2a
vimboss
parents: 1154
diff changeset
154 if s:ext =~? '\.eo'
82b5078be2dd updated for version 7.2a
vimboss
parents: 1154
diff changeset
155 let s:ext = ".eo.utf-8"
82b5078be2dd updated for version 7.2a
vimboss
parents: 1154
diff changeset
156 endif
82b5078be2dd updated for version 7.2a
vimboss
parents: 1154
diff changeset
157 " Vietnamese is only available in utf-8
82b5078be2dd updated for version 7.2a
vimboss
parents: 1154
diff changeset
158 if s:ext =~? '\.vi'
82b5078be2dd updated for version 7.2a
vimboss
parents: 1154
diff changeset
159 let s:ext = ".vi.utf-8"
82b5078be2dd updated for version 7.2a
vimboss
parents: 1154
diff changeset
160 endif
82b5078be2dd updated for version 7.2a
vimboss
parents: 1154
diff changeset
161
82b5078be2dd updated for version 7.2a
vimboss
parents: 1154
diff changeset
162 " If 'encoding' is utf-8 s:ext must end in utf-8.
82b5078be2dd updated for version 7.2a
vimboss
parents: 1154
diff changeset
163 if &enc == 'utf-8' && s:ext !~ '\.utf-8'
1698
f4f8014d516e updated for version 7.2c-000
vimboss
parents: 1621
diff changeset
164 let s:ext .= '.utf-8'
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
165 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
166
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
167 " 2. Build the name of the file:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
168 let s:tutorfile = "/tutor/tutor"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
169 let s:tutorxx = $VIMRUNTIME . s:tutorfile . s:ext
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
170
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
171 " 3. Finding the file:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
172 if filereadable(s:tutorxx)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
173 let $TUTOR = s:tutorxx
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
174 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
175 let $TUTOR = $VIMRUNTIME . s:tutorfile
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
176 echo "The file " . s:tutorxx . " does not exist.\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
177 echo "Copying English version: " . $TUTOR
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
178 4sleep
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
179 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
180
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
181 " 4. Making the copy and exiting Vim:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
182 e $TUTOR
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
183 wq! $TUTORCOPY