Skip to content

feat(list): Add --enter-response option for separate Enter key exit code#322

Open
mg-dev25 wants to merge 1 commit intov1cont:masterfrom
Mgdev-25:feat/enter-response-option
Open

feat(list): Add --enter-response option for separate Enter key exit code#322
mg-dev25 wants to merge 1 commit intov1cont:masterfrom
Mgdev-25:feat/enter-response-option

Conversation

@mg-dev25
Copy link
Contributor

@mg-dev25 mg-dev25 commented Dec 6, 2025

Summary

Adds --enter-response option allowing separate exit codes for Enter vs Ctrl+Enter in list dialogs.

Use Case

When building interactive dialogs, it can be useful to have Enter and Ctrl+Enter trigger different actions:

  • Enter opens a secondary dialog (e.g., edit mode)
  • Ctrl+Enter confirms and submits

Currently both keys return the same --response value, making differentiation impossible.

Implementation

Three files changed:

  • yad.h: Added enter_resp field to YadData structure
  • option.c: Added --enter-response option (defaults to -1)
  • list.c: Modified list_activate_cb to use enter_resp for plain Enter

Behavior Table

Key Behavior
Ctrl+Enter Exits with --response value (unchanged)
Enter (no dclick-action) Exits with --enter-response if set, otherwise --response
Enter (with dclick-action) Triggers double-click action (unchanged)

Example

yad --list --response=10 --enter-response=0 --column=Option Item1 Item2
# Enter returns 0, Ctrl+Enter returns 10

Backward Compatibility

--enter-response defaults to -1 (unset), so existing scripts continue to work unchanged.

Add a new --enter-response option that allows setting a different exit code
for the Enter key versus Ctrl+Enter in list dialogs. This enables workflows
where Enter and Ctrl+Enter need to trigger different actions.

Behavior:
- Ctrl+Enter: Always exits with --response value (default: 0)
- Enter (without dclick-action): Exits with --enter-response if set,
  otherwise falls back to --response for backward compatibility
- Enter (with dclick-action): Unchanged, triggers double-click action

The --enter-response defaults to -1 (unset), maintaining full backward
compatibility with existing scripts.

Example usage:
  yad --list --response=10 --enter-response=0 ...
  # Enter exits with 0, Ctrl+Enter exits with 10
@mg-dev25 mg-dev25 marked this pull request as ready for review December 7, 2025 09:12
@mg-dev25 mg-dev25 closed this Dec 7, 2025
@mg-dev25 mg-dev25 deleted the feat/enter-response-option branch December 7, 2025 10:52
@mg-dev25 mg-dev25 restored the feat/enter-response-option branch December 7, 2025 23:15
@mg-dev25 mg-dev25 reopened this Dec 7, 2025
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.

1 participant