diff --git a/TeXmacs/progs/prog/glue-symbols.scm b/TeXmacs/progs/prog/glue-symbols.scm index 8a85ecf919..0549b288aa 100644 --- a/TeXmacs/progs/prog/glue-symbols.scm +++ b/TeXmacs/progs/prog/glue-symbols.scm @@ -580,6 +580,7 @@ "system-1" "system-2" "system-url->string" +"open-url" "url-grep" "url-search-upwards" "picture-cache-reset" diff --git a/TeXmacs/progs/texmacs/texmacs/tm-files.scm b/TeXmacs/progs/texmacs/texmacs/tm-files.scm index 291c77e060..a46aad8dfc 100644 --- a/TeXmacs/progs/texmacs/texmacs/tm-files.scm +++ b/TeXmacs/progs/texmacs/texmacs/tm-files.scm @@ -418,22 +418,10 @@ (file-of-format? u "postscript") (file-of-format? u "generic"))) -(tm-define (default-open) - (cond ((os-macos?) "open") - ((or (os-mingw?) (os-win32?)) "start") - (else "xdg-open"))) - (tm-define (load-external u) (when (not (url-rooted? u)) (set! u (url-relative (current-buffer) u))) - (cond ((not (url-rooted-web? u)) - (system-1 (default-open) u)) - ((or (os-mingw?) (os-win32?)) - (system (string-append (default-open) " " - (string-replace (url->system u) "&" "^&")))) - (else - (system (string-append (default-open) " " - (raw-quote (url->system u))))))) + (open-url u)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Loading buffers diff --git a/src/Plugins/Qt/qt_sys_utils.cpp b/src/Plugins/Qt/qt_sys_utils.cpp index 8b7a71d257..e1eb78bd45 100644 --- a/src/Plugins/Qt/qt_sys_utils.cpp +++ b/src/Plugins/Qt/qt_sys_utils.cpp @@ -18,6 +18,8 @@ #include #include #include +#include +#include string qt_get_current_cpu_arch () { @@ -27,3 +29,8 @@ string qt_get_current_cpu_arch () { string qt_get_pretty_os_name () { return from_qstring (QSysInfo::prettyProductName ()); } + +void qt_open_url (url u) { + QString link = to_qstring (as_string (u)); + QDesktopServices::openUrl (QUrl (link)); +} diff --git a/src/Plugins/Qt/qt_sys_utils.hpp b/src/Plugins/Qt/qt_sys_utils.hpp index 56e0569a15..951de90b27 100644 --- a/src/Plugins/Qt/qt_sys_utils.hpp +++ b/src/Plugins/Qt/qt_sys_utils.hpp @@ -13,6 +13,7 @@ #define QT_SYS_UTILS_H #include "string.hpp" +#include "url.hpp" string qt_get_current_cpu_arch (); @@ -28,5 +29,6 @@ int qt_system (string); int qt_system (string, string&); int qt_system (string, string&, string&); -#endif // defined QT_SYS_UTILS_H +void qt_open_url (url u); +#endif // defined QT_SYS_UTILS_H diff --git a/src/Scheme/L3/glue_misc.lua b/src/Scheme/L3/glue_misc.lua index 14a1053fe6..f19d8afdb0 100644 --- a/src/Scheme/L3/glue_misc.lua +++ b/src/Scheme/L3/glue_misc.lua @@ -116,6 +116,14 @@ function main() cpp_name = "default_look_and_feel", ret_type = "string" }, + { + scm_name = "open-url", + cpp_name = "open_url", + ret_type = "void", + arg_list = { + "url" + } + } } } end diff --git a/src/System/Misc/tm_sys_utils.cpp b/src/System/Misc/tm_sys_utils.cpp index 6bd627562e..20e226f6a5 100644 --- a/src/System/Misc/tm_sys_utils.cpp +++ b/src/System/Misc/tm_sys_utils.cpp @@ -154,3 +154,9 @@ default_look_and_feel () { static const char* ret= default_look_and_feel_impl (); return ret; } + +void open_url (url u) { +#ifdef QTTEXMACS + qt_open_url (u); +#endif +} diff --git a/src/System/Misc/tm_sys_utils.hpp b/src/System/Misc/tm_sys_utils.hpp index 60ea1fff52..dcf3e1618e 100644 --- a/src/System/Misc/tm_sys_utils.hpp +++ b/src/System/Misc/tm_sys_utils.hpp @@ -36,4 +36,6 @@ void set_printing_cmd (string cmd); const char* default_look_and_feel (); +void open_url (url u); + #endif