Ugh! Terminal libraries are so misdesigned. GNU readline almost demands to talk to a real terminal. ncurses definitely does. They all use global variables so you can't talk to more than one at a time.
All these libraries do is parse incoming characters and send characters back out according to a set of rules about what a terminal is supposed to understand. Parsers like bison allow you multiple parser instances and allow you a fair amount of flexibility regarding input sources. Why can't readline or ncurses?!