49 .replace('\0+', "")\ |
49 .replace('\0+', "")\ |
50 .replace('\0-', "")\ |
50 .replace('\0-', "")\ |
51 .replace('\0^', "")\ |
51 .replace('\0^', "")\ |
52 .replace('\1', "") |
52 .replace('\1', "") |
53 |
53 |
54 linenumberformat = "%%%dd" % linenumberwidth |
54 linenumberformat = "{{0:{0:d}d}}".format(linenumberwidth) |
55 emptylineno = ' ' * linenumberwidth |
55 emptylineno = ' ' * linenumberwidth |
56 |
56 |
57 for (ln1, l1), (ln2, l2), flag in _mdiff(a, b, None, None, IS_CHARACTER_JUNK): |
57 for (ln1, l1), (ln2, l2), flag in _mdiff(a, b, None, None, IS_CHARACTER_JUNK): |
58 if not flag: |
58 if not flag: |
59 yield ('e', linenumberformat % ln1, l1, |
59 yield ('e', linenumberformat.format(ln1), l1, |
60 linenumberformat % ln2, l2) |
60 linenumberformat.format(ln2), l2) |
61 continue |
61 continue |
62 if ln2 == "" and l2 == "\n": |
62 if ln2 == "" and l2 == "\n": |
63 yield ('d', linenumberformat % ln1, removeMarkers(l1), |
63 yield ('d', linenumberformat.format(ln1), removeMarkers(l1), |
64 emptylineno, '\n') |
64 emptylineno, '\n') |
65 continue |
65 continue |
66 if ln1 == "" and l1 == "\n": |
66 if ln1 == "" and l1 == "\n": |
67 yield ('i', emptylineno, '\n', |
67 yield ('i', emptylineno, '\n', |
68 linenumberformat % ln2, removeMarkers(l2)) |
68 linenumberformat.format(ln2), removeMarkers(l2)) |
69 continue |
69 continue |
70 yield ('r', linenumberformat % ln1, l1, |
70 yield ('r', linenumberformat.format(ln1), l1, |
71 linenumberformat % ln2, l2) |
71 linenumberformat.format(ln2), l2) |
72 |
72 |
73 class CompareDialog(QWidget, Ui_CompareDialog): |
73 class CompareDialog(QWidget, Ui_CompareDialog): |
74 """ |
74 """ |
75 Class implementing a dialog to compare two files and show the result side by side. |
75 Class implementing a dialog to compare two files and show the result side by side. |
76 """ |
76 """ |
183 tc = pane.textCursor() |
183 tc = pane.textCursor() |
184 tc.movePosition(QTextCursor.End) |
184 tc.movePosition(QTextCursor.End) |
185 pane.setTextCursor(tc) |
185 pane.setTextCursor(tc) |
186 pane.setCurrentCharFormat(format) |
186 pane.setCurrentCharFormat(format) |
187 if interLine: |
187 if interLine: |
188 pane.insertPlainText("%s " % linenumber) |
188 pane.insertPlainText("{0} ".format(linenumber)) |
189 for txt in re.split(self.markerPattern, line): |
189 for txt in re.split(self.markerPattern, line): |
190 if txt: |
190 if txt: |
191 if txt.count('\1'): |
191 if txt.count('\1'): |
192 txt1, txt = txt.split('\1', 1) |
192 txt1, txt = txt.split('\1', 1) |
193 tc = pane.textCursor() |
193 tc = pane.textCursor() |
199 tc.movePosition(QTextCursor.End) |
199 tc.movePosition(QTextCursor.End) |
200 pane.setTextCursor(tc) |
200 pane.setTextCursor(tc) |
201 pane.setCurrentCharFormat(self.cNormalFormat) |
201 pane.setCurrentCharFormat(self.cNormalFormat) |
202 pane.insertPlainText(txt) |
202 pane.insertPlainText(txt) |
203 else: |
203 else: |
204 pane.insertPlainText("%s %s" % (linenumber, line)) |
204 pane.insertPlainText("{0} {1}".format(linenumber, line)) |
205 |
205 |
206 def on_buttonBox_clicked(self, button): |
206 def on_buttonBox_clicked(self, button): |
207 """ |
207 """ |
208 Private slot called by a button of the button box clicked. |
208 Private slot called by a button of the button box clicked. |
209 |
209 |