General overview
In a curses wrapper, I have a main stdscr
. If I press : then I enter in a specific mode where I can type text inside a curses.textpad.Textbox
.
In my following MWE it work fine until this state. But the goal now is to break the the typing mode if the user type ESC.
Minimal working example
import curses
import curses.textpad
def enteringExMode(stdscr):
curses.curs_set(1) # Show cursor
editwin = curses.newwin(0, 0, 0, 0)
editwin.clear()
# Edition in textzone
tb = curses.textpad.Textbox(editwin)
tb.edit()
# Get the writen text
user_text = tb.gather()
def main(stdscr):
while True:
stdscr.clear()
key = stdscr.get_wch()
if key == ":":
enteringExMode(stdscr)
curses.wrapper(main)
The question
So how to make the typing mode take end if the user type ESC
?