DiffTextView.st
changeset 13784 0b7b083dc0e4
parent 12455 dab98ae0d660
child 13785 8efb823ca577
equal deleted inserted replaced
13783:00625eec40bc 13784:0b7b083dc0e4
   337             entry isNil ifTrue:[
   337             entry isNil ifTrue:[
   338                 nr1 := text1 size + 1.
   338                 nr1 := text1 size + 1.
   339                 nr2 := text2 size + 1.
   339                 nr2 := text2 size + 1.
   340                 state := #finish.
   340                 state := #finish.
   341             ] ifFalse:[
   341             ] ifFalse:[
   342                 diffLineNumbers add:l1 size.
       
   343 
       
   344                 s := ReadStream on:entry.
   342                 s := ReadStream on:entry.
   345                 nr1 := Integer readFrom:s.
   343                 nr1 := Integer readFrom:s.
   346                 s peek == $, ifTrue:[
   344                 s peek == $, ifTrue:[
   347                     s next.
   345                     s next.
   348                     Integer readFrom:s
   346                     Integer readFrom:s
   353                     s next.
   351                     s next.
   354                     nr3 := Integer readFrom:s
   352                     nr3 := Integer readFrom:s
   355                 ] ifFalse:[
   353                 ] ifFalse:[
   356                     nr3 := nil
   354                     nr3 := nil
   357                 ].
   355                 ].
       
   356                 diffLineNumbers add:{ op . nr1 . nr2 }.
   358 
   357 
   359                 op == $c ifTrue:[
   358                 op == $c ifTrue:[
   360                     state := #changed.
   359                     state := #changed.
   361                 ] ifFalse:[
   360                 ] ifFalse:[
   362                     (op == $a) ifTrue:[
   361                     (op == $a) ifTrue:[
   398             state == #deleted ifTrue:[
   397             state == #deleted ifTrue:[
   399                 l2 add:(text2 at:idx2 ifAbsent:'').
   398                 l2 add:(text2 at:idx2 ifAbsent:'').
   400                 idx2 := idx2 + 1.
   399                 idx2 := idx2 + 1.
   401             ].
   400             ].
   402 
   401 
   403 
       
   404             "
   402             "
   405              add a separating line, except at end
   403              add a separating line, except at end
   406             "
   404             "
   407             any ifTrue:[
   405             any ifTrue:[
   408                 state ~~ #finish ifTrue:[
   406                 state ~~ #finish ifTrue:[
   409                     showSeparators ifTrue:[
   407                     showSeparators ifTrue:[
   410                         l1 add:'--------'.
   408                         l1 add:'--------'.
   411                         l2 add:'--------'.
   409                         l2 add:'--------'.
   412                     ]
   410                     ].
   413                 ]
   411                 ]
   414             ].
   412             ].
   415 
       
   416         ] ifFalse:[
   413         ] ifFalse:[
   417             state == #changed ifTrue:[
   414             state == #changed ifTrue:[
   418                 line1 := line2 := nil.
   415                 line1 := line2 := nil.
   419                 (entry at:1) == $< ifTrue:[
   416                 (entry at:1) == $< ifTrue:[
   420                     useColors ifTrue:[
   417                     useColors ifTrue:[
   523                             dIdx := dIdx - 1
   520                             dIdx := dIdx - 1
   524                         ]
   521                         ]
   525                     ] 
   522                     ] 
   526                     "must be in finish otherwise"
   523                     "must be in finish otherwise"
   527                 ]
   524                 ]
   528             ]
   525             ].
   529         ].
   526         ].
   530         dIdx := dIdx + 1
   527         dIdx := dIdx + 1
   531     ].
   528     ].
   532     [l1 size < l2 size] whileTrue:[
   529     [l1 size < l2 size] whileTrue:[
   533         l1 add:''.
   530         l1 add:''.
   576 
   573 
   577     lists := self processDiffList:diffList from:text1 and:text2.
   574     lists := self processDiffList:diffList from:text1 and:text2.
   578 
   575 
   579     textView1 list:lists first.
   576     textView1 list:lists first.
   580     textView2 list:lists second.
   577     textView2 list:lists second.
       
   578 
       
   579     self updateScrollbarBackground
       
   580 !
       
   581 
       
   582 updateScrollbarBackground
       
   583     "define a background in the scroller allowing quick positioning to changes"
       
   584 
       
   585     |container vScroller thumb|
       
   586 
       
   587     (container := self container) isScrollWrapper ifTrue:[
       
   588         (vScroller := container verticalScrollBar) notNil ifTrue:[
       
   589             (thumb := vScroller thumb) notNil ifTrue:[
       
   590                 thumb 
       
   591                     backgroundDrawHook:[:x :y :w :h |
       
   592                         |overAllHeight|
       
   593 
       
   594                         overAllHeight := textViews first numberOfLines.
       
   595                         1 to:overAllHeight do:[:lineNr |
       
   596                             |l1 l2 isDiff yThumb clr e|
       
   597 
       
   598                             l1 := textViews first listAt:lineNr.
       
   599                             l2 := textViews second listAt:lineNr.
       
   600                             (l1 notNil and:[l1 isText]) ifTrue:[
       
   601                                 e := l1 emphasis
       
   602                             ] ifFalse:[
       
   603                                 (l2 notNil and:[l2 isText ]) ifTrue:[
       
   604                                     e := l2 emphasis
       
   605                                 ]
       
   606                             ].
       
   607                             e size > 0 ifTrue:[
       
   608                                 clr := Text extractEmphasis:#backgroundColor from:(e at:1).
       
   609                                 thumb paint:clr.
       
   610                                 yThumb := (thumb height * (lineNr / overAllHeight)) rounded.
       
   611                                 thumb displayLineFromX:1 y:yThumb toX:thumb width-2 y:yThumb.
       
   612                             ].
       
   613                         ]
       
   614                     ]
       
   615             ]
       
   616         ]
       
   617     ].
   581 ! !
   618 ! !
   582 
   619 
   583 !DiffTextView class methodsFor:'documentation'!
   620 !DiffTextView class methodsFor:'documentation'!
   584 
   621 
   585 version
   622 version
   586     ^ '$Header: /cvs/stx/stx/libtool/DiffTextView.st,v 1.58 2013-03-11 11:51:45 cg Exp $'
   623     ^ '$Header: /cvs/stx/stx/libtool/DiffTextView.st,v 1.59 2014-01-26 13:54:14 cg Exp $'
   587 !
   624 !
   588 
   625 
   589 version_CVS
   626 version_CVS
   590     ^ '$Header: /cvs/stx/stx/libtool/DiffTextView.st,v 1.58 2013-03-11 11:51:45 cg Exp $'
   627     ^ '$Header: /cvs/stx/stx/libtool/DiffTextView.st,v 1.59 2014-01-26 13:54:14 cg Exp $'
   591 ! !
   628 ! !
   592 
   629