Ejemplo n.º 1
0
    def render(self):
        # colspan -1 is count of '|'
        total_col_len = (self.col_len
                         + (self.colspan - 1)
                         + sum([col.col_len for col in self.pseudo_columns]))

        #if self.syntax.multi_markdown_syntax():
        #    total_col_len = total_col_len - (self.colspan - 1)
        total_col_len = (total_col_len
                         # left border already calculated
                         # - (len(self.left_border_text) - 1)
                         - (len(self.right_border_text) - 1))

        norm = self._norm()
        space_len = len(self.left_space) + len(self.right_space)

        total_align_len = total_col_len - wcount(norm)
        if self.header and self.syntax.detect_header:
            align_value = norm.center(total_align_len - space_len, ' ')
        elif self.align == Column.ALIGN_RIGHT:
            align_value = norm.rjust(total_align_len - space_len, ' ')
        elif self.align == Column.ALIGN_CENTER:
            align_value = norm.center(total_align_len - space_len, ' ')
        else:
            align_value = norm.ljust(total_align_len - space_len, ' ')
        return self.left_space + align_value + self.right_space
Ejemplo n.º 2
0
    def render(self):
        # colspan -1 is count of '|'
        total_col_len = (self.col_len
                         + (self.colspan - 1)
                         + sum([col.col_len for col in self.pseudo_columns]))

        #if self.syntax.multi_markdown_syntax():
        #    total_col_len = total_col_len - (self.colspan - 1)
        total_col_len = (total_col_len
                         # left border already calculated
                         # - (len(self.left_border_text) - 1)
                         - (len(self.right_border_text) - 1))

        norm = self._norm()
        space_len = len(self.left_space) + len(self.right_space)

        total_align_len = total_col_len - wcount(norm)
        if self.header and self.syntax.detect_header:
            align_value = norm.center(total_align_len - space_len, ' ')
        elif self.align == Column.ALIGN_RIGHT:
            align_value = norm.rjust(total_align_len - space_len, ' ')
        elif self.align == Column.ALIGN_CENTER:
            align_value = norm.center(total_align_len - space_len, ' ')
        else:
            align_value = norm.ljust(total_align_len - space_len, ' ')
        return self.left_space + align_value + self.right_space
    def render(self):
        # colspan -1 is count of '|'
        total_col_len = self.col_len + (self.colspan - 1) + sum([col.col_len for col in self.pseudo_columns])

        total_align_len = total_col_len - wcount(self.data)
        if '>' in self.attr and not '<>' in self.attr:
            return self.attr + ' ' + self.data.rjust(total_align_len - len(self.attr) - 2, ' ') + ' '
        elif '=' in self.attr or '_' in self.attr:
            return self.attr + ' ' + self.data.center(total_align_len - len(self.attr) - 2, ' ') + ' '
        else:
            return self.attr + ' ' + self.data.ljust(total_align_len - len(self.attr) - 2, ' ') + ' '
Ejemplo n.º 4
0
    def render(self):
        # colspan -1 is count of '|'
        total_col_len = self.col_len + (self.colspan - 1) + sum(
            [col.col_len for col in self.pseudo_columns])

        total_align_len = total_col_len - wcount(self.data)
        if '>' in self.attr and not '<>' in self.attr:
            return self.attr + ' ' + self.data.rjust(
                total_align_len - len(self.attr) - 2, ' ') + ' '
        elif '=' in self.attr or '_' in self.attr:
            return self.attr + ' ' + self.data.center(
                total_align_len - len(self.attr) - 2, ' ') + ' '
        else:
            return self.attr + ' ' + self.data.ljust(
                total_align_len - len(self.attr) - 2, ' ') + ' '
Ejemplo n.º 5
0
 def get_cursor(self, table, visual_pos):
     #
     # '   |  1 |  2  |  3_| 4 |'
     internal_pos = self.visual_to_internal_index(table, visual_pos)
     base_len = (len(table.prefix)
                 + sum([column.col_len - wcount(column.render()) for column, ind
                       in zip(table[visual_pos.row_num].columns,
                              range(internal_pos.field_num))])
                 + internal_pos.field_num + 1  # count of '|'
                 )
     text = table[internal_pos.row_num][internal_pos.field_num].render()
     match = re.search(r"([^\s])\s*$", text)
     if match:
         col_pos = match.end(1)
     else:
         col_pos = 1
     return base_len + col_pos
Ejemplo n.º 6
0
 def get_cursor(self, table, visual_pos):
     #
     # '   |  1 |  2  |  3_| 4 |'
     internal_pos = self.visual_to_internal_index(table, visual_pos)
     base_len = (len(table.prefix)
                 + sum([column.col_len - wcount(column.render()) for column, ind
                       in zip(table[visual_pos.row_num].columns,
                              range(internal_pos.field_num))])
                 + internal_pos.field_num + 1  # count of '|'
                 )
     text = table[internal_pos.row_num][internal_pos.field_num].render()
     match = re.search(r"([^\s])\s*$", text)
     if match:
         col_pos = match.end(1)
     else:
         col_pos = 1
     return base_len + col_pos