Python curses.A_DIM Examples

The following are 5 code examples of curses.A_DIM(). 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: selection.py    From babi with MIT License 6 votes vote down vote up
def highlight_until(self, lines: Buf, idx: int) -> None:
        if self.start is None or self.end is None:
            return

        # XXX: this assumes pair 1 is the background
        attr = curses.A_REVERSE | curses.A_DIM | curses.color_pair(1)
        (s_y, s_x), (e_y, e_x) = self.get()
        if s_y == e_y:
            self.regions[s_y] = (HL(x=s_x, end=e_x, attr=attr),)
        else:
            self.regions[s_y] = (
                HL(x=s_x, end=len(lines[s_y]) + 1, attr=attr),
            )
            for l_y in range(s_y + 1, e_y):
                self.regions[l_y] = (
                    HL(x=0, end=len(lines[l_y]) + 1, attr=attr),
                )
            self.regions[e_y] = (HL(x=0, end=e_x, attr=attr),) 
Example #2
Source File: window.py    From lyrics-in-terminal with MIT License 5 votes vote down vote up
def set_titlebar(self):
		track_info = self.player.track.track_info(self.width - 1)
		# track_info -> ['title', 'artist', 'album'] - all algined
		self.stdscr.addstr(0, 1, track_info[0], curses.A_REVERSE)
		self.stdscr.addstr(1, 1, track_info[1], 
					curses.A_REVERSE | curses.A_BOLD | curses.A_DIM)
		self.stdscr.addstr(2, 1, track_info[2], curses.A_REVERSE) 
Example #3
Source File: screen.py    From wpm with GNU Affero General Public License v3.0 5 votes vote down vote up
def set_colors(self):
        """Sets up curses color pairs."""
        hicolor = os.getenv("TERM").endswith("256color")

        if self.monochrome:
            color = self.config.monochromecolors
        elif hicolor:
            color = self.config.xterm256colors
        else:
            color = self.config.xtermcolors

        bg = color.background
        curses.init_pair(Screen.COLOR_AUTHOR, *color.author)
        curses.init_pair(Screen.COLOR_BACKGROUND, bg, bg)
        curses.init_pair(Screen.COLOR_CORRECT, *color.correct)
        curses.init_pair(Screen.COLOR_HISCORE, *color.score)
        curses.init_pair(Screen.COLOR_INCORRECT, *color.incorrect)
        curses.init_pair(Screen.COLOR_PROMPT, *color.prompt)
        curses.init_pair(Screen.COLOR_QUOTE, *color.quote)
        curses.init_pair(Screen.COLOR_STATUS, *color.top_bar)

        # Rebind class variables
        Screen.COLOR_AUTHOR = curses.color_pair(Screen.COLOR_AUTHOR)
        Screen.COLOR_BACKGROUND = curses.color_pair(Screen.COLOR_BACKGROUND)
        Screen.COLOR_CORRECT = curses.color_pair(Screen.COLOR_CORRECT)
        Screen.COLOR_HISCORE = curses.color_pair(Screen.COLOR_HISCORE)
        Screen.COLOR_INCORRECT = curses.color_pair(Screen.COLOR_INCORRECT)
        Screen.COLOR_PROMPT = curses.color_pair(Screen.COLOR_PROMPT)
        Screen.COLOR_QUOTE = curses.color_pair(Screen.COLOR_QUOTE)
        Screen.COLOR_STATUS = curses.color_pair(Screen.COLOR_STATUS)

        if not hicolor:
            # Make certain colors more visible
            Screen.COLOR_CORRECT |= curses.A_DIM
            Screen.COLOR_INCORRECT |= curses.A_UNDERLINE | curses.A_BOLD
            Screen.COLOR_QUOTE |= curses.A_BOLD
            Screen.COLOR_STATUS |= curses.A_BOLD 
Example #4
Source File: replace.py    From babi with MIT License 5 votes vote down vote up
def region(self, y: int, x: int, end: int) -> Generator[None, None, None]:
        # XXX: this assumes pair 1 is the background
        attr = curses.A_REVERSE | curses.A_DIM | curses.color_pair(1)
        self.regions[y] = (HL(x=x, end=end, attr=attr),)
        try:
            yield
        finally:
            del self.regions[y] 
Example #5
Source File: menu_screen.py    From botany with ISC License 5 votes vote down vote up
def draw_default(self):
        # draws default menu
        clear_bar = " " * (int(self.maxx*2/3))
        self.screen_lock.acquire()
        self.screen.addstr(1, 2, self.title, curses.A_STANDOUT) # Title for this menu
        self.screen.addstr(3, 2, self.subtitle, curses.A_BOLD) #Subtitle for this menu
        # clear menu on screen
        for index in range(len(self.options)+1):
            self.screen.addstr(4+index, 4, clear_bar, curses.A_NORMAL)
        # display all the menu items, showing the 'pos' item highlighted
        for index in range(len(self.options)):
            textstyle = self.normal
            if index == self.selected:
                textstyle = self.highlighted
            self.screen.addstr(4+index ,4, clear_bar, curses.A_NORMAL)
            self.screen.addstr(4+index ,4, "%d - %s" % (index+1, self.options[index]), textstyle)

        self.screen.addstr(12, 2, clear_bar, curses.A_NORMAL)
        self.screen.addstr(13, 2, clear_bar, curses.A_NORMAL)
        self.screen.addstr(12, 2, "plant: ", curses.A_DIM)
        self.screen.addstr(12, 9, self.plant_string, curses.A_NORMAL)
        self.screen.addstr(13, 2, "score: ", curses.A_DIM)
        self.screen.addstr(13, 9, self.plant_ticks, curses.A_NORMAL)

        # display fancy water gauge
        if not self.plant.dead:
            water_gauge_str = self.water_gauge()
            self.screen.addstr(4,14, water_gauge_str, curses.A_NORMAL)
        else:
            self.screen.addstr(4,13, clear_bar, curses.A_NORMAL)
            self.screen.addstr(4,14, "(   RIP   )", curses.A_NORMAL)

        # draw cute ascii from files
        if self.visited_plant:
            # Needed to prevent drawing over a visited plant
            self.draw_plant_ascii(self.visited_plant)
        else:
            self.draw_plant_ascii(self.plant)
        self.screen_lock.release()