Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1 | :: Start Vim on a copy of the tutor file. |
| 2 | @echo off |
| 3 | |
| 4 | :: Usage: vimtutor [-console] [xx] |
| 5 | :: |
| 6 | :: -console means gvim will not be used |
| 7 | :: xx is a language code like "es" or "nl". |
| 8 | :: When an xx argument is given, it tries loading that tutor. |
| 9 | :: When this fails or no xx argument was given, it tries using 'v:lang' |
| 10 | :: When that also fails, it uses the English version. |
| 11 | |
| 12 | :: Use Vim to copy the tutor, it knows the value of $VIMRUNTIME |
Bram Moolenaar | 37f471d | 2020-03-19 17:13:40 +0100 | [diff] [blame] | 13 | FOR %%d in (. %TMP% %TEMP%) DO ( |
Christian Brabandt | ee2cbcd | 2021-09-15 12:53:40 +0200 | [diff] [blame] | 14 | call :test_dir_writable "%~dpf0" %%d |
Bram Moolenaar | 37f471d | 2020-03-19 17:13:40 +0100 | [diff] [blame] | 15 | IF NOT ERRORLEVEL 1 GOTO dir_ok |
| 16 | ) |
| 17 | |
| 18 | echo No working directory is found |
| 19 | GOTO end |
| 20 | |
| 21 | :test_dir_writable |
| 22 | SET TUTORCOPY=%2\$tutor$ |
| 23 | COPY %1 %TUTORCOPY% >nul 2>nul |
| 24 | GOTO end |
| 25 | |
| 26 | :dir_ok |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 27 | |
| 28 | SET xx=%1 |
| 29 | |
| 30 | IF NOT .%1==.-console GOTO use_gui |
| 31 | SHIFT |
| 32 | SET xx=%1 |
| 33 | GOTO use_vim |
| 34 | :use_gui |
| 35 | |
| 36 | :: Try making a copy of tutor with gvim. If gvim cannot be found, try using |
| 37 | :: vim instead. If vim cannot be found, alert user to check environment and |
| 38 | :: installation. |
| 39 | |
| 40 | :: The script tutor.vim tells Vim which file to copy. |
Bram Moolenaar | 37f471d | 2020-03-19 17:13:40 +0100 | [diff] [blame] | 41 | start "dummy" /b /w "%~dp0gvim.exe" -u NONE -c "so $VIMRUNTIME/tutor/tutor.vim" |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 42 | IF ERRORLEVEL 1 GOTO use_vim |
| 43 | |
| 44 | :: Start gvim without any .vimrc, set 'nocompatible' |
Bram Moolenaar | 37f471d | 2020-03-19 17:13:40 +0100 | [diff] [blame] | 45 | start "dummy" /b /w "%~dp0gvim.exe" -u NONE -c "set nocp" %TUTORCOPY% |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 46 | |
| 47 | GOTO end |
| 48 | |
| 49 | :use_vim |
| 50 | :: The script tutor.vim tells Vim which file to copy |
Bram Moolenaar | dde403c | 2017-09-17 21:43:00 +0200 | [diff] [blame] | 51 | call vim -u NONE -c "so $VIMRUNTIME/tutor/tutor.vim" |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 52 | IF ERRORLEVEL 1 GOTO no_executable |
| 53 | |
| 54 | :: Start vim without any .vimrc, set 'nocompatible' |
Bram Moolenaar | dde403c | 2017-09-17 21:43:00 +0200 | [diff] [blame] | 55 | call vim -u NONE -c "set nocp" %TUTORCOPY% |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 56 | |
| 57 | GOTO end |
| 58 | |
| 59 | :no_executable |
| 60 | ECHO. |
| 61 | ECHO. |
| 62 | ECHO No vim or gvim found in current directory or PATH. |
| 63 | ECHO Check your installation or re-run install.exe |
| 64 | |
| 65 | :end |
| 66 | :: remove the copy of the tutor |
| 67 | IF EXIST %TUTORCOPY% DEL %TUTORCOPY% |
| 68 | SET xx= |