I've got a a program in which I want to prompt the user for some file and folder names. Ideally they just type half of it and then press tab to complete it based on files in the current working directory. However, when my program is running and I use scanf
, fgets
, fgetc
, getchar
, whatever, I press tab and it simply inserts a tab-character.
Whilst looking for a solution I learned about the GNU Readline
library. Using readline()
instead of fgets()
, I have tab-completion again! But I'd really rather not use it because of all the unnecessary features and keybinds it adds which I don't need. (using readline, I can't use Ctrl-C to interrupt my program anymore, what's up with that?)
I thought tab-completion was a feature of the shell I used, the text I typed inside there was inaccessible to my program until after I pressed Enter. So what is Readline doing? Is it modifying the characters as I type them, or is it simply enabling a setting of the shell? How can I do this myself? Ideally without using the GNU Readline library.