views:

61

answers:

1

Is there any way to have multi-line input in Python? Solutions I have seen don't allow you to edit past lines after you have pressed enter and have other problems. I am making a simple text editor in Python and I want to have a text input that can be multiline and pressing buttons like left or right would move the text cursor. I need it to stop taking input when certain buttons are pressed, like ctrl-s or ctrl-q. So it would be nice if there was a way to get text input following these rules that would specify which button had been pressed to end the input when it was ended. For example, a function that would return a tuple with the button pressed and the text.
I am doing this from the console.

A: 

You might want to take a look at the curses module that allows you to control various aspects of console input and output. Start with the official HOWTO: http://docs.python.org/howto/curses.html

Ferdinand Beyer