Python curses.noecho() Examples
The following are 30
code examples of curses.noecho().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
curses
, or try the search function
.
Example #1
Source File: interface.py From bitcoind-ncurses with MIT License | 8 votes |
def init_curses(): window = curses.initscr() curses.noecho() # prevents user input from being echoed curses.curs_set(0) # make cursor invisible curses.start_color() curses.init_pair(1, curses.COLOR_GREEN, curses.COLOR_BLACK) curses.init_pair(2, curses.COLOR_CYAN, curses.COLOR_BLACK) curses.init_pair(3, curses.COLOR_RED, curses.COLOR_BLACK) curses.init_pair(4, curses.COLOR_MAGENTA, curses.COLOR_BLACK) curses.init_pair(5, curses.COLOR_YELLOW, curses.COLOR_BLACK) window.timeout(50) window.keypad(1) # interpret arrow keys, etc return window
Example #2
Source File: CLI.py From email_hack with MIT License | 7 votes |
def init_curses(self): """Setup the curses""" self.window = curses.initscr() self.height, self.width = self.window.getmaxyx() if self.width < 60: self.too_small = True return self.window.keypad(True) # self.window.nodelay(True) curses.noecho() curses.curs_set(False) curses.cbreak() curses.start_color() curses.init_pair(1, curses.COLOR_RED, curses.COLOR_BLACK) curses.init_pair(2, curses.COLOR_YELLOW, curses.COLOR_BLACK) curses.init_pair(3, curses.COLOR_WHITE, curses.COLOR_BLACK) curses.init_pair(4, curses.COLOR_GREEN, curses.COLOR_BLACK) curses.init_pair(5, curses.COLOR_WHITE, curses.COLOR_CYAN)
Example #3
Source File: gcore_box.py From gaycore with MIT License | 6 votes |
def _init_curses(self): self.stdscr = curses.initscr() self.stdscr.keypad(1) curses.noecho() curses.cbreak() curses.curs_set(0) curses.start_color() try: curses.init_pair(1, curses.COLOR_BLACK, 197) # 接近机核主题的颜色 except: # 树莓派 windows无法使用机核like色 curses.init_pair(1, curses.COLOR_BLACK, curses.COLOR_RED) curses.init_pair(2, curses.COLOR_WHITE, curses.COLOR_BLACK) self.stdscr.bkgd(curses.color_pair(2)) self.stdscr.timeout(100) self.stdscr.refresh()
Example #4
Source File: screen.py From babi with MIT License | 6 votes |
def _init_screen() -> 'curses._CursesWindow': # set the escape delay so curses does not pause waiting for sequences if sys.version_info >= (3, 9): # pragma: no cover curses.set_escdelay(25) else: # pragma: no cover os.environ.setdefault('ESCDELAY', '25') stdscr = curses.initscr() curses.noecho() curses.cbreak() # <enter> is not transformed into '\n' so it can be differentiated from ^J curses.nonl() # ^S / ^Q / ^Z / ^\ are passed through curses.raw() stdscr.keypad(True) with contextlib.suppress(curses.error): curses.start_color() curses.use_default_colors() return stdscr
Example #5
Source File: bookViewer.py From PyLimitOrderBook with MIT License | 6 votes |
def get_int_value(self, message): dimensions = self.screen.getmaxyx() if len(message) < dimensions[1]: empty = dimensions[1] - len(message) - 2 self.screen.addstr(dimensions[0] - 2, len(message) + 1, \ " " * empty, curses.A_STANDOUT) self.screen.addstr(dimensions[0] - 2, 1, message, curses.A_STANDOUT) curses.curs_set(1); curses.echo() # show cursor value = self.screen.getstr() self.draw_help() curses.curs_set(0); curses.noecho() try: return int(value) except ValueError: return None
Example #6
Source File: bookViewer.py From PyLimitOrderBook with MIT License | 6 votes |
def get_int_value(self, message): dimensions = self.screen.getmaxyx() if len(message) < dimensions[1]: empty = dimensions[1] - len(message) - 2 self.screen.addstr(dimensions[0] - 2, len(message) + 1, \ " " * empty, curses.A_STANDOUT) self.screen.addstr(dimensions[0] - 2, 1, message, curses.A_STANDOUT) curses.curs_set(1); curses.echo() # show cursor value = self.screen.getstr() self.draw_help() curses.curs_set(0); curses.noecho() try: return int(value) except ValueError: return None
Example #7
Source File: cli.py From SecureChat with MIT License | 6 votes |
def setup(self): """ Perform basic command-line interface setup. """ curses.curs_set(1) curses.noecho() curses.cbreak() # Keypad disabled until scrolling properly implemented # self.stdscr.keypad(True) self.stdscr.clear() self.stdscr.addstr("SecureChat v{}".format(__version__)) self.chat_container.box() self.chat_win.addstr("Welcome to SecureChat!") self.chat_win.scrollok(True) self.chat_win.setscrreg(0, self.max_y - 5) self.prompt_win.addstr("> ") self.refresh_all()
Example #8
Source File: wrapper.py From BinderFilter with MIT License | 6 votes |
def wrapper(func, *args, **kwds): """Wrapper function that initializes curses and calls another function, restoring normal keyboard/screen behavior on error. The callable object 'func' is then passed the main window 'stdscr' as its first argument, followed by any other arguments passed to wrapper(). """ try: # Initialize curses stdscr = curses.initscr() # Turn off echoing of keys, and enter cbreak mode, # where no buffering is performed on keyboard input curses.noecho() curses.cbreak() # In keypad mode, escape sequences for special keys # (like the cursor keys) will be interpreted and # a special value like curses.KEY_LEFT will be returned stdscr.keypad(1) # Start color, too. Harmless if the terminal doesn't have # color; user can test with has_color() later on. The try/catch # works around a minor bit of over-conscientiousness in the curses # module -- the error return from C start_color() is ignorable. try: curses.start_color() except: pass return func(stdscr, *args, **kwds) finally: # Set everything back to normal if 'stdscr' in locals(): stdscr.keypad(0) curses.echo() curses.nocbreak() curses.endwin()
Example #9
Source File: space_invaders.py From sqlalchemy with MIT License | 6 votes |
def setup_curses(): """Setup terminal/curses state.""" window = curses.initscr() curses.noecho() window = curses.newwin( WINDOW_HEIGHT + (VERT_PADDING * 2), WINDOW_WIDTH + (HORIZ_PADDING * 2), WINDOW_TOP - VERT_PADDING, WINDOW_LEFT - HORIZ_PADDING, ) curses.start_color() global _COLOR_PAIRS _COLOR_PAIRS = {} for i, (k, v) in enumerate(COLOR_MAP.items(), 1): curses.init_pair(i, v, curses.COLOR_BLACK) _COLOR_PAIRS[k] = curses.color_pair(i) return window
Example #10
Source File: npyssafewrapper.py From EDCOP with Apache License 2.0 | 6 votes |
def wrapper_fork(call_function, reset=True): pid = os.fork() if pid: # Parent os.waitpid(pid, 0) if reset: external_reset() else: locale.setlocale(locale.LC_ALL, '') _SCREEN = curses.initscr() try: curses.start_color() except: pass _SCREEN.keypad(1) curses.noecho() curses.cbreak() curses.def_prog_mode() curses.reset_prog_mode() return_code = call_function(_SCREEN) _SCREEN.keypad(0) curses.echo() curses.nocbreak() curses.endwin() sys.exit(0)
Example #11
Source File: npyssafewrapper.py From EDCOP with Apache License 2.0 | 6 votes |
def wrapper_basic(call_function): #set the locale properly locale.setlocale(locale.LC_ALL, '') return curses.wrapper(call_function) #def wrapper(call_function): # locale.setlocale(locale.LC_ALL, '') # screen = curses.initscr() # curses.noecho() # curses.cbreak() # # return_code = call_function(screen) # # curses.nocbreak() # curses.echo() # curses.endwin()
Example #12
Source File: mitop.py From mitogen with BSD 3-Clause "New" or "Revised" License | 6 votes |
def __init__(self, hosts): self.stdscr = curses.initscr() curses.start_color() self.height, self.width = self.stdscr.getmaxyx() curses.cbreak() curses.noecho() self.stdscr.keypad(1) self.hosts = hosts self.format = ( '%(hostname)10.10s ' '%(pid)7.7s ' '%(ppid)7.7s ' '%(pcpu)6.6s ' '%(rss)5.5s ' '%(command)20s' )
Example #13
Source File: npyssafewrapper.py From apple_bleee with GNU General Public License v3.0 | 6 votes |
def wrapper_fork(call_function, reset=True): pid = os.fork() if pid: # Parent os.waitpid(pid, 0) if reset: external_reset() else: locale.setlocale(locale.LC_ALL, '') _SCREEN = curses.initscr() try: curses.start_color() except: pass _SCREEN.keypad(1) curses.noecho() curses.cbreak() curses.def_prog_mode() curses.reset_prog_mode() return_code = call_function(_SCREEN) _SCREEN.keypad(0) curses.echo() curses.nocbreak() curses.endwin() sys.exit(0)
Example #14
Source File: npyssafewrapper.py From HomePWN with GNU General Public License v3.0 | 6 votes |
def wrapper_basic(call_function): #set the locale properly locale.setlocale(locale.LC_ALL, '') return curses.wrapper(call_function) #def wrapper(call_function): # locale.setlocale(locale.LC_ALL, '') # screen = curses.initscr() # curses.noecho() # curses.cbreak() # # return_code = call_function(screen) # # curses.nocbreak() # curses.echo() # curses.endwin()
Example #15
Source File: npyssafewrapper.py From HomePWN with GNU General Public License v3.0 | 6 votes |
def wrapper_fork(call_function, reset=True): pid = os.fork() if pid: # Parent os.waitpid(pid, 0) if reset: external_reset() else: locale.setlocale(locale.LC_ALL, '') _SCREEN = curses.initscr() try: curses.start_color() except: pass _SCREEN.keypad(1) curses.noecho() curses.cbreak() curses.def_prog_mode() curses.reset_prog_mode() return_code = call_function(_SCREEN) _SCREEN.keypad(0) curses.echo() curses.nocbreak() curses.endwin() sys.exit(0)
Example #16
Source File: airpydump.py From airpydump with MIT License | 6 votes |
def __init__(self, scanner): self.scanner = scanner self.screen = curses.initscr() curses.noecho() curses.cbreak() self.screen.keypad(1) self.screen.scrollok(True) self.x, self.y = self.screen.getmaxyx() curses.start_color() curses.use_default_colors() try: self.screen.curs_set(0) except: try: self.screen.curs_set(1) except: pass
Example #17
Source File: command.py From SpotipyTUI with MIT License | 6 votes |
def get_input(self, prompt): """Get user input through the user interface and return it.""" curses.curs_set(2) self.prompt_area.clear() self.input_prompt.addstr(0, 0, prompt) self.search_window.clear() self.prompt_area.refresh() curses.echo() user_input = self.search_window.getstr().decode(encoding="utf-8") curses.noecho() self.prompt_area.clear() self.prompt_area.refresh() curses.curs_set(0) return user_input
Example #18
Source File: pg-top.py From postgresql-perf-tools with GNU General Public License v2.0 | 6 votes |
def pg_top(scr, pgt, con, opts): curses.noecho() # disable echo curses.cbreak() # keys are read directly, without hitting Enter # curses.curs_set(0) # disable mouse pgt.init(scr, con, opts) t = threading.Thread(target=main_loop, args=(pgt,)) t.daemon = True t.start() while 1: try: key = pgt.getkey() if key == 'q': pgt.terminate = True break except KeyboardInterrupt: break pgt.terminate = True
Example #19
Source File: npyssafewrapper.py From apple_bleee with GNU General Public License v3.0 | 6 votes |
def wrapper_basic(call_function): #set the locale properly locale.setlocale(locale.LC_ALL, '') return curses.wrapper(call_function) #def wrapper(call_function): # locale.setlocale(locale.LC_ALL, '') # screen = curses.initscr() # curses.noecho() # curses.cbreak() # # return_code = call_function(screen) # # curses.nocbreak() # curses.echo() # curses.endwin()
Example #20
Source File: npyssafewrapper.py From TelegramTUI with MIT License | 5 votes |
def wrapper_basic(call_function): #set the locale properly locale.setlocale(locale.LC_ALL, '') return curses.wrapper(call_function) #def wrapper(call_function): # locale.setlocale(locale.LC_ALL, '') # screen = curses.initscr() # curses.noecho() # curses.cbreak() # # return_code = call_function(screen) # # curses.nocbreak() # curses.echo() # curses.endwin()
Example #21
Source File: display.py From castero with MIT License | 5 votes |
def _get_y_n(self, prompt) -> bool: """Prompts the user for a yes or no (y/n) input. Args: prompt: a string to inform the user of what they need to enter Returns: bool: true if the user presses y, false otherwise """ assert self._footer_window is not None assert isinstance(prompt, str) curses.echo() curses.curs_set(1) self._footer_window.addstr( 1, 0, " " * (self._footer_window.getmaxyx()[1] - 1) ) self._footer_window.addstr(1, 0, prompt) char = self._footer_window.getch() self._footer_window.clear() curses.curs_set(0) curses.noecho() return char == ord('y')
Example #22
Source File: inspect.py From flowcraft with GNU General Public License v3.0 | 5 votes |
def display_overview(self): """Displays the default pipeline inspection overview """ stay_alive = True self.screen = curses.initscr() self.screen.keypad(True) self.screen.nodelay(-1) curses.cbreak() curses.noecho() curses.start_color() self.screen_lines = self.screen.getmaxyx()[0] # self.screen_width = self.screen.getmaxyx()[1] try: while stay_alive: # Provide functionality to certain keybindings self._curses_keybindings() # Updates main inspector attributes self.update_inspection() # Display curses interface self.flush_overview() sleep(self.refresh_rate) except FileNotFoundError: sys.stderr.write(colored_print( "ERROR: nextflow log and/or trace files are no longer " "reachable!", "red_bold")) except Exception as e: sys.stderr.write(str(e)) finally: curses.nocbreak() self.screen.keypad(0) curses.echo() curses.endwin()
Example #23
Source File: curses_display.py From anyMesh-Python with MIT License | 5 votes |
def start(self): """ Initialize the screen and input mode. """ assert self._started == False self.s = curses.initscr() self.has_color = curses.has_colors() if self.has_color: curses.start_color() if curses.COLORS < 8: # not colourful enough self.has_color = False if self.has_color: try: curses.use_default_colors() self.has_default_colors=True except _curses.error: self.has_default_colors=False self._setup_colour_pairs() curses.noecho() curses.meta(1) curses.halfdelay(10) # use set_input_timeouts to adjust self.s.keypad(0) if not self._signal_keys_set: self._old_signal_keys = self.tty_signal_keys() super(Screen, self).start()
Example #24
Source File: dvedeky.py From typhon-vx with GNU General Public License v3.0 | 5 votes |
def maindraw(): global phones global mainpad global height,width mainpad.erase() for i in range(0,len(phones)): phoneline(i) helptext() curses.noecho() curses.cbreak() stdscr.keypad(1) stdscr.refresh() mainpad.redrawwin() mainpad.refresh( 0,0, 0,0, height,width)
Example #25
Source File: screen.py From WiFiBroot with GNU General Public License v3.0 | 5 votes |
def __init__(self, verbosity): self.screen = curses.initscr() curses.noecho() curses.cbreak() self.screen.keypad(1) self.screen.scrollok(True) self.verbose = verbosity
Example #26
Source File: 2048.py From Python-Application with GNU General Public License v3.0 | 5 votes |
def game(board, stdscr, rscore): global score global change # curses.noecho() # 屏幕不显示用户输入的字符 curses.noecho() while 1: # stdscr.getch() # 读取用户输入的字符 order = stdscr.getch() # move()对用户移动的响应 current_board, change = move(order, board) # change 为 1 随机产生 2 或 4 if change: current_board = choice(board) # 打印棋盘 print_board(stdscr, current_board, rscore) # 当棋盘被填满,判断是否游戏结束 if (current_board != 0).all(): fail(current_board) # win 为 1 打印获胜提示 if win: stdscr.addstr('You win') # 随机产生 2 或 4
Example #27
Source File: ui.py From oandapybot with MIT License | 5 votes |
def Start(self): self._oanda.SubscribeHeartbeat(self) self._oanda.SubscribeTicker(self) self._oanda.SubscribeUpdates(self) # init curses self.stdscr = curses.initscr() curses.noecho() self.stdscr.keypad(1) self.stdscr.nodelay(1) self.Update(None) self.Render()
Example #28
Source File: wrapper.py From PokemonGo-DesktopMap with MIT License | 5 votes |
def wrapper(func, *args, **kwds): """Wrapper function that initializes curses and calls another function, restoring normal keyboard/screen behavior on error. The callable object 'func' is then passed the main window 'stdscr' as its first argument, followed by any other arguments passed to wrapper(). """ try: # Initialize curses stdscr = curses.initscr() # Turn off echoing of keys, and enter cbreak mode, # where no buffering is performed on keyboard input curses.noecho() curses.cbreak() # In keypad mode, escape sequences for special keys # (like the cursor keys) will be interpreted and # a special value like curses.KEY_LEFT will be returned stdscr.keypad(1) # Start color, too. Harmless if the terminal doesn't have # color; user can test with has_color() later on. The try/catch # works around a minor bit of over-conscientiousness in the curses # module -- the error return from C start_color() is ignorable. try: curses.start_color() except: pass return func(stdscr, *args, **kwds) finally: # Set everything back to normal if 'stdscr' in locals(): stdscr.keypad(0) curses.echo() curses.nocbreak() curses.endwin()
Example #29
Source File: wrapper.py From Splunking-Crime with GNU Affero General Public License v3.0 | 5 votes |
def wrapper(func, *args, **kwds): """Wrapper function that initializes curses and calls another function, restoring normal keyboard/screen behavior on error. The callable object 'func' is then passed the main window 'stdscr' as its first argument, followed by any other arguments passed to wrapper(). """ try: # Initialize curses stdscr = curses.initscr() # Turn off echoing of keys, and enter cbreak mode, # where no buffering is performed on keyboard input curses.noecho() curses.cbreak() # In keypad mode, escape sequences for special keys # (like the cursor keys) will be interpreted and # a special value like curses.KEY_LEFT will be returned stdscr.keypad(1) # Start color, too. Harmless if the terminal doesn't have # color; user can test with has_color() later on. The try/catch # works around a minor bit of over-conscientiousness in the curses # module -- the error return from C start_color() is ignorable. try: curses.start_color() except: pass return func(stdscr, *args, **kwds) finally: # Set everything back to normal if 'stdscr' in locals(): stdscr.keypad(0) curses.echo() curses.nocbreak() curses.endwin()
Example #30
Source File: npyssafewrapper.py From HomePWN with GNU General Public License v3.0 | 5 votes |
def wrapper_no_fork(call_function, reset=False): global _NEVER_RUN_INITSCR if not _NEVER_RUN_INITSCR: warnings.warn("""Repeated calls of endwin may cause a memory leak. Use wrapper_fork to avoid.""") global _SCREEN return_code = None if _NEVER_RUN_INITSCR: _NEVER_RUN_INITSCR = False locale.setlocale(locale.LC_ALL, '') _SCREEN = curses.initscr() try: curses.start_color() except: pass curses.noecho() curses.cbreak() _SCREEN.keypad(1) curses.noecho() curses.cbreak() _SCREEN.keypad(1) try: return_code = call_function(_SCREEN) finally: _SCREEN.keypad(0) curses.echo() curses.nocbreak() # Calling endwin() and then refreshing seems to cause a memory leak. curses.endwin() if reset: external_reset() return return_code