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.90 date: 2024/04/09 12:20:34
user: stefan
file: DiffTextView.st directory: libtool
module: stx stc-classLibrary: libtool

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.

copyright

COPYRIGHT (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.

Class protocol:

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

o  diffCommandTemplate: aCommandTemplateString
set the diff-command template

o  textViewClass
return the type of the synced subViews.
Redefined to use a CodeView

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  showSeparators: aBoolean

o  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

o  useColors: aBoolean

initialization
o  addNextPreviousButtons
(comment from inherited method)
set up-down buttons

o  initStyle
no device - no style.
May happen when doing headless checks of classes non-gui functionality.
Use device-independent colors.

o  postRealize
(comment from inherited method)
invoked after a view was realized.
Can be redefined in subclasses to perform delayed actions.

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

o  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

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.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Mon, 18 Nov 2024 04:15:58 GMT