eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'DiffTextView':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: DiffTextView


Inheritance:

   Object
   |
   +--GraphicsMedium
      |
      +--DisplaySurface
         |
         +--SimpleView
            |
            +--SyncedMultiColumnTextView
               |
               +--TwoColumnTextView
                  |
                  +--DiffTextView
                     |
                     +--DiffCodeView

Package:
stx:libtool
Category:
Views-Text
Version:
rev: 1.71 date: 2017/11/29 10:41:18
user: cg
file: DiffTextView.st directory: libtool
module: stx stc-classLibrary: libtool
Author:
Claus Gittinger

Description:


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.


Related information:

    TextView
    EditTextView
    Diff3TextView

Class protocol:

defaults
o  diffCommand
return the diff-command (with argument placeHolders)

o  diffCommandTemplate: aCommandTemplateString
set the diff-command template

instance creation
o  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

o  openOnClass: someClass labelA: lblA sourceA: sourceA labelB: lblB sourceB: sourceB
provided for protocol compatibility with the VersionDiffBrowser;
actually, the class is ignored here

o  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

o  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


Instance protocol:

accessing
o  text1: t1 text2: t2
set the two texts which are to be diffed;
execute DiffCommand and update the two textViews.

initialization
o  addNextPreviousButtons

o  initStyle
(comment from inherited method)
this method sets up all style dependent things

o  postRealize

private
o  diffListFor: text1 and: text2
return a raw difflist for the two texts which are to be diffed

o  processDiffList: diffList from: text1 and: text2
given the two texts in text1 and text2, and the diff-output in diffList,
return new left and right lists.

o  updateListsFrom: text1 and: text2 diffs: diffList
given the two texts in text1 and text2, and the diff-output in diffList,
update my views contents

o  updateScrollbarBackground
define a background in the scroller allowing quick positioning to changes


Private classes:

    DiffTextScrollerBackground

Examples:


    |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'


ST/X 7.1.0.0; WebServer 1.663 at exept.de:8081; Thu, 15 Nov 2018 12:24:20 GMT