Skip to content

Commit

Permalink
[47_3] Fix preview-buffer via open-url
Browse files Browse the repository at this point in the history
  • Loading branch information
da-liii committed Oct 19, 2023
1 parent c2788f2 commit 861b992
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 26 deletions.
26 changes: 2 additions & 24 deletions TeXmacs/progs/texmacs/texmacs/tm-print.scm
Original file line number Diff line number Diff line change
Expand Up @@ -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)))

Expand Down
10 changes: 8 additions & 2 deletions src/Plugins/Qt/qt_sys_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "basic.hpp"
#include "string.hpp"
#include "tm_debug.hpp"
#include "file.hpp"

#include <QProcess>
#include <QString>
Expand All @@ -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));
}
}

0 comments on commit 861b992

Please sign in to comment.