[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Android port of Emacs

From: Po Lu
Subject: Re: Android port of Emacs
Date: Fri, 07 Jul 2023 10:46:50 +0800
User-agent: Gnus/5.13 (Gnus v5.13)

Ant <ar0x2ff@gmail.com> writes:

> * Po Lu:
>> I think I will look into providing modifier keys using the tool bar.
> Thank you for the addition. They for sure make Emacs for Android (or
> handheld devices in general) much more comfortable to use.
> The fact that having a modifier on temporarily overrides the text
> conversion style is very handy. I'd like to have modifiers on physical
> keys too, so I chose to re-use some of your functions:
> (define-key local-function-key-map (kbd "<volume-up>")
> #'tool-bar-event-apply-meta-modifier)
> (define-key local-function-key-map (kbd "<volume-down>")
> #'tool-bar-event-apply-control-modifier)
> And it works good, except when I want both modifiers on: pressing
> <volume-up> and then <volume-down> is recognized as M-<volume-down>. 
> The tool-bar-apply-modifiers function does address this issue and in
> fact it is possible to activate multiple modifiers through the new
> tool bar feature, but I'm unable to dig further and try to make it fit
> with physical keys.
> I just wanted to address this for everyone who wants to insert
> modifiers on Emacs for Android. And also, thank you again Po Lu for
> the addition.

The key to applying multiple modifier keys simultaneously is this part
of the function `modifier-bar-buttons':

          (let* ((modifiers init-modifier-list) event1
                 (overriding-text-conversion-style nil)
                 (event (read-event)))
            ;; Combine any more modifier key presses.
            (while (eq event 'tool-bar)
              (setq event1 (event-basic-type (read-event)))
              ;; Reject unknown tool bar events.
              (unless (memq event1 '(alt super hyper shift control meta))
                (user-error "Unknown tool-bar event %s" event1))
              ;; If `event' is the name of a modifier key, apply that
              ;; modifier key as well.
              (unless (memq event1 modifiers)
                (push event1 modifiers)
                ;; This list is used to check which tool bar buttons
                ;; need to be enabled.
                (push event1 modifier-bar-modifier-list))
              ;; Update the tool bar to disable the modifier button
              ;; that was read.
              ;; Read another event.
              (setq event (read-event)))

To allow applying multiple modifier keys, you must also check if the
basic type of the event read is either `volume-up' or `volume-down', and
push the appropriate modifier key to `modifiers' and
`modifier-bar-modifier-list' if that is so.  You might want to include
your own version of this function in your customizations, since it's not
exactly relevant to the modifier bar.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]