summaryrefslogtreecommitdiff
path: root/src/nsxwidget.m
diff options
context:
space:
mode:
authorSungbin Jo <pcr910303@icloud.com>2020-08-12 12:34:29 +0200
committerLars Ingebrigtsen <larsi@gnus.org>2020-08-12 12:34:39 +0200
commit9e1af8251fe241fa163e721f3e796c1e8cca86cf (patch)
treeadab8c4d0b919c5771fe978379260c96ae5711a1 /src/nsxwidget.m
parent433d8184970bd2d569744155d58cde2cd4807a0a (diff)
downloademacs-9e1af8251fe241fa163e721f3e796c1e8cca86cf.tar.gz
Add utility functions and new xwidget commands
Co-authored-by: Jaesup Kwak <veshboo@gmail.com> * etc/NEWS: Announce new functions and options. * lisp/xwidget.el (xwidget): New defgroup. (xwidget-webkit-mode-map): Add new keybindings. (xwidget-webkit-scroll-up, xwidget-webkit-scroll-down) (xwidget-webkit-scroll-forward, xwidget-webkit-scroll-backward): Add optional argument to specify specific amounts to scroll down. (xwidget-webkit-scroll-up-line, xwidget-webkit-scroll-down-line): New functions. (xwidget-webkit-scroll-bottom): Fix function to scroll to the bottom of the document. (xwidget-webkit-callback): Use new function to update buffer title even when Javascript is disabled. (xwidget-webkit-bookmark-jump-new-session): New variable. (xwidget-webkit-bookmark-make-record): Modify to use xwidget-webkit to open bookmark that is created in xwidget-webkit. (xwidget-webkit-insert-string): Fix Javascript snippet to not throw Javsscript exceptions. (xwidget-webkit-inside-pixel-width) (xwidget-window-inside-pixel-height): New functions. (xwidget-webkit-adjust-size-to-window): Use new functions. (xwidget-webkit-new-session): Insert invisible URL instead of an empty string to achieve better default behavior. (xwidget-webkit-back, xwidget-webkit-forward, xwidget-webkit-reload) (xwidget-webkit-current-url): Use new functions to enable scrolling even when Javascript is disabled. (xwidget-webkit-copy-selection-as-kill): Remove unnecessary lambda. * src/nsxwidget.h src/nsxwidget.m (nsxwidget_webkit_uri) (nsxwidget_webkit_title, nsxwidget_webkit_goto_history): Add new functions. * src/xwidget.c (Fxwidget_webkit_uri, Fxwidget_webkit_title) (Fxwidget_webkit_goto_history): Add new functions. (syms_of_xwidget): Define new functions.
Diffstat (limited to 'src/nsxwidget.m')
-rw-r--r--src/nsxwidget.m26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/nsxwidget.m b/src/nsxwidget.m
index c5376dd311c..8643ba24d80 100644
--- a/src/nsxwidget.m
+++ b/src/nsxwidget.m
@@ -292,6 +292,21 @@ nsxwidget_is_web_view (struct xwidget *xw)
return xw->xwWidget != NULL &&
[xw->xwWidget isKindOfClass:WKWebView.class];
}
+
+Lisp_Object
+nsxwidget_webkit_uri (struct xwidget *xw)
+{
+ XwWebView *xwWebView = (XwWebView *) xw->xwWidget;
+ return build_string_with_nsstr (xwWebView.URL.absoluteString);
+}
+
+Lisp_Object
+nsxwidget_webkit_title (struct xwidget *xw)
+{
+ XwWebView *xwWebView = (XwWebView *) xw->xwWidget;
+ return build_string_with_nsstr (xwWebView.title);
+}
+
/* @Note ATS - Need application transport security in 'Info.plist' or
remote pages will not loaded. */
void
@@ -305,6 +320,17 @@ nsxwidget_webkit_goto_uri (struct xwidget *xw, const char *uri)
}
void
+nsxwidget_webkit_goto_history (struct xwidget *xw, int rel_pos)
+{
+ XwWebView *xwWebView = (XwWebView *) xw->xwWidget;
+ switch (rel_pos) {
+ case -1: [xwWebView goBack]; break;
+ case 0: [xwWebView reload]; break;
+ case 1: [xwWebView goForward]; break;
+ }
+}
+
+void
nsxwidget_webkit_zoom (struct xwidget *xw, double zoom_change)
{
XwWebView *xwWebView = (XwWebView *) xw->xwWidget;