I'm writing a linux shell for a custom scripting language, and I want to print a "... " before each follow-up line a user enters for a single statement, with the first line having a ">>> " printed, then waiting for input. Following is an example:
>>> void f() {
... "this is a test"
... }
>>>
I'm reading the line with fgets, and after I read it completely, I print the "... ", and repeat using another call to fgets. This works fine for moderately fast interactive input. But if I paste code containing newlines into the terminal, what I get is the following
>>> void f() {
"this is a test"
}
... ... >>>
The "... "'es are printed too late, even though I emit a fflush call after I print them to stdout. Does anyone know whether there is anything special to do to make this work?
printfthe text I read? That sounds good.printfit, or once you've started with ncurses you can use other ncurses stuff to place the text.