diff options
| author | Po Lu | 2021-11-12 17:48:56 +0800 |
|---|---|---|
| committer | Po Lu | 2021-11-12 17:50:20 +0800 |
| commit | 2803cabe890b3ec47f54ebaa63c84de588809a6f (patch) | |
| tree | f6b05b5c1c7755b055caccbf1b8ed5dea6bb5839 | |
| parent | 00e3baf6e32d39c8434f50e1f0b0a83ad2ad3aeb (diff) | |
| download | emacs-2803cabe890b3ec47f54ebaa63c84de588809a6f.tar.gz emacs-2803cabe890b3ec47f54ebaa63c84de588809a6f.zip | |
Add support for input methods to xwidget-webkit-edit-mode
* lisp/xwidget.el (xwidget-webkit--input-method-events): New
variable.
(xwidget-webkit-pass-command-event-with-input-method): New
function.
(xwidget-webkit-pass-command-event): Consult input method about
key events if input method is enabled.
| -rw-r--r-- | lisp/xwidget.el | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/lisp/xwidget.el b/lisp/xwidget.el index 3d4e96f92d0..e98143b9559 100644 --- a/lisp/xwidget.el +++ b/lisp/xwidget.el | |||
| @@ -146,11 +146,36 @@ in `split-window-right' with a new xwidget webkit session." | |||
| 146 | 146 | ||
| 147 | (declare-function xwidget-perform-lispy-event "xwidget.c") | 147 | (declare-function xwidget-perform-lispy-event "xwidget.c") |
| 148 | 148 | ||
| 149 | (defvar xwidget-webkit--input-method-events nil | ||
| 150 | "Internal variable used to store input method events.") | ||
| 151 | |||
| 152 | (defun xwidget-webkit-pass-command-event-with-input-method () | ||
| 153 | "Handle a `with-input-method' event." | ||
| 154 | (interactive) | ||
| 155 | (let ((key (pop unread-command-events))) | ||
| 156 | (setq xwidget-webkit--input-method-events | ||
| 157 | (funcall input-method-function key)) | ||
| 158 | (exit-minibuffer))) | ||
| 159 | |||
| 149 | (defun xwidget-webkit-pass-command-event () | 160 | (defun xwidget-webkit-pass-command-event () |
| 150 | "Pass `last-command-event' to the current buffer's WebKit widget." | 161 | "Pass `last-command-event' to the current buffer's WebKit widget. |
| 162 | If `current-input-method' is non-nil, consult `input-method-function' | ||
| 163 | for the actual events that will be sent." | ||
| 151 | (interactive) | 164 | (interactive) |
| 152 | (xwidget-perform-lispy-event (xwidget-webkit-current-session) | 165 | (if (and current-input-method |
| 153 | last-command-event)) | 166 | (characterp last-command-event)) |
| 167 | (let ((xwidget-webkit--input-method-events nil) | ||
| 168 | (minibuffer-local-map (make-keymap))) | ||
| 169 | (define-key minibuffer-local-map [with-input-method] | ||
| 170 | 'xwidget-webkit-pass-command-event-with-input-method) | ||
| 171 | (push last-command-event unread-command-events) | ||
| 172 | (push 'with-input-method unread-command-events) | ||
| 173 | (read-from-minibuffer "" nil nil nil nil nil t) | ||
| 174 | (dolist (event xwidget-webkit--input-method-events) | ||
| 175 | (xwidget-perform-lispy-event (xwidget-webkit-current-session) | ||
| 176 | event))) | ||
| 177 | (xwidget-perform-lispy-event (xwidget-webkit-current-session) | ||
| 178 | last-command-event))) | ||
| 154 | 179 | ||
| 155 | ;;todo. | 180 | ;;todo. |
| 156 | ;; - check that the webkit support is compiled in | 181 | ;; - check that the webkit support is compiled in |