Python curses.COLOR_PAIRS Examples
The following are 29
code examples of curses.COLOR_PAIRS().
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: __init__.py From Imogen with MIT License | 6 votes |
def initscr(): import _curses, curses # we call setupterm() here because it raises an error # instead of calling exit() in error cases. setupterm(term=_os.environ.get("TERM", "unknown"), fd=_sys.__stdout__.fileno()) stdscr = _curses.initscr() for key, value in _curses.__dict__.items(): if key[0:4] == 'ACS_' or key in ('LINES', 'COLS'): setattr(curses, key, value) return stdscr # This is a similar wrapper for start_color(), which adds the COLORS and # COLOR_PAIRS variables which are only available after start_color() is # called.
Example #2
Source File: __init__.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 6 votes |
def initscr(): import _curses, curses # we call setupterm() here because it raises an error # instead of calling exit() in error cases. setupterm(term=_os.environ.get("TERM", "unknown"), fd=_sys.__stdout__.fileno()) stdscr = _curses.initscr() for key, value in _curses.__dict__.items(): if key[0:4] == 'ACS_' or key in ('LINES', 'COLS'): setattr(curses, key, value) return stdscr # This is a similar wrapper for start_color(), which adds the COLORS and # COLOR_PAIRS variables which are only available after start_color() is # called.
Example #3
Source File: __init__.py From Splunking-Crime with GNU Affero General Public License v3.0 | 6 votes |
def initscr(): import _curses, curses # we call setupterm() here because it raises an error # instead of calling exit() in error cases. setupterm(term=_os.environ.get("TERM", "unknown"), fd=_sys.__stdout__.fileno()) stdscr = _curses.initscr() for key, value in _curses.__dict__.items(): if key[0:4] == 'ACS_' or key in ('LINES', 'COLS'): setattr(curses, key, value) return stdscr # This is a similar wrapper for start_color(), which adds the COLORS and # COLOR_PAIRS variables which are only available after start_color() is # called.
Example #4
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 #5
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 #6
Source File: __init__.py From ironpython3 with Apache License 2.0 | 6 votes |
def initscr(): import _curses, curses # we call setupterm() here because it raises an error # instead of calling exit() in error cases. setupterm(term=_os.environ.get("TERM", "unknown"), fd=_sys.__stdout__.fileno()) stdscr = _curses.initscr() for key, value in _curses.__dict__.items(): if key[0:4] == 'ACS_' or key in ('LINES', 'COLS'): setattr(curses, key, value) return stdscr # This is a similar wrapper for start_color(), which adds the COLORS and # COLOR_PAIRS variables which are only available after start_color() is # called.
Example #7
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 #8
Source File: __init__.py From Fluid-Designer with GNU General Public License v3.0 | 6 votes |
def initscr(): import _curses, curses # we call setupterm() here because it raises an error # instead of calling exit() in error cases. setupterm(term=_os.environ.get("TERM", "unknown"), fd=_sys.__stdout__.fileno()) stdscr = _curses.initscr() for key, value in _curses.__dict__.items(): if key[0:4] == 'ACS_' or key in ('LINES', 'COLS'): setattr(curses, key, value) return stdscr # This is a similar wrapper for start_color(), which adds the COLORS and # COLOR_PAIRS variables which are only available after start_color() is # called.
Example #9
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 #10
Source File: __init__.py From oss-ftp with MIT License | 6 votes |
def initscr(): import _curses, curses # we call setupterm() here because it raises an error # instead of calling exit() in error cases. setupterm(term=_os.environ.get("TERM", "unknown"), fd=_sys.__stdout__.fileno()) stdscr = _curses.initscr() for key, value in _curses.__dict__.items(): if key[0:4] == 'ACS_' or key in ('LINES', 'COLS'): setattr(curses, key, value) return stdscr # This is a similar wrapper for start_color(), which adds the COLORS and # COLOR_PAIRS variables which are only available after start_color() is # called.
Example #11
Source File: conftest.py From rtv with MIT License | 6 votes |
def stdscr(): with patch('curses.initscr'), \ patch('curses.echo'), \ patch('curses.flash'), \ patch('curses.endwin'), \ patch('curses.newwin'), \ patch('curses.noecho'), \ patch('curses.cbreak'), \ patch('curses.doupdate'), \ patch('curses.nocbreak'), \ patch('curses.curs_set'), \ patch('curses.init_pair'), \ patch('curses.color_pair'), \ patch('curses.has_colors'), \ patch('curses.start_color'), \ patch('curses.use_default_colors'): out = MockStdscr(nlines=40, ncols=80, x=0, y=0) curses.initscr.return_value = out curses.newwin.side_effect = lambda *args: out.derwin(*args) curses.color_pair.return_value = 23 curses.has_colors.return_value = True curses.ACS_VLINE = 0 curses.COLORS = 256 curses.COLOR_PAIRS = 256 yield out
Example #12
Source File: terminal.py From ttrv with MIT License | 5 votes |
def set_theme(self, theme=None): """ Check that the terminal supports the provided theme, and applies the theme to the terminal if possible. If the terminal doesn't support the theme, this falls back to the default theme. The default theme only requires 8 colors so it should be compatible with any terminal that supports basic colors. """ terminal_colors = curses.COLORS if curses.has_colors() else 0 default_theme = Theme(use_color=bool(terminal_colors)) if theme is None: theme = default_theme elif theme.required_color_pairs > curses.COLOR_PAIRS: _logger.warning( 'Theme `%s` requires %s color pairs, but $TERM=%s only ' 'supports %s color pairs, switching to default theme', theme.name, theme.required_color_pairs, self._term, curses.COLOR_PAIRS) theme = default_theme elif theme.required_colors > terminal_colors: _logger.warning( 'Theme `%s` requires %s colors, but $TERM=%s only ' 'supports %s colors, switching to default theme', theme.name, theme.required_colors, self._term, curses.COLORS) theme = default_theme theme.bind_curses() self.theme = theme # Apply the default color to the whole screen self.stdscr.bkgd(str(' '), self.attr('Normal'))
Example #13
Source File: __init__.py From PokemonGo-DesktopMap with MIT License | 5 votes |
def start_color(): import _curses, curses retval = _curses.start_color() if hasattr(_curses, 'COLORS'): curses.COLORS = _curses.COLORS if hasattr(_curses, 'COLOR_PAIRS'): curses.COLOR_PAIRS = _curses.COLOR_PAIRS return retval # Import Python has_key() implementation if _curses doesn't contain has_key()
Example #14
Source File: terminal.py From rtv with MIT License | 5 votes |
def check_theme(theme): """ Check if the given theme is compatible with the terminal """ terminal_colors = curses.COLORS if curses.has_colors() else 0 if theme.required_colors > terminal_colors: return False elif theme.required_color_pairs > curses.COLOR_PAIRS: return False else: return True
Example #15
Source File: __init__.py From PokemonGo-DesktopMap with MIT License | 5 votes |
def initscr(): import _curses, curses # we call setupterm() here because it raises an error # instead of calling exit() in error cases. setupterm(term=_os.environ.get("TERM", "unknown"), fd=_sys.__stdout__.fileno()) stdscr = _curses.initscr() for key, value in _curses.__dict__.items(): if key[0:4] == 'ACS_' or key in ('LINES', 'COLS'): setattr(curses, key, value) return stdscr # This is a similar wrapper for start_color(), which adds the COLORS and # COLOR_PAIRS variables which are only available after start_color() is # called.
Example #16
Source File: conftest.py From castero with MIT License | 5 votes |
def stdscr(): with mock.patch('curses.initscr'), \ mock.patch('curses.echo'), \ mock.patch('curses.flash'), \ mock.patch('curses.endwin'), \ mock.patch('curses.newwin'), \ mock.patch('curses.newpad'), \ mock.patch('curses.noecho'), \ mock.patch('curses.cbreak'), \ mock.patch('curses.doupdate'), \ mock.patch('curses.nocbreak'), \ mock.patch('curses.curs_set'), \ mock.patch('curses.init_pair'), \ mock.patch('curses.color_pair'), \ mock.patch('curses.has_colors'), \ mock.patch('curses.start_color'), \ mock.patch('curses.use_default_colors'): result = MockStdscr(nlines=24, ncols=100, x=0, y=0) curses.initscr.return_value = result curses.newwin.side_effect = lambda *args: result.derwin(*args) curses.color_pair.return_value = 1 curses.has_colors.return_value = True curses.ACS_VLINE = 0 curses.ACS_HLINE = 0 curses.COLORS = 16 curses.COLOR_PAIRS = 16 yield result
Example #17
Source File: terminal.py From rtv with MIT License | 5 votes |
def set_theme(self, theme=None): """ Check that the terminal supports the provided theme, and applies the theme to the terminal if possible. If the terminal doesn't support the theme, this falls back to the default theme. The default theme only requires 8 colors so it should be compatible with any terminal that supports basic colors. """ terminal_colors = curses.COLORS if curses.has_colors() else 0 default_theme = Theme(use_color=bool(terminal_colors)) if theme is None: theme = default_theme elif theme.required_color_pairs > curses.COLOR_PAIRS: _logger.warning( 'Theme `%s` requires %s color pairs, but $TERM=%s only ' 'supports %s color pairs, switching to default theme', theme.name, theme.required_color_pairs, self._term, curses.COLOR_PAIRS) theme = default_theme elif theme.required_colors > terminal_colors: _logger.warning( 'Theme `%s` requires %s colors, but $TERM=%s only ' 'supports %s colors, switching to default theme', theme.name, theme.required_colors, self._term, curses.COLORS) theme = default_theme theme.bind_curses() self.theme = theme # Apply the default color to the whole screen self.stdscr.bkgd(str(' '), self.attr('Normal'))
Example #18
Source File: test_terminal.py From rtv with MIT License | 5 votes |
def test_terminal_check_theme(terminal): monochrome = Theme(use_color=False) default = Theme() color256 = Theme.from_name('molokai') curses.has_colors.return_value = False assert terminal.check_theme(monochrome) assert not terminal.check_theme(default) assert not terminal.check_theme(color256) curses.has_colors.return_value = True curses.COLORS = 0 assert terminal.check_theme(monochrome) assert not terminal.check_theme(default) assert not terminal.check_theme(color256) curses.COLORS = 8 assert terminal.check_theme(monochrome) assert terminal.check_theme(default) assert not terminal.check_theme(color256) curses.COLORS = 256 assert terminal.check_theme(monochrome) assert terminal.check_theme(default) assert terminal.check_theme(color256) curses.COLOR_PAIRS = 8 assert terminal.check_theme(monochrome) assert terminal.check_theme(default) assert not terminal.check_theme(color256)
Example #19
Source File: __init__.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def start_color(): import _curses, curses retval = _curses.start_color() if hasattr(_curses, 'COLORS'): curses.COLORS = _curses.COLORS if hasattr(_curses, 'COLOR_PAIRS'): curses.COLOR_PAIRS = _curses.COLOR_PAIRS return retval # Import Python has_key() implementation if _curses doesn't contain has_key()
Example #20
Source File: __init__.py From Splunking-Crime with GNU Affero General Public License v3.0 | 5 votes |
def start_color(): import _curses, curses retval = _curses.start_color() if hasattr(_curses, 'COLORS'): curses.COLORS = _curses.COLORS if hasattr(_curses, 'COLOR_PAIRS'): curses.COLOR_PAIRS = _curses.COLOR_PAIRS return retval # Import Python has_key() implementation if _curses doesn't contain has_key()
Example #21
Source File: __init__.py From ironpython2 with Apache License 2.0 | 5 votes |
def initscr(): import _curses, curses # we call setupterm() here because it raises an error # instead of calling exit() in error cases. setupterm(term=_os.environ.get("TERM", "unknown"), fd=_sys.__stdout__.fileno()) stdscr = _curses.initscr() for key, value in _curses.__dict__.items(): if key[0:4] == 'ACS_' or key in ('LINES', 'COLS'): setattr(curses, key, value) return stdscr # This is a similar wrapper for start_color(), which adds the COLORS and # COLOR_PAIRS variables which are only available after start_color() is # called.
Example #22
Source File: terminal.py From ttrv with MIT License | 5 votes |
def check_theme(theme): """ Check if the given theme is compatible with the terminal """ terminal_colors = curses.COLORS if curses.has_colors() else 0 if theme.required_colors > terminal_colors: return False elif theme.required_color_pairs > curses.COLOR_PAIRS: return False else: return True
Example #23
Source File: __init__.py From ironpython3 with Apache License 2.0 | 5 votes |
def start_color(): import _curses, curses retval = _curses.start_color() if hasattr(_curses, 'COLORS'): curses.COLORS = _curses.COLORS if hasattr(_curses, 'COLOR_PAIRS'): curses.COLOR_PAIRS = _curses.COLOR_PAIRS return retval # Import Python has_key() implementation if _curses doesn't contain has_key()
Example #24
Source File: __init__.py From Imogen with MIT License | 5 votes |
def start_color(): import _curses, curses retval = _curses.start_color() if hasattr(_curses, 'COLORS'): curses.COLORS = _curses.COLORS if hasattr(_curses, 'COLOR_PAIRS'): curses.COLOR_PAIRS = _curses.COLOR_PAIRS return retval # Import Python has_key() implementation if _curses doesn't contain has_key()
Example #25
Source File: __init__.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def start_color(): import _curses, curses retval = _curses.start_color() if hasattr(_curses, 'COLORS'): curses.COLORS = _curses.COLORS if hasattr(_curses, 'COLOR_PAIRS'): curses.COLOR_PAIRS = _curses.COLOR_PAIRS return retval # Import Python has_key() implementation if _curses doesn't contain has_key()
Example #26
Source File: __init__.py From oss-ftp with MIT License | 5 votes |
def start_color(): import _curses, curses retval = _curses.start_color() if hasattr(_curses, 'COLORS'): curses.COLORS = _curses.COLORS if hasattr(_curses, 'COLOR_PAIRS'): curses.COLOR_PAIRS = _curses.COLOR_PAIRS return retval # Import Python has_key() implementation if _curses doesn't contain has_key()
Example #27
Source File: __init__.py From BinderFilter with MIT License | 5 votes |
def start_color(): import _curses, curses retval = _curses.start_color() if hasattr(_curses, 'COLORS'): curses.COLORS = _curses.COLORS if hasattr(_curses, 'COLOR_PAIRS'): curses.COLOR_PAIRS = _curses.COLOR_PAIRS return retval # Import Python has_key() implementation if _curses doesn't contain has_key()
Example #28
Source File: __init__.py From BinderFilter with MIT License | 5 votes |
def initscr(): import _curses, curses # we call setupterm() here because it raises an error # instead of calling exit() in error cases. setupterm(term=_os.environ.get("TERM", "unknown"), fd=_sys.__stdout__.fileno()) stdscr = _curses.initscr() for key, value in _curses.__dict__.items(): if key[0:4] == 'ACS_' or key in ('LINES', 'COLS'): setattr(curses, key, value) return stdscr # This is a similar wrapper for start_color(), which adds the COLORS and # COLOR_PAIRS variables which are only available after start_color() is # called.
Example #29
Source File: __init__.py From ironpython2 with Apache License 2.0 | 5 votes |
def start_color(): import _curses, curses retval = _curses.start_color() if hasattr(_curses, 'COLORS'): curses.COLORS = _curses.COLORS if hasattr(_curses, 'COLOR_PAIRS'): curses.COLOR_PAIRS = _curses.COLOR_PAIRS return retval # Import Python has_key() implementation if _curses doesn't contain has_key()