termux / termux-app

Termux - a terminal emulator application for Android OS extendible by variety of packages.
https://f-droid.org/en/packages/com.termux
Other
36.29k stars 3.81k forks source link

[Feature]: Support for multiple sets of extra-keys #3601

Open petrmachcz opened 1 year ago

petrmachcz commented 1 year ago

Feature description

The Termux is great and I really loved the extra-keys. I use several sets of configurations that I change before running the program. For example, I have one, two and three line configurations for vim/python, I have a set for vim/html, vim/javascript, and also for the Tome2 game. I prefer this to a physical keyboard for typing, because I'm Czech, I have an accented keyboard and I have to type all the 'programming' characters intricately via modifiers. With the extra-keys in termux I don't have to.

It would be very useful to me if the various sets of extra-keys were supported directly by termux. I imagine that there would be multiple extra-keys sections in termux.properties, namely extra-keys-1 to extra-keys-9.

There would also be virtual keys (similar to KEYBOARD and DRAWER) EXTRA0 to EXTRA9 that would switch the virtual keyboard to the appropriate set. Key EXTRA0 would switch to the existing set of extra-keys.

An example of such a configuration for switching between two keyboards:

extra-keys-1 = [[{key: 'EXTRA2', display: 'TMUX'}, ~vim specific configuration~]] extra-keys-2 = [[{key: 'EXTRA1', display: 'VIM'}, ~tmux specific configuration~]]

Absolute perfection would be color support, something like:

{key: '@@', display: 'Run macro', color: 9}

This would allow not only to show in color on the set switch which set is active, but also to distinguish in color the individual keys in the extra-keys.

Thank you for reading Petr Mach

Translated with www.DeepL.com/Translator (free version)

Additional information

None aditional information.

agnostic-apollo commented 1 year ago

Not a bad idea for future, the extra-keys key could support a list. For now you can also create a script yourself that dynamically sets required extra-keys value in properties file and runs termux-reload-settings and you can call it with a numbered macro.

For example replacement of a key value, check https://github.com/termux/termux-tasker#allow-external-apps-property-optional

RalfWerner commented 1 year ago

... can also create a script yourself ...

I agree to @agnostic-apollo and also use a script to switch. The action itself can also be done via EK=extra keys.

Unfortunately, the preferences are no longer used in Termux-X11 from @twaik, as in version02.04. In the current version, the EK can only be transferred with Copy/Paste. In the case of devices that can show both APK on the screen (Split/PopView), the EK are also twice and they are never displayed with Termux-float.

The desire to show the EK only once (like on-screen-KB) I had written several times. Maybe it will be realized in the next version since @fornwall seems to be back again. If Termux would also had a full screen option, like X11, the two APK would work much better together.

twaik commented 1 year ago

The desire to show the EK only once

Do you mean disabling EK when there is no software keyboard? This is not achievable since there is no reliable way to check if there is software keyboard on screen. And even if there is, it is not possible to attach/bind EK bar to IME since IME is drawn by system, on system overlay and EK is drawn on application surface/window.

Even if we compare window size to check if there is software keyboard there will be a bug with freeform/multiwindow/split screen.

Even in the case if we get the reliable way to check if software keyboard is visible in all possible modes EK will appear on the bottom of Termux's window, there is no way to anchor/bind/link/attach it to system software keyboard. And even if we succeed it will send events only to termux.

The same point is relevant to termux-x11.

twaik commented 1 year ago

Unfortunately, the preferences are no longer used in Termux-X11 from @twaik, as in version02.04. In the current version, the EK can only be transferred with Copy/Paste.

The reason for this is pretty simple. Termux:X11 is not a standard termux plugin. It has no sharedUserId. It has different signature. It has no access to termux's filesystem.

The only possible way to let termux-x11 read configuration file is to enable termux's allow-external-apps and ask user for Termux's RUN_COMMAND permission. I tried that before and users posted a lot of issues about errors appearing because of allow-external-apps disabled. They simply do not want to read readme, error text or anything else so I decided not to use it at all, making application as simple as possible, with as many features enabled by default, as many functions working out-of-the-box as it possible. Currently termux-x11 setting up and starting sequences contain only the most neccessary things which may not be avoided and even in this case there are enough users which have problems with setting it up or starting it.

RalfWerner commented 1 year ago

Thank you @twaik for the detailed justification of your strategy :) I also had an extensive dialogue with @agnostic-apollo until on-screen-KB and EK predominate completely and without overlapping the terminal. It is also clear to me that the full screen option makes a consistent presentation difficult because it creates further configurations events when sweep gestures are from the edge.

In 02.04 (ekeys) this was also made correctly with full screen. So it works! If the only reason is the missing sharedUserid, could it be corrected as in all other plugins? The development is then only necessary once as @suhan-paradkar here has done.

This is not an X11 issue, which is why only the full screen wish for Termux-app. However, I would also like the ekeys behavior there. EK is currently (x11a) completely overwriting my task manager (fluxbox), shows only part of the EK as symbols, does not generate any configuration events with which an Xclient could adapt the size and is switched on/off unmotivated in Direct mode if more than two fingers are used.

twaik commented 1 year ago

If the only reason is the missing sharedUserid, could it be corrected as in all other plugins?

No and never. Termux:X11 must work with all versions of termux regardless of its origin (github action, fdroid, custom) or signature. In the case of sharedUserId user must install Termux:X11 from the same source as termux and other plugins. Now it works fine with all versions and even without termux at all (with standalone chroot system in separate container). And it is off-topic in current issue.

The development is then only necessary once as @suhan-paradkar https://github.com/termux/termux-x11/pull/19#issuecomment-999296011 has done.

That is an old version which is very outdated...

EK is currently (x11a) completely overwriting my task manager (fluxbox)

Did not understand that.

shows only part of the EK as symbols

What??

does not generate any configuration events with which an Xclient could adapt the size

if more than two fingers are used

In latest version it is an overlay and can be shown/hidden with triple finger swipe down or VolumeDown key (the latter must be enabled in preferences in order to work). It is done for purpose to let users work with EK without changing virtual display resolution (and flicker, at least on some devices) every time user enables/disables EK.

RalfWerner commented 1 year ago

No and never...

The topic would only fit here if a joint EK management is an option as in ekeys. I understand that you prefer not to do it and implement everything new in x11a. This is a lot of work but ok. I have created many pictures and videos for ekeys, which are no longer possible with x11a, which is more difficult to present, but will try here.

petrmachcz commented 9 months ago

Screenshot_20240209_231758_Termux

This is my extra keyboard. I'm considering expanding it to another floor, but it would take up too much space. I'd really like a keyboard switch. See the first post.

RalfWerner commented 9 months ago

@agnostic-apollo and I made the suggestion to do this by script. Did you try that? If you share the Properties of your EK here, I could make a script suggestion.