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

RFC single key press to end "show output" #673

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

gsigh
Copy link

@gsigh gsigh commented Jan 6, 2025

Adds new 'show_output' config option. Remains backwards compatible, uses Python's input(3) by default. Extends that to also accept single key presses when configured. Should increase usability when 'o' and SPACE are as acceptable as ENTER is, which is rather distant from 'o'.

You can tell how this started with a quick local hack. Then grew bigger fast when I considered upstreaming. Became a little monster by now. The commit message provides details on the approach, and lists issues of the current implementation. This PR is meant to gather feedback.

Lack of doc update and UI adjustment is the biggest drawback. Just tell me your preference for more or fewer options, maybe point out which places need adjustment as new options are introduced. And I will improve that v1 to make it more acceptable.

Remaining text is the one commit's message, for your reference.

Introduce the 'show_output' config option, pass its value from the debugger's .show_output() method to the StoppedScreen class. Default to the 'python_input' selection for backwards compatibility. Support 'single_key' as an alternative, which accepts additional optional keywords: 'silent' to not prompt for key presses, and several sets of terminating key presses like 'o_space_enter', 'enter_only', or 'any_key' to reduce behavioural changes from to earlier versions.

show_output = python_input
show_output = single_key
show_output = single_key silent o_space_enter

In the absence of terminating key press specs, any key press leaves the output screen. The implementation uses Python select(3) which may not work with stdin on Windows. The StoppedScreen implementation lends itself to more keywords and other ways of getting user input if desired.

TODO

  • Config file handling is incomplete. Implements the keyword and its default value, but lacks documentation and UI controls.
  • Move NonBlockingConsole to a better location, common support or platform dependent?
  • Drop diagnostics.
  • Is it confusing to have too many configuration options? Just have "single key, any key" as one boolean choice while the default is the input(3) invocation that is portable to all platforms?
  • Maybe adjust Python style where required.

… screen

Introduce the 'show_output' config option, pass its value from the
debugger's .show_output() method to the StoppedScreen class. Default
to the 'python_input' selection for backwards compatibility. Support
'single_key' as an alternative, which accepts additional optional
keywords: 'silent' to not prompt for key presses, and several sets
of terminating key presses like 'o_space_enter', 'enter_only', or
'any_key' to reduce behavioural changes from to earlier versions.

  show_output = python_input
  show_output = single_key
  show_output = single_key silent o_space_enter

In the absence of terminating key press specs, any key press leaves
the output screen. The implementation uses Python select(3) which may
not work with stdin on Windows. The StoppedScreen implementation lends
itself to more keywords and other ways of getting user input if desired.

TODO
- Config file handling is incomplete. Implements the keyword and its
  default value, but lacks documentation and UI controls.
- Move NonBlockingConsole to a better location, common support or
  platform dependent?
- Drop diagnostics.
- Is it confusing to have too many configuration options? Just have
  "single key, any key" as one boolean choice while the default is
  the input(3) invocation that is portable to all platforms?
- Maybe adjust Python style where required.
@inducer
Copy link
Owner

inducer commented Jan 7, 2025

Thanks for making this! As it stands, I'll admit I'm not a huge fan. This seems like a fairly fiddly approach to a (subjectively) minor annoyance. There might also be a simpler solution: why not add "Enter" as a key to show the console? IIRC, that's not currently mapped. Maybe that's hare-brained for some reason? Not sure.

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.

2 participants