Discussion:
Temporarily unbind a keysym in an extension.
Marcel
2018-07-27 13:24:12 UTC
Permalink
Hi,

I am developing a perl extension and have the use case where I would
like to enable/disable some key bindings. For instance, there might be a
binding of Control-l which I would like to enable/disable with another
binding, e.g. Meta-o .

That is, the user could trigger Meta-o and now be able to use Control-l.
Or trigger Meta-o again to disable the binding to Control-l which then
would normaly clear the screen in a terminal.

I tried on_user_command() or on_action(). But so far I have not been
successful. Is this possible? How would I be able to achieve this?

Cheers,

Marcel
Marc Lehmann
2018-07-29 05:31:06 UTC
Permalink
I am developing a perl extension and have the use case where I would like to
enable/disable some key bindings. For instance, there might be a binding of
Control-l which I would like to enable/disable with another binding, e.g.
Meta-o .
The normal way to do this is by calling the bind_action method, although I am
not sure it's particularly suitable for frequent redefines.

If you temporarily want to take over the keyboard, you can temporarily
->enable your own key_press and/or tt_write handlers, as e.g.
searchable-scrollback does, and this way override normal processing of
these events.

Other than that, I don't think there is a way.
--
The choice of a Deliantra, the free code+content MORPG
-----==- _GNU_ http://www.deliantra.net
----==-- _ generation
---==---(_)__ __ ____ __ Marc Lehmann
--==---/ / _ \/ // /\ \/ / ***@schmorp.de
-=====/_/_//_/\_,_/ /_/\_\
Marcel
2018-07-29 17:48:25 UTC
Permalink
Hi Marc,

thanks a lot for your answer. I will check out your hints, especially
searchable-scollback. I hope, I will find my solution there :)

Cheers,

Marcel
Post by Marc Lehmann
I am developing a perl extension and have the use case where I would like to
enable/disable some key bindings. For instance, there might be a binding of
Control-l which I would like to enable/disable with another binding, e.g.
Meta-o .
The normal way to do this is by calling the bind_action method, although I am
not sure it's particularly suitable for frequent redefines.
If you temporarily want to take over the keyboard, you can temporarily
->enable your own key_press and/or tt_write handlers, as e.g.
searchable-scrollback does, and this way override normal processing of
these events.
Other than that, I don't think there is a way.
Marcel
2018-08-02 21:16:36 UTC
Permalink
Ding it with on_key_press and forwarding it to tt_write seems to work. I
had to extract the relevant attributes and do some calculation to find
out what combinations of Control, Meta and Shift are active, but it
looks like it got it.

Thanks again for the help.
Post by Marc Lehmann
I am developing a perl extension and have the use case where I would like to
enable/disable some key bindings. For instance, there might be a binding of
Control-l which I would like to enable/disable with another binding, e.g.
Meta-o .
The normal way to do this is by calling the bind_action method, although I am
not sure it's particularly suitable for frequent redefines.
If you temporarily want to take over the keyboard, you can temporarily
->enable your own key_press and/or tt_write handlers, as e.g.
searchable-scrollback does, and this way override normal processing of
these events.
Other than that, I don't think there is a way.
Loading...