def get_attr(self, *keys): """Returns the curses attribute for the specified keys Ready to use for curses.setattr() """ fg, bg, attr = self.get(*flatten(keys)) return attr | color_pair(get_color(fg, bg))
def draw_border(self, draw_border, border_attr): """ Using curses draw a border of floating window. :param draw_border bool: draw border if True :param border_attr dict: key contain 'fg' and 'bg', value's range is [-1-255] """ if not draw_border: return from ranger.gui import color # pylint: disable=import-outside-toplevel try: attr_fg, attr_bg = border_attr.get('fg', -1), border_attr.get('bg', -1) attr_fg, attr_bg = int(attr_fg), int(attr_bg) if not -1 <= attr_fg < 256: attr_fg = -1 if not -1 <= attr_bg < 256: attr_bg = -1 except TypeError: attr_fg, attr_bg = -1, -1 except ValueError: attr_fg, attr_bg = -1, -1 attr = curses.color_pair(color.get_color(attr_fg, attr_bg)) ui.enhance_draw_border(attr, self.fm.client) viewmiller.enhance_draw_border(attr)
def draw_border(self): """ Using curses draw a border of floating window. """ client = self.fm.client try: draw_border = client.nvim.vars['rnvimr_draw_border'] except KeyError: return if not draw_border: return from ranger.gui import color # pylint: disable=import-outside-toplevel try: attr_dict = client.nvim.vars['rnvimr_border_attr'] except KeyError: attr_dict = {} try: attr_fg, attr_bg = attr_dict.get('fg', -1), attr_dict.get('bg', -1) attr_fg, attr_bg = int(attr_fg), int(attr_bg) if not -1 <= attr_fg < 256: attr_fg = -1 if not -1 <= attr_bg < 256: attr_bg = -1 except TypeError: attr_fg, attr_bg = -1, -1 except ValueError: attr_fg, attr_bg = -1, -1 attr = curses.color_pair(color.get_color(attr_fg, attr_bg)) ui.enhance_draw_border(attr, client) viewmiller.enhance_draw_border(attr)
def set_fg_bg_attr(self, fg, bg, attr): try: self.win.attrset(curses.color_pair(get_color(fg, bg)) | attr) except curses.error: pass