support multiple programs to view given file
this patch introduce helper function and extend pdf program list
usually user install only popular choice of program list
order rules:
1. old known first (keep compatible characteristics with older mc versions)
2. viewer (faster then editor)
3. editor
(tested with bash and busybox sh, please cross check with ksh)
Signed-off-by: Andreas Mohr <and@gmx.li>
a
|
b
|
|
10 | 10 | |
11 | 11 | STAROFFICE_REGEXP='\.(sxw|sdw|stw|sxc|stc|sxi|sti|sxd|std||sxm||sxg)$' |
12 | 12 | |
| 13 | # order rules: |
| 14 | # 1. old known first (keep compatible characteristics with older mc versions) |
| 15 | # 2. viewer (faster then editor) |
| 16 | # 3. editor |
| 17 | helper_which_program() { |
| 18 | _program_list=$* |
| 19 | |
| 20 | for _program in ${_program_list}; do |
| 21 | which "${_program}" >/dev/null 2>&1 || continue |
| 22 | echo "${_program}" |
| 23 | break |
| 24 | done |
| 25 | unset _program |
| 26 | unset _program_list |
| 27 | return |
| 28 | } |
| 29 | |
13 | 30 | staroffice_console() { |
14 | 31 | filename=$1;shift |
15 | 32 | is_view=$1; shift |
… |
… |
|
100 | 117 | pdf) |
101 | 118 | if [ ! -n "$DISPLAY" ]; then |
102 | 119 | pdftotext -layout -nopgbrk "${MC_EXT_FILENAME}" - | ${PAGER:-more} |
103 | | elif see > /dev/null 2>&1; then |
104 | | (see "${MC_EXT_FILENAME}" &) |
105 | 120 | else |
106 | | (xpdf "${MC_EXT_FILENAME}" &) |
| 121 | _program_caller=`helper_which_program see xpdf acroread ghostview mupdf` |
| 122 | [ "x${_program_caller}" = "x" ] || (${_program_caller} "${MC_EXT_FILENAME}" &) |
| 123 | unset _program_caller |
107 | 124 | fi |
108 | | #(acroread "${MC_EXT_FILENAME}" &) |
109 | | #(ghostview "${MC_EXT_FILENAME}" &) |
110 | 125 | ;; |
111 | 126 | ooffice) |
112 | 127 | if [ -n "$DISPLAY" ]; then |