Python curses.use_default_colors() Examples
The following are 30
code examples of curses.use_default_colors().
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: npysThemeManagers.py From HomePWN with GNU General Public License v3.0 | 6 votes |
def __init__(self): #curses.use_default_colors() self.define_colour_numbers() self._defined_pairs = {} self._names = {} try: self._max_pairs = curses.COLOR_PAIRS - 1 do_color = True except AttributeError: # curses.start_color has failed or has not been called do_color = False # Disable all color use across the application disableColor() if do_color and curses.has_colors(): self.initialize_pairs() self.initialize_names()
Example #2
Source File: npysThemeManagers.py From TelegramTUI with MIT License | 6 votes |
def __init__(self): #curses.use_default_colors() self.define_colour_numbers() self._defined_pairs = {} self._names = {} try: self._max_pairs = curses.COLOR_PAIRS - 1 do_color = True except AttributeError: # curses.start_color has failed or has not been called do_color = False # Disable all color use across the application disableColor() if do_color and curses.has_colors(): self.initialize_pairs() self.initialize_names()
Example #3
Source File: npysThemeManagers.py From EDCOP with Apache License 2.0 | 6 votes |
def __init__(self): #curses.use_default_colors() self.define_colour_numbers() self._defined_pairs = {} self._names = {} try: self._max_pairs = curses.COLOR_PAIRS - 1 do_color = True except AttributeError: # curses.start_color has failed or has not been called do_color = False # Disable all color use across the application disableColor() if do_color and curses.has_colors(): self.initialize_pairs() self.initialize_names()
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: termdown.py From termdown with GNU General Public License v3.0 | 6 votes |
def setup(stdscr): # curses curses.use_default_colors() curses.init_pair(1, curses.COLOR_RED, -1) curses.init_pair(2, curses.COLOR_RED, curses.COLOR_RED) curses.init_pair(3, curses.COLOR_GREEN, -1) curses.init_pair(4, -1, curses.COLOR_RED) try: curses.curs_set(False) except curses.error: # fails on some terminals pass stdscr.timeout(0) # prepare input thread mechanisms curses_lock = Lock() input_queue = Queue() quit_event = Event() return (curses_lock, input_queue, quit_event)
Example #6
Source File: npysThemeManagers.py From apple_bleee with GNU General Public License v3.0 | 6 votes |
def __init__(self): #curses.use_default_colors() self.define_colour_numbers() self._defined_pairs = {} self._names = {} try: self._max_pairs = curses.COLOR_PAIRS - 1 do_color = True except AttributeError: # curses.start_color has failed or has not been called do_color = False # Disable all color use across the application disableColor() if do_color and curses.has_colors(): self.initialize_pairs() self.initialize_names()
Example #7
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 #8
Source File: top.py From python-scripts with GNU General Public License v3.0 | 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 #9
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 #10
Source File: obsoletepythonsupport.py From BitTorrent with GNU General Public License v3.0 | 5 votes |
def import_curses(): import curses if not hasattr(curses, 'use_default_colors'): def use_default_colors(): return curses.use_default_colors = use_default_colors return curses
Example #11
Source File: obsoletepythonsupport.py From BitTorrent with GNU General Public License v3.0 | 5 votes |
def import_curses(): import curses if not hasattr(curses, 'use_default_colors'): def use_default_colors(): return curses.use_default_colors = use_default_colors return curses
Example #12
Source File: start.py From gpymusic with MIT License | 5 votes |
def set_colours(colours): """ Set curses colours. Arguments: colours: Dict with colour information. """ crs.start_color() # Define colours. if colours['background'] == 'default': crs.use_default_colors() background = -1 else: crs.init_color(0, *hex_to_rgb(colours['background'])) background = 0 crs.init_color(1, *hex_to_rgb(colours['foreground'])) crs.init_color(2, *hex_to_rgb(colours['highlight'])) crs.init_color(3, *hex_to_rgb(colours['content1'])) crs.init_color(4, *hex_to_rgb(colours['content2'])) # Define colour pairs. crs.init_pair(1, 1, background) crs.init_pair(2, 2, background) crs.init_pair(3, 3, background) crs.init_pair(4, 4, background) # Set colours. crs.start_color() common.w.main.bkgdset(' ', crs.color_pair(1)) common.w.inbar.bkgdset(' ', crs.color_pair(1)) common.w.infobar.bkgdset(' ', crs.color_pair(2)) common.w.outbar.bkgdset(' ', crs.color_pair(4)) common.w.refresh()
Example #13
Source File: npysThemes.py From EDCOP with Apache License 2.0 | 5 votes |
def __init__(self, *args, **keywords): curses.use_default_colors() super(TransparentThemeDarkText, self).__init__(*args, **keywords)
Example #14
Source File: python_pick.py From NSC_BUILDER with MIT License | 5 votes |
def config_curses(self): # use the default colors of the terminal curses.use_default_colors() # hide the cursor curses.curs_set(0) #add some color for multi_select #@todo make colors configurable curses.init_pair(1, curses.COLOR_GREEN, curses.COLOR_WHITE)
Example #15
Source File: cgroup_top.py From python-scripts with GNU General Public License v3.0 | 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 #16
Source File: cursesAPI.py From PathPicker with MIT License | 5 votes |
def useDefaultColors(self): curses.use_default_colors()
Example #17
Source File: unimatrix.py From unimatrix with GNU General Public License v3.0 | 5 votes |
def __init__(self, screen): self.screen = screen self.screen.scrollok(0) curses.curs_set(0) curses.use_default_colors() curses.init_pair(1, start_color, start_bg) curses.init_pair(2, curses.COLOR_WHITE, start_bg) curses.init_pair(3, curses.COLOR_BLACK, curses.COLOR_WHITE) self.white = curses.color_pair(2)
Example #18
Source File: worldmap.py From EasY_HaCk with Apache License 2.0 | 5 votes |
def __init__(self, map_name='world', map_conf=None, window=None, encoding=None): if map_conf is None: map_conf = MAPS[map_name] self.map = map_conf['data'] self.coords = map_conf['coords'] self.corners = map_conf['corners'] if window is None: window = curses.newwin(0, 0) self.window = window self.data = [] self.data_timestamp = None # JSON contents _should_ be UTF8 (so, python internal unicode here...) if encoding is None: encoding = locale.getpreferredencoding() self.encoding = encoding # check if we can use transparent background or not if curses.can_change_color(): curses.use_default_colors() background = -1 else: background = curses.COLOR_BLACK tmp_colors = [ ('red', curses.COLOR_RED, background), ('blue', curses.COLOR_BLUE, background), ('pink', curses.COLOR_MAGENTA, background) ] self.colors = {} if curses.has_colors(): for i, (name, fgcolor, bgcolor) in enumerate(tmp_colors, 1): curses.init_pair(i, fgcolor, bgcolor) self.colors[name] = i
Example #19
Source File: display.py From castero with MIT License | 5 votes |
def __init__(self, stdscr, database) -> None: """ Args: stdscr: a stdscr from curses.initscr() database: a connected castero.Database """ self._stdscr = stdscr self._database = database self._parent_x = -1 self._parent_y = -1 self._perspectives = {} self._active_perspective = 1 self._header_window = None self._footer_window = None self._queue = Queue(self) self._download_queue = DownloadQueue(self) self._status = "" self._header_str = "" self._footer_str = "" self._status_timer = self.STATUS_TIMEOUT self._update_timer = self.UPDATE_TIMEOUT self._menus_valid = True self._modified_episodes = [] # basic preliminary operations self._stdscr.timeout(self.INPUT_TIMEOUT) curses.start_color() curses.use_default_colors() curses.noecho() curses.curs_set(0) curses.cbreak() self._stdscr.keypad(True) self.update_parent_dimensions() self.create_color_pairs() self._load_perspectives() self._load_players() self._restore_queue() self._create_windows() self.create_menus()
Example #20
Source File: colors.py From pipenv-pipes with MIT License | 5 votes |
def initialize(self): """ This can only be executed after curses.wrapper() """ curses.use_default_colors() # use the default colors of the terminal for name, integer in Colors.CONSTANTS.items(): color = Color(index=integer, fg=integer, bg=Color.TRANSPARENT) self._colors[name] = color
Example #21
Source File: npysThemes.py From TelegramTUI with MIT License | 5 votes |
def __init__(self, *args, **keywords): curses.use_default_colors() super(TransparentThemeDarkText, self).__init__(*args, **keywords)
Example #22
Source File: curses_ui.py From Serverless-Deep-Learning-with-TensorFlow-and-AWS-Lambda with MIT License | 5 votes |
def _screen_color_init(self): """Initialization of screen colors.""" curses.start_color() curses.use_default_colors() self._color_pairs = {} color_index = 0 # Prepare color pairs. for fg_color in self._FOREGROUND_COLORS: for bg_color in self._BACKGROUND_COLORS: color_index += 1 curses.init_pair(color_index, self._FOREGROUND_COLORS[fg_color], self._BACKGROUND_COLORS[bg_color]) color_name = fg_color if bg_color != "transparent": color_name += "_on_" + bg_color self._color_pairs[color_name] = curses.color_pair(color_index) # Try getting color(s) available only under 256-color support. try: color_index += 1 curses.init_pair(color_index, 245, -1) self._color_pairs[cli_shared.COLOR_GRAY] = curses.color_pair(color_index) except curses.error: # Use fall-back color(s): self._color_pairs[cli_shared.COLOR_GRAY] = ( self._color_pairs[cli_shared.COLOR_GREEN]) # A_BOLD or A_BLINK is not really a "color". But place it here for # convenience. self._color_pairs["bold"] = curses.A_BOLD self._color_pairs["blink"] = curses.A_BLINK self._color_pairs["underline"] = curses.A_UNDERLINE # Default color pair to use when a specified color pair does not exist. self._default_color_pair = self._color_pairs[cli_shared.COLOR_WHITE]
Example #23
Source File: __init__.py From pick with MIT License | 5 votes |
def config_curses(self): try: # use the default colors of the terminal curses.use_default_colors() # hide the cursor curses.curs_set(0) # add some color for multi_select # @todo make colors configurable curses.init_pair(1, curses.COLOR_GREEN, curses.COLOR_WHITE) except: # Curses failed to initialize color support, eg. when TERM=vt100 curses.initscr()
Example #24
Source File: sifter.py From sandsifter with BSD 3-Clause "New" or "Revised" License | 5 votes |
def __init__(self, ts, injector, tests, do_tick, disassembler=disas_capstone): self.ts = ts; self.injector = injector self.T = tests self.gui_thread = None self.do_tick = do_tick self.ticks = 0 self.last_ins_count = 0 self.delta_log = deque(maxlen=self.RATE_Q) self.time_log = deque(maxlen=self.RATE_Q) self.disas = disassembler self.stdscr = curses.initscr() curses.start_color() # doesn't work # self.orig_colors = [curses.color_content(x) for x in xrange(256)] curses.use_default_colors() curses.noecho() curses.cbreak() curses.curs_set(0) self.stdscr.nodelay(1) self.sx = 0 self.sy = 0 self.init_colors() self.stdscr.bkgd(curses.color_pair(self.WHITE)) self.last_time = time.time()
Example #25
Source File: ui.py From musicbox with MIT License | 5 votes |
def __init__(self): self.screen = curses.initscr() self.screen.timeout(100) # the screen refresh every 100ms # charactor break buffer curses.cbreak() self.screen.keypad(1) curses.start_color() if Config().get("curses_transparency"): curses.use_default_colors() curses.init_pair(1, curses.COLOR_GREEN, -1) curses.init_pair(2, curses.COLOR_CYAN, -1) curses.init_pair(3, curses.COLOR_RED, -1) curses.init_pair(4, curses.COLOR_YELLOW, -1) else: 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_YELLOW, curses.COLOR_BLACK) # term resize handling size = terminalsize.get_terminal_size() self.x = max(size[0], 10) self.y = max(size[1], 25) self.startcol = int(float(self.x) / 5) self.indented_startcol = max(self.startcol - 3, 0) self.update_space() self.lyric = "" self.now_lyric = "" self.post_lyric = "" self.now_lyric_index = 0 self.tlyric = "" self.storage = Storage() self.config = Config() self.newversion = False
Example #26
Source File: tabview.py From OpenTrader with GNU Lesser General Public License v3.0 | 5 votes |
def main(stdscr, *args, **kwargs): try: curses.use_default_colors() except (AttributeError, _curses.error): pass try: curses.curs_set(False) except (AttributeError, _curses.error): pass Viewer(stdscr, *args, **kwargs).run()
Example #27
Source File: window.py From lyrics-in-terminal with MIT License | 5 votes |
def __init__(self, stdscr, player, timeout): self.stdscr = stdscr self.height, self.width = stdscr.getmaxyx() self.player = player self.scroll_pad = curses.newpad(self.player.track.length + 2, self.player.track.width + 2) self.current_pos = 0 self.pad_offset = 1 self.text_padding = 5 self.keys = Key() curses.use_default_colors() self.stdscr.timeout(timeout) self.set_up()
Example #28
Source File: event_listening.py From stem with GNU Lesser General Public License v3.0 | 5 votes |
def __init__(self, stdscr): self._stdscr = stdscr # Mappings of names to the curses color attribute. Initially these all # reference black text, but if the terminal can handle color then # they're set with that foreground color. self._colors = dict([(color, 0) for color in COLOR_LIST]) # allows for background transparency try: curses.use_default_colors() except curses.error: pass # makes the cursor invisible try: curses.curs_set(0) except curses.error: pass # initializes colors if the terminal can handle them try: if curses.has_colors(): color_pair = 1 for name, foreground in COLOR_LIST.items(): background = -1 # allows for default (possibly transparent) background curses.init_pair(color_pair, foreground, background) self._colors[name] = curses.color_pair(color_pair) color_pair += 1 except curses.error: pass
Example #29
Source File: curses_ui.py From lambda-packs with MIT License | 5 votes |
def _screen_color_init(self): """Initialization of screen colors.""" curses.start_color() curses.use_default_colors() self._color_pairs = {} color_index = 0 # Prepare color pairs. for fg_color in self._FOREGROUND_COLORS: for bg_color in self._BACKGROUND_COLORS: color_index += 1 curses.init_pair(color_index, self._FOREGROUND_COLORS[fg_color], self._BACKGROUND_COLORS[bg_color]) color_name = fg_color if bg_color != "transparent": color_name += "_on_" + bg_color self._color_pairs[color_name] = curses.color_pair(color_index) # Try getting color(s) available only under 256-color support. try: color_index += 1 curses.init_pair(color_index, 245, -1) self._color_pairs[cli_shared.COLOR_GRAY] = curses.color_pair(color_index) except curses.error: # Use fall-back color(s): self._color_pairs[cli_shared.COLOR_GRAY] = ( self._color_pairs[cli_shared.COLOR_GREEN]) # A_BOLD or A_BLINK is not really a "color". But place it here for # convenience. self._color_pairs["bold"] = curses.A_BOLD self._color_pairs["blink"] = curses.A_BLINK self._color_pairs["underline"] = curses.A_UNDERLINE # Default color pair to use when a specified color pair does not exist. self._default_color_pair = self._color_pairs[cli_shared.COLOR_WHITE]
Example #30
Source File: cryptop.py From cryptop with MIT License | 5 votes |
def conf_scr(): '''Configure the screen and colors/etc''' curses.curs_set(0) curses.start_color() curses.use_default_colors() text, banner, banner_text, background = get_theme_colors() curses.init_pair(2, text, background) curses.init_pair(3, banner_text, banner) curses.halfdelay(10)