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

Completion functions returning strings containing tabs or spaces display incorrectly #5

Open
C0deH4cker opened this issue Sep 25, 2015 · 3 comments

Comments

@C0deH4cker
Copy link
Contributor

In a project of mine, I wrote a completer function that does only return strdup("\t"); (to disable completion of filenames, which are meaningless for my project). However, this prints ^I instead of a tab as it should. When I try to return something like strdup("hello world"), it prints hello\ world instead. I assume that the issue is due to the very questionable implementation of CTL() and META(). It seems to me that the proper way of doing this is to use a type larger than a char, where the modifers are stored in higher bits. Of course this will require changing the public interface to libeditline, so maybe the current functions should be deprecated (but still remain), and new, proper functions should be added.

I just did some digging and found out that the string returned from my completer function is passed to insert_string(), which passes it to tty_string(), and then each character goes to tty_show(), which does use the ISCTL() and ISMETA() macros to incorrectly convert a tab into ^I. Also, it is line 1385 of editline.c which adds a newline before spaces. No idea why it does that though.

@troglobit
Copy link
Owner

If you want to disable TAB completion, simply add the following to your code:

rl_inhibit_complete = 1;

@C0deH4cker
Copy link
Contributor Author

Okay, I will do that for now, but I'm curious how you're supposed to complete a string that contains spaces without adding backslashes to them. That is still an issue I believe.

On Sep 25, 2015, at 2:48 AM, Joachim Nilsson [email protected] wrote:

If you want to disable TAB completion, simply add the following to your code:

rl_inhibit_complete = 1;

Reply to this email directly or view it on GitHub.

@troglobit
Copy link
Owner

It's a bit limited, admittedly. I think it was initially written to do filename completion.

Pull requests with fixes are most welcome! 😏

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