|
Class: DiffTextView
Object
|
+--GraphicsMedium
|
+--DisplaySurface
|
+--SimpleView
|
+--SyncedMultiColumnTextView
|
+--TwoColumnTextView
|
+--DiffTextView
|
+--DiffCodeView
- Package:
- stx:libtool
- Category:
- Views-Text
- Version:
- rev:
1.90
date: 2024/04/09 12:20:34
- user: stefan
- file: DiffTextView.st directory: libtool
- module: stx stc-classLibrary: libtool
a view showing diff output (see unix manual pages)
in a user-friendly form.
The view is created and opened with:
d := DiffTextView openOn:text1 and:text2
or:
d := DiffTextView openOn:text1 label:l1
and:text2 label:l2
and it will show the differences side-by-side.
The colors mean:
red - removed
green - added
blue - changed
light-blue changed, but not really (i.e. spaces only)
For a real world application and use of this widget,
see the ChangesBrowsers `compare',
or the browsers 'compare with repository' functions.
Notice:
A diff command must be available on your system and found
along the PATH (you will see a warning on stderr, if there is no diff).
We use gnu-diff.
copyrightCOPYRIGHT (c) 1994 by Claus Gittinger
All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
inclusion of the above copyright notice. This software may not
be provided or otherwise made available to, or used by, any
other person. No title to or ownership of the software is
hereby transferred.
defaults
-
diffCommand
-
return the diff-command (with argument placeHolders)
-
diffCommandTemplate: aCommandTemplateString
-
set the diff-command template
-
textViewClass
-
return the type of the synced subViews.
Redefined to use a CodeView
instance creation
-
openOnClass: classA labelA: lblA andClass: classB labelB: lblB title: title ifSame: sameAction
-
provided for protocol compatibility with the VersionDiffBrowser;
actually, the classes are ignored here
-
openOnClass: someClass labelA: lblA sourceA: sourceA labelB: lblB sourceB: sourceB
-
provided for protocol compatibility with the VersionDiffBrowser;
actually, the class is ignored here
-
openOnClass: someClass labelA: lblA sourceA: sourceA labelB: lblB sourceB: sourceB title: title
-
provided for protocol compatibility with the VersionDiffBrowser;
actually, the class is ignored here
-
openOnClass: someClass labelA: lblA sourceA: sourceA labelB: lblB sourceB: sourceB title: title ifSame: sameAction
-
provided for protocol compatibility with the VersionDiffBrowser;
actually, the class is ignored here
accessing
-
showSeparators: aBoolean
-
-
text1: t1 text2: t2
-
set the two texts which are to be diffed;
execute DiffCommand and update the two textViews.
Usage example(s):
|v|
v := HVScrollableView for:DiffTextView.
v scrolledView text1:('../libview/Color.st' asFilename readStream contents)
text2:('../libview/Color.st.old' asFilename readStream contents).
v open
|
Usage example(s):
|v t1 t2|
t1 := '
one
two
three
four
'.
t2 := '
one
two-a
two-b
three
three-b
four
'.
v := DiffTextView new.
v text1:t1 text2:t2.
v open
|
-
useColors: aBoolean
-
initialization
-
addNextPreviousButtons
-
(comment from inherited method)
set up-down buttons
-
initStyle
-
no device - no style.
May happen when doing headless checks of classes non-gui functionality.
Use device-independent colors.
-
postRealize
-
(comment from inherited method)
invoked after a view was realized.
Can be redefined in subclasses to perform delayed actions.
private
-
diffListFor: text1 and: text2
-
return a raw difflist for the two texts which are to be diffed
-
processDiffList: diffList from: textOrStringCollection1 and: textOrStringCollection2
-
given the two texts in text1 and text2, and the diff-output in diffList,
return new left and right lists.
This aligns the lines and colorizes them for presentation
-
updateListsFrom: text1 and: text2 diffs: diffList
-
given the two texts in text1 and text2, and the diff-output in diffList,
update my views' contents
-
updateScrollbarBackground
-
define a background in the scroller allowing quick positioning to changes
DiffTextScrollerBackground
|text1 text2|
text1 := 'hello world
here is some difference
more text
this line has been removed
more text
more text
'.
text2 := 'hello world
where is the difference ?
more text
more text
more text
this line has been added
'.
DiffTextView openOn:text1 label:'text1'
and:text2 label:'text2'
|
|