~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to colordiff.py

  • Committer: Marius Kruger
  • Date: 2008-04-19 15:10:17 UTC
  • mto: This revision was merged to the branch mainline in revision 632.
  • Revision ID: amanic@gmail.com-20080419151017-klp7w1vlzj25ee10
in colorstring() call terminal.colorstring from one place,
to improve code readability

Show diffs side-by-side

added added

removed removed

Lines of Context:
96
96
        color = self.colors[type]
97
97
        if color is not None:
98
98
            if self.check_style and bad_ws_match:
99
 
                lt = terminal.colorstring(bad_ws_match.group(1).expandtabs(),
100
 
                    None, self.colors['leadingtabs'])
101
 
                txt = terminal.colorstring(
102
 
                    bad_ws_match.group(2)[0:self.max_line_len], color)
103
 
                longtxt = terminal.colorstring(
104
 
                    bad_ws_match.group(2)[self.max_line_len:],
105
 
                    color, self.colors['longline'])
106
 
                tr_ws = terminal.colorstring(bad_ws_match.group(3), None,
107
 
                    self.colors['trailingspace'])
108
 
                crlf = bad_ws_match.group(4)
109
 
                item.contents = lt + txt + longtxt + tr_ws + crlf
 
99
                #highlight were needed
 
100
                item.contents = ''.join(terminal.colorstring(txt, color, bcol)
 
101
                    for txt, bcol in (
 
102
                        (bad_ws_match.group(1).expandtabs(),
 
103
                             self.colors['leadingtabs']),
 
104
                        (bad_ws_match.group(2)[0:self.max_line_len], None),
 
105
                        (bad_ws_match.group(2)[self.max_line_len:],
 
106
                             self.colors['longline']),
 
107
                        (bad_ws_match.group(3), self.colors['trailingspace'])
 
108
                    )) + bad_ws_match.group(4)
110
109
            string = terminal.colorstring(str(item), color)
111
110
        else:
112
111
            string = str(item)