tclib
tclib copied to clipboard
[tc_editline] Add callbacks for tab completion and hints
Currently, only a single callback exists. Instead, multiple events should be recognized and passed to the user.
I have already decided to go with option nr. 3, but for the record, there were three options:
-
N callbacks registered separately
void tcedit_register_tabcomplete(int (*cb)(<...>), void* udata); void tcedit_register_echo(<...>, void* udata); -
N callbacks registered at once (via a struct)
typedef struct TC_EditHandler { int (*tabcomplete)(<...>); <...> void* udata; } TC_EditHandler; void tcedit_register_handler(TC_EditHandler* handler); -
A single callback which is passed an event type.
typedef struct TC_EditEvent { int type; TC_String* input; <...> } TC_EditEvent; typedef int TC_EditCallback(TC_EditEvent* event, void* udata); void tcedit_register_callback(TC_EditCallback* callback, void* udata);