From 861b9926c7fd7122f0d122765b67aed2d4d120eb Mon Sep 17 00:00:00 2001 From: Darcy Shen Date: Thu, 19 Oct 2023 20:12:37 +0800 Subject: [PATCH] [47_3] Fix preview-buffer via open-url --- TeXmacs/progs/texmacs/texmacs/tm-print.scm | 26 ++-------------------- src/Plugins/Qt/qt_sys_utils.cpp | 10 +++++++-- 2 files changed, 10 insertions(+), 26 deletions(-) diff --git a/TeXmacs/progs/texmacs/texmacs/tm-print.scm b/TeXmacs/progs/texmacs/texmacs/tm-print.scm index d4cc10b342..0b10a070cc 100644 --- a/TeXmacs/progs/texmacs/texmacs/tm-print.scm +++ b/TeXmacs/progs/texmacs/texmacs/tm-print.scm @@ -163,32 +163,10 @@ (:proposals last (list (number->string (get-page-count)) ""))) (tm-define (preview-file u) - (with s (url-sys-concretize u) - (cond ((!= preview-command "default") - (shell (string-append preview-command " " s " &"))) - ((or (os-mingw?) (os-win32?)) - (shell (string-append "cmd /c start " s))) - ((os-macos?) - (shell (string-append "open " s))) - ((url-exists-in-path? "xdg-open") - (shell (string-append "xdg-open " s))) - ((url-exists-in-path? "ggv") - (shell (string-append "ggv " s " &"))) - ((url-exists-in-path? "ghostview") - (shell (string-append "ghostview " s " &"))) - ((url-exists-in-path? "gv") - (shell (string-append "gv " s " &"))) - (else (set-message - "Error: ghostview does not seem to be installed on your system" - "preview"))))) + (open-url u)) (tm-define (preview-buffer) - (with file (system->url - (cond ((os-mingw?) - "$TEXMACS_HOME_PATH/system/tmp/preview.pdf") - ((or (os-macos?) (get-boolean-preference "native pdf")) - "$TEXMACS_HOME_PATH/system/tmp/preview.pdf") - (else "$TEXMACS_HOME_PATH/system/tmp/preview.ps"))) + (with file (url-glue (url-temp) (if (supports-native-pdf?) ".pdf" ".ps")) (print-to-file file) (preview-file file))) diff --git a/src/Plugins/Qt/qt_sys_utils.cpp b/src/Plugins/Qt/qt_sys_utils.cpp index e1eb78bd45..9404e8952e 100644 --- a/src/Plugins/Qt/qt_sys_utils.cpp +++ b/src/Plugins/Qt/qt_sys_utils.cpp @@ -14,6 +14,7 @@ #include "basic.hpp" #include "string.hpp" #include "tm_debug.hpp" +#include "file.hpp" #include #include @@ -31,6 +32,11 @@ string qt_get_pretty_os_name () { } void qt_open_url (url u) { - QString link = to_qstring (as_string (u)); - QDesktopServices::openUrl (QUrl (link)); + if (is_rooted_web (u) || is_rooted (u, "file")) { + QString link = to_qstring (as_string (u)); + QDesktopServices::openUrl (QUrl (link)); + } else if (is_local_and_single (u)) { + QString link = to_qstring ("file:///" * as_string (u)); + QDesktopServices::openUrl (QUrl (link)); + } }