Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support lone Alt key presses in KeyFunctions #1245

Merged
merged 1 commit into from Dec 10, 2023

Conversation

ak2
Copy link
Contributor

@ak2 ak2 commented Dec 10, 2023

A lone Alt key press in Windows applications normally brings up the application menu bar (which is why its virtual keycode is VK_MENU). There's no such menu bar in mintty, which relies on the context menu and window menu instead, so make lone Alt key presses available for mapping in the KeyFunctions setting.

The action is triggered when the Alt key is released, but only if no other modifier was down when the Alt key was pressed, and if nothing else was pressed in-between.

Also make sure that AltGr does not trigger this action or Alt code processing, unless the AltGrIsAlsoAlt setting is enabled.

One use case for this is to map Alt to the context menu via the 'menu-text' action, to make it easier to reach on keyboards that don't have the context menu key.

Another is to map it to ^[, i.e. the Esc key code, which might be convenient for vim users. It also makes plenty of sense as Alt modifier combinations normally prefix the modified key with ^[.

As the Esc key's default function can be replaced in this way, also make unmodified Esc key presses available for mapping in KeyFunctions. One use case for that is to map it to a non-letter control character such as ^, and then use that as the interrupt character in the stty settings, instead of ^C. That gives Esc its usual Windows meaning of interrupting or cancelling actions, and makes ^C available for copying.

A lone Alt key press in Windows applications normally brings up the
application menu bar (which is why its virtual keycode is VK_MENU).
There's no such menu bar in mintty, which relies on the context menu
and window menu instead, so make lone Alt key presses available for
mapping in the KeyFunctions setting.

The action is triggered when the Alt key is released, but only if no
other modifier was down when the Alt key was pressed, and if nothing
else was pressed in-between.

Also make sure that AltGr does not trigger this action or Alt code
processing, unless the AltGrIsAlsoAlt setting is enabled.

One use case for this is to map Alt to the context menu via the
'menu-text' action, to make it easier to reach on keyboards that don't
have the context menu key.

Another is to map it to ^[, i.e. the Esc key code, which might be
convenient for vim users. It also makes plenty of sense as Alt modifier
combinations normally prefix the modified key with ^[.

As the Esc key's default function can be replaced in this way, also make
unmodified Esc key presses available for mapping in KeyFunctions. One
use case for that is to map it to a non-letter control character such as
^\, and then use that as the interrupt character in the stty settings,
instead of ^C. That gives Esc its usual Windows meaning of interrupting
or cancelling actions, and makes ^C available for copying.
@mintty mintty merged commit 267b0c2 into mintty:master Dec 10, 2023
1 check passed
@mintty
Copy link
Owner

mintty commented Dec 10, 2023

One use case for this is to map Alt to the context menu via the 'menu-text' action, to make it easier to reach on keyboards that don't have the context menu key.

Added an example for this to the manual.

As the Esc key's default function can be replaced in this way, also make unmodified Esc key presses available for mapping in KeyFunctions. One use case for that is to map it to a non-letter control character such as ^, and then use that as the interrupt character in the stty settings, instead of ^C.

This can be achieved more directly and decoupled from actual ^C settings by
KeyFunctions=Esc:break
Not added as an exmple though.

@ak2
Copy link
Contributor Author

ak2 commented Dec 10, 2023

One use case for this is to map Alt to the context menu via the 'menu-text' action, to make it easier to reach on keyboards that don't have the context menu key.

Added an example for this to the manual.

Thanks!

As the Esc key's default function can be replaced in this way, also make unmodified Esc key presses available for mapping in KeyFunctions. One use case for that is to map it to a non-letter control character such as ^, and then use that as the interrupt character in the stty settings, instead of ^C.

This can be achieved more directly and decoupled from actual ^C settings by KeyFunctions=Esc:break Not added as an example though.

That doesn't work with ssh though, because the SIGINT is delivered to the foreground process group of the pty that mintty created, thus killing ssh itself, whereas control chars are sent to the remote pty.

(Screen on the other hand apparently translates the SIGINT sent by 'break' into the control character specified for SIGINT in the stty settings and sends that to its child process.)

@mintty
Copy link
Owner

mintty commented Dec 11, 2023

Thanks for the SIGINT hints, I just had the idea to add a user-definable function intr which does exactly what you say screen does.

mintty added a commit that referenced this pull request Dec 16, 2023
@mintty
Copy link
Owner

mintty commented Feb 24, 2024

Released 3.7.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants