~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to colordiff.py

  • Committer: Marius Kruger
  • Date: 2007-01-17 16:34:37 UTC
  • mto: This revision was merged to the branch mainline in revision 632.
  • Revision ID: amanic@gmail.com-20070117163437-jislmb94syw3l9ue
Highlight trailing white space

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
#    along with this program; if not, write to the Free Software
16
16
#    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17
17
 
 
18
import re
18
19
import sys
19
20
from os.path import expanduser
20
21
 
88
89
    def colorstring(self, type, string):
89
90
        color = self.colors[type]
90
91
        if color is not None:
91
 
            string = terminal.colorstring(str(string), color)
 
92
            if self.check_style:
 
93
              has_tr_ws = re.match(r'^(.*?)([\t ]+)(\r?\n)$',str(string))
 
94
              if has_tr_ws:
 
95
                txt = terminal.colorstring(str(has_tr_ws.group(1)), color)
 
96
                tr_ws = terminal.colorstring(str(has_tr_ws.group(2)), color,
 
97
                  'yellow')
 
98
                crlf = has_tr_ws.group(3)
 
99
                string = txt + tr_ws + crlf
 
100
              else:
 
101
                string = terminal.colorstring(str(string), color)
 
102
            else:
 
103
              string = terminal.colorstring(str(string), color)
92
104
        self.target.write(string)
93
105
 
94
106
    def write(self, text):