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

Control Signal field in mircrol_t #5

Open
ari26squared opened this issue Dec 3, 2022 · 2 comments
Open

Control Signal field in mircrol_t #5

ari26squared opened this issue Dec 3, 2022 · 2 comments
Assignees

Comments

@ari26squared
Copy link

I think it would be very useful to have a more generic option to act on any control signal.

For me, I have it set so that can catch ^W to change my execute function back to the original execute function with out having to change any hardware data streams (uart). That is, I have access to all the nice stuff of typing into a command line while not having to muck around with updating my hardware input, if that makes sense.

The change would be here prv_control_char_process where you just set the signal value of mrl to ch and call the signal interrupt function provided by the user, which can have its own switch case to determine what to do.

I hope this makes sense to you. And I could just put in my own branch, but I think it should be here as well.

@dimmykar
Copy link
Owner

dimmykar commented Dec 4, 2022

Hello! Thank you for participating in the project!

Your idea is quite interesting, there are many ^+key control keys that are not used by the library. So that the registered characters do not impact to already implemented ones in the library, I see the implementation of this field in the structure by using of an enumeration, for example, microrl_ctrl_signal_keys_t with keys available for callback (and not used in library yet). Also, it is possible to implement several of these signals with custom callbacks instead of one signal with one callback, using the microrl_ctrl_signal_t signals structure array with configurable size, and using a function for registering these signals. The possible implementation of the microrl_ctrl_signal_t is:

typedef enum {
    ....
    MICRORL_CTRL_SIGNAL_W = 0x77; /* 'w' ASCII code */
    ....
} microrl_ctrl_signal_keys_t;

typedef struct {
    microrl_ctrl_signal_keys_t key; /* Control signal key */
    microrl_ctrl_signal_fn ctrl_signal_fn; /* Control signal user's callback */
} microrl_ctrl_signal_t;

I will implement this feature in the near future, but now I have little free time. If you urgently need such feature, you can prepare a Pull Request with your own implementation of this feature.

@dimmykar dimmykar self-assigned this Dec 4, 2022
@ari26squared
Copy link
Author

I had a different impression on how to achieve this, which is why I suggested it to you. You know the way the library works better than I do.

I am also busy, but I will try making the change into a pull request (given your thoughts). You may beat me to it!

Thank you

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

2 participants