Comments (6)
Can you explain what is the use of the proposed API function?
from replxx.
It's the equivalent of the exemple in cxx-api.cxx (hints.size()) to detect that only one hint's remain
from replxx.
cxx-api example has call hints.size()
indeed, but this call is not using replxx
API, it is client code only. You can already achieve the same effect with C API. To be honest I still do not understand what do you want to achieve. Client code knows how many hints there are and replxx
code does not cache this information anywhere. And caching this information should be responsibility of client code anyway.
from replxx.
How can you get the hints.size using the c api :O ?
from replxx.
Please look at the code of the cxx-api example carefully.
The hints
variable is defined locally, and populated locally in the for
loop, hints.size()
is just a lucky convenience given by std::vector<T>
type. In C code one would have to use local variable to count hints.
Using c-api hintHook
as an example:
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.
}
from replxx.
Ok I got it, thank's a lot
from replxx.
Related Issues (20)
- error: debug map object file ... has changed ... since this executable was linked, file will be ignored HOT 1
- stdin loses unbuffered setting during callbacks HOT 1
- Memory handling for replxx_add_completion() / replxx_add_color_completion() undocumented HOT 1
- Pressing enter right after incremental search doesn't show the accepted line HOT 2
- retrieve last line before EOF HOT 1
- Replxx submitted to Fedora HOT 2
- Prompt is not re-rendered when I press "up" HOT 1
- Multiline text with <tab> leads to crash HOT 4
- How to abort "input" in another thread? HOT 5
- Help: wired behavior of Ctrl-A HOT 2
- segmentation fault on down arrow keypress HOT 5
- How to break loop when user press CTRL+C or CTRL+D or CTRL+Z or ESC ? HOT 2
- Support the switch of beep.
- How to enable multiline HOT 1
- Support custom file descriptors
- Homebrew integration for mac
- Undo
- New warning from gcc 13
- Looks like Marcin Konarski died in November 2021 HOT 5
- Colored user input while displaying hints
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from replxx.