Skip to content

Commit

Permalink
Merge pull request #6 from mj-xmr/ui-asciimatics
Browse files Browse the repository at this point in the history
Curses fix
  • Loading branch information
mj-xmr committed Apr 16, 2022
2 parents 7d7e190 + 23c1f87 commit 60fd9c9
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/ui_curses.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,17 @@ def main(stdscr):

# Get resulting contents
message = box.gather()
print("Message = ", message)

stdscr = curses.initscr()
#Usually curses applications turn off automatic echoing of keys to the screen, in order to be able to read keys and only display them under certain circumstances. This requires calling the noecho() function.
curses.noecho()
#Applications will also commonly need to react to keys instantly, without requiring the Enter key to be pressed; this is called cbreak mode, as opposed to the usual buffered input mode.
curses.cbreak()
#Terminals usually return special keys, such as the cursor keys or navigation keys such as Page Up and Home, as a multibyte escape sequence. While you could write your application to expect such sequences and process them accordingly, curses can do it for you, returning a special value such as curses.KEY_LEFT. To get curses to do the job, you’ll have to enable keypad mode.
stdscr.keypad(True)
main(stdscr)
#Terminating a curses application is much easier than starting one. You’ll need to call:
curses.nocbreak()
stdscr.keypad(False)
curses.echo()

0 comments on commit 60fd9c9

Please sign in to comment.