eric6/UI/CompareDialog.py

branch
maintenance
changeset 8273
698ae46f40a4
parent 8176
31965986ecd1
parent 8220
006ee31b4835
equal deleted inserted replaced
8190:fb0ef164f536 8273:698ae46f40a4
93 93
94 @param files list of files to compare and their label 94 @param files list of files to compare and their label
95 (list of two tuples of two strings) 95 (list of two tuples of two strings)
96 @param parent parent widget (QWidget) 96 @param parent parent widget (QWidget)
97 """ 97 """
98 super(CompareDialog, self).__init__(parent) 98 super().__init__(parent)
99 self.setupUi(self) 99 self.setupUi(self)
100 100
101 if files is None: 101 if files is None:
102 files = [] 102 files = []
103 103
184 184
185 @param filename name of a file to use as the first file (string) 185 @param filename name of a file to use as the first file (string)
186 """ 186 """
187 if filename: 187 if filename:
188 self.file1Picker.setText(filename) 188 self.file1Picker.setText(filename)
189 super(CompareDialog, self).show() 189 super().show()
190 190
191 def __appendText(self, pane, linenumber, line, charFormat, 191 def __appendText(self, pane, linenumber, line, charFormat,
192 interLine=False): 192 interLine=False):
193 """ 193 """
194 Private method to append text to the end of the contents pane. 194 Private method to append text to the end of the contents pane.
305 # counters for changes 305 # counters for changes
306 added = 0 306 added = 0
307 deleted = 0 307 deleted = 0
308 changed = 0 308 changed = 0
309 309
310 paras = 1
311 self.diffParas = [] 310 self.diffParas = []
312 self.currentDiffPos = -1 311 self.currentDiffPos = -1
313 oldOpcode = '' 312 oldOpcode = ''
314 for opcode, ln1, l1, ln2, l2 in sbsdiff(lines1, lines2): 313 for paras, (opcode, ln1, l1, ln2, l2) in enumerate(
314 sbsdiff(lines1, lines2), start=1
315 ):
315 if opcode in 'idr': 316 if opcode in 'idr':
316 if oldOpcode != opcode: 317 if oldOpcode != opcode:
317 oldOpcode = opcode 318 oldOpcode = opcode
318 self.diffParas.append(paras) 319 self.diffParas.append(paras)
319 # update counters 320 # update counters
342 oldOpcode = '' 343 oldOpcode = ''
343 format1 = self.cNormalFormat 344 format1 = self.cNormalFormat
344 format2 = self.cNormalFormat 345 format2 = self.cNormalFormat
345 self.__appendText(self.contents_1, ln1, l1, format1, opcode == 'r') 346 self.__appendText(self.contents_1, ln1, l1, format1, opcode == 'r')
346 self.__appendText(self.contents_2, ln2, l2, format2, opcode == 'r') 347 self.__appendText(self.contents_2, ln2, l2, format2, opcode == 'r')
347 paras += 1
348 if not (paras % self.updateInterval): 348 if not (paras % self.updateInterval):
349 QApplication.processEvents() 349 QApplication.processEvents()
350 350
351 self.vsb1.setValue(0) 351 self.vsb1.setValue(0)
352 self.vsb2.setValue(0) 352 self.vsb2.setValue(0)
468 468
469 @param files list of files to compare and their label 469 @param files list of files to compare and their label
470 (list of two tuples of two strings) 470 (list of two tuples of two strings)
471 @param parent reference to the parent widget (QWidget) 471 @param parent reference to the parent widget (QWidget)
472 """ 472 """
473 super(CompareWindow, self).__init__(parent) 473 super().__init__(parent)
474 474
475 self.setStyle(Preferences.getUI("Style"), 475 self.setStyle(Preferences.getUI("Style"),
476 Preferences.getUI("StyleSheet")) 476 Preferences.getUI("StyleSheet"))
477 477
478 self.cw = CompareDialog(files, self) 478 self.cw = CompareDialog(files, self)

eric ide

mercurial