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
Add a replxx_hints_size function for c api. #43
Comments
Can you explain what is the use of the proposed API function? |
It's the equivalent of the exemple in cxx-api.cxx (hints.size()) to detect that only one hint's remain |
cxx-api example has call |
How can you get the hints.size using the c api :O ? |
Please look at the code of the cxx-api example carefully. Using c-api void hintHook(char const* context, replxx_hints* lc, int* contextLen, ReplxxColor* c, void* ud) {
char** examples = (char**)( ud );
int i;
int utf8ContextLen = context_len( context );
int prefixLen = strlen( context ) - utf8ContextLen;
int hintCount = 0;
*contextLen = utf8str_codepoint_len( context + prefixLen, utf8ContextLen );
if ( *contextLen > 0 ) {
for (i = 0; examples[i] != NULL; ++i) {
if (strncmp(context + prefixLen, examples[i], utf8ContextLen) == 0) {
replxx_add_hint(lc, examples[i]);
++ hintCount;
}
}
}
// now `hintCount` variable holds the number of hints.
} |
Ok I got it, thank's a lot |
So we can detect if there is only one match in the hints, and make a colorized output also in C and other bindings.
The text was updated successfully, but these errors were encountered: