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
Initial version of newshell autocompletion #75
Conversation
|
Not yet. I would wait a bit for that and first provide basic autocompletion. I've tried it in radare2 and it doesnt' work that well... |
24f0900
to
8470f01
Compare
Unfortunately, unit testing this seems quite hard as it would require to setup a full I was only able to unit test the |
I'm converting this to draft as I actually found many things to still improve for the initial review. The hardest thing, as you can see, it's identifying exactly what token the user is trying to write. The actual autocompletion and finding of the possible options is quite easy. |
Theoretically you should be able to just create a local |
I did not try actually... I could though. I'll let you know. |
0e50919
to
6f904ac
Compare
Ok, I think it is ready for review now. I tried to add some comments wherever I thought there was some need. If something is hard to understand, tell me and I'll try to document/explain better. |
98608f6
to
e8ee621
Compare
e5f7dc9
to
dfce513
Compare
Any thoughts on supporting custom completion callback type? You already have union which could store the callback pointer for corrsponding RzCmdArgType. Could be used to reduce amount of direct dependencies for the command processing/completion mechanism and also allow custom completion for plugin commands. For example zignature completion is somewhat specific to zignature command family. |
} | ||
|
||
static void print_options(int argc, const char **argv) { | ||
int cols = (int)(rz_cons_get_size (NULL) * 0.82); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's with 0.82
? Subjectively pleasing fraction of screen to fill?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no idea... I just copied this code from what was already there and extracted it in a function because I needed to do the same thing. It's probably a "random" number though, yeah.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
1f08d1e
to
18844d9
Compare
What would be the advantage of completing zignatures arguments with a "custom" function instead of having a RZ_CMD_ARG_TYPE_ZIGN type? I think the custom function would have to be in RzCore anyway, so I don't see a clear advantage by doing that. However, I agree it can be useful when some autocompletion is just for one command and defining a new type just for that would be a bit too much or when you have external plugins. |
Yes, having a custom autocompletion would be highly beneficial. |
* Add unit test for RzCore autocompletion
18844d9
to
303e4ee
Compare
2c3b513
to
6637b6d
Compare
This (quite big) PR adds support for autocompletion based on all the info available in "newshell".
Limitations of existing autocompletion:
$(
it won't detect that a new command can be suggested; etc.)Advantages of
cfg.newshell.autocompletion
:$(
,@@c:
,.
, etc.)Current limitations/issues:
za
<type>
field) are autocompleted.zs "hell<tab>
is not valid according to the parser, because the"
is not completed, so we need to try and see what is the proper thing to do).