From: Jaesup Kwak <veshboo@gmail.com>
To: 29565@debbugs.gnu.org
Subject: bug#29565: [PATCH] Support xwidget webkit for macOS X
Date: Fri, 15 Dec 2017 11:01:27 +0900 [thread overview]
Message-ID: <CAADX8xJ+QDBPOtn+_Sg8+hJHSFMuCjOK4JB75XnygyH3Uetdiw@mail.gmail.com> (raw)
In-Reply-To: <CAADX8xLDj_vWMhEHV0PhfucjuWm7OHXe8Cg2mjVnxZGE-z3O+w@mail.gmail.com>
[-- Attachment #1.1: Type: text/plain, Size: 229 bytes --]
Enhance xwidget webkit scroll (Bug#29565)
Add key map 'S-SPC' for scroll down page.
Correct remappings for scroll by page and by line.
Add 'xwidget-webkit-scroll-line-height' variable.
Fix scroll to bottom function.
Thank you.
[-- Attachment #1.2: Type: text/html, Size: 356 bytes --]
[-- Attachment #2: 0001-Enhance-xwidget-webkit-scroll-Bug-29565.patch --]
[-- Type: application/octet-stream, Size: 5211 bytes --]
From 36cb782cb203c0f9bddfa5a4e138bbfe1aabf834 Mon Sep 17 00:00:00 2001
From: Jaesup Kwak <veshboo@gmail.com>
Date: Fri, 15 Dec 2017 10:05:27 +0900
Subject: [PATCH] Enhance xwidget webkit scroll (Bug#29565)
Add key map 'S-SPC' for scroll down page.
Correct remappings for scroll by page and by line.
Add 'xwidget-webkit-scroll-line-height' variable.
Fix scroll to bottom function.
* lisp/xwidget.el
(xwidget-webkit-mode-map): Well suited scroll key mappings.
(xwidget-webkit-scroll-up, xwidget-webkit-scroll-down): Add optional
argument, scroll by a screen page by default.
(xwidget-webkit-scroll-line-height): Add variable.
(xwidget-webkit-scroll-up-line, xwidget-webkit-scroll-down-line): New
functions to scroll by lines.
(xwidget-webkit-scroll-bottom): Fix to scroll to bottom of the
document.
---
lisp/xwidget.el | 55 +++++++++++++++++++++++++++++++++++++++++--------------
1 file changed, 41 insertions(+), 14 deletions(-)
diff --git a/lisp/xwidget.el b/lisp/xwidget.el
index e5b3fb2ad9..386b2d84ee 100644
--- a/lisp/xwidget.el
+++ b/lisp/xwidget.el
@@ -135,20 +135,21 @@ xwidget-webkit-mode-map
;;similar to image mode bindings
(define-key map (kbd "SPC") 'xwidget-webkit-scroll-up)
+ (define-key map (kbd "S-SPC") 'xwidget-webkit-scroll-down)
(define-key map (kbd "DEL") 'xwidget-webkit-scroll-down)
- (define-key map [remap scroll-up] 'xwidget-webkit-scroll-up)
+ (define-key map [remap scroll-up] 'xwidget-webkit-scroll-up-line)
(define-key map [remap scroll-up-command] 'xwidget-webkit-scroll-up)
- (define-key map [remap scroll-down] 'xwidget-webkit-scroll-down)
+ (define-key map [remap scroll-down] 'xwidget-webkit-scroll-down-line)
(define-key map [remap scroll-down-command] 'xwidget-webkit-scroll-down)
(define-key map [remap forward-char] 'xwidget-webkit-scroll-forward)
(define-key map [remap backward-char] 'xwidget-webkit-scroll-backward)
(define-key map [remap right-char] 'xwidget-webkit-scroll-forward)
(define-key map [remap left-char] 'xwidget-webkit-scroll-backward)
- (define-key map [remap previous-line] 'xwidget-webkit-scroll-down)
- (define-key map [remap next-line] 'xwidget-webkit-scroll-up)
+ (define-key map [remap previous-line] 'xwidget-webkit-scroll-down-line)
+ (define-key map [remap next-line] 'xwidget-webkit-scroll-up-line)
;; (define-key map [remap move-beginning-of-line] 'image-bol)
;; (define-key map [remap move-end-of-line] 'image-eol)
@@ -173,19 +174,45 @@ xwidget-webkit-zoom-out
(interactive)
(xwidget-webkit-zoom (xwidget-webkit-current-session) -0.1))
-(defun xwidget-webkit-scroll-up ()
- "Scroll webkit up."
- (interactive)
+(defun xwidget-webkit-scroll-up (&optional n)
+ "Scroll webkit up by N pixels or window height pixels.
+Stop if the bottom edge of the page is reached.
+If N is omitted or nil, scroll up by window height pixels."
+ (interactive "P")
+ (message "scroll-up n=%S" n)
(xwidget-webkit-execute-script
(xwidget-webkit-current-session)
- "window.scrollBy(0, 50);"))
-
-(defun xwidget-webkit-scroll-down ()
- "Scroll webkit down."
- (interactive)
+ (cond ((null n) "window.scrollBy(0, window.document.body.clientHeight);")
+ (t (format "window.scrollBy(0, %d);" n)))))
+
+(defun xwidget-webkit-scroll-down (&optional n)
+ "Scroll webkit down by N pixels or window height pixels.
+Stop if the top edge of the page is reached.
+If N is omitted or nil, scroll down by window height pixels."
+ (interactive "P")
(xwidget-webkit-execute-script
(xwidget-webkit-current-session)
- "window.scrollBy(0, -50);"))
+ (cond ((null n) "window.scrollBy(0, -window.document.body.clientHeight);")
+ (t (format "window.scrollBy(0, %d);" (- n))))))
+
+(defvar xwidget-webkit-scroll-line-height 50
+ "Default line height in pixels for scroll xwidget webkit.")
+
+(defun xwidget-webkit-scroll-up-line (&optional n)
+ "Scroll webkit up by N lines.
+The height of line is `xwidget-webkit-scroll-line-height' pixels.
+Stop if the bottom edge of the page is reached.
+If N is omitted or nil, scroll up by one line."
+ (interactive "p")
+ (xwidget-webkit-scroll-up (* n xwidget-webkit-scroll-line-height)))
+
+(defun xwidget-webkit-scroll-down-line (&optional n)
+ "Scroll webkit down by N lines.
+The height of line is `xwidget-webkit-scroll-line-height' pixels.
+Stop if the top edge of the page is reached.
+If N is omitted or nil, scroll down by one line."
+ (interactive "p")
+ (xwidget-webkit-scroll-down (* n xwidget-webkit-scroll-line-height)))
(defun xwidget-webkit-scroll-forward ()
"Scroll webkit forwards."
@@ -213,7 +240,7 @@ xwidget-webkit-scroll-bottom
(interactive)
(xwidget-webkit-execute-script
(xwidget-webkit-current-session)
- "window.scrollTo(pageXOffset, window.document.body.clientHeight);"))
+ "window.scrollTo(pageXOffset, window.document.body.scrollHeight);"))
;; The xwidget event needs to go into a higher level handler
;; since the xwidget can generate an event even if it's offscreen.
--
2.15.0
next prev parent reply other threads:[~2017-12-15 2:01 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-04 16:44 bug#29565: [PATCH] Support xwidget webkit for macOS X Jaesup Kwak
2017-12-04 20:59 ` Alan Third
2017-12-05 6:01 ` Jaesup Kwak
2017-12-05 7:55 ` Jaesup Kwak
2017-12-05 20:00 ` Alan Third
2017-12-06 5:59 ` Jaesup Kwak
2017-12-06 6:20 ` Jaesup Kwak
2017-12-13 11:15 ` Jaesup Kwak
2017-12-13 11:27 ` Jaesup Kwak
2017-12-13 16:13 ` Jaesup Kwak
2017-12-15 2:01 ` Jaesup Kwak [this message]
2017-12-15 2:27 ` Jaesup Kwak
2017-12-15 16:06 ` Jaesup Kwak
2017-12-20 2:39 ` bug#29565: [PATCH] Fix compile failure for GTK xwidget (Bug#29565) Jaesup Kwak
2017-12-20 8:25 ` bug#29565: [PATCH] Enable plugins for ns xwidget webkit (Bug#29565) Jaesup Kwak
2017-12-21 4:12 ` bug#29565: [PATCH] Support file download and upload (Bug#29565) Jaesup Kwak
2018-03-30 11:48 ` bug#29565: [PATCH] Support xwidget webkit for macOS X Alan Third
2018-03-30 12:19 ` Jaesup Kwak
2019-09-28 23:52 ` Stefan Kangas
2020-08-10 13:55 ` Lars Ingebrigtsen
2020-08-10 19:06 ` Alan Third
2020-08-11 11:04 ` Lars Ingebrigtsen
2020-08-11 15:22 ` Eli Zaretskii
2020-08-11 16:26 ` Lars Ingebrigtsen
2020-08-11 18:28 ` Eli Zaretskii
2020-08-11 19:26 ` Lars Ingebrigtsen
2020-08-11 19:33 ` Eli Zaretskii
2020-08-12 10:44 ` Lars Ingebrigtsen
2020-08-11 19:56 ` Alan Third
2020-08-11 19:58 ` Lars Ingebrigtsen
2020-08-11 20:18 ` Alan Third
2020-08-11 20:29 ` Lars Ingebrigtsen
2020-08-11 20:35 ` Alan Third
2020-08-11 20:50 ` Lars Ingebrigtsen
2020-08-12 3:46 ` Unknown
2020-08-12 10:05 ` Lars Ingebrigtsen
2020-08-12 16:34 ` Alan Third
2020-08-12 2:26 ` Richard Stallman
2020-08-12 4:13 ` Eli Zaretskii
2020-08-12 4:27 ` Eli Zaretskii
2020-08-13 3:43 ` Richard Stallman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAADX8xJ+QDBPOtn+_Sg8+hJHSFMuCjOK4JB75XnygyH3Uetdiw@mail.gmail.com \
--to=veshboo@gmail.com \
--cc=29565@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.