Python curses.init_color() Examples
The following are 11
code examples of curses.init_color().
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: sifter.py From sandsifter with BSD 3-Clause "New" or "Revised" License | 5 votes |
def cleanup(gui, poll, injector, ts, tests, command_line, args): ts.run = False if gui: gui.stop() if poll: poll.stop() if injector: injector.stop() ''' # doesn't work if gui: for (i, c) in enumerate(gui.orig_colors): curses.init_color(i, c[0], c[1], c[2]) ''' curses.nocbreak(); curses.echo() curses.endwin() dump_artifacts(tests, injector, command_line) if args.save: with open(LAST, "w") as f: f.write(hexlify(cstr2py(tests.r.raw_insn))) sys.exit(0)
Example #2
Source File: gui.py From sandsifter with BSD 3-Clause "New" or "Revised" License | 5 votes |
def init_colors(self): if curses.has_colors() and curses.can_change_color(): curses.init_color(self.COLOR_BLACK, 0, 0, 0) curses.init_color(self.COLOR_WHITE, 1000, 1000, 1000) curses.init_color(self.COLOR_BLUE, 0, 0, 1000) curses.init_color(self.COLOR_RED, 1000, 0, 0) curses.init_color(self.COLOR_GREEN, 0, 1000, 0) for i in xrange(0, self.GRAYS): curses.init_color( self.GRAY_BASE + i, i * 1000 / (self.GRAYS - 1), i * 1000 / (self.GRAYS - 1), i * 1000 / (self.GRAYS - 1) ) curses.init_pair( self.GRAY_BASE + i, self.GRAY_BASE + i, self.COLOR_BLACK ) else: self.COLOR_BLACK = curses.COLOR_BLACK self.COLOR_WHITE = curses.COLOR_WHITE self.COLOR_BLUE = curses.COLOR_BLUE self.COLOR_RED = curses.COLOR_RED self.COLOR_GREEN = curses.COLOR_GREEN for i in xrange(0, self.GRAYS): curses.init_pair( self.GRAY_BASE + i, self.COLOR_WHITE, self.COLOR_BLACK ) curses.init_pair(self.BLACK, self.COLOR_BLACK, self.COLOR_BLACK) curses.init_pair(self.WHITE, self.COLOR_WHITE, self.COLOR_BLACK) curses.init_pair(self.BLUE, self.COLOR_BLUE, self.COLOR_BLACK) curses.init_pair(self.RED, self.COLOR_RED, self.COLOR_BLACK) curses.init_pair(self.GREEN, self.COLOR_GREEN, self.COLOR_BLACK)
Example #3
Source File: curses.py From BiblioPixel with MIT License | 5 votes |
def set_curses_colors(): s = 1000 / 255 for r, g, b in itertools.product(range(8), range(8), range(4)): index = r + 8 * (g + 8 * b) # Color 0 is black and can't be changed. # Pair 0 is white on black and can't be changed. if index: r, g, b = r << 5, g << 5, b << 6 _curses.init_color(index, int(r * s), int(g * s), int(b * s)) _curses.init_pair(index, index, 0)
Example #4
Source File: npysThemeManagers.py From apple_bleee with GNU General Public License v3.0 | 5 votes |
def define_colour_numbers(self): if curses.can_change_color(): for c in self._color_values: curses.init_color(c[0], *c[1])
Example #5
Source File: npysThemeManagers.py From HomePWN with GNU General Public License v3.0 | 5 votes |
def define_colour_numbers(self): if curses.can_change_color(): for c in self._color_values: curses.init_color(c[0], *c[1])
Example #6
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 #7
Source File: npysThemeManagers.py From EDCOP with Apache License 2.0 | 5 votes |
def define_colour_numbers(self): if curses.can_change_color(): for c in self._color_values: curses.init_color(c[0], *c[1])
Example #8
Source File: color_manager.py From babi with MIT License | 5 votes |
def init_color(self, color: Color) -> None: if curses.can_change_color(): n = min(self.colors.values(), default=256) - 1 self.colors[color] = n curses.init_color(n, *_color_to_curses(color)) elif curses.COLORS >= 256: self.colors[color] = color_kd.nearest(color, color_kd.make_256()) else: self.colors[color] = -1
Example #9
Source File: npysThemeManagers.py From TelegramTUI with MIT License | 5 votes |
def define_colour_numbers(self): if curses.can_change_color(): for c in self._color_values: curses.init_color(c[0], *c[1])
Example #10
Source File: sifter.py From sandsifter with BSD 3-Clause "New" or "Revised" License | 4 votes |
def init_colors(self): if curses.has_colors() and curses.can_change_color(): curses.init_color(self.COLOR_BLACK, 0, 0, 0) curses.init_color(self.COLOR_WHITE, 1000, 1000, 1000) curses.init_color(self.COLOR_BLUE, 0, 0, 1000) curses.init_color(self.COLOR_RED, 1000, 0, 0) curses.init_color(self.COLOR_GREEN, 0, 1000, 0) # this will remove flicker, but gives boring colors ''' self.COLOR_BLACK = curses.COLOR_BLACK self.COLOR_WHITE = curses.COLOR_WHITE self.COLOR_BLUE = curses.COLOR_BLUE self.COLOR_RED = curses.COLOR_RED self.COLOR_GREEN = curses.COLOR_GREEN ''' for i in xrange(0, self.GRAYS): curses.init_color( self.GRAY_BASE + i, i * 1000 / (self.GRAYS - 1), i * 1000 / (self.GRAYS - 1), i * 1000 / (self.GRAYS - 1) ) curses.init_pair( self.GRAY_BASE + i, self.GRAY_BASE + i, self.COLOR_BLACK ) else: self.COLOR_BLACK = curses.COLOR_BLACK self.COLOR_WHITE = curses.COLOR_WHITE self.COLOR_BLUE = curses.COLOR_BLUE self.COLOR_RED = curses.COLOR_RED self.COLOR_GREEN = curses.COLOR_GREEN for i in xrange(0, self.GRAYS): curses.init_pair( self.GRAY_BASE + i, self.COLOR_WHITE, self.COLOR_BLACK ) curses.init_pair(self.BLACK, self.COLOR_BLACK, self.COLOR_BLACK) curses.init_pair(self.WHITE, self.COLOR_WHITE, self.COLOR_BLACK) curses.init_pair(self.BLUE, self.COLOR_BLUE, self.COLOR_BLACK) curses.init_pair(self.RED, self.COLOR_RED, self.COLOR_BLACK) curses.init_pair(self.GREEN, self.COLOR_GREEN, self.COLOR_BLACK)
Example #11
Source File: ci_program.py From ci_edit with Apache License 2.0 | 4 votes |
def setUpCurses(self, cursesScreen): self.cursesScreen = cursesScreen curses.mousemask(-1) curses.mouseinterval(0) # Enable mouse tracking in xterm. sys.stdout.write('\033[?1002;h') #sys.stdout.write('\033[?1005;h') curses.meta(1) # Access ^c before shell does. curses.raw() # Enable Bracketed Paste Mode. sys.stdout.write('\033[?2004;h') # Push the escape codes out to the terminal. (Whether this is needed # seems to vary by platform). sys.stdout.flush() try: curses.start_color() if not curses.has_colors(): userMessage("This terminal does not support color.") self.quitNow() else: curses.use_default_colors() except curses.error as e: app.log.error(e) app.log.startup(u"curses.COLORS", curses.COLORS) if 0: assert curses.COLORS == 256 assert curses.can_change_color() == 1 assert curses.has_colors() == 1 app.log.detail("color_content:") for i in range(0, curses.COLORS): app.log.detail("color", i, ": ", curses.color_content(i)) for i in range(16, curses.COLORS): curses.init_color(i, 500, 500, i * 787 % 1000) app.log.detail("color_content, after:") for i in range(0, curses.COLORS): app.log.detail("color", i, ": ", curses.color_content(i)) if 1: #rows, cols = self.cursesScreen.getmaxyx() cursesWindow = self.cursesScreen cursesWindow.leaveok(1) # Don't update cursor position. cursesWindow.scrollok(0) cursesWindow.timeout(10) cursesWindow.keypad(1) app.window.mainCursesWindow = cursesWindow