Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import curses
- def command():
- curses.echo()
- cmd = screen.getstr(0,10,15)
- curses.noecho()
- screen.addstr(2,0,cmd,curses.color_pair(2))
- screen = curses.initscr() # Creates our screen
- curses.start_color()
- curses.init_pair(1, curses.COLOR_CYAN, curses.COLOR_BLACK) # Creates a color pair as 1 with foreground cyan and background black
- curses.init_pair(2, curses.COLOR_GREEN, curses.COLOR_RED)
- curses.noecho() # Keeps the keys we press from
- curses.cbreak() # Takes input right away
- screen.keypad(1)
- screen.addstr(0,0,"Command:> ",curses.color_pair(1)) # Add a COLORED string at 10,0
- screen.refresh() # Refresh screen now that strings added
- # While loop to wait for key events, then
- while 1:
- key = screen.getch() # Get presse keys
- if key == ord("q"): break
- elif key == ord("c"): command() # Call our input function
- curses.endwin() # Closes curses environment
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement