Пример #1
0
 def _draw_line(self, i, line):
     if self.markup is None:
         self.addstr(i, 0, line)
     elif self.markup == 'ansi':
         try:
             self.win.move(i, 0)
         except curses.error:
             pass
         else:
             for chunk in ansi.text_with_fg_bg_attr(line):
                 if isinstance(chunk, tuple):
                     self.set_fg_bg_attr(*chunk)
                 else:
                     self.addstr(chunk)
Пример #2
0
 def _draw_line(self, i, line):
     if self.markup is None:
         self.addstr(i, 0, line)
     elif self.markup == 'ansi':
         try:
             self.win.move(i, 0)
         except curses.error:
             pass
         else:
             for chunk in ansi.text_with_fg_bg_attr(line):
                 if isinstance(chunk, tuple):
                     self.set_fg_bg_attr(*chunk)
                 else:
                     self.addstr(chunk)
Пример #3
0
    def _draw_line(self, i, line):
        if self.markup is None:
            self.addstr(i, 0, line)
        elif self.markup is 'help':
            self.addstr(i, 0, line)

            baseclr = ('in_pager', 'help_markup')

            if line.startswith('===='):
                self.color_at(i, 0, len(line), 'seperator', *baseclr)
                return

            if line.startswith('        ') and \
             len(line) >= 16 and line[15] == ' ':
                self.color_at(i, 0, 16, 'key', *baseclr)

            for m in BAR_REGEXP.finditer(line):
                start, length = m.start(), m.end() - m.start()
                self.color_at(i, start, length, 'bars', *baseclr)
                self.color_at(i, start + 1, length - 2, 'link', *baseclr)

            for m in QUOTES_REGEXP.finditer(line):
                start, length = m.start(), m.end() - m.start()
                self.color_at(i, start, length, 'quotes', *baseclr)
                self.color_at(i, start + 1, length - 2, 'text', *baseclr)

            for m in SPECIAL_CHARS_REGEXP.finditer(line):
                start, length = m.start(), m.end() - m.start()
                self.color_at(i, start, length, 'special', *baseclr)

            if TITLE_REGEXP.match(line):
                self.color_at(i, 0, -1, 'title', *baseclr)
        elif self.markup == 'ansi':
            self.win.move(i, 0)
            for chunk in ansi.text_with_fg_bg_attr(line):
                if isinstance(chunk, tuple):
                    self.set_fg_bg_attr(*chunk)
                else:
                    self.addstr(chunk)
Пример #4
0
	def _draw_line(self, i, line):
		if self.markup is None:
			self.addstr(i, 0, line)
		elif self.markup is 'help':
			self.addstr(i, 0, line)

			baseclr = ('in_pager', 'help_markup')

			if line.startswith('===='):
				self.color_at(i, 0, len(line), 'seperator', *baseclr)
				return

			if line.startswith('        ') and \
				len(line) >= 16 and line[15] == ' ':
				self.color_at(i, 0, 16, 'key', *baseclr)

			for m in BAR_REGEXP.finditer(line):
				start, length = m.start(), m.end() - m.start()
				self.color_at(i, start, length, 'bars', *baseclr)
				self.color_at(i, start + 1, length - 2, 'link', *baseclr)

			for m in QUOTES_REGEXP.finditer(line):
				start, length = m.start(), m.end() - m.start()
				self.color_at(i, start, length, 'quotes', *baseclr)
				self.color_at(i, start + 1, length - 2, 'text', *baseclr)

			for m in SPECIAL_CHARS_REGEXP.finditer(line):
				start, length = m.start(), m.end() - m.start()
				self.color_at(i, start, length, 'special', *baseclr)

			if TITLE_REGEXP.match(line):
				self.color_at(i, 0, -1, 'title', *baseclr)
		elif self.markup == 'ansi':
			self.win.move(i, 0)
			for chunk in ansi.text_with_fg_bg_attr(line):
				if isinstance(chunk, tuple):
					self.set_fg_bg_attr(*chunk)
				else:
					self.addstr(chunk)