Ticket #3436: mc-allow-multiple-doc-programs.patch

File mc-allow-multiple-doc-programs.patch, 1.7 KB (added by and, 10 years ago)
  • misc/ext.d/doc.sh.in

    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  
    1010 
    1111STAROFFICE_REGEXP='\.(sxw|sdw|stw|sxc|stc|sxi|sti|sxd|std||sxm||sxg)$' 
    1212 
     13# order rules: 
     14# 1. old known first (keep compatible characteristics with older mc versions) 
     15# 2. viewer (faster then editor) 
     16# 3. editor 
     17helper_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 
    1330staroffice_console() { 
    1431    filename=$1;shift 
    1532    is_view=$1; shift 
     
    100117    pdf) 
    101118        if [ ! -n "$DISPLAY" ]; then 
    102119            pdftotext -layout -nopgbrk "${MC_EXT_FILENAME}" - | ${PAGER:-more} 
    103         elif see > /dev/null 2>&1; then 
    104             (see "${MC_EXT_FILENAME}" &) 
    105120        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 
    107124        fi 
    108         #(acroread "${MC_EXT_FILENAME}" &) 
    109         #(ghostview "${MC_EXT_FILENAME}" &) 
    110125        ;; 
    111126    ooffice) 
    112127        if [ -n "$DISPLAY" ]; then