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

Prevent monit7 from exiting for inadvertent escape sequences #204

Closed
wehimwich opened this issue May 26, 2023 · 1 comment
Closed

Prevent monit7 from exiting for inadvertent escape sequences #204

wehimwich opened this issue May 26, 2023 · 1 comment

Comments

@wehimwich
Copy link
Member

@jfhquick reported that monit7 exits for key combinations that generate escape sequences while the window has the focus. An example is <Ctrl>+<Alt>+<Down>. Not exiting on <Escape> would avoid this, but other characters in the escape sequences can cause monit7 to do unexpected things. It is not clear that it would be easy to filter out escape sequences in general (suggestions welcome!), but @jfhquick suggested that they might be detected by the arrival rate of the characters. In the meantime if they are causing a problem, particular combinations that are troublesome they can be filtered out using settings in ~/.Xresources or maybe in the window manager configuration.

@wehimwich
Copy link
Member Author

Using escape sequence removal for the "CSI sequences" at ANSI escape code might be a solution. Testing suggests that it would handle the escape sequences generated by the available terminal key combinations.

The sticky issue would be what to do if the user hits an inadvertent<Escape>, thereby triggering escape sequence processing. That could be handled by treating anything other than [ after an initial <Escape> as new input, i.e., not part of the current escape sequence (but possibly the start of a new escape sequence). This would also handle repeated <Escape>s (auto-repeat). Similarly any other out-of-order character in an escape sequence could just be considered new input.

I doubt we can handle arbitrary escape-like sequences entered by the user, either accidentally or intentional. In come cases, some characters intended as commands could be absorbed into the escape sequence processing. The approach in this post would handle the most likely inadvertent key presses (desktop key combinations and <Escape>) without any visible effects. Currently [ is not a monit7 command and it would be good to avoid making it one in the future.

Not having a time-out (for arrival rate) avoids having to distinguish between input pauses and network delays OR having a one-size solution that does not fit both cases.

Writing an interpreter is a fraught business, even for a small one like this!

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

No branches or pull requests

1 participant