397 self.contents.setTextCursor(tc) |
397 self.contents.setTextCursor(tc) |
398 self.contents.setCurrentCharFormat(format) |
398 self.contents.setCurrentCharFormat(format) |
399 self.contents.insertPlainText(txt) |
399 self.contents.insertPlainText(txt) |
400 |
400 |
401 def __generateUnifiedDiff(self, a, b, fromfile, tofile, |
401 def __generateUnifiedDiff(self, a, b, fromfile, tofile, |
402 fromfiledate, tofiledate): |
402 fromfiledate, tofiledate): |
403 """ |
403 """ |
404 Private slot to generate a unified diff output. |
404 Private slot to generate a unified diff output. |
405 |
405 |
406 @param a first sequence of lines (list of strings) |
406 @param a first sequence of lines (list of strings) |
407 @param b second sequence of lines (list of strings) |
407 @param b second sequence of lines (list of strings) |
410 @param fromfiledate modification time of the first file (string) |
410 @param fromfiledate modification time of the first file (string) |
411 @param tofiledate modification time of the second file (string) |
411 @param tofiledate modification time of the second file (string) |
412 """ |
412 """ |
413 paras = 0 |
413 paras = 0 |
414 for line in unified_diff(a, b, fromfile, tofile, |
414 for line in unified_diff(a, b, fromfile, tofile, |
415 fromfiledate, tofiledate): |
415 fromfiledate, tofiledate): |
416 if line.startswith('+') or line.startswith('>'): |
416 if line.startswith('+') or line.startswith('>'): |
417 format = self.cAddedFormat |
417 format = self.cAddedFormat |
418 elif line.startswith('-') or line.startswith('<'): |
418 elif line.startswith('-') or line.startswith('<'): |
419 format = self.cRemovedFormat |
419 format = self.cRemovedFormat |
420 elif line.startswith('@@'): |
420 elif line.startswith('@@'): |
429 if paras == 0: |
429 if paras == 0: |
430 self.__appendText( |
430 self.__appendText( |
431 self.trUtf8('There is no difference.'), self.cNormalFormat) |
431 self.trUtf8('There is no difference.'), self.cNormalFormat) |
432 |
432 |
433 def __generateContextDiff(self, a, b, fromfile, tofile, |
433 def __generateContextDiff(self, a, b, fromfile, tofile, |
434 fromfiledate, tofiledate): |
434 fromfiledate, tofiledate): |
435 """ |
435 """ |
436 Private slot to generate a context diff output. |
436 Private slot to generate a context diff output. |
437 |
437 |
438 @param a first sequence of lines (list of strings) |
438 @param a first sequence of lines (list of strings) |
439 @param b second sequence of lines (list of strings) |
439 @param b second sequence of lines (list of strings) |
442 @param fromfiledate modification time of the first file (string) |
442 @param fromfiledate modification time of the first file (string) |
443 @param tofiledate modification time of the second file (string) |
443 @param tofiledate modification time of the second file (string) |
444 """ |
444 """ |
445 paras = 0 |
445 paras = 0 |
446 for line in context_diff(a, b, fromfile, tofile, |
446 for line in context_diff(a, b, fromfile, tofile, |
447 fromfiledate, tofiledate): |
447 fromfiledate, tofiledate): |
448 if line.startswith('+ '): |
448 if line.startswith('+ '): |
449 format = self.cAddedFormat |
449 format = self.cAddedFormat |
450 elif line.startswith('- '): |
450 elif line.startswith('- '): |
451 format = self.cRemovedFormat |
451 format = self.cRemovedFormat |
452 elif line.startswith('! '): |
452 elif line.startswith('! '): |