Documentation/Source/eric6.UI.DiffDialog.html

changeset 3673
e26d7d0c1088
child 4109
809b8268183d
equal deleted inserted replaced
3670:f0cb7579c0b4 3673:e26d7d0c1088
1 <!DOCTYPE html>
2 <html><head>
3 <title>eric6.UI.DiffDialog</title>
4 <meta charset="UTF-8">
5 <style>
6 body {
7 background: #EDECE6;
8 margin: 0em 1em 10em 1em;
9 color: black;
10 }
11
12 h1 { color: white; background: #85774A; }
13 h2 { color: white; background: #85774A; }
14 h3 { color: white; background: #9D936E; }
15 h4 { color: white; background: #9D936E; }
16
17 a { color: #BA6D36; }
18
19 </style>
20 </head>
21 <body><a NAME="top" ID="top"></a>
22 <h1>eric6.UI.DiffDialog</h1>
23 <p>
24 Module implementing a dialog to compare two files.
25 </p>
26 <h3>Global Attributes</h3>
27 <table>
28 <tr><td>None</td></tr>
29 </table>
30 <h3>Classes</h3>
31 <table>
32 <tr>
33 <td><a href="#DiffDialog">DiffDialog</a></td>
34 <td>Class implementing a dialog to compare two files.</td>
35 </tr><tr>
36 <td><a href="#DiffWindow">DiffWindow</a></td>
37 <td>Main window class for the standalone dialog.</td>
38 </tr>
39 </table>
40 <h3>Functions</h3>
41 <table>
42 <tr>
43 <td><a href="#context_diff">context_diff</a></td>
44 <td>Compare two sequences of lines; generate the delta as a context diff.</td>
45 </tr><tr>
46 <td><a href="#unified_diff">unified_diff</a></td>
47 <td>Compare two sequences of lines; generate the delta as a unified diff.</td>
48 </tr>
49 </table>
50 <hr /><hr />
51 <a NAME="DiffDialog" ID="DiffDialog"></a>
52 <h2>DiffDialog</h2>
53 <p>
54 Class implementing a dialog to compare two files.
55 </p>
56 <h3>Derived from</h3>
57 QWidget, Ui_DiffDialog
58 <h3>Class Attributes</h3>
59 <table>
60 <tr><td>None</td></tr>
61 </table>
62 <h3>Class Methods</h3>
63 <table>
64 <tr><td>None</td></tr>
65 </table>
66 <h3>Methods</h3>
67 <table>
68 <tr>
69 <td><a href="#DiffDialog.__init__">DiffDialog</a></td>
70 <td>Constructor</td>
71 </tr><tr>
72 <td><a href="#DiffDialog.__appendText">__appendText</a></td>
73 <td>Private method to append text to the end of the contents pane.</td>
74 </tr><tr>
75 <td><a href="#DiffDialog.__fileChanged">__fileChanged</a></td>
76 <td>Private slot to enable/disable the Compare button.</td>
77 </tr><tr>
78 <td><a href="#DiffDialog.__generateContextDiff">__generateContextDiff</a></td>
79 <td>Private slot to generate a context diff output.</td>
80 </tr><tr>
81 <td><a href="#DiffDialog.__generateUnifiedDiff">__generateUnifiedDiff</a></td>
82 <td>Private slot to generate a unified diff output.</td>
83 </tr><tr>
84 <td><a href="#DiffDialog.__selectFile">__selectFile</a></td>
85 <td>Private slot to display a file selection dialog.</td>
86 </tr><tr>
87 <td><a href="#DiffDialog.on_buttonBox_clicked">on_buttonBox_clicked</a></td>
88 <td>Private slot called by a button of the button box clicked.</td>
89 </tr><tr>
90 <td><a href="#DiffDialog.on_diffButton_clicked">on_diffButton_clicked</a></td>
91 <td>Private slot to handle the Compare button press.</td>
92 </tr><tr>
93 <td><a href="#DiffDialog.on_file1Button_clicked">on_file1Button_clicked</a></td>
94 <td>Private slot to handle the file 1 file selection button press.</td>
95 </tr><tr>
96 <td><a href="#DiffDialog.on_file2Button_clicked">on_file2Button_clicked</a></td>
97 <td>Private slot to handle the file 2 file selection button press.</td>
98 </tr><tr>
99 <td><a href="#DiffDialog.on_saveButton_clicked">on_saveButton_clicked</a></td>
100 <td>Private slot to handle the Save button press.</td>
101 </tr><tr>
102 <td><a href="#DiffDialog.show">show</a></td>
103 <td>Public slot to show the dialog.</td>
104 </tr>
105 </table>
106 <h3>Static Methods</h3>
107 <table>
108 <tr><td>None</td></tr>
109 </table>
110 <a NAME="DiffDialog.__init__" ID="DiffDialog.__init__"></a>
111 <h4>DiffDialog (Constructor)</h4>
112 <b>DiffDialog</b>(<i>parent=None</i>)
113 <p>
114 Constructor
115 </p><dl>
116 <dt><i>parent</i></dt>
117 <dd>
118 reference to the parent widget (QWidget)
119 </dd>
120 </dl><a NAME="DiffDialog.__appendText" ID="DiffDialog.__appendText"></a>
121 <h4>DiffDialog.__appendText</h4>
122 <b>__appendText</b>(<i>txt, format</i>)
123 <p>
124 Private method to append text to the end of the contents pane.
125 </p><dl>
126 <dt><i>txt</i></dt>
127 <dd>
128 text to insert (string)
129 </dd><dt><i>format</i></dt>
130 <dd>
131 text format to be used (QTextCharFormat)
132 </dd>
133 </dl><a NAME="DiffDialog.__fileChanged" ID="DiffDialog.__fileChanged"></a>
134 <h4>DiffDialog.__fileChanged</h4>
135 <b>__fileChanged</b>(<i></i>)
136 <p>
137 Private slot to enable/disable the Compare button.
138 </p><a NAME="DiffDialog.__generateContextDiff" ID="DiffDialog.__generateContextDiff"></a>
139 <h4>DiffDialog.__generateContextDiff</h4>
140 <b>__generateContextDiff</b>(<i>a, b, fromfile, tofile, fromfiledate, tofiledate</i>)
141 <p>
142 Private slot to generate a context diff output.
143 </p><dl>
144 <dt><i>a</i></dt>
145 <dd>
146 first sequence of lines (list of strings)
147 </dd><dt><i>b</i></dt>
148 <dd>
149 second sequence of lines (list of strings)
150 </dd><dt><i>fromfile</i></dt>
151 <dd>
152 filename of the first file (string)
153 </dd><dt><i>tofile</i></dt>
154 <dd>
155 filename of the second file (string)
156 </dd><dt><i>fromfiledate</i></dt>
157 <dd>
158 modification time of the first file (string)
159 </dd><dt><i>tofiledate</i></dt>
160 <dd>
161 modification time of the second file (string)
162 </dd>
163 </dl><a NAME="DiffDialog.__generateUnifiedDiff" ID="DiffDialog.__generateUnifiedDiff"></a>
164 <h4>DiffDialog.__generateUnifiedDiff</h4>
165 <b>__generateUnifiedDiff</b>(<i>a, b, fromfile, tofile, fromfiledate, tofiledate</i>)
166 <p>
167 Private slot to generate a unified diff output.
168 </p><dl>
169 <dt><i>a</i></dt>
170 <dd>
171 first sequence of lines (list of strings)
172 </dd><dt><i>b</i></dt>
173 <dd>
174 second sequence of lines (list of strings)
175 </dd><dt><i>fromfile</i></dt>
176 <dd>
177 filename of the first file (string)
178 </dd><dt><i>tofile</i></dt>
179 <dd>
180 filename of the second file (string)
181 </dd><dt><i>fromfiledate</i></dt>
182 <dd>
183 modification time of the first file (string)
184 </dd><dt><i>tofiledate</i></dt>
185 <dd>
186 modification time of the second file (string)
187 </dd>
188 </dl><a NAME="DiffDialog.__selectFile" ID="DiffDialog.__selectFile"></a>
189 <h4>DiffDialog.__selectFile</h4>
190 <b>__selectFile</b>(<i>lineEdit</i>)
191 <p>
192 Private slot to display a file selection dialog.
193 </p><dl>
194 <dt><i>lineEdit</i></dt>
195 <dd>
196 field for the display of the selected filename
197 (QLineEdit)
198 </dd>
199 </dl><a NAME="DiffDialog.on_buttonBox_clicked" ID="DiffDialog.on_buttonBox_clicked"></a>
200 <h4>DiffDialog.on_buttonBox_clicked</h4>
201 <b>on_buttonBox_clicked</b>(<i>button</i>)
202 <p>
203 Private slot called by a button of the button box clicked.
204 </p><dl>
205 <dt><i>button</i></dt>
206 <dd>
207 button that was clicked (QAbstractButton)
208 </dd>
209 </dl><a NAME="DiffDialog.on_diffButton_clicked" ID="DiffDialog.on_diffButton_clicked"></a>
210 <h4>DiffDialog.on_diffButton_clicked</h4>
211 <b>on_diffButton_clicked</b>(<i></i>)
212 <p>
213 Private slot to handle the Compare button press.
214 </p><a NAME="DiffDialog.on_file1Button_clicked" ID="DiffDialog.on_file1Button_clicked"></a>
215 <h4>DiffDialog.on_file1Button_clicked</h4>
216 <b>on_file1Button_clicked</b>(<i></i>)
217 <p>
218 Private slot to handle the file 1 file selection button press.
219 </p><a NAME="DiffDialog.on_file2Button_clicked" ID="DiffDialog.on_file2Button_clicked"></a>
220 <h4>DiffDialog.on_file2Button_clicked</h4>
221 <b>on_file2Button_clicked</b>(<i></i>)
222 <p>
223 Private slot to handle the file 2 file selection button press.
224 </p><a NAME="DiffDialog.on_saveButton_clicked" ID="DiffDialog.on_saveButton_clicked"></a>
225 <h4>DiffDialog.on_saveButton_clicked</h4>
226 <b>on_saveButton_clicked</b>(<i></i>)
227 <p>
228 Private slot to handle the Save button press.
229 </p><p>
230 It saves the diff shown in the dialog to a file in the local
231 filesystem.
232 </p><a NAME="DiffDialog.show" ID="DiffDialog.show"></a>
233 <h4>DiffDialog.show</h4>
234 <b>show</b>(<i>filename=None</i>)
235 <p>
236 Public slot to show the dialog.
237 </p><dl>
238 <dt><i>filename</i></dt>
239 <dd>
240 name of a file to use as the first file (string)
241 </dd>
242 </dl>
243 <div align="right"><a href="#top">Up</a></div>
244 <hr /><hr />
245 <a NAME="DiffWindow" ID="DiffWindow"></a>
246 <h2>DiffWindow</h2>
247 <p>
248 Main window class for the standalone dialog.
249 </p>
250 <h3>Derived from</h3>
251 E5MainWindow
252 <h3>Class Attributes</h3>
253 <table>
254 <tr><td>None</td></tr>
255 </table>
256 <h3>Class Methods</h3>
257 <table>
258 <tr><td>None</td></tr>
259 </table>
260 <h3>Methods</h3>
261 <table>
262 <tr>
263 <td><a href="#DiffWindow.__init__">DiffWindow</a></td>
264 <td>Constructor</td>
265 </tr><tr>
266 <td><a href="#DiffWindow.eventFilter">eventFilter</a></td>
267 <td>Public method to filter events.</td>
268 </tr>
269 </table>
270 <h3>Static Methods</h3>
271 <table>
272 <tr><td>None</td></tr>
273 </table>
274 <a NAME="DiffWindow.__init__" ID="DiffWindow.__init__"></a>
275 <h4>DiffWindow (Constructor)</h4>
276 <b>DiffWindow</b>(<i>parent=None</i>)
277 <p>
278 Constructor
279 </p><dl>
280 <dt><i>parent</i></dt>
281 <dd>
282 reference to the parent widget (QWidget)
283 </dd>
284 </dl><a NAME="DiffWindow.eventFilter" ID="DiffWindow.eventFilter"></a>
285 <h4>DiffWindow.eventFilter</h4>
286 <b>eventFilter</b>(<i>obj, event</i>)
287 <p>
288 Public method to filter events.
289 </p><dl>
290 <dt><i>obj</i></dt>
291 <dd>
292 reference to the object the event is meant for (QObject)
293 </dd><dt><i>event</i></dt>
294 <dd>
295 reference to the event object (QEvent)
296 </dd>
297 </dl><dl>
298 <dt>Returns:</dt>
299 <dd>
300 flag indicating, whether the event was handled (boolean)
301 </dd>
302 </dl>
303 <div align="right"><a href="#top">Up</a></div>
304 <hr /><hr />
305 <a NAME="context_diff" ID="context_diff"></a>
306 <h2>context_diff</h2>
307 <b>context_diff</b>(<i>a, b, fromfile='', tofile='', fromfiledate='', tofiledate='', n=3, lineterm='\n'</i>)
308 <p>
309 Compare two sequences of lines; generate the delta as a context diff.
310 </p><p>
311 Context diffs are a compact way of showing line changes and a few
312 lines of context. The number of context lines is set by 'n' which
313 defaults to three.
314 </p><p>
315 By default, the diff control lines (those with *** or ---) are
316 created with a trailing newline. This is helpful so that inputs
317 created from file.readlines() result in diffs that are suitable for
318 file.writelines() since both the inputs and outputs have trailing
319 newlines.
320 </p><p>
321 For inputs that do not have trailing newlines, set the lineterm
322 argument to "" so that the output will be uniformly newline free.
323 </p><p>
324 The context diff format normally has a header for filenames and
325 modification times. Any or all of these may be specified using
326 strings for 'fromfile', 'tofile', 'fromfiledate', and 'tofiledate'.
327 The modification times are normally expressed in the format returned
328 by time.ctime(). If not specified, the strings default to blanks.
329 </p><p>
330 Example:
331 </p><p>
332 <pre>
333 &gt;&gt;&gt; print ''.join(
334 ... context_diff('one\ntwo\nthree\nfour\n'.splitlines(1),
335 ... 'zero\none\ntree\nfour\n'.splitlines(1), 'Original', 'Current',
336 ... 'Sat Jan 26 23:30:50 1991', 'Fri Jun 06 10:22:46 2003')),
337 *** Original Sat Jan 26 23:30:50 1991
338 --- Current Fri Jun 06 10:22:46 2003
339 ***************
340 *** 1,4 ****
341 one
342 ! two
343 ! three
344 four
345 --- 1,4 ----
346 + zero
347 one
348 ! tree
349 four
350 </pre>
351 </p><dl>
352 <dt><i>a</i></dt>
353 <dd>
354 first sequence of lines (list of strings)
355 </dd><dt><i>b</i></dt>
356 <dd>
357 second sequence of lines (list of strings)
358 </dd><dt><i>fromfile</i></dt>
359 <dd>
360 filename of the first file (string)
361 </dd><dt><i>tofile</i></dt>
362 <dd>
363 filename of the second file (string)
364 </dd><dt><i>fromfiledate</i></dt>
365 <dd>
366 modification time of the first file (string)
367 </dd><dt><i>tofiledate</i></dt>
368 <dd>
369 modification time of the second file (string)
370 </dd><dt><i>n</i></dt>
371 <dd>
372 number of lines of context (integer)
373 </dd><dt><i>lineterm</i></dt>
374 <dd>
375 line termination string (string)
376 </dd>
377 </dl><dl>
378 <dt>Returns:</dt>
379 <dd>
380 a generator yielding lines of differences
381 </dd>
382 </dl>
383 <div align="right"><a href="#top">Up</a></div>
384 <hr /><hr />
385 <a NAME="unified_diff" ID="unified_diff"></a>
386 <h2>unified_diff</h2>
387 <b>unified_diff</b>(<i>a, b, fromfile='', tofile='', fromfiledate='', tofiledate='', n=3, lineterm='\n'</i>)
388 <p>
389 Compare two sequences of lines; generate the delta as a unified diff.
390 </p><p>
391 Unified diffs are a compact way of showing line changes and a few
392 lines of context. The number of context lines is set by 'n' which
393 defaults to three.
394 </p><p>
395 By default, the diff control lines (those with ---, +++, or @@) are
396 created with a trailing newline. This is helpful so that inputs
397 created from file.readlines() result in diffs that are suitable for
398 file.writelines() since both the inputs and outputs have trailing
399 newlines.
400 </p><p>
401 For inputs that do not have trailing newlines, set the lineterm
402 argument to "" so that the output will be uniformly newline free.
403 </p><p>
404 The unidiff format normally has a header for filenames and modification
405 times. Any or all of these may be specified using strings for
406 'fromfile', 'tofile', 'fromfiledate', and 'tofiledate'. The modification
407 times are normally expressed in the format returned by time.ctime().
408 </p><p>
409 Example:
410 </p><p>
411 <pre>
412 &gt;&gt;&gt; for line in unified_diff('one two three four'.split(),
413 ... 'zero one tree four'.split(), 'Original', 'Current',
414 ... 'Sat Jan 26 23:30:50 1991', 'Fri Jun 06 10:20:52 2003',
415 ... lineterm=''):
416 ... print line
417 --- Original Sat Jan 26 23:30:50 1991
418 +++ Current Fri Jun 06 10:20:52 2003
419 @ -1,4 +1,4 @@
420 +zero
421 one
422 -two
423 -three
424 +tree
425 four
426 </pre>
427 </p><dl>
428 <dt><i>a</i></dt>
429 <dd>
430 first sequence of lines (list of strings)
431 </dd><dt><i>b</i></dt>
432 <dd>
433 second sequence of lines (list of strings)
434 </dd><dt><i>fromfile</i></dt>
435 <dd>
436 filename of the first file (string)
437 </dd><dt><i>tofile</i></dt>
438 <dd>
439 filename of the second file (string)
440 </dd><dt><i>fromfiledate</i></dt>
441 <dd>
442 modification time of the first file (string)
443 </dd><dt><i>tofiledate</i></dt>
444 <dd>
445 modification time of the second file (string)
446 </dd><dt><i>n</i></dt>
447 <dd>
448 number of lines of context (integer)
449 </dd><dt><i>lineterm</i></dt>
450 <dd>
451 line termination string (string)
452 </dd>
453 </dl><dl>
454 <dt>Returns:</dt>
455 <dd>
456 a generator yielding lines of differences
457 </dd>
458 </dl>
459 <div align="right"><a href="#top">Up</a></div>
460 <hr />
461 </body></html>

eric ide

mercurial