Bram Moolenaar | b46fecd | 2019-06-15 17:58:09 +0200 | [diff] [blame] | 1 | " Command to check for the presence of a feature. |
| 2 | command -nargs=1 CheckFeature call CheckFeature(<f-args>) |
| 3 | func CheckFeature(name) |
| 4 | if !has(a:name) |
| 5 | throw 'Skipped: ' .. a:name .. ' feature missing' |
| 6 | endif |
| 7 | endfunc |
| 8 | |
| 9 | " Command to check for the presence of a working option. |
| 10 | command -nargs=1 CheckOption call CheckOption(<f-args>) |
| 11 | func CheckOption(name) |
| 12 | if !exists('+' .. a:name) |
| 13 | throw 'Skipped: ' .. a:name .. ' option not supported' |
| 14 | endif |
| 15 | endfunc |
| 16 | |
| 17 | " Command to check for the presence of a function. |
| 18 | command -nargs=1 CheckFunction call CheckFunction(<f-args>) |
| 19 | func CheckFunction(name) |
| 20 | if !exists('*' .. a:name) |
| 21 | throw 'Skipped: ' .. a:name .. ' function missing' |
| 22 | endif |
| 23 | endfunc |
Bram Moolenaar | 4641a12 | 2019-07-29 22:10:23 +0200 | [diff] [blame] | 24 | |
Bram Moolenaar | 8c5a278 | 2019-08-07 23:07:07 +0200 | [diff] [blame] | 25 | " Command to check for the presence of an Ex command |
| 26 | command -nargs=1 CheckCommand call CheckCommand(<f-args>) |
| 27 | func CheckCommand(name) |
| 28 | if !exists(':' .. a:name) |
| 29 | throw 'Skipped: ' .. a:name .. ' command not supported' |
| 30 | endif |
| 31 | endfunc |
| 32 | |
| 33 | " Command to check for the presence of a shell command |
| 34 | command -nargs=1 CheckExecutable call CheckExecutable(<f-args>) |
| 35 | func CheckExecutable(name) |
| 36 | if !executable(a:name) |
| 37 | throw 'Skipped: ' .. a:name .. ' program not executable' |
| 38 | endif |
| 39 | endfunc |
| 40 | |
Bram Moolenaar | 4641a12 | 2019-07-29 22:10:23 +0200 | [diff] [blame] | 41 | " Command to check for running on MS-Windows |
| 42 | command CheckMSWindows call CheckMSWindows() |
| 43 | func CheckMSWindows() |
| 44 | if !has('win32') |
| 45 | throw 'Skipped: only works on MS-Windows' |
| 46 | endif |
| 47 | endfunc |
| 48 | |
Bram Moolenaar | 8c5a278 | 2019-08-07 23:07:07 +0200 | [diff] [blame] | 49 | " Command to check for NOT running on MS-Windows |
| 50 | command CheckNotMSWindows call CheckNotMSWindows() |
| 51 | func CheckNotMSWindows() |
| 52 | if has('win32') |
| 53 | throw 'Skipped: does not work on MS-Windows' |
| 54 | endif |
| 55 | endfunc |
| 56 | |
Bram Moolenaar | 4641a12 | 2019-07-29 22:10:23 +0200 | [diff] [blame] | 57 | " Command to check for running on Unix |
| 58 | command CheckUnix call CheckUnix() |
| 59 | func CheckUnix() |
| 60 | if !has('unix') |
| 61 | throw 'Skipped: only works on Unix' |
| 62 | endif |
| 63 | endfunc |
Bram Moolenaar | 3c8ee62 | 2019-08-03 22:55:50 +0200 | [diff] [blame] | 64 | |
| 65 | " Command to check that making screendumps is supported. |
| 66 | " Caller must source screendump.vim |
| 67 | command CheckScreendump call CheckScreendump() |
| 68 | func CheckScreendump() |
| 69 | if !CanRunVimInTerminal() |
| 70 | throw 'Skipped: cannot make screendumps' |
| 71 | endif |
| 72 | endfunc |
| 73 | |
| 74 | " Command to check that we can Run Vim in a terminal window |
| 75 | command CheckRunVimInTerminal call CheckRunVimInTerminal() |
| 76 | func CheckRunVimInTerminal() |
| 77 | if !CanRunVimInTerminal() |
| 78 | throw 'Skipped: cannot run Vim in a terminal window' |
| 79 | endif |
| 80 | endfunc |
Bram Moolenaar | 8c5a278 | 2019-08-07 23:07:07 +0200 | [diff] [blame] | 81 | |
| 82 | " Command to check that we can run the GUI |
| 83 | command CheckCanRunGui call CheckCanRunGui() |
| 84 | func CheckCanRunGui() |
| 85 | if !has('gui') || ($DISPLAY == "" && !has('gui_running')) |
| 86 | throw 'Skipped: cannot run start the GUI' |
| 87 | endif |
| 88 | endfunc |
| 89 | |
| 90 | " Command to check that we are using the GUI |
| 91 | command CheckGui call CheckGui() |
| 92 | func CheckGui() |
| 93 | if !has('gui_running') |
| 94 | throw 'Skipped: only works in the GUI' |
| 95 | endif |
| 96 | endfunc |
| 97 | |
| 98 | " Command to check that not currently using the GUI |
| 99 | command CheckNotGui call CheckNotGui() |
| 100 | func CheckNotGui() |
| 101 | if has('gui_running') |
| 102 | throw 'Skipped: only works in the terminal' |
| 103 | endif |
| 104 | endfunc |