Example #1
0
 def __init__(self, string, *lst):
     self.string = WideString(string)
     self.lst = lst
     self.fixed = False
     if not len(string) or not len(self.string.chars):
         self.min_size = 0
     elif PY3:
         self.min_size = utf_char_width(string[0])
     else:
         self.min_size = utf_char_width(self.string.chars[0].decode('utf-8'))
Example #2
0
 def __init__(self, string, *lst):
     self.string = WideString(string)
     self.lst = lst
     self.fixed = False
     if not len(string) or not len(self.string.chars):
         self.min_size = 0
     elif PY3:
         self.min_size = utf_char_width(string[0])
     else:
         self.min_size = utf_char_width(self.string.chars[0].decode("utf-8"))
Example #3
0
    def _generate_lines(self, starty, startx):
        i = starty
        if not self.source:
            return
        while True:
            try:
                line = self._get_line(i).expandtabs(4)
                text = ansi.ansi_re.sub('', line) if self.markup == 'ansi' else line
                text_len = len(text)
                size = 0
                pos = 0
                #  Get the start position
                while startx > size and pos < text_len:
                    size += utf_char_width(text[pos])
                    pos += 1
                old_pos = pos
                size = 0
                while True:
                    if text_len in (0, pos):
                        line_bit = (ansi.char_slice(line, old_pos,
                                                    text_len) + ansi.reset) \
                            if self.markup == 'ansi' else text[old_pos:]
                        yield line_bit.rstrip().replace('\r\n', '\n')
                        break

                    size += utf_char_width(text[pos])
                    #  Last char of this line is east_asian_char,
                    #  show it at next line so ignore it at this line.
                    if size > self.wid:
                        pos -= 1

                    if size >= self.wid:
                        line_bit = (ansi.char_slice(line, old_pos,
                                                    pos + 1 - old_pos) + ansi.reset) \
                            if self.markup == 'ansi' else text[old_pos:pos + 1]
                        yield line_bit.rstrip().replace('\r\n', '\n')

                        #  Don't wrap lines in pager.
                        if not self.fm.settings.wrap_plaintext_previews or self.focused:
                            break
                        old_pos = pos + 1
                        size = 0
                    pos += 1

            except IndexError:
                return
            i += 1