mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-03 10:04:32 +03:00
Ticket #2103: mc.ext enhancement
This commit makes a few improvements in default bindings: * use chm_http text-mode handler for CHM files; * play sounds only from videos in text mode; * use pdftotext -layout -nopgbrk switches; * try to use elinks before links for HTML; * soffice2html text-mode handler for SXW files; * wvHtml text-mode handler for doc files; * xlhtml text-mode handler for XLS files; * ppthtml text-mode handler for PPT/PPS files; * open=view+pager fallback (noX) for PostScript, PDF, OD[PST] and DVI; * standarized $DISPLAY checks. Signed-off-by: Slava Zanko <slavazanko@gmail.com>
This commit is contained in:
parent
ff096a3e3a
commit
ce07bec728
@ -7,6 +7,22 @@ action=$1
|
|||||||
filetype=$2
|
filetype=$2
|
||||||
|
|
||||||
|
|
||||||
|
STAROFFICE_REGEXP='\.(sxw|sdw|stw|sxc|stc|sxi|sti|sxd|std||sxm||sxg)$'
|
||||||
|
|
||||||
|
staroffice_console() {
|
||||||
|
filename=$1;shift
|
||||||
|
is_view=$1; shift
|
||||||
|
if [ -n "${is_view}" ]; then
|
||||||
|
is_view='-dump'
|
||||||
|
fi
|
||||||
|
|
||||||
|
tmp=`mktemp -d ${TMPDIR:-/tmp}/%p.XXXXXX`
|
||||||
|
cd $tmp
|
||||||
|
soffice2html.pl "${filename}"
|
||||||
|
elinks ${is_view} content.html
|
||||||
|
rm -rf "$tmp"
|
||||||
|
}
|
||||||
|
|
||||||
do_view_action() {
|
do_view_action() {
|
||||||
filetype=$1
|
filetype=$1
|
||||||
|
|
||||||
@ -15,19 +31,36 @@ do_view_action() {
|
|||||||
ps2ascii "${MC_EXT_FILENAME}"
|
ps2ascii "${MC_EXT_FILENAME}"
|
||||||
;;
|
;;
|
||||||
pdf)
|
pdf)
|
||||||
pdftotext "${MC_EXT_FILENAME}" -
|
pdftotext -layout -nopgbrk "${MC_EXT_FILENAME}" -
|
||||||
;;
|
;;
|
||||||
odt)
|
odt)
|
||||||
odt2txt "${MC_EXT_FILENAME}"
|
if [ ` echo "${MC_EXT_FILENAME}" | grep -c "${STAROFFICE_REGEXP}"` -ne 0 ]; then
|
||||||
|
staroffice_console "${MC_EXT_FILENAME}" "view"
|
||||||
|
else
|
||||||
|
odt2txt "${MC_EXT_FILENAME}"
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
msdoc)
|
msdoc)
|
||||||
antiword -t "${MC_EXT_FILENAME}" || \
|
which wvHtml >/dev/null 2>&1 &&
|
||||||
|
{
|
||||||
|
tmp=`mktemp -d ${TMPDIR:-/tmp}/%p.XXXXXX`
|
||||||
|
wvHtml "${MC_EXT_FILENAME}" --targetdir="$tmp" page.html
|
||||||
|
elinks -dump "$tmp/page.html"
|
||||||
|
rm -rf "$tmp"
|
||||||
|
} || \
|
||||||
|
antiword -t "${MC_EXT_FILENAME}" || \
|
||||||
catdoc -w "${MC_EXT_FILENAME}" || \
|
catdoc -w "${MC_EXT_FILENAME}" || \
|
||||||
word2x -f text "${MC_EXT_FILENAME}" - || \
|
word2x -f text "${MC_EXT_FILENAME}" - || \
|
||||||
strings "${MC_EXT_FILENAME}"
|
strings "${MC_EXT_FILENAME}"
|
||||||
;;
|
;;
|
||||||
msxls)
|
msxls)
|
||||||
xls2csv "${MC_EXT_FILENAME}" || \
|
which xlHtml >/dev/null 2>&1 && {
|
||||||
|
tmp=`mktemp -d ${TMPDIR:-/tmp}/%p.XXXXXX`
|
||||||
|
xlhtml -a "${MC_EXT_FILENAME}" > "$tmp/page.html"
|
||||||
|
elinks -dump "$tmp/page.html"
|
||||||
|
rm -rf "$tmp"
|
||||||
|
} || \
|
||||||
|
xls2csv "${MC_EXT_FILENAME}" || \
|
||||||
strings "${MC_EXT_FILENAME}"
|
strings "${MC_EXT_FILENAME}"
|
||||||
;;
|
;;
|
||||||
dvi)
|
dvi)
|
||||||
@ -46,31 +79,72 @@ do_open_action() {
|
|||||||
|
|
||||||
case "${filetype}" in
|
case "${filetype}" in
|
||||||
ps)
|
ps)
|
||||||
(gv "${MC_EXT_FILENAME}" &)
|
if [ -n "$DISPLAY" ]; then
|
||||||
|
(gv "${MC_EXT_FILENAME}" &)
|
||||||
|
else
|
||||||
|
ps2ascii "${MC_EXT_FILENAME}" | ${PAGER:-more}
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
pdf)
|
pdf)
|
||||||
(xpdf "${MC_EXT_FILENAME}" &)
|
if [ -n "$DISPLAY" ]; then
|
||||||
|
(xpdf "${MC_EXT_FILENAME}" &)
|
||||||
|
else
|
||||||
|
pdftotext -layout -nopgbrk "${MC_EXT_FILENAME}" - | ${PAGER:-more}
|
||||||
|
fi
|
||||||
#(acroread "${MC_EXT_FILENAME}" &)
|
#(acroread "${MC_EXT_FILENAME}" &)
|
||||||
#(ghostview "${MC_EXT_FILENAME}" &)
|
#(ghostview "${MC_EXT_FILENAME}" &)
|
||||||
;;
|
;;
|
||||||
ooffice)
|
ooffice)
|
||||||
(ooffice "${MC_EXT_FILENAME}" &)
|
if [ -n "$DISPLAY" ]; then
|
||||||
|
(ooffice "${MC_EXT_FILENAME}" &)
|
||||||
|
else
|
||||||
|
if [ ` echo "${MC_EXT_FILENAME}" | grep -c "${STAROFFICE_REGEXP}"` -ne 0 ]; then
|
||||||
|
staroffice_console "${MC_EXT_FILENAME}"
|
||||||
|
else
|
||||||
|
odt2txt "${MC_EXT_FILENAME}" | ${PAGER:-more}
|
||||||
|
fi
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
abw)
|
abw)
|
||||||
(abiword "${MC_EXT_FILENAME}" &)
|
(abiword "${MC_EXT_FILENAME}" &)
|
||||||
;;
|
;;
|
||||||
msdoc)
|
msdoc)
|
||||||
(abiword "${MC_EXT_FILENAME}" >/dev/null 2>&1 &)
|
if [ -n "$DISPLAY" ]; then
|
||||||
|
(abiword "${MC_EXT_FILENAME}" >/dev/null 2>&1 &)
|
||||||
|
else
|
||||||
|
tmp=`mktemp -d ${TMPDIR:-/tmp}/%p.XXXXXX`
|
||||||
|
wvHtml "${MC_EXT_FILENAME}" --targetdir="$tmp" page.html -1
|
||||||
|
elinks "$tmp/page.html"
|
||||||
|
rm -rf "$tmp"
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
msxls)
|
msxls)
|
||||||
(gnumeric "${MC_EXT_FILENAME}" >/dev/null 2>&1 &)
|
if [ -n "$DISPLAY" ]; then
|
||||||
|
(gnumeric "${MC_EXT_FILENAME}" >/dev/null 2>&1 &)
|
||||||
|
else
|
||||||
|
tmp=`mktemp -d ${TMPDIR:-/tmp}/%p.XXXXXX`
|
||||||
|
xlhtml -a "${MC_EXT_FILENAME}" > "$tmp/page.html"
|
||||||
|
elinks "$tmp/page.html"
|
||||||
|
rm -rf "$tmp"
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
msppt)
|
||||||
|
if [ -n "$DISPLAY" ]; then
|
||||||
|
(ooffice %f >/dev/null 2>&1 &)
|
||||||
|
else
|
||||||
|
tmp=`mktemp -d ${TMPDIR:-/tmp}/%p.XXXXXX`
|
||||||
|
ppthtml %f > "$tmp/page.html"
|
||||||
|
elinks "$tmp/page.html"
|
||||||
|
rm -rf "$tmp"
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
framemaker)
|
framemaker)
|
||||||
fmclient -f "${MC_EXT_FILENAME}"
|
fmclient -f "${MC_EXT_FILENAME}"
|
||||||
;;
|
;;
|
||||||
dvi)
|
dvi)
|
||||||
if [ x$DISPLAY = x ]; then
|
if [ -z "$DISPLAY" ]; then
|
||||||
dvisvga "${MC_EXT_FILENAME}"
|
dvisvga "${MC_EXT_FILENAME}" || \
|
||||||
|
dvi2tty "${MC_EXT_FILENAME}" | ${PAGER:-more}
|
||||||
else
|
else
|
||||||
(xdvi "${MC_EXT_FILENAME}" &)
|
(xdvi "${MC_EXT_FILENAME}" &)
|
||||||
fi
|
fi
|
||||||
|
@ -33,7 +33,7 @@ do_open_action() {
|
|||||||
(gimp "${MC_EXT_FILENAME}" &)
|
(gimp "${MC_EXT_FILENAME}" &)
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
if [ "$DISPLAY" = "" ]; then
|
if [ -z "$DISPLAY" ]; then
|
||||||
zgv "${MC_EXT_FILENAME}"
|
zgv "${MC_EXT_FILENAME}"
|
||||||
else
|
else
|
||||||
(gqview "${MC_EXT_FILENAME}" &)
|
(gqview "${MC_EXT_FILENAME}" &)
|
||||||
|
@ -32,7 +32,7 @@ do_open_action() {
|
|||||||
|
|
||||||
case "${filetype}" in
|
case "${filetype}" in
|
||||||
common)
|
common)
|
||||||
if [ "$DISPLAY" = "" ]; then
|
if [ -z "$DISPLAY" ]; then
|
||||||
play "${MC_EXT_FILENAME}"
|
play "${MC_EXT_FILENAME}"
|
||||||
else
|
else
|
||||||
(xmms "${MC_EXT_FILENAME}" >/dev/null 2>&1 &)
|
(xmms "${MC_EXT_FILENAME}" >/dev/null 2>&1 &)
|
||||||
@ -46,14 +46,14 @@ do_open_action() {
|
|||||||
vplay -s 22 "${MC_EXT_FILENAME}"
|
vplay -s 22 "${MC_EXT_FILENAME}"
|
||||||
;;
|
;;
|
||||||
mp3)
|
mp3)
|
||||||
if [ "$DISPLAY" = "" ]; then
|
if [ -z "$DISPLAY" ]; then
|
||||||
mpg123 "${MC_EXT_FILENAME}"
|
mpg123 "${MC_EXT_FILENAME}"
|
||||||
else
|
else
|
||||||
(xmms "${MC_EXT_FILENAME}" >/dev/null 2>&1 &)
|
(xmms "${MC_EXT_FILENAME}" >/dev/null 2>&1 &)
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
ogg)
|
ogg)
|
||||||
if [ "$DISPLAY" = "" ]; then
|
if [ -z "$DISPLAY" ]; then
|
||||||
ogg123 "${MC_EXT_FILENAME}"
|
ogg123 "${MC_EXT_FILENAME}"
|
||||||
else
|
else
|
||||||
(xmms "${MC_EXT_FILENAME}" >/dev/null 2>&1 &)
|
(xmms "${MC_EXT_FILENAME}" >/dev/null 2>&1 &)
|
||||||
|
@ -112,7 +112,14 @@ do_open_action() {
|
|||||||
esac | ${pager}
|
esac | ${pager}
|
||||||
;;
|
;;
|
||||||
chm)
|
chm)
|
||||||
which kchmviewer > /dev/null 2>&1 && (kchmviewer "${MC_EXT_FILENAME}" &) || (xchm "${MC_EXT_FILENAME}" &)
|
if [ -n "$DISPLAY" ]; then
|
||||||
|
which kchmviewer > /dev/null 2>&1 \
|
||||||
|
&& (kchmviewer "${MC_EXT_FILENAME}" &) \
|
||||||
|
|| (xchm "${MC_EXT_FILENAME}" &)
|
||||||
|
else
|
||||||
|
chm_http "${MC_EXT_FILENAME}" & elinks http://localhost:8080/index.html
|
||||||
|
kill -INT %1
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
;;
|
;;
|
||||||
|
@ -25,7 +25,11 @@ do_open_action() {
|
|||||||
(realplay "${MC_EXT_FILENAME}" >/dev/null 2>&1 &)
|
(realplay "${MC_EXT_FILENAME}" >/dev/null 2>&1 &)
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
(mplayer "${MC_EXT_FILENAME}" >/dev/null 2>&1 &)
|
if [ -z "$DISPLAY" ]; then
|
||||||
|
mplayer -vo null "${MC_EXT_FILENAME}"
|
||||||
|
else
|
||||||
|
(mplayer "${MC_EXT_FILENAME}" >/dev/null 2>&1 &)
|
||||||
|
fi
|
||||||
#(gtv "${MC_EXT_FILENAME}" >/dev/null 2>&1 &)
|
#(gtv "${MC_EXT_FILENAME}" >/dev/null 2>&1 &)
|
||||||
#(xanim "${MC_EXT_FILENAME}" >/dev/null 2>&1 &)
|
#(xanim "${MC_EXT_FILENAME}" >/dev/null 2>&1 &)
|
||||||
;;
|
;;
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
action=$1
|
action=$1
|
||||||
filetype=$2
|
filetype=$2
|
||||||
|
|
||||||
|
|
||||||
do_view_action() {
|
do_view_action() {
|
||||||
filetype=$1
|
filetype=$1
|
||||||
|
|
||||||
@ -26,10 +25,11 @@ do_open_action() {
|
|||||||
|
|
||||||
case "${filetype}" in
|
case "${filetype}" in
|
||||||
html)
|
html)
|
||||||
(if test -n "@X11_WWW@" && test -n "$DISPLAY"; then
|
(if [ -n "@X11_WWW@" -a -n "$DISPLAY" ]; then
|
||||||
(@X11_WWW@ file://"${MC_EXT_CURRENTDIR}"/"${MC_EXT_BASENAME}" &) 1>&2
|
(@X11_WWW@ file://"${MC_EXT_CURRENTDIR}"/"${MC_EXT_BASENAME}" &) 1>&2
|
||||||
else
|
else
|
||||||
links "${MC_EXT_FILENAME}" || \
|
elinks "${MC_EXT_FILENAME}" || \
|
||||||
|
links "${MC_EXT_FILENAME}" || \
|
||||||
lynx -force_html "${MC_EXT_FILENAME}" || \
|
lynx -force_html "${MC_EXT_FILENAME}" || \
|
||||||
${PAGER:-more} "${MC_EXT_FILENAME}"
|
${PAGER:-more} "${MC_EXT_FILENAME}"
|
||||||
fi) 2>/dev/null
|
fi) 2>/dev/null
|
||||||
|
@ -564,6 +564,10 @@ type/^Microsoft\ Excel
|
|||||||
Open=@EXTHELPERSDIR@/doc.sh open msxls
|
Open=@EXTHELPERSDIR@/doc.sh open msxls
|
||||||
View=%view{ascii} @EXTHELPERSDIR@/doc.sh view msxls
|
View=%view{ascii} @EXTHELPERSDIR@/doc.sh view msxls
|
||||||
|
|
||||||
|
regex/i/\.(ppt|pps)$
|
||||||
|
Open=@EXTHELPERSDIR@/doc.sh open msppt
|
||||||
|
View=%view{ascii} @EXTHELPERSDIR@/doc.sh view msppt
|
||||||
|
|
||||||
# Use OpenOffice.org to open any MS Office documents
|
# Use OpenOffice.org to open any MS Office documents
|
||||||
type/^Microsoft\ Office\ Document
|
type/^Microsoft\ Office\ Document
|
||||||
Open=@EXTHELPERSDIR@/doc.sh open ooffice
|
Open=@EXTHELPERSDIR@/doc.sh open ooffice
|
||||||
|
Loading…
Reference in New Issue
Block a user