Skip to content

how to trap keypress inside a command? #221

@elbrandt

Description

@elbrandt

Hi,
Fantastic library, well written and feature packed. Thanks for your work.
We're using CliLocalTerminalSession with a LoopScheduler. One of the commands we've implemented, we'd like the command to run in a loop 'until the user presses a key' to end the command and return to the menu.

When we implement this in our command's lambda using the select() function, they way we typically would in a regular command line app, I find that we're in a race condition with a thread running the same select() command in an instance of the LinuxKeyboard class. So, I think either we're doing it wrong, or this "run command until key is pressed" use case isn't supported in this library.
Is there a relatively pain-free way to do what we want? Can we somehow temporarily pause the scheduler within our command?
I can elaborate more on the use case if this question is unclear.
Thanks again for an excellent library.
-Eric.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions