Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[47_2] glue: open_url impl in Qt #1282

Merged
merged 2 commits into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions TeXmacs/progs/prog/glue-symbols.scm
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,7 @@
"system-1"
"system-2"
"system-url->string"
"open-url"
"url-grep"
"url-search-upwards"
"picture-cache-reset"
Expand Down
14 changes: 1 addition & 13 deletions TeXmacs/progs/texmacs/texmacs/tm-files.scm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions src/Plugins/Qt/qt_sys_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
#include <QProcess>
#include <QString>
#include <QSysInfo>
#include <QDesktopServices>
#include <QUrl>


string qt_get_current_cpu_arch () {
Expand All @@ -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));
}
4 changes: 3 additions & 1 deletion src/Plugins/Qt/qt_sys_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#define QT_SYS_UTILS_H

#include "string.hpp"
#include "url.hpp"


string qt_get_current_cpu_arch ();
Expand All @@ -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
8 changes: 8 additions & 0 deletions src/Scheme/L3/glue_misc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 6 additions & 0 deletions src/System/Misc/tm_sys_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
2 changes: 2 additions & 0 deletions src/System/Misc/tm_sys_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,6 @@ void set_printing_cmd (string cmd);

const char* default_look_and_feel ();

void open_url (url u);

#endif
Loading