In Python, I'd like to write a terminal program using both cmd and curses together, ie. use cmd to accept and decode full input lines, but position the output with curses.
Mashing together examples of both curses and cmd like this :
import curses
import cmd
class HelloWorld(cmd.Cmd):
"""Simple command processor example."""
def do_greet(self, line):
screen.clear()
screen.addstr(1,1,"hello "+line)
screen.addstr(0,1,">")
screen.refresh()
def do_q(self, line):
curses.endwin()
return True
if __name__ == '__main__':
screen = curses.initscr()
HelloWorld().cmdloop()
I find that I'm not seeing anything when I type. curses is presumably waiting for a refresh before displaying anything on the screen. I could switch to using getch() but then I'd lose the value of cmd.
Is there a way to make these work together?