|
1 <!DOCTYPE html> |
|
2 <html><head> |
|
3 <title>eric7.UI.CompareDialog</title> |
|
4 <meta charset="UTF-8"> |
|
5 <link rel="stylesheet" href="styles.css"> |
|
6 </head> |
|
7 <body> |
|
8 <a NAME="top" ID="top"></a> |
|
9 <h1>eric7.UI.CompareDialog</h1> |
|
10 |
|
11 <p> |
|
12 Module implementing a dialog to compare two files and show the result side by |
|
13 side. |
|
14 </p> |
|
15 <h3>Global Attributes</h3> |
|
16 |
|
17 <table> |
|
18 <tr><td>None</td></tr> |
|
19 </table> |
|
20 <h3>Classes</h3> |
|
21 |
|
22 <table> |
|
23 |
|
24 <tr> |
|
25 <td><a href="#CompareDialog">CompareDialog</a></td> |
|
26 <td>Class implementing a dialog to compare two files and show the result side by side.</td> |
|
27 </tr> |
|
28 <tr> |
|
29 <td><a href="#CompareWindow">CompareWindow</a></td> |
|
30 <td>Main window class for the standalone dialog.</td> |
|
31 </tr> |
|
32 </table> |
|
33 <h3>Functions</h3> |
|
34 |
|
35 <table> |
|
36 |
|
37 <tr> |
|
38 <td><a href="#removeMarkers">removeMarkers</a></td> |
|
39 <td>Internal function to remove all diff markers.</td> |
|
40 </tr> |
|
41 <tr> |
|
42 <td><a href="#sbsdiff">sbsdiff</a></td> |
|
43 <td>Compare two sequences of lines; generate the delta for display side by side.</td> |
|
44 </tr> |
|
45 </table> |
|
46 <hr /> |
|
47 <hr /> |
|
48 <a NAME="CompareDialog" ID="CompareDialog"></a> |
|
49 <h2>CompareDialog</h2> |
|
50 |
|
51 <p> |
|
52 Class implementing a dialog to compare two files and show the result side |
|
53 by side. |
|
54 </p> |
|
55 <h3>Derived from</h3> |
|
56 QWidget, Ui_CompareDialog |
|
57 <h3>Class Attributes</h3> |
|
58 |
|
59 <table> |
|
60 <tr><td>None</td></tr> |
|
61 </table> |
|
62 <h3>Class Methods</h3> |
|
63 |
|
64 <table> |
|
65 <tr><td>None</td></tr> |
|
66 </table> |
|
67 <h3>Methods</h3> |
|
68 |
|
69 <table> |
|
70 |
|
71 <tr> |
|
72 <td><a href="#CompareDialog.__init__">CompareDialog</a></td> |
|
73 <td>Constructor</td> |
|
74 </tr> |
|
75 <tr> |
|
76 <td><a href="#CompareDialog.__appendText">__appendText</a></td> |
|
77 <td>Private method to append text to the end of the contents pane.</td> |
|
78 </tr> |
|
79 <tr> |
|
80 <td><a href="#CompareDialog.__compare">__compare</a></td> |
|
81 <td>Private method to compare two lists of text.</td> |
|
82 </tr> |
|
83 <tr> |
|
84 <td><a href="#CompareDialog.__fileChanged">__fileChanged</a></td> |
|
85 <td>Private slot to enable/disable the Compare button.</td> |
|
86 </tr> |
|
87 <tr> |
|
88 <td><a href="#CompareDialog.__generateFormats">__generateFormats</a></td> |
|
89 <td>Private method to generate the various text formats.</td> |
|
90 </tr> |
|
91 <tr> |
|
92 <td><a href="#CompareDialog.__moveTextToCurrentDiffPos">__moveTextToCurrentDiffPos</a></td> |
|
93 <td>Private slot to move the text display to the current diff position.</td> |
|
94 </tr> |
|
95 <tr> |
|
96 <td><a href="#CompareDialog.__scrollBarMoved">__scrollBarMoved</a></td> |
|
97 <td>Private slot to enable the buttons and set the current diff position depending on scrollbar position.</td> |
|
98 </tr> |
|
99 <tr> |
|
100 <td><a href="#CompareDialog.compare">compare</a></td> |
|
101 <td>Public method to compare two lists of text.</td> |
|
102 </tr> |
|
103 <tr> |
|
104 <td><a href="#CompareDialog.on_buttonBox_clicked">on_buttonBox_clicked</a></td> |
|
105 <td>Private slot called by a button of the button box clicked.</td> |
|
106 </tr> |
|
107 <tr> |
|
108 <td><a href="#CompareDialog.on_diffButton_clicked">on_diffButton_clicked</a></td> |
|
109 <td>Private slot to handle the Compare button press.</td> |
|
110 </tr> |
|
111 <tr> |
|
112 <td><a href="#CompareDialog.on_downButton_clicked">on_downButton_clicked</a></td> |
|
113 <td>Private slot to go to the next difference.</td> |
|
114 </tr> |
|
115 <tr> |
|
116 <td><a href="#CompareDialog.on_firstButton_clicked">on_firstButton_clicked</a></td> |
|
117 <td>Private slot to go to the first difference.</td> |
|
118 </tr> |
|
119 <tr> |
|
120 <td><a href="#CompareDialog.on_lastButton_clicked">on_lastButton_clicked</a></td> |
|
121 <td>Private slot to go to the last difference.</td> |
|
122 </tr> |
|
123 <tr> |
|
124 <td><a href="#CompareDialog.on_synchronizeCheckBox_toggled">on_synchronizeCheckBox_toggled</a></td> |
|
125 <td>Private slot to connect or disconnect the scrollbars of the displays.</td> |
|
126 </tr> |
|
127 <tr> |
|
128 <td><a href="#CompareDialog.on_upButton_clicked">on_upButton_clicked</a></td> |
|
129 <td>Private slot to go to the previous difference.</td> |
|
130 </tr> |
|
131 <tr> |
|
132 <td><a href="#CompareDialog.show">show</a></td> |
|
133 <td>Public slot to show the dialog.</td> |
|
134 </tr> |
|
135 </table> |
|
136 <h3>Static Methods</h3> |
|
137 |
|
138 <table> |
|
139 <tr><td>None</td></tr> |
|
140 </table> |
|
141 |
|
142 <a NAME="CompareDialog.__init__" ID="CompareDialog.__init__"></a> |
|
143 <h4>CompareDialog (Constructor)</h4> |
|
144 <b>CompareDialog</b>(<i>files=None, parent=None</i>) |
|
145 |
|
146 <p> |
|
147 Constructor |
|
148 </p> |
|
149 <dl> |
|
150 |
|
151 <dt><i>files</i></dt> |
|
152 <dd> |
|
153 list of files to compare and their label |
|
154 (list of two tuples of two strings) |
|
155 </dd> |
|
156 <dt><i>parent</i></dt> |
|
157 <dd> |
|
158 parent widget (QWidget) |
|
159 </dd> |
|
160 </dl> |
|
161 <a NAME="CompareDialog.__appendText" ID="CompareDialog.__appendText"></a> |
|
162 <h4>CompareDialog.__appendText</h4> |
|
163 <b>__appendText</b>(<i>pane, linenumber, line, charFormat, interLine=False</i>) |
|
164 |
|
165 <p> |
|
166 Private method to append text to the end of the contents pane. |
|
167 </p> |
|
168 <dl> |
|
169 |
|
170 <dt><i>pane</i></dt> |
|
171 <dd> |
|
172 text edit widget to append text to (QTextedit) |
|
173 </dd> |
|
174 <dt><i>linenumber</i></dt> |
|
175 <dd> |
|
176 number of line to insert (string) |
|
177 </dd> |
|
178 <dt><i>line</i></dt> |
|
179 <dd> |
|
180 text to insert (string) |
|
181 </dd> |
|
182 <dt><i>charFormat</i></dt> |
|
183 <dd> |
|
184 text format to be used (QTextCharFormat) |
|
185 </dd> |
|
186 <dt><i>interLine</i></dt> |
|
187 <dd> |
|
188 flag indicating interline changes (boolean) |
|
189 </dd> |
|
190 </dl> |
|
191 <a NAME="CompareDialog.__compare" ID="CompareDialog.__compare"></a> |
|
192 <h4>CompareDialog.__compare</h4> |
|
193 <b>__compare</b>(<i>lines1, lines2</i>) |
|
194 |
|
195 <p> |
|
196 Private method to compare two lists of text. |
|
197 </p> |
|
198 <dl> |
|
199 |
|
200 <dt><i>lines1</i></dt> |
|
201 <dd> |
|
202 text to compare against (list of strings) |
|
203 </dd> |
|
204 <dt><i>lines2</i></dt> |
|
205 <dd> |
|
206 text to compare (list of strings) |
|
207 </dd> |
|
208 </dl> |
|
209 <a NAME="CompareDialog.__fileChanged" ID="CompareDialog.__fileChanged"></a> |
|
210 <h4>CompareDialog.__fileChanged</h4> |
|
211 <b>__fileChanged</b>(<i></i>) |
|
212 |
|
213 <p> |
|
214 Private slot to enable/disable the Compare button. |
|
215 </p> |
|
216 <a NAME="CompareDialog.__generateFormats" ID="CompareDialog.__generateFormats"></a> |
|
217 <h4>CompareDialog.__generateFormats</h4> |
|
218 <b>__generateFormats</b>(<i></i>) |
|
219 |
|
220 <p> |
|
221 Private method to generate the various text formats. |
|
222 </p> |
|
223 <a NAME="CompareDialog.__moveTextToCurrentDiffPos" ID="CompareDialog.__moveTextToCurrentDiffPos"></a> |
|
224 <h4>CompareDialog.__moveTextToCurrentDiffPos</h4> |
|
225 <b>__moveTextToCurrentDiffPos</b>(<i></i>) |
|
226 |
|
227 <p> |
|
228 Private slot to move the text display to the current diff position. |
|
229 </p> |
|
230 <a NAME="CompareDialog.__scrollBarMoved" ID="CompareDialog.__scrollBarMoved"></a> |
|
231 <h4>CompareDialog.__scrollBarMoved</h4> |
|
232 <b>__scrollBarMoved</b>(<i>value</i>) |
|
233 |
|
234 <p> |
|
235 Private slot to enable the buttons and set the current diff position |
|
236 depending on scrollbar position. |
|
237 </p> |
|
238 <dl> |
|
239 |
|
240 <dt><i>value</i></dt> |
|
241 <dd> |
|
242 scrollbar position (integer) |
|
243 </dd> |
|
244 </dl> |
|
245 <a NAME="CompareDialog.compare" ID="CompareDialog.compare"></a> |
|
246 <h4>CompareDialog.compare</h4> |
|
247 <b>compare</b>(<i>lines1, lines2, name1="", name2=""</i>) |
|
248 |
|
249 <p> |
|
250 Public method to compare two lists of text. |
|
251 </p> |
|
252 <dl> |
|
253 |
|
254 <dt><i>lines1</i></dt> |
|
255 <dd> |
|
256 text to compare against (string or list of strings) |
|
257 </dd> |
|
258 <dt><i>lines2</i></dt> |
|
259 <dd> |
|
260 text to compare (string or list of strings) |
|
261 </dd> |
|
262 <dt><i>name1</i></dt> |
|
263 <dd> |
|
264 name to be shown for the first text (string) |
|
265 </dd> |
|
266 <dt><i>name2</i></dt> |
|
267 <dd> |
|
268 name to be shown for the second text (string) |
|
269 </dd> |
|
270 </dl> |
|
271 <a NAME="CompareDialog.on_buttonBox_clicked" ID="CompareDialog.on_buttonBox_clicked"></a> |
|
272 <h4>CompareDialog.on_buttonBox_clicked</h4> |
|
273 <b>on_buttonBox_clicked</b>(<i>button</i>) |
|
274 |
|
275 <p> |
|
276 Private slot called by a button of the button box clicked. |
|
277 </p> |
|
278 <dl> |
|
279 |
|
280 <dt><i>button</i></dt> |
|
281 <dd> |
|
282 button that was clicked (QAbstractButton) |
|
283 </dd> |
|
284 </dl> |
|
285 <a NAME="CompareDialog.on_diffButton_clicked" ID="CompareDialog.on_diffButton_clicked"></a> |
|
286 <h4>CompareDialog.on_diffButton_clicked</h4> |
|
287 <b>on_diffButton_clicked</b>(<i></i>) |
|
288 |
|
289 <p> |
|
290 Private slot to handle the Compare button press. |
|
291 </p> |
|
292 <a NAME="CompareDialog.on_downButton_clicked" ID="CompareDialog.on_downButton_clicked"></a> |
|
293 <h4>CompareDialog.on_downButton_clicked</h4> |
|
294 <b>on_downButton_clicked</b>(<i></i>) |
|
295 |
|
296 <p> |
|
297 Private slot to go to the next difference. |
|
298 </p> |
|
299 <a NAME="CompareDialog.on_firstButton_clicked" ID="CompareDialog.on_firstButton_clicked"></a> |
|
300 <h4>CompareDialog.on_firstButton_clicked</h4> |
|
301 <b>on_firstButton_clicked</b>(<i></i>) |
|
302 |
|
303 <p> |
|
304 Private slot to go to the first difference. |
|
305 </p> |
|
306 <a NAME="CompareDialog.on_lastButton_clicked" ID="CompareDialog.on_lastButton_clicked"></a> |
|
307 <h4>CompareDialog.on_lastButton_clicked</h4> |
|
308 <b>on_lastButton_clicked</b>(<i></i>) |
|
309 |
|
310 <p> |
|
311 Private slot to go to the last difference. |
|
312 </p> |
|
313 <a NAME="CompareDialog.on_synchronizeCheckBox_toggled" ID="CompareDialog.on_synchronizeCheckBox_toggled"></a> |
|
314 <h4>CompareDialog.on_synchronizeCheckBox_toggled</h4> |
|
315 <b>on_synchronizeCheckBox_toggled</b>(<i>sync</i>) |
|
316 |
|
317 <p> |
|
318 Private slot to connect or disconnect the scrollbars of the displays. |
|
319 </p> |
|
320 <dl> |
|
321 |
|
322 <dt><i>sync</i></dt> |
|
323 <dd> |
|
324 flag indicating synchronisation status (boolean) |
|
325 </dd> |
|
326 </dl> |
|
327 <a NAME="CompareDialog.on_upButton_clicked" ID="CompareDialog.on_upButton_clicked"></a> |
|
328 <h4>CompareDialog.on_upButton_clicked</h4> |
|
329 <b>on_upButton_clicked</b>(<i></i>) |
|
330 |
|
331 <p> |
|
332 Private slot to go to the previous difference. |
|
333 </p> |
|
334 <a NAME="CompareDialog.show" ID="CompareDialog.show"></a> |
|
335 <h4>CompareDialog.show</h4> |
|
336 <b>show</b>(<i>filename=None</i>) |
|
337 |
|
338 <p> |
|
339 Public slot to show the dialog. |
|
340 </p> |
|
341 <dl> |
|
342 |
|
343 <dt><i>filename</i></dt> |
|
344 <dd> |
|
345 name of a file to use as the first file (string) |
|
346 </dd> |
|
347 </dl> |
|
348 <div align="right"><a href="#top">Up</a></div> |
|
349 <hr /> |
|
350 <hr /> |
|
351 <a NAME="CompareWindow" ID="CompareWindow"></a> |
|
352 <h2>CompareWindow</h2> |
|
353 |
|
354 <p> |
|
355 Main window class for the standalone dialog. |
|
356 </p> |
|
357 <h3>Derived from</h3> |
|
358 EricMainWindow |
|
359 <h3>Class Attributes</h3> |
|
360 |
|
361 <table> |
|
362 <tr><td>None</td></tr> |
|
363 </table> |
|
364 <h3>Class Methods</h3> |
|
365 |
|
366 <table> |
|
367 <tr><td>None</td></tr> |
|
368 </table> |
|
369 <h3>Methods</h3> |
|
370 |
|
371 <table> |
|
372 |
|
373 <tr> |
|
374 <td><a href="#CompareWindow.__init__">CompareWindow</a></td> |
|
375 <td>Constructor</td> |
|
376 </tr> |
|
377 <tr> |
|
378 <td><a href="#CompareWindow.eventFilter">eventFilter</a></td> |
|
379 <td>Public method to filter events.</td> |
|
380 </tr> |
|
381 </table> |
|
382 <h3>Static Methods</h3> |
|
383 |
|
384 <table> |
|
385 <tr><td>None</td></tr> |
|
386 </table> |
|
387 |
|
388 <a NAME="CompareWindow.__init__" ID="CompareWindow.__init__"></a> |
|
389 <h4>CompareWindow (Constructor)</h4> |
|
390 <b>CompareWindow</b>(<i>files=None, parent=None</i>) |
|
391 |
|
392 <p> |
|
393 Constructor |
|
394 </p> |
|
395 <dl> |
|
396 |
|
397 <dt><i>files</i></dt> |
|
398 <dd> |
|
399 list of files to compare and their label |
|
400 (list of two tuples of two strings) |
|
401 </dd> |
|
402 <dt><i>parent</i></dt> |
|
403 <dd> |
|
404 reference to the parent widget (QWidget) |
|
405 </dd> |
|
406 </dl> |
|
407 <a NAME="CompareWindow.eventFilter" ID="CompareWindow.eventFilter"></a> |
|
408 <h4>CompareWindow.eventFilter</h4> |
|
409 <b>eventFilter</b>(<i>obj, event</i>) |
|
410 |
|
411 <p> |
|
412 Public method to filter events. |
|
413 </p> |
|
414 <dl> |
|
415 |
|
416 <dt><i>obj</i></dt> |
|
417 <dd> |
|
418 reference to the object the event is meant for (QObject) |
|
419 </dd> |
|
420 <dt><i>event</i></dt> |
|
421 <dd> |
|
422 reference to the event object (QEvent) |
|
423 </dd> |
|
424 </dl> |
|
425 <dl> |
|
426 <dt>Return:</dt> |
|
427 <dd> |
|
428 flag indicating, whether the event was handled (boolean) |
|
429 </dd> |
|
430 </dl> |
|
431 <div align="right"><a href="#top">Up</a></div> |
|
432 <hr /> |
|
433 <hr /> |
|
434 <a NAME="removeMarkers" ID="removeMarkers"></a> |
|
435 <h2>removeMarkers</h2> |
|
436 <b>removeMarkers</b>(<i>line</i>) |
|
437 |
|
438 <p> |
|
439 Internal function to remove all diff markers. |
|
440 </p> |
|
441 <dl> |
|
442 |
|
443 <dt><i>line</i></dt> |
|
444 <dd> |
|
445 line to work on (string) |
|
446 </dd> |
|
447 </dl> |
|
448 <dl> |
|
449 <dt>Return:</dt> |
|
450 <dd> |
|
451 line without diff markers (string) |
|
452 </dd> |
|
453 </dl> |
|
454 <div align="right"><a href="#top">Up</a></div> |
|
455 <hr /> |
|
456 <hr /> |
|
457 <a NAME="sbsdiff" ID="sbsdiff"></a> |
|
458 <h2>sbsdiff</h2> |
|
459 <b>sbsdiff</b>(<i>a, b, linenumberwidth=4</i>) |
|
460 |
|
461 <p> |
|
462 Compare two sequences of lines; generate the delta for display side by |
|
463 side. |
|
464 </p> |
|
465 <dl> |
|
466 |
|
467 <dt><i>a</i></dt> |
|
468 <dd> |
|
469 first sequence of lines (list of strings) |
|
470 </dd> |
|
471 <dt><i>b</i></dt> |
|
472 <dd> |
|
473 second sequence of lines (list of strings) |
|
474 </dd> |
|
475 <dt><i>linenumberwidth</i></dt> |
|
476 <dd> |
|
477 width (in characters) of the linenumbers (integer) |
|
478 </dd> |
|
479 </dl> |
|
480 <dl> |
|
481 <dt>Yield:</dt> |
|
482 <dd> |
|
483 tuples of differences. Each tuple is composed of strings as follows. |
|
484 <ul> |
|
485 <li>opcode -- one of e, d, i, r for equal, delete, insert, |
|
486 replace</li> |
|
487 <li>lineno a -- linenumber of sequence a</li> |
|
488 <li>line a -- line of sequence a</li> |
|
489 <li>lineno b -- linenumber of sequence b</li> |
|
490 <li>line b -- line of sequence b</li> |
|
491 </ul> |
|
492 </dd> |
|
493 </dl> |
|
494 <dl> |
|
495 <dt>Yield Type:</dt> |
|
496 <dd> |
|
497 tuple of (str, str, str, str, str) |
|
498 </dd> |
|
499 </dl> |
|
500 <div align="right"><a href="#top">Up</a></div> |
|
501 <hr /> |
|
502 </body></html> |