Python curses.nocbreak() Examples
The following are 30
code examples of curses.nocbreak().
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: 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 #2
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 #3
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 #4
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 #5
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 #6
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 #7
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 #8
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 #9
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 #10
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 #11
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 #12
Source File: interface.py From bitcoind-ncurses with MIT License | 6 votes |
def main(block_viewer, window, interface_queue, rpcc, poller, initial_mode=None): error_message = False rpcc.request("getnetworkinfo") rpcc.request("getblockchaininfo") try: state = init_state() splash.draw_window(state, window) check_window_size(interface_queue, state, window, 12, 75) # min_y, min_x if initial_mode: hotkey.change_mode(state, window, initial_mode, poller) error_message = loop(block_viewer, state, window, interface_queue, rpcc, poller) finally: # restore sane terminal state, end RPC thread curses.nocbreak() curses.endwin() if error_message: sys.stderr.write("bitcoind-ncurses encountered an error\n") sys.stderr.write("Message: " + error_message + "\n")
Example #13
Source File: npyssafewrapper.py From TelegramTUI with MIT License | 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: curses_ui.py From Serverless-Deep-Learning-with-TensorFlow-and-AWS-Lambda with MIT License | 5 votes |
def _screen_terminate(self): """Terminate the curses screen.""" self._stdscr.keypad(0) curses.nocbreak() curses.echo() curses.endwin() try: # Remove SIGINT handler. signal.signal(signal.SIGINT, signal.SIG_DFL) except ValueError: # Can't catch signals unless you're the main thread. pass
Example #15
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 #16
Source File: npyssafewrapper.py From TelegramTUI with MIT License | 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 #17
Source File: npyssafewrapper.py From EDCOP with Apache License 2.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 #18
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 #19
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 #20
Source File: picker.py From Spelt with MIT License | 5 votes |
def curses_stop(self): curses.nocbreak() self.stdscr.keypad(0) curses.echo() curses.endwin()
Example #21
Source File: grid.py From ngrid with BSD 3-Clause "New" or "Revised" License | 5 votes |
def show_model(model, cfg={}, num_frozen=0): """ Shows an interactive view of the model on a connected TTY. @type model A model instance from this module. """ full_cfg = dict(DEFAULT_CFG) full_cfg.update(cfg) cfg = full_cfg view = GridView(model, cfg, num_frozen=num_frozen) scr = curses.initscr() curses.start_color() curses.use_default_colors() curses.init_pair(1, -1, -1) # normal curses.init_pair(2, curses.COLOR_BLUE, -1) # frozen curses.init_pair(3, -1, -1) # separator curses.init_pair(4, -1, -1) # footer curses.init_pair(5, curses.COLOR_BLACK, curses.COLOR_WHITE) # cursor curses.init_pair(6, curses.COLOR_WHITE, curses.COLOR_BLUE) # selection curses.init_pair(7, curses.COLOR_BLUE, curses.COLOR_WHITE) # frz sel try: curses.noecho() curses.cbreak() scr.keypad(1) view.set_screen(scr, locale.getpreferredencoding()) view.show() finally: curses.nocbreak() scr.keypad(0) curses.echo() curses.endwin()
Example #22
Source File: screen.py From aws-elastic-beanstalk-cli with Apache License 2.0 | 5 votes |
def close(self, restore=True): """ Close down this Screen and tidy up the environment as required. :param restore: whether to restore the environment or not. """ self._signal_state.restore() if restore: self._screen.keypad(0) curses.echo() curses.nocbreak() curses.endwin()
Example #23
Source File: curses_ui.py From keras-lambda with MIT License | 5 votes |
def _screen_terminate(self): """Terminate the curses screen.""" self._stdscr.keypad(0) curses.nocbreak() curses.echo() curses.endwin() # Remove SIGINT handler. signal.signal(signal.SIGINT, signal.SIG_DFL)
Example #24
Source File: top.py From python-scripts with GNU General Public License v3.0 | 5 votes |
def do_finish(): """ Stop top.py and reinit curses.""" curses.nocbreak() stdscr.keypad(0) curses.echo() curses.endwin() #The end... sys.exit(0)
Example #25
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 #26
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 #27
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 #28
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 #29
Source File: dashvote.py From dashman with MIT License | 5 votes |
def cleanup(): curses.nocbreak() stdscr.keypad(0) curses.echo() curses.endwin()
Example #30
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