On Mac OSX and linux with the GNU libreadline, if I background gdl with Control-z and then bring it back to the foreground, the terminal appearance becomes messed-up. I believe the problem is due to the way readline and ncurses handle signals when they both use their default signal handlers.
It appears that the only place ncurses is explicitly used in the code is to get the terminal width. If the gnu libreadline library is used, this patch uses readline to get the terminal width and height, and ncurses is not used. Putting gdl to the background and then back to the foreground seems to work ok with this patch.
A second benefit of this patch if GNU libreadline is used is that readline keeps track of the terminal dimensions, so if the terminal window is resized the print command will subsequently format the output nicely to the terminal dimensions.
This patch does 2 things:
1) Move readline initialization into InitGDL so that it is called before TermWidth
2) If have_libreadline, use readline to get the terminal width and height instead of the (n)curses library.
I have only tested this with Mac OSX but see no problems.