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

Feature: Commands should be able to request input from user #31

Open
Huy-DNA opened this issue Nov 28, 2024 · 0 comments
Open

Feature: Commands should be able to request input from user #31

Huy-DNA opened this issue Nov 28, 2024 · 0 comments
Assignees

Comments

@Huy-DNA
Copy link
Owner

Huy-DNA commented Nov 28, 2024

Description

  • The frontend hardwires the logic to show previous lines + current editable lines.
  • There's no way for a command to request an input from user, because command is sandboxed from the UI, but the UI is needed to add an editable lines.
  • Current workaround is that a command must require the user to pass all of the inputs as arguments to the command, which is awkward.

Suggestion

  • The UI and the command execution should still be decoupled.

  • The command should be passed some kind of callbacks, like read() and write() to signals that it wants to do I/O.

  • The UI contains:

    • Rendering logic (so that the user can read whatever) based on the input it's passed, for example, it should interpret ANSI escape code.
    • Input logic (so that user can type whatever).
  • Likely solution: A simulated terminal driver like in Linux terminals.

    • Input queue: User types -> input goes into input buffer.
    • Output queue:
  • The flow:

       User types -> Terminal driver interprets (normal characters or special characters like `Ctrl+C`) -> Terminal driver pushes to the input queue (also the output queue for the "input echoing" effect) or sends some signal to the command (how to deal with signals?).
       <If a command is running> -> Command performs a `read()` some time -> Take characters from the input queue. -> Command performs a `write()` some time -> Append to the input queue.
    
@Huy-DNA Huy-DNA self-assigned this Nov 28, 2024
@Huy-DNA Huy-DNA changed the title Feature: Commands should be alble to request input from user. Feature: Commands should be alble to request input from user Nov 28, 2024
@Huy-DNA Huy-DNA changed the title Feature: Commands should be alble to request input from user Feature: Commands should be able to request input from user Dec 4, 2024
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