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

Investigate binding ctrl+left_square_brace #3023

Closed
darrenburns opened this issue Jul 27, 2023 · 6 comments
Closed

Investigate binding ctrl+left_square_brace #3023

darrenburns opened this issue Jul 27, 2023 · 6 comments
Labels
bug Something isn't working

Comments

@darrenburns
Copy link
Member

It seems we have support for ctrl+right_square_bracket and ctrl+left_square_brace. Note that we've called it "bracket" in the first binding, and "brace" in the latter.

The bindings for the key alias ctrl+left_square_brace also don't seem to fire.

Also, it seems that changing the alias brace -> bracket doesn't fix the issue - when the bindings are checked, it seems the alias isn't being used.

Not sure if this is relating to the fact that ESC is an alias of the same key.

Basically, there's something fishy with this binding. It doesn't seem to fire and I don't know what the correct behaviour is -- it needs investigation.

@TomJGooding
Copy link
Contributor

TomJGooding commented Jul 27, 2023

Just to add that this seems to be the case for all keys with aliases. If you uncomment the binding for escape below for example, then pressing Ctrl+[ will fire the notification.

from textual.app import App, ComposeResult
from textual.widgets import Footer


class ExampleApp(App):
    BINDINGS = [
        ("ctrl+left_square_brace", "ctrl_left_square_brace", "Miss"),
        # ("escape", "escape", "Fires"),
        ("ctrl+space", "ctrl_space", "Miss"),
        # ("ctrl+@", "ctrl_at", "Fires"),
        ("ctrl+m", "ctrl_m", "Miss"),
        # ("enter", "enter", "Fires"),
    ]

    def compose(self) -> ComposeResult:
        yield Footer()

    def action_ctrl_left_square_brace(self) -> None:
        self.bell()
        self.notify("You pressed ctrl+left_square_brace")

    def action_escape(self) -> None:
        self.bell()
        self.notify("You pressed escape")

    def action_ctrl_space(self) -> None:
        self.bell()
        self.notify("You pressed ctrl+space")

    def action_ctrl_at(self) -> None:
        self.bell()
        self.notify("You pressed ctrl+@")

    def action_ctrl_m(self) -> None:
        self.bell()
        self.notify("You pressed ctrl+m")

    def action_enter(self) -> None:
        self.bell()
        self.notify("You pressed enter")


if __name__ == "__main__":
    app = ExampleApp()
    app.run()

@darrenburns darrenburns added the bug Something isn't working label Jul 31, 2023
@davep
Copy link
Contributor

davep commented Oct 30, 2023

Possibly see also #3563.

@rndusr
Copy link
Contributor

rndusr commented Nov 1, 2023

I don't think this is related to #3563.

If you run textual keys, you can see that the key events fire as
expected. This works with current main and the #3563 PR branch.

@davep
Copy link
Contributor

davep commented Nov 1, 2023

The see-also is more of a "there's other key-binding related things going on here too so do check in there" link than anything else.

@willmcgugan
Copy link
Collaborator

The ctrl_left_square_brace has been named ctrl_left_square_bracket now. With that change, it works as expected.

ctrl+space is used as a hotkey to switch languages, at least on macOS, so we can't do much about that.

ctrl+m comes through as enter on older terminals, but can be bound on new terminals that support the updated key protocol.

Just some legacy terminal weirdness I'm afraid. Not much can be done about it.

Copy link

Don't forget to star the repository!

Follow @textualizeio for Textual updates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants