Python curses.echo() Examples
The following are 30
code examples of curses.echo().
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: termpdf.py From termpdf.py with MIT License | 7 votes |
def clean_exit(message=''): scr.create_text_win(1, ' ') for doc in bufs.docs: # save current state doc.write_state() # close the document doc.close() # close curses scr.stdscr.keypad(False) curses.echo() curses.curs_set(1) curses.endwin() raise SystemExit(message)
Example #2
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 #3
Source File: display.py From castero with MIT License | 6 votes |
def terminate(self) -> None: """Set console settings to their normal state. This method does not, by itself, cause the application to exit. Nor does it even cause the input loop to end. It should simply be seen as a "wrapping up" method for any actions which need to be performed before the object is destroyed. """ self._queue.stop() self.database.replace_queue(self._queue) curses.nocbreak() self._stdscr.keypad(False) curses.echo() curses.endwin()
Example #4
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 #5
Source File: __main__.py From asciidots with GNU Affero General Public License v3.0 | 6 votes |
def curses_input(self, stdscr, row, col, prompt_string, ascii_mode=False): """ Get an input string with curses. Row and col are the start position ot the prompt_string. """ curses.echo() stdscr.addstr(row, col, str(prompt_string), curses.A_REVERSE) stdscr.addstr(row + 1, col, " " * (curses.COLS - 1)) stdscr.refresh() input_val = "" while len(input_val) <= 0: if ascii_mode: input_val = chr(stdscr.getch()) break else: input_val = stdscr.getstr(row + 1, col, 20) return input_val
Example #6
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 #7
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 #8
Source File: inspect.py From flowcraft with GNU General Public License v3.0 | 6 votes |
def signal_handler(screen): """This function is bound to the SIGINT signal (like ctrl+c) to graciously exit the program and reset the curses options. """ if screen: screen.clear() screen.refresh() curses.nocbreak() screen.keypad(0) curses.echo() curses.endwin() print("Exiting flowcraft inspection... Bye") sys.exit(0)
Example #9
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 #10
Source File: console.py From fluxclient with GNU Affero General Public License v3.0 | 6 votes |
def setup(self): curses.start_color() curses.init_pair(1, curses.COLOR_WHITE, curses.COLOR_BLUE) curses.cbreak() curses.echo() lines, cols = self.stdscr.getmaxyx() self.logwin = self.stdscr.subwin(lines - 2, cols, 0, 0) self.sepwin = self.stdscr.subwin(1, cols, lines - 2, 0) self.cmdwin = self.stdscr.subwin(1, cols, lines - 1, 0) self.logwin.scrollok(True) self.sepwin.bkgd(curses.color_pair(1)) self.sepwin.refresh()
Example #11
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 #12
Source File: curses_display.py From anyMesh-Python with MIT License | 6 votes |
def stop(self): """ Restore the screen. """ if self._started == False: return curses.echo() self._curs_set(1) try: curses.endwin() except _curses.error: pass # don't block original error with curses error if self._old_signal_keys: self.tty_signal_keys(*self._old_signal_keys) super(Screen, self).stop()
Example #13
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 #14
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 #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: 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 #17
Source File: __main__.py From musicbox with MIT License | 6 votes |
def start(): parser = argparse.ArgumentParser() parser.add_argument( "-v", "--version", help="show this version and exit", action="store_true" ) args = parser.parse_args() if args.version: latest = Menu().check_version() curses.endwin() print("NetEase-MusicBox installed version:" + version) if latest != version: print("NetEase-MusicBox latest version:" + str(latest)) sys.exit() nembox_menu = Menu() try: nembox_menu.start_fork(version) except (OSError, TypeError, ValueError, KeyError, IndexError): # clean up terminal while failed curses.echo() curses.nocbreak() curses.endwin() traceback.print_exc()
Example #18
Source File: airpydump.py From airpydump with MIT License | 6 votes |
def manipulate(self, pkt): if self.save: self.file__.write(pkt) self.call1(pkt) self.call2(pkt) call3_varbell = self.call3(pkt) if bool(call3_varbell): self.ntwk_call_3.append(call3_varbell) call4_varbell = self.call4(pkt) if bool(call4_varbell): self.ntwk_call_4.append(call4_varbell) if self.curses: try: self.display.print_handler() except: curses.nocbreak() self.display.screen.keypad(0) curses.echo() curses.endwin() return
Example #19
Source File: parse.py From eapeak with BSD 3-Clause "New" or "Revised" License | 5 votes |
def cleanup_curses(self): """ This cleans up the curses interface and resets things back to normal. """ if not self.curses_enabled: return self.screen.erase() del self.screen curses.endwin() curses.echo() self.curses_enabled = False
Example #20
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
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: ui.py From oandapybot with MIT License | 5 votes |
def Stop(self): if not self.stdscr: return # deinit curses self.stdscr.nodelay(0) self.stdscr.keypad(0) curses.echo() curses.endwin()
Example #23
Source File: render.py From ricedb with GNU General Public License v3.0 | 5 votes |
def end(self): self.scr.clear() curses.nocbreak() self.scr.keypad(False) curses.echo() curses.endwin()
Example #24
Source File: gcore_box.py From gaycore with MIT License | 5 votes |
def _end_curses(self): """ Terminates the curses application. """ curses.nocbreak() self.stdscr.keypad(0) curses.echo() curses.endwin()
Example #25
Source File: grid.py From ngrid with BSD 3-Clause "New" or "Revised" License | 5 votes |
def __do_search(self, dir): self.__screen.addstr( self.__screen_height - 1, 0, ("/" if dir == 1 else "?") + " " * (self.__screen_width - 2), curses.A_REVERSE) curses.echo() pattern = self.__screen.getstr(self.__screen_height -1 , 1) curses.noecho() if len(pattern) > 0: self.searchTerm = re.compile(pattern) self._nextSearchOccurrence(dir, includeCurrentLine=True) else: self.searchTerm = None
Example #26
Source File: cgroup_top.py From ctop with MIT License | 5 votes |
def init_screen(): curses.start_color() # load colors curses.use_default_colors() curses.noecho() # do not echo text curses.cbreak() # do not wait for "enter" curses.mousemask(curses.ALL_MOUSE_EVENTS) # Hide cursor, if terminal AND curse supports it if hasattr(curses, 'curs_set'): try: curses.curs_set(0) except: pass
Example #27
Source File: dashvote.py From dashman with MIT License | 5 votes |
def cleanup(): curses.nocbreak() stdscr.keypad(0) curses.echo() curses.endwin()
Example #28
Source File: ncurses.py From collection with MIT License | 5 votes |
def quit (self): if self.screen: self.screen.keypad(0) self.screen = None curses.echo() curses.nocbreak() curses.endwin() # curses.reset_shell_mode() return 0
Example #29
Source File: dht_monitor.py From lbry-sdk with MIT License | 5 votes |
def teardown_curses(): curses.nocbreak() stdscr.keypad(0) curses.echo() curses.endwin()
Example #30
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()