From ce07bec728024f3a6dccfcc997bb78877f46d608 Mon Sep 17 00:00:00 2001 From: Slava Zanko Date: Fri, 18 May 2012 18:42:26 +0300 Subject: [PATCH 1/4] 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 --- misc/ext.d/doc.sh.in | 96 ++++++++++++++++++++++++++++++++++++++----- misc/ext.d/image.sh | 2 +- misc/ext.d/sound.sh | 6 +-- misc/ext.d/text.sh.in | 9 +++- misc/ext.d/video.sh | 6 ++- misc/ext.d/web.sh.in | 6 +-- misc/mc.ext.in | 4 ++ 7 files changed, 109 insertions(+), 20 deletions(-) diff --git a/misc/ext.d/doc.sh.in b/misc/ext.d/doc.sh.in index 57723e6bd..521642679 100644 --- a/misc/ext.d/doc.sh.in +++ b/misc/ext.d/doc.sh.in @@ -7,6 +7,22 @@ action=$1 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() { filetype=$1 @@ -15,19 +31,36 @@ do_view_action() { ps2ascii "${MC_EXT_FILENAME}" ;; pdf) - pdftotext "${MC_EXT_FILENAME}" - + pdftotext -layout -nopgbrk "${MC_EXT_FILENAME}" - ;; 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) - 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}" || \ word2x -f text "${MC_EXT_FILENAME}" - || \ strings "${MC_EXT_FILENAME}" ;; 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}" ;; dvi) @@ -46,31 +79,72 @@ do_open_action() { case "${filetype}" in ps) - (gv "${MC_EXT_FILENAME}" &) + if [ -n "$DISPLAY" ]; then + (gv "${MC_EXT_FILENAME}" &) + else + ps2ascii "${MC_EXT_FILENAME}" | ${PAGER:-more} + fi ;; 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}" &) #(ghostview "${MC_EXT_FILENAME}" &) ;; 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) (abiword "${MC_EXT_FILENAME}" &) ;; 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) - (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) fmclient -f "${MC_EXT_FILENAME}" ;; dvi) - if [ x$DISPLAY = x ]; then - dvisvga "${MC_EXT_FILENAME}" + if [ -z "$DISPLAY" ]; then + dvisvga "${MC_EXT_FILENAME}" || \ + dvi2tty "${MC_EXT_FILENAME}" | ${PAGER:-more} else (xdvi "${MC_EXT_FILENAME}" &) fi diff --git a/misc/ext.d/image.sh b/misc/ext.d/image.sh index 89dcd8b9d..f19c02937 100644 --- a/misc/ext.d/image.sh +++ b/misc/ext.d/image.sh @@ -33,7 +33,7 @@ do_open_action() { (gimp "${MC_EXT_FILENAME}" &) ;; *) - if [ "$DISPLAY" = "" ]; then + if [ -z "$DISPLAY" ]; then zgv "${MC_EXT_FILENAME}" else (gqview "${MC_EXT_FILENAME}" &) diff --git a/misc/ext.d/sound.sh b/misc/ext.d/sound.sh index 33f00e032..962426358 100644 --- a/misc/ext.d/sound.sh +++ b/misc/ext.d/sound.sh @@ -32,7 +32,7 @@ do_open_action() { case "${filetype}" in common) - if [ "$DISPLAY" = "" ]; then + if [ -z "$DISPLAY" ]; then play "${MC_EXT_FILENAME}" else (xmms "${MC_EXT_FILENAME}" >/dev/null 2>&1 &) @@ -46,14 +46,14 @@ do_open_action() { vplay -s 22 "${MC_EXT_FILENAME}" ;; mp3) - if [ "$DISPLAY" = "" ]; then + if [ -z "$DISPLAY" ]; then mpg123 "${MC_EXT_FILENAME}" else (xmms "${MC_EXT_FILENAME}" >/dev/null 2>&1 &) fi ;; ogg) - if [ "$DISPLAY" = "" ]; then + if [ -z "$DISPLAY" ]; then ogg123 "${MC_EXT_FILENAME}" else (xmms "${MC_EXT_FILENAME}" >/dev/null 2>&1 &) diff --git a/misc/ext.d/text.sh.in b/misc/ext.d/text.sh.in index 5efd04bbb..65211a5ca 100644 --- a/misc/ext.d/text.sh.in +++ b/misc/ext.d/text.sh.in @@ -112,7 +112,14 @@ do_open_action() { esac | ${pager} ;; 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 ;; *) ;; diff --git a/misc/ext.d/video.sh b/misc/ext.d/video.sh index 8b7652662..6db599c6a 100644 --- a/misc/ext.d/video.sh +++ b/misc/ext.d/video.sh @@ -25,7 +25,11 @@ do_open_action() { (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 &) #(xanim "${MC_EXT_FILENAME}" >/dev/null 2>&1 &) ;; diff --git a/misc/ext.d/web.sh.in b/misc/ext.d/web.sh.in index d00d717cd..f7531449c 100644 --- a/misc/ext.d/web.sh.in +++ b/misc/ext.d/web.sh.in @@ -6,7 +6,6 @@ action=$1 filetype=$2 - do_view_action() { filetype=$1 @@ -26,10 +25,11 @@ do_open_action() { case "${filetype}" in 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 else - links "${MC_EXT_FILENAME}" || \ + elinks "${MC_EXT_FILENAME}" || \ + links "${MC_EXT_FILENAME}" || \ lynx -force_html "${MC_EXT_FILENAME}" || \ ${PAGER:-more} "${MC_EXT_FILENAME}" fi) 2>/dev/null diff --git a/misc/mc.ext.in b/misc/mc.ext.in index 322e8bb33..5eb80aed2 100644 --- a/misc/mc.ext.in +++ b/misc/mc.ext.in @@ -564,6 +564,10 @@ type/^Microsoft\ Excel Open=@EXTHELPERSDIR@/doc.sh open 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 type/^Microsoft\ Office\ Document Open=@EXTHELPERSDIR@/doc.sh open ooffice From 8498c6afe010953170dfcd99d4d7db2c08446407 Mon Sep 17 00:00:00 2001 From: Slava Zanko Date: Fri, 18 May 2012 18:48:03 +0300 Subject: [PATCH 2/4] Added support of SQLite database files Signed-off-by: Slava Zanko --- misc/ext.d/misc.sh.in | 6 ++++++ misc/mc.ext.in | 7 ++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/misc/ext.d/misc.sh.in b/misc/ext.d/misc.sh.in index ea80ced73..4a8103567 100644 --- a/misc/ext.d/misc.sh.in +++ b/misc/ext.d/misc.sh.in @@ -32,6 +32,9 @@ do_view_action() { dbf) dbview -b "${MC_EXT_FILENAME}" ;; + sqlite) + sqlite3 "${MC_EXT_FILENAME}" .dump + ;; mo) msgunfmt "${MC_EXT_FILENAME}" || \ cat "${MC_EXT_FILENAME}" @@ -57,6 +60,9 @@ do_open_action() { dbf) dbview "${MC_EXT_FILENAME}" ;; + sqlite) + sqlite3 "${MC_EXT_FILENAME}" + ;; glade) if glade-3 --version >/dev/null 2>&1; then (glade-3 "${MC_EXT_FILENAME}" >/dev/null 2>&1 &) diff --git a/misc/mc.ext.in b/misc/mc.ext.in index 5eb80aed2..9f65f1f00 100644 --- a/misc/mc.ext.in +++ b/misc/mc.ext.in @@ -604,9 +604,14 @@ shell/Imakefile regex/^Makefile.(PL|pl)$ Open=%var{PERL:perl} %f +# sqlite3.db +type/^SQLite 3.x database + Open=@EXTHELPERSDIR@/misc.sh open sqlite + View=%view{ascii} @EXTHELPERSDIR@/misc.sh view sqlite + # dbf shell/i/.dbf - Open=%view{ascii} @EXTHELPERSDIR@/misc.sh open dbf + Open=@EXTHELPERSDIR@/misc.sh open dbf View=%view{ascii} @EXTHELPERSDIR@/misc.sh view dbf # REXX script From aa5ffa2b87be2de67b5d8d45e6fef35db77f23c9 Mon Sep 17 00:00:00 2001 From: Slava Zanko Date: Tue, 26 Jun 2012 15:39:31 +0300 Subject: [PATCH 3/4] changed type of checking: used -n operator instead of -z Signed-off-by: Slava Zanko --- misc/ext.d/doc.sh.in | 6 +++--- misc/ext.d/image.sh | 6 +++--- misc/ext.d/sound.sh | 24 ++++++++++++------------ misc/ext.d/video.sh | 6 +++--- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/misc/ext.d/doc.sh.in b/misc/ext.d/doc.sh.in index 521642679..d59875332 100644 --- a/misc/ext.d/doc.sh.in +++ b/misc/ext.d/doc.sh.in @@ -142,11 +142,11 @@ do_open_action() { fmclient -f "${MC_EXT_FILENAME}" ;; dvi) - if [ -z "$DISPLAY" ]; then + if [ -n "$DISPLAY" ]; then + (xdvi "${MC_EXT_FILENAME}" &) + else dvisvga "${MC_EXT_FILENAME}" || \ dvi2tty "${MC_EXT_FILENAME}" | ${PAGER:-more} - else - (xdvi "${MC_EXT_FILENAME}" &) fi ;; djvu) diff --git a/misc/ext.d/image.sh b/misc/ext.d/image.sh index f19c02937..e09f92f9e 100644 --- a/misc/ext.d/image.sh +++ b/misc/ext.d/image.sh @@ -33,10 +33,10 @@ do_open_action() { (gimp "${MC_EXT_FILENAME}" &) ;; *) - if [ -z "$DISPLAY" ]; then - zgv "${MC_EXT_FILENAME}" - else + if [ -n "$DISPLAY" ]; then (gqview "${MC_EXT_FILENAME}" &) + else + zgv "${MC_EXT_FILENAME}" fi ;; esac diff --git a/misc/ext.d/sound.sh b/misc/ext.d/sound.sh index 962426358..913bf23c3 100644 --- a/misc/ext.d/sound.sh +++ b/misc/ext.d/sound.sh @@ -32,10 +32,10 @@ do_open_action() { case "${filetype}" in common) - if [ -z "$DISPLAY" ]; then - play "${MC_EXT_FILENAME}" - else + if [ -n "$DISPLAY" ]; then (xmms "${MC_EXT_FILENAME}" >/dev/null 2>&1 &) + else + play "${MC_EXT_FILENAME}" fi ;; mod) @@ -46,17 +46,17 @@ do_open_action() { vplay -s 22 "${MC_EXT_FILENAME}" ;; mp3) - if [ -z "$DISPLAY" ]; then - mpg123 "${MC_EXT_FILENAME}" - else + if [ -n "$DISPLAY" ]; then (xmms "${MC_EXT_FILENAME}" >/dev/null 2>&1 &) + else + mpg123 "${MC_EXT_FILENAME}" fi ;; ogg) - if [ -z "$DISPLAY" ]; then - ogg123 "${MC_EXT_FILENAME}" - else + if [ -n "$DISPLAY" ]; then (xmms "${MC_EXT_FILENAME}" >/dev/null 2>&1 &) + else + ogg123 "${MC_EXT_FILENAME}" fi ;; midi) @@ -66,10 +66,10 @@ do_open_action() { mplayer -vo null "${MC_EXT_FILENAME}" ;; playlist) - if [ -z "$DISPLAY" ]; then - mplayer -vo null -playlist "${MC_EXT_FILENAME}" - else + if [ -n "$DISPLAY" ]; then (xmms -p "${MC_EXT_FILENAME}" >/dev/null 2>&1 &) + else + mplayer -vo null -playlist "${MC_EXT_FILENAME}" fi ;; *) diff --git a/misc/ext.d/video.sh b/misc/ext.d/video.sh index 6db599c6a..bb89cee15 100644 --- a/misc/ext.d/video.sh +++ b/misc/ext.d/video.sh @@ -25,10 +25,10 @@ do_open_action() { (realplay "${MC_EXT_FILENAME}" >/dev/null 2>&1 &) ;; *) - if [ -z "$DISPLAY" ]; then - mplayer -vo null "${MC_EXT_FILENAME}" - else + if [ -n "$DISPLAY" ]; then (mplayer "${MC_EXT_FILENAME}" >/dev/null 2>&1 &) + else + mplayer -vo null "${MC_EXT_FILENAME}" fi #(gtv "${MC_EXT_FILENAME}" >/dev/null 2>&1 &) #(xanim "${MC_EXT_FILENAME}" >/dev/null 2>&1 &) From b03da1c3b373049c8ba985ba8a8d58e945e78262 Mon Sep 17 00:00:00 2001 From: Slava Zanko Date: Mon, 27 Aug 2012 11:09:30 +0300 Subject: [PATCH 4/4] Added support of viewing the compiled Java files (*.class). Signed-off-by: Slava Zanko --- misc/ext.d/misc.sh.in | 3 +++ misc/mc.ext.in | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/misc/ext.d/misc.sh.in b/misc/ext.d/misc.sh.in index 4a8103567..80776bf0c 100644 --- a/misc/ext.d/misc.sh.in +++ b/misc/ext.d/misc.sh.in @@ -45,6 +45,9 @@ do_view_action() { torrent) ctorrent -x "${MC_EXT_FILENAME}" 2>/dev/null ;; + javaclass) + jad -p "${MC_EXT_FILENAME}" 2>/dev/null + ;; *) ;; esac diff --git a/misc/mc.ext.in b/misc/mc.ext.in index 9f65f1f00..0636d2bfc 100644 --- a/misc/mc.ext.in +++ b/misc/mc.ext.in @@ -592,6 +592,10 @@ regex/i/\.djvu?$ ### Miscellaneous ### +# Compiled Java classes +shell/.class + View=%view{ascii} @EXTHELPERSDIR@/misc.sh view javaclass + # Makefile regex/[Mm]akefile$ Open=make -f %f %{Enter parameters}